/**
   * Notify RM to create a new node.
   *
   * @param parentID The ID of the machine the node belongs to
   * @param name the name of the node
   * @param number the number of the node (rank)
   * @return the id of the new node
   */
  public String createNode(String parentID, String name, int number) {
    String id = generateID();
    ElementAttributeManager mgr = new ElementAttributeManager();
    AttributeManager attrMgr = new AttributeManager();
    attrMgr.addAttribute(
        NodeAttributes.getStateAttributeDefinition().create(NodeAttributes.State.UP));
    try {
      attrMgr.addAttribute(
          NodeAttributes.getNumberAttributeDefinition().create(new Integer(number)));
    } catch (IllegalValueException e) {
      /*
       * This exception is not possible, since number is always valid.
       */
      RMCorePlugin.log(e);
      assert false;
    }
    attrMgr.addAttribute(ElementAttributes.getNameAttributeDefinition().create(name));
    mgr.setAttributeManager(new RangeSet(id), attrMgr);
    fireRuntimeNewNodeEvent(eventFactory.newRuntimeNewNodeEvent(parentID, mgr));

    DebugUtil.trace(
        DebugUtil.RTS_TRACING,
        "RTS {0}: new node #{1}",
        getResourceManager().getConfiguration().getName(),
        id); //$NON-NLS-1$

    return id;
  }
  /**
   * Create a single process.
   *
   * @param jobId the parent job that the process belongs to
   * @param the index (job rank) of the new process
   * @since 2.0
   */
  public void createProcess(String jobId, int index) {
    ElementAttributeManager mgr = new ElementAttributeManager();
    AttributeManager attrMgr = new AttributeManager();
    attrMgr.addAttribute(
        ProcessAttributes.getStateAttributeDefinition().create(ProcessAttributes.State.STARTING));
    mgr.setAttributeManager(new RangeSet(index), attrMgr);
    fireRuntimeNewProcessEvent(eventFactory.newRuntimeNewProcessEvent(jobId, mgr));

    DebugUtil.trace(
        DebugUtil.RTS_TRACING,
        "RTS {0}: new process #{1}",
        getResourceManager().getConfiguration().getName(),
        Integer.toString(index)); // $NON-NLS-1$
  }
示例#3
0
 protected PElement(String id, IPElement parent, IAttribute<?, ?, ?>[] attrs) {
   elementId = id;
   elementParent = parent;
   ArrayList<IAttribute<?, ?, ?>> attrList =
       new ArrayList<IAttribute<?, ?, ?>>(Arrays.asList(attrs));
   attrList.add(ElementAttributes.getIdAttributeDefinition().create(id));
   attributeValues.addAttributes(attrList.toArray(new IAttribute<?, ?, ?>[0]));
 }
