Пример #1
0
  private void addComponents() {
    // Loop over all components and add them to this form
    for (Component c : mooseModel.getForm().getComponents()) {
      if (c.getName().equals("Mesh")) {
        c.setName("Mesh and Output Files");
      }
      form.addComponent(c);
    }

    // Grab an explicit reference to the files component from the Model
    modelFiles = (DataComponent) form.getComponent(1);

    // Register this Item as a listener to the MOOSE-Based Application
    // Entry so that if it changes to Remote, we can grab the
    // IRemoteConnection
    modelFiles.retrieveEntry("MOOSE-Based Application").register(this);

    // Add the parallel execution component
    form.addComponent(mooseLauncher.getForm().getComponent(3));

    // Get a handle to the model input tree
    modelTree = (TreeComposite) form.getComponent(2);

    fileEntryTreeMapping = new HashMap<String, TreeComposite>();

    // Initialize the postProcessor Mapping
    postProcessorResources = new HashMap<String, ICEResource>();

    // Create the Postprocessors DataComponent
    postProcessorsData = new DataComponent();
    postProcessorsData.setName("Show Postprocessors?");
    postProcessorsData.setDescription(
        "Enable the Postprocessors you would like to monitor in real time.");
    postProcessorsData.setId(MOOSE.ppDataId);
    form.addComponent(postProcessorsData);

    TreeComposite ppTree;
    if ((ppTree = getTreeByName("Postprocessors")) != null) {
      setupPostprocessorData(ppTree);
    }
  }
Пример #2
0
  /**
   * (non-Javadoc)
   *
   * @see org.eclipse.ice.item.Item#loadInput(java.lang.String)
   */
  @Override
  public void loadInput(String input) {
    mooseModel.loadInput(input);

    form = new Form();

    String description =
        "The Multiphysics Object-Oriented Simulation "
            + "Environment (MOOSE) is a multiphysics framework developed "
            + "by Idaho National Laboratory.";

    // Set the model defaults
    form.setName("MOOSE Workflow");
    form.setDescription(description);
    form.setItemID(getId());
    form.setActionList(allowedActions);

    // Loop over all components and add them to this form
    for (Component c : mooseModel.getForm().getComponents()) {
      form.addComponent(c);
    }

    // Add the model files component
    modelFiles = (DataComponent) form.getComponent(1);

    // Loop over all components and add the parallel exec and output
    // components only
    for (Component c : mooseLauncher.getForm().getComponents()) {

      if ("Parallel Execution".equals(c.getName()) || "Output Files and Data".equals(c.getName())) {
        form.addComponent(c);
      }
    }

    // Set up the postProcessorData DataComponent to contain
    // a list of Boolean Discrete Entries for each Postprocessor
    postProcessorsData = new DataComponent();
    postProcessorsData.setName("Show Postprocessors?");
    postProcessorsData.setDescription(
        "Enable the Postprocessors you would like to monitor in real time.");
    postProcessorsData.setId(MOOSE.ppDataId);
    form.addComponent(postProcessorsData);

    TreeComposite ppTree;
    if ((ppTree = getTreeByName("Postprocessors")) != null) {
      setupPostprocessorData(ppTree);
    }

    // Get a handle to the model input tree
    modelTree = (TreeComposite) form.getComponent(2);

    loadFileEntries();

    // Register this Item as a listener to the Variables block
    // this is so we can use the variables to populate things like
    // kernel variable entries.
    TreeComposite vars = getTreeByName("Variables");
    if (vars != null) {
      vars.register(this);
    }
    TreeComposite aux = getTreeByName("AuxVariables");
    if (aux != null) {
      aux.register(this);
    }
    modelTree.register(this);
    registered = true;

    return;
  }
