/** * 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(); }
/** * 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$ } }