示例#4
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.ptp.core.elements.IPElement#getName()
  */
 public String getName() {
   StringAttribute attr =
       attributeValues.getAttribute(ElementAttributes.getNameAttributeDefinition());
   if (attr != null) {
     return attr.getValue();
   }
   return getID();
 }
  /** @since 3.0 */
  public void submitJob(String subId, ILaunchConfiguration configuration, String mode)
      throws CoreException {
    if (remoteServices == null) {
      throw new CoreException(
          new Status(
              IStatus.ERROR,
              RMCorePlugin.PLUGIN_ID,
              Messages.AbstractToolRuntimeSystem_Exception_ResourceManagerNotInitialized));
    }

    AttributeManager attrMgr =
        new AttributeManager(
            getAttributes(configuration, mode).toArray(new IAttribute<?, ?, ?>[0]));

    /*
     * Add some more attributes to the launch information.
     */
    attrMgr.addAttribute(JobAttributes.getSubIdAttributeDefinition().create(subId));

    /*
     * Create the IPJob.
     */
    String queueID = attrMgr.getAttribute(JobAttributes.getQueueIdAttributeDefinition()).getValue();
    String jobID = createJob(queueID, attrMgr);
    attrMgr.addAttribute(JobAttributes.getJobIdAttributeDefinition().create(jobID));

    DebugUtil.trace(
        DebugUtil.JOB_TRACING,
        "RTS {0}: job submission #{0}, job id #{1}, queue id @{2}",
        getResourceManager().getConfiguration().getName(),
        subId,
        jobID,
        queueID); //$NON-NLS-1$

    /*
     * Create the job that runs the application.
     */
    Job job = createRuntimeSystemJob(jobID, attrMgr);
    jobs.put(jobID, job);
    try {
      pendingJobQueue.put(job);
    } catch (InterruptedException e) {
      throw new CoreException(new Status(IStatus.ERROR, RMCorePlugin.PLUGIN_ID, e.getMessage()));
    }
  }
  /**
   * Notify RM to create a new queue.
   *
   * @param name the name of the queue
   * @return the id of the new queue
   */
  public String createQueue(String name) {
    String id = generateID();
    ElementAttributeManager mgr = new ElementAttributeManager();
    AttributeManager attrMgr = new AttributeManager();
    attrMgr.addAttribute(ElementAttributes.getNameAttributeDefinition().create(name));
    mgr.setAttributeManager(new RangeSet(id), attrMgr);
    IPResourceManager rm =
        (IPResourceManager) getResourceManager().getAdapter(IPResourceManager.class);
    fireRuntimeNewQueueEvent(eventFactory.newRuntimeNewQueueEvent(rm.getID(), mgr));

    DebugUtil.trace(
        DebugUtil.RTS_TRACING,
        "RTS {0}: new queue #{1}",
        getResourceManager().getConfiguration().getName(),
        id); //$NON-NLS-1$

    return id;
  }
  /**
   * Change attributes of a node
   *
   * @param nodeID
   * @param changedAttrMgr
   */
  public void changeNode(String nodeID, AttributeManager changedAttrMgr) {
    AttributeManager attrMgr = new AttributeManager();
    attrMgr.addAttributes(changedAttrMgr.getAttributes());
    ElementAttributeManager elementAttrs = new ElementAttributeManager();
    elementAttrs.setAttributeManager(new RangeSet(nodeID), attrMgr);
    IRuntimeNodeChangeEvent event = eventFactory.newRuntimeNodeChangeEvent(elementAttrs);
    fireRuntimeNodeChangeEvent(event);

    for (IAttribute<?, ?, ?> attr : changedAttrMgr.getAttributes()) {
      DebugUtil.trace(
          DebugUtil.RTS_TRACING,
          "RTS {0}, node #{1}: {2}={3}",
          getResourceManager().getConfiguration().getName(),
          nodeID,
          attr.getDefinition().getId(),
          attr.getValueAsString()); // $NON-NLS-1$
    }
  }
  /**
   * Change attributes of a process
   *
   * @param jobId id of processes' parent job
   * @param processJobRanks
   * @param changedAttrMgr
   * @since 2.0
   */
  public void changeProcesses(
      String jobId, BitSet processJobRanks, AttributeManager changedAttrMgr) {
    AttributeManager attrMgr = new AttributeManager();
    attrMgr.addAttributes(changedAttrMgr.getAttributes());
    ElementAttributeManager elementAttrs = new ElementAttributeManager();
    elementAttrs.setAttributeManager(new RangeSet(processJobRanks), attrMgr);
    IRuntimeProcessChangeEvent event =
        eventFactory.newRuntimeProcessChangeEvent(jobId, elementAttrs);
    fireRuntimeProcessChangeEvent(event);

    for (IAttribute<?, ?, ?> attr : changedAttrMgr.getAttributes()) {
      DebugUtil.trace(
          DebugUtil.RTS_TRACING,
          "RTS {0}, processes #{1}: {2}={3}",
          getResourceManager().getConfiguration().getName(),
          processJobRanks,
          attr.getDefinition().getId(),
          attr.getValueAsString()); // $NON-NLS-1$
    }
  }
 /**
  * Safely retrieve an attribute value.
  *
  * @param attrDef attribute definition of the attribute to retrieve
  * @param attrMgr attribute manager containing the attributes
  * @return value of the attribute
  * @throws CoreException if the attribute does not exist.
  */
 private <T, A extends IAttribute<T, A, D>, D extends IAttributeDefinition<T, A, D>>
     T getAttributeValue(D attrDef, AttributeManager attrMgr) throws CoreException {
   IAttribute<T, A, D> attr = attrMgr.getAttribute(attrDef);
   if (attr == null) {
     throw new CoreException(
         new Status(
             IStatus.ERROR,
             RMCorePlugin.PLUGIN_ID,
             NLS.bind(Messages.AbstractToolRuntimeSystem_3, attrDef.getName())));
   }
   return attr.getValue();
 }
示例#10
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.eclipse.ptp.core.elements.IPElement#getAttribute(java.lang.String)
  */
 public IAttribute<?, ?, ?> getAttribute(String attrId) {
   return attributeValues.getAttribute(attrId);
 }
示例#11
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.eclipse.ptp.core.IPElement#getAttribute(org.eclipse.ptp.core.attributes
  * .IAttributeDefinition)
  */
 public <T, A extends IAttribute<T, A, D>, D extends IAttributeDefinition<T, A, D>> A getAttribute(
     D attrDef) {
   return attributeValues.getAttribute(attrDef);
 }
