Class NodeAttributesManagerImpl
java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.yarn.nodelabels.NodeAttributesManager
org.apache.hadoop.yarn.server.resourcemanager.nodelabels.NodeAttributesManagerImpl
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.service.Service
public class NodeAttributesManagerImpl
extends org.apache.hadoop.yarn.nodelabels.NodeAttributesManager
Manager holding the attributes to Labels.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAHostcan have multipleNodes.Nested classes/interfaces inherited from interface org.apache.hadoop.service.Service
org.apache.hadoop.service.Service.STATE -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringIf a user doesn't specify value for a label, then empty string is considered as default.protected static final org.slf4j.Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivateNode(org.apache.hadoop.yarn.api.records.NodeId nodeId, org.apache.hadoop.yarn.api.records.Resource resource) voidaddNodeAttributes(Map<String, Set<org.apache.hadoop.yarn.api.records.NodeAttribute>> nodeAttributeMapping) voiddeactivateNode(org.apache.hadoop.yarn.api.records.NodeId nodeId) Map<org.apache.hadoop.yarn.api.records.NodeAttribute,org.apache.hadoop.yarn.nodelabels.AttributeValue> getAttributesForNode(String hostName) Map<org.apache.hadoop.yarn.api.records.NodeAttributeKey,Map<String, org.apache.hadoop.yarn.nodelabels.AttributeValue>> getAttributesToNodes(Set<org.apache.hadoop.yarn.api.records.NodeAttributeKey> attributes) Set<org.apache.hadoop.yarn.api.records.NodeAttribute>getClusterNodeAttributes(Set<String> prefix) getNodesToAttributes(Set<String> hostNames) List<org.apache.hadoop.yarn.server.api.protocolrecords.NodeToAttributes>getNodeToAttributes(Set<String> prefix) org.apache.hadoop.yarn.api.records.ResourcegetResourceByAttribute(org.apache.hadoop.yarn.api.records.NodeAttribute attribute) protected voidprotected voidinitDispatcher(org.apache.hadoop.conf.Configuration conf) protected voidinitNodeAttributeStore(org.apache.hadoop.conf.Configuration conf) protected voidinternalUpdateAttributesOnNodes(Map<String, Map<org.apache.hadoop.yarn.api.records.NodeAttribute, org.apache.hadoop.yarn.nodelabels.AttributeValue>> nodeAttributeMapping, org.apache.hadoop.yarn.server.api.protocolrecords.AttributeMappingOperationType op, Map<org.apache.hadoop.yarn.api.records.NodeAttributeKey, org.apache.hadoop.yarn.nodelabels.RMNodeAttribute> newAttributesToBeAdded, String attributePrefix) protected StringnormalizeAttributeValue(String value) voidrefreshNodeAttributesToScheduler(org.apache.hadoop.yarn.api.records.NodeId nodeId) Refresh node attributes on a given node during RM recovery.voidremoveNodeAttributes(Map<String, Set<org.apache.hadoop.yarn.api.records.NodeAttribute>> nodeAttributeMapping) voidreplaceNodeAttributes(String prefix, Map<String, Set<org.apache.hadoop.yarn.api.records.NodeAttribute>> nodeAttributeMapping) protected voidprotected voidvoidsetRMContext(RMContext context) protected voidprotected voidvoidupdateNodeResource(org.apache.hadoop.yarn.api.records.NodeId node, org.apache.hadoop.yarn.api.records.Resource newResource) protected Map<String,Map<org.apache.hadoop.yarn.api.records.NodeAttribute, org.apache.hadoop.yarn.nodelabels.AttributeValue>> validate(Map<String, Set<org.apache.hadoop.yarn.api.records.NodeAttribute>> nodeAttributeMapping, Map<org.apache.hadoop.yarn.api.records.NodeAttributeKey, org.apache.hadoop.yarn.nodelabels.RMNodeAttribute> newAttributesToBeAdded, boolean isRemoveOperation) Validate for attributes.Methods inherited from class org.apache.hadoop.service.AbstractService
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, serviceInit, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop
-
Field Details
-
LOG
protected static final org.slf4j.Logger LOG -
EMPTY_ATTRIBUTE_VALUE
If a user doesn't specify value for a label, then empty string is considered as default.- See Also:
-
-
Constructor Details
-
NodeAttributesManagerImpl
public NodeAttributesManagerImpl()
-
-
Method Details
-
initDispatcher
protected void initDispatcher(org.apache.hadoop.conf.Configuration conf) -
startDispatcher
protected void startDispatcher() -
serviceStart
- Overrides:
serviceStartin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
initNodeAttributeStore
- Throws:
Exception
-
internalUpdateAttributesOnNodes
@VisibleForTesting protected void internalUpdateAttributesOnNodes(Map<String, Map<org.apache.hadoop.yarn.api.records.NodeAttribute, org.apache.hadoop.yarn.nodelabels.AttributeValue>> nodeAttributeMapping, org.apache.hadoop.yarn.server.api.protocolrecords.AttributeMappingOperationType op, Map<org.apache.hadoop.yarn.api.records.NodeAttributeKey, org.apache.hadoop.yarn.nodelabels.RMNodeAttribute> newAttributesToBeAdded, String attributePrefix) -
validate
protected Map<String,Map<org.apache.hadoop.yarn.api.records.NodeAttribute, validateorg.apache.hadoop.yarn.nodelabels.AttributeValue>> (Map<String, Set<org.apache.hadoop.yarn.api.records.NodeAttribute>> nodeAttributeMapping, Map<org.apache.hadoop.yarn.api.records.NodeAttributeKey, throws IOExceptionorg.apache.hadoop.yarn.nodelabels.RMNodeAttribute> newAttributesToBeAdded, boolean isRemoveOperation) Validate for attributes.- Parameters:
nodeAttributeMapping- NodeAttribute MappingnewAttributesToBeAdded- new Attributes ToBeAddedisRemoveOperation- : to indicate whether it's a remove operation.- Returns:
- Map of String to Map of NodeAttribute to AttributeValue
- Throws:
IOException- : on invalid mapping in the current request or against already existing NodeAttributes.
-
normalizeAttributeValue
-
getClusterNodeAttributes
public Set<org.apache.hadoop.yarn.api.records.NodeAttribute> getClusterNodeAttributes(Set<String> prefix) - Specified by:
getClusterNodeAttributesin classorg.apache.hadoop.yarn.nodelabels.NodeAttributesManager
-
getAttributesToNodes
public Map<org.apache.hadoop.yarn.api.records.NodeAttributeKey,Map<String, getAttributesToNodesorg.apache.hadoop.yarn.nodelabels.AttributeValue>> (Set<org.apache.hadoop.yarn.api.records.NodeAttributeKey> attributes) - Specified by:
getAttributesToNodesin classorg.apache.hadoop.yarn.nodelabels.NodeAttributesManager
-
getResourceByAttribute
public org.apache.hadoop.yarn.api.records.Resource getResourceByAttribute(org.apache.hadoop.yarn.api.records.NodeAttribute attribute) -
getAttributesForNode
public Map<org.apache.hadoop.yarn.api.records.NodeAttribute,org.apache.hadoop.yarn.nodelabels.AttributeValue> getAttributesForNode(String hostName) - Specified by:
getAttributesForNodein classorg.apache.hadoop.yarn.nodelabels.NodeAttributesManager
-
getNodeToAttributes
public List<org.apache.hadoop.yarn.server.api.protocolrecords.NodeToAttributes> getNodeToAttributes(Set<String> prefix) - Specified by:
getNodeToAttributesin classorg.apache.hadoop.yarn.nodelabels.NodeAttributesManager
-
getNodesToAttributes
public Map<String,Set<org.apache.hadoop.yarn.api.records.NodeAttribute>> getNodesToAttributes(Set<String> hostNames) - Specified by:
getNodesToAttributesin classorg.apache.hadoop.yarn.nodelabels.NodeAttributesManager
-
activateNode
public void activateNode(org.apache.hadoop.yarn.api.records.NodeId nodeId, org.apache.hadoop.yarn.api.records.Resource resource) -
deactivateNode
public void deactivateNode(org.apache.hadoop.yarn.api.records.NodeId nodeId) -
updateNodeResource
public void updateNodeResource(org.apache.hadoop.yarn.api.records.NodeId node, org.apache.hadoop.yarn.api.records.Resource newResource) -
handleStoreEvent
-
replaceNodeAttributes
public void replaceNodeAttributes(String prefix, Map<String, Set<org.apache.hadoop.yarn.api.records.NodeAttribute>> nodeAttributeMapping) throws IOException- Specified by:
replaceNodeAttributesin classorg.apache.hadoop.yarn.nodelabels.NodeAttributesManager- Throws:
IOException
-
addNodeAttributes
public void addNodeAttributes(Map<String, Set<org.apache.hadoop.yarn.api.records.NodeAttribute>> nodeAttributeMapping) throws IOException- Specified by:
addNodeAttributesin classorg.apache.hadoop.yarn.nodelabels.NodeAttributesManager- Throws:
IOException
-
removeNodeAttributes
public void removeNodeAttributes(Map<String, Set<org.apache.hadoop.yarn.api.records.NodeAttribute>> nodeAttributeMapping) throws IOException- Specified by:
removeNodeAttributesin classorg.apache.hadoop.yarn.nodelabels.NodeAttributesManager- Throws:
IOException
-
stopDispatcher
protected void stopDispatcher() -
serviceStop
- Overrides:
serviceStopin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
setRMContext
-
refreshNodeAttributesToScheduler
public void refreshNodeAttributesToScheduler(org.apache.hadoop.yarn.api.records.NodeId nodeId) Refresh node attributes on a given node during RM recovery.- Specified by:
refreshNodeAttributesToSchedulerin classorg.apache.hadoop.yarn.nodelabels.NodeAttributesManager- Parameters:
nodeId- Node Id
-