Пример #3
0
  /**
   * (non-Javadoc)
   *
   * @see org.eclipse.ice.item.Item#process(java.lang.String)
   */
  @Override
  public FormStatus process(String actionName) {
    // Local Declarations
    FormStatus retStatus = FormStatus.InfoError;

    // Set our outputFile as the MooseLauncher's output file
    // so we can see the streaming output
    outputFile = mooseLauncher.getOutputFile();

    // Parse the action name
    if ("Launch the Job".equals(actionName)) {

      // FIXME WE NEED TO DO A CHECK FOR ALL THE REQUIRED BLOCKS!!!!

      // Add the ICEUpdater tree block to Outputs
      TreeComposite outputs = getTreeByName("Outputs");
      TreeComposite postProcessors = getTreeByName("Postprocessors");

      // First check to see if we have any post processors to
      // watch for.
      if (postProcessors.isActive() && postProcessors.getNumberOfChildren() > 0) {

        // If we do, we should add an ICEUpdater
        boolean iNeedUpdater = true;

        // If we already have one, then we shouldn't add another one
        for (int i = 0; i < outputs.getNumberOfChildren(); i++) {
          if ("ICEUpdater".equals(outputs.getChildAtIndex(i).getName())) {

            // But if the current one is not configured correctly
            // then we should add a new one, Here we make sure the
            // Item Id is correct...
            TreeComposite iceUpdater = outputs.getChildAtIndex(i);
            DataComponent data = (DataComponent) iceUpdater.getDataNodes().get(0);
            Entry itemIdEntry = data.retrieveEntry("item_id");
            if (Integer.valueOf(itemIdEntry.getValue()) != getId()) {
              itemIdEntry.setValue(String.valueOf(getId()));
            }

            // Now we have a valid ICEUpdater, so we don't need
            // to create a new one.
            iNeedUpdater = false;
            break;
          }
        }

        if (iNeedUpdater) {
          for (int i = 0; i < outputs.getChildExemplars().size(); i++) {
            if ("ICEUpdater".equals(outputs.getChildExemplars().get(i).getName())) {
              TreeComposite updater = (TreeComposite) outputs.getChildExemplars().get(i).clone();
              outputs.setNextChild(updater);

              DataComponent data = (DataComponent) updater.getDataNodes().get(0);
              data.retrieveEntry("item_id").setValue(String.valueOf(getId()));
              data.retrieveEntry("url")
                  .setValue(
                      "http://localhost:"
                          + System.getProperty("org.eclipse.equinox.http.jetty.http.port")
                          + "/ice/update");
              updater.setActive(true);
              updater.setActiveDataNode(data);
              break;
            }
          }
        }
      }

      // Get a reference to the Launchers files component
      DataComponent launcherFiles = (DataComponent) mooseLauncher.getForm().getComponent(1);

      // Grab the file name the user has specified for the input file
      String fileName = modelFiles.retrieveEntry("Output File Name").getValue();

      // Write the Moose file if it doesn't exist
      retStatus = mooseModel.process("Write MOOSE File");
      if (!retStatus.equals(FormStatus.Processed)) {
        return retStatus;
      }

      // Set the value of the input file to the user-specified
      // file name
      launcherFiles.retrieveEntry("Input File").setValue(fileName);

      // Update the MooseLauncher's set of input files...
      mooseLauncher.update(launcherFiles.retrieveEntry("Input File"));
      for (Entry e : modelFiles.retrieveAllEntries()) {
        Entry launcherFile = launcherFiles.retrieveEntry(e.getName());
        if (launcherFile != null) {
          launcherFile.setValue(e.getValue());
        }
      }

      // Get the application URI
      URI appUri = URI.create(modelFiles.retrieveEntry("MOOSE-Based Application").getValue());

      // Check if we're local or remote
      if ("ssh".equals(appUri.getScheme())) {

        mooseLauncher.setExecutable(
            Paths.get(appUri.getRawPath()).getFileName().toString(),
            "",
            appUri.getRawPath() + " -i ${inputFile} --no-color");

        // Setup the hosts table to use the remote host
        TableComponent hostsTable =
            (TableComponent) mooseLauncher.getForm().getComponent(JobLauncherForm.parallelId + 1);
        IRemoteConnection remoteConnection = mooseLauncher.getRemoteConnection(appUri.getHost());
        String hostname =
            remoteConnection.getService(IRemoteConnectionHostService.class).getHostname();
        int index = hostsTable.addRow();
        ArrayList<Entry> row = hostsTable.getRow(index);
        ArrayList<Integer> selected = new ArrayList<Integer>();
        selected.add(new Integer(index));
        row.get(0).setValue(hostname);
        hostsTable.setSelectedRows(selected);

      } else {

        // Set the executable string
        mooseLauncher.setExecutable(
            new File(appUri).getName(), "", appUri.getPath() + " -i ${inputFile} --no-color");
      }

      // Register as a listener of the resource component
      // so we can add the resources to our resource component
      ((ResourceComponent) mooseLauncher.getForm().getComponent(JobLauncherForm.outputId))
          .register(this);

      // Launch the Moose application
      retStatus = mooseLauncher.process(actionName);

    } else if ("Write MOOSE File".equals(actionName)) {
      // Simply pass this along to the Model
      retStatus = mooseModel.process(actionName);
    }

    // Set the status flag.
    status = retStatus;

    // Keep the status in sync
    if (status.equals(FormStatus.Processing)) {
      Thread statusThread =
          new Thread(
              new Runnable() {
                @Override
                public void run() {
                  while (!status.equals(FormStatus.Processed)) {
                    // Sleep for a bit
                    Thread.currentThread();
                    try {
                      Thread.sleep(100);
                    } catch (InterruptedException e) {
                      logger.error(getClass().getName() + " Exception!", e);
                    }

                    // Set the status
                    status = mooseLauncher.getStatus();
                  }

                  return;
                }
              });

      statusThread.start();
    }
    return retStatus;
  }