示例#12
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.eclipse.ptp.core.elements.IPElement#addAttributes(org.eclipse.ptp
  * .core.attributes.IAttribute[])
  */
 public void addAttributes(IAttribute<?, ?, ?>[] attribs) {
   attributeValues.addAttributes(attribs);
   doAddAttributeHook(new AttributeManager(attribs));
 }
示例#13
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.eclipse.ptp.core.elements.IPElement#removeAttribute(org.eclipse.ptp
  * .core.attributes.IAttribute)
  */
 public void removeAttribute(IAttribute<?, ?, ?> attrib) {
   attributeValues.removeAttribute(attrib);
 }
示例#14
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.ptp.core.elements.IPElement#getDisplayAttributes()
  */
 public IAttribute<?, ?, ?>[] getDisplayAttributes() {
   return attributeValues.getDisplayAttributes();
 }
示例#15
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.ptp.core.elements.IPElement#getAttributeKeys()
  */
 public IAttributeDefinition<?, ?, ?>[] getAttributeKeys() {
   return attributeValues.getKeys();
 }
  /**
   * Notify RM to create a new job.
   *
   * @param parentID parent element ID
   * @param jobID the ID of the job
   * @param attrMgr attributes from the job thread
   * @return job id of the newly created job
   */
  public String createJob(String parentID, AttributeManager attrMgr) throws CoreException {
    ElementAttributeManager mgr = new ElementAttributeManager();
    AttributeManager jobAttrMgr = new AttributeManager();

    /*
     * Add generated attributes.
     */
    String jobID = generateID().toString();
    jobAttrMgr.addAttribute(JobAttributes.getJobIdAttributeDefinition().create(jobID));
    jobAttrMgr.addAttribute(
        JobAttributes.getStatusAttributeDefinition()
            .create(MPIJobAttributes.Status.NORMAL.toString()));
    jobAttrMgr.addAttribute(
        JobAttributes.getUserIdAttributeDefinition().create(System.getenv("USER"))); // $NON-NLS-1$
    jobAttrMgr.addAttribute(
        ElementAttributes.getNameAttributeDefinition().create(generateJobName()));

    /*
     * Get mandatory launch attributes.
     */
    String subId = getAttributeValue(JobAttributes.getSubIdAttributeDefinition(), attrMgr);
    String execName =
        getAttributeValue(JobAttributes.getExecutableNameAttributeDefinition(), attrMgr);
    String execPath =
        getAttributeValue(JobAttributes.getExecutablePathAttributeDefinition(), attrMgr);
    String workDir =
        getAttributeValue(JobAttributes.getWorkingDirectoryAttributeDefinition(), attrMgr);
    Integer numProcs =
        getAttributeValue(JobAttributes.getNumberOfProcessesAttributeDefinition(), attrMgr);
    List<? extends String> progArgs =
        getAttributeValue(JobAttributes.getProgramArgumentsAttributeDefinition(), attrMgr);

    /*
     * Copy these relevant attributes to IPJob.
     */
    jobAttrMgr.addAttribute(JobAttributes.getSubIdAttributeDefinition().create(subId));
    jobAttrMgr.addAttribute(JobAttributes.getExecutableNameAttributeDefinition().create(execName));
    jobAttrMgr.addAttribute(JobAttributes.getExecutablePathAttributeDefinition().create(execPath));
    jobAttrMgr.addAttribute(JobAttributes.getWorkingDirectoryAttributeDefinition().create(workDir));
    try {
      jobAttrMgr.addAttribute(
          JobAttributes.getNumberOfProcessesAttributeDefinition().create(numProcs));
    } catch (IllegalValueException e) {
      RMCorePlugin.log(e);
    }
    jobAttrMgr.addAttribute(
        JobAttributes.getProgramArgumentsAttributeDefinition()
            .create(progArgs.toArray(new String[0])));

    /*
     * Copy optional attributes
     */
    BooleanAttribute debugAttr =
        attrMgr.getAttribute(JobAttributes.getDebugFlagAttributeDefinition());
    if (debugAttr != null) {
      jobAttrMgr.addAttribute(
          JobAttributes.getDebugFlagAttributeDefinition().create(debugAttr.getValue()));
    }

    /*
     * Notify RM.
     */
    mgr.setAttributeManager(new RangeSet(jobID), jobAttrMgr);
    fireRuntimeNewJobEvent(eventFactory.newRuntimeNewJobEvent(parentID, mgr));

    DebugUtil.trace(
        DebugUtil.RTS_TRACING,
        "RTS {0}: new job #{1}",
        getResourceManager().getConfiguration().getName(),
        jobID); //$NON-NLS-1$

    return jobID;
  }