/** * 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; }
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])); }
/* * (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(); }
/** Initialize the attribute manager. This is called each time the runtime is started. */ private void initialize() { attrMgr.clear(); attrMgr.setAttributeDefinitions(ElementAttributes.getDefaultAttributeDefinitions()); attrMgr.setAttributeDefinitions(ErrorAttributes.getDefaultAttributeDefinitions()); attrMgr.setAttributeDefinitions(FilterAttributes.getDefaultAttributeDefinitions()); attrMgr.setAttributeDefinitions(JobAttributes.getDefaultAttributeDefinitions()); attrMgr.setAttributeDefinitions(MachineAttributes.getDefaultAttributeDefinitions()); attrMgr.setAttributeDefinitions(MessageAttributes.getDefaultAttributeDefinitions()); attrMgr.setAttributeDefinitions(NodeAttributes.getDefaultAttributeDefinitions()); attrMgr.setAttributeDefinitions(ProcessAttributes.getDefaultAttributeDefinitions()); attrMgr.setAttributeDefinitions(QueueAttributes.getDefaultAttributeDefinitions()); attrMgr.setAttributeDefinitions(ResourceManagerAttributes.getDefaultAttributeDefinitions()); }
/** * 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; }
/** * 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; }