protected NodeAttributesManager createNodeAttributesManager() { NodeAttributesManagerImpl namImpl = new NodeAttributesManagerImpl(); namImpl.setRMContext(rmContext); return namImpl; }
public void updateNodeResource(NodeId node, Resource newResource) { deactivateNode(node); activateNode(node, newResource); }
private void replaceNodeToAttribute(String nodeHost, String prefix, Map<NodeAttribute, AttributeValue> oldAttributeMappings, Map<NodeAttribute, AttributeValue> newAttributeMappings) { if (oldAttributeMappings != null) { Set<NodeAttribute> toRemoveAttributes = NodeLabelUtil.filterAttributesByPrefix( oldAttributeMappings.keySet(), prefix); removeNodeFromAttributes(nodeHost, toRemoveAttributes); } addNodeToAttribute(nodeHost, newAttributeMappings); }
private void processMapping( Map<String, Set<NodeAttribute>> nodeAttributeMapping, AttributeMappingOperationType mappingType, String attributePrefix) throws IOException { Map<NodeAttributeKey, RMNodeAttribute> newAttributesToBeAdded = new HashMap<>(); Map<String, Map<NodeAttribute, AttributeValue>> validMapping = validate(nodeAttributeMapping, newAttributesToBeAdded, false); if (validMapping.size() > 0) { internalUpdateAttributesOnNodes(validMapping, mappingType, newAttributesToBeAdded, attributePrefix); } }
@Override protected void serviceStart() throws Exception { initNodeAttributeStore(getConfig()); // init dispatcher only when service start, because recover will happen in // service init, we don't want to trigger any event handling at that time. initDispatcher(getConfig()); if (null != dispatcher) { dispatcher.register(NodeAttributesStoreEventType.class, new ForwardingEventHandler()); } startDispatcher(); super.serviceStart(); }
removeNodeFromAttributes(nodeHost, attributes.keySet()); node.removeAttributes(attributes); break; case ADD: clusterAttributes.putAll(newAttributesToBeAdded); addNodeToAttribute(nodeHost, attributes); node.addAttributes(attributes); break; case REPLACE: clusterAttributes.putAll(newAttributesToBeAdded); replaceNodeToAttribute(nodeHost, attributePrefix, node.getAttributes(), attributes); node.replaceAttributes(attributes, attributePrefix);
@Before public void init() throws IOException { Configuration conf = new Configuration(); attributesManager = new NodeAttributesManagerImpl(); conf.setClass(YarnConfiguration.FS_NODE_ATTRIBUTE_STORE_IMPL_CLASS, FileSystemNodeAttributeStore.class, NodeAttributeStore.class); conf = NodeAttributeTestUtils.getRandomDirConf(conf); attributesManager.init(conf); attributesManager.start(); }
@Override public void handle(NodeAttributesStoreEvent event) { handleStoreEvent(event); } }
protected void initNodeAttributeStore(Configuration conf) throws Exception { this.store = getAttributeStoreClass(conf); this.store.init(conf, this); this.store.recover(); }