@InterfaceAudience.Private
public class CommonNodeLabelsManager
extends org.apache.hadoop.service.AbstractService
Modifier and Type | Class and Description |
---|---|
static class |
CommonNodeLabelsManager.Host
A
Host can have multiple Node s |
protected static class |
CommonNodeLabelsManager.Node |
Modifier and Type | Field and Description |
---|---|
static Set<String> |
ACCESS_ANY_LABEL_SET |
static String |
ANY |
protected Dispatcher |
dispatcher |
static Set<org.apache.hadoop.yarn.api.records.NodeLabel> |
EMPTY_NODELABEL_SET |
static Set<String> |
EMPTY_STRING_SET |
protected ConcurrentMap<String,RMNodeLabel> |
labelCollections |
protected static org.slf4j.Logger |
LOG |
static String |
NO_LABEL
If a user doesn't specify label of a queue or node, it belongs
DEFAULT_LABEL
|
static String |
NODE_LABELS_NOT_ENABLED_ERR
Error messages
|
protected ConcurrentMap<String,CommonNodeLabelsManager.Host> |
nodeCollections |
protected RMNodeLabel |
noNodeLabel |
protected ReentrantReadWriteLock.ReadLock |
readLock |
protected NodeLabelsStore |
store |
static int |
WILDCARD_PORT |
protected ReentrantReadWriteLock.WriteLock |
writeLock |
Constructor and Description |
---|
CommonNodeLabelsManager() |
Modifier and Type | Method and Description |
---|---|
void |
addLabelsToNode(Map<org.apache.hadoop.yarn.api.records.NodeId,Set<String>> addedLabelsToNode)
add more labels to nodes.
|
void |
addToCluserNodeLabels(Collection<org.apache.hadoop.yarn.api.records.NodeLabel> labels) |
void |
addToCluserNodeLabelsWithDefaultExclusivity(Set<String> labels)
Add multiple node labels to repository.
|
protected void |
checkAddLabelsToNode(Map<org.apache.hadoop.yarn.api.records.NodeId,Set<String>> addedLabelsToNode) |
protected void |
checkRemoveFromClusterNodeLabels(Collection<String> labelsToRemove) |
protected void |
checkRemoveLabelsFromNode(Map<org.apache.hadoop.yarn.api.records.NodeId,Set<String>> removeLabelsFromNode) |
protected void |
checkReplaceLabelsOnNode(Map<org.apache.hadoop.yarn.api.records.NodeId,Set<String>> replaceLabelsToNode) |
protected void |
createHostIfNonExisted(String hostName) |
protected void |
createNodeIfNonExisted(org.apache.hadoop.yarn.api.records.NodeId nodeId) |
Set<String> |
getClusterNodeLabelNames()
Get existing valid labels in repository
|
List<org.apache.hadoop.yarn.api.records.NodeLabel> |
getClusterNodeLabels() |
protected Set<String> |
getLabelsByNode(org.apache.hadoop.yarn.api.records.NodeId nodeId) |
protected Set<String> |
getLabelsByNode(org.apache.hadoop.yarn.api.records.NodeId nodeId,
Map<String,CommonNodeLabelsManager.Host> map) |
Set<org.apache.hadoop.yarn.api.records.NodeLabel> |
getLabelsInfoByNode(org.apache.hadoop.yarn.api.records.NodeId nodeId) |
Map<org.apache.hadoop.yarn.api.records.NodeLabel,Set<org.apache.hadoop.yarn.api.records.NodeId>> |
getLabelsInfoToNodes()
Get mapping of labels to nodes for all the labels.
|
Map<org.apache.hadoop.yarn.api.records.NodeLabel,Set<org.apache.hadoop.yarn.api.records.NodeId>> |
getLabelsInfoToNodes(Set<String> labels)
Get mapping of labels info to nodes for specified set of labels.
|
Map<String,Set<org.apache.hadoop.yarn.api.records.NodeId>> |
getLabelsToNodes()
Get mapping of labels to nodes for all the labels.
|
Map<String,Set<org.apache.hadoop.yarn.api.records.NodeId>> |
getLabelsToNodes(Set<String> labels)
Get mapping of labels to nodes for specified set of labels.
|
protected CommonNodeLabelsManager.Node |
getNMInNodeSet(org.apache.hadoop.yarn.api.records.NodeId nodeId) |
protected CommonNodeLabelsManager.Node |
getNMInNodeSet(org.apache.hadoop.yarn.api.records.NodeId nodeId,
Map<String,CommonNodeLabelsManager.Host> map) |
protected CommonNodeLabelsManager.Node |
getNMInNodeSet(org.apache.hadoop.yarn.api.records.NodeId nodeId,
Map<String,CommonNodeLabelsManager.Host> map,
boolean checkRunning) |
Map<org.apache.hadoop.yarn.api.records.NodeId,Set<String>> |
getNodeLabels()
Get mapping of nodes to labels
|
Map<org.apache.hadoop.yarn.api.records.NodeId,Set<org.apache.hadoop.yarn.api.records.NodeLabel>> |
getNodeLabelsInfo()
Get mapping of nodes to label info
|
Set<org.apache.hadoop.yarn.api.records.NodeId> |
getNodesWithoutALabel()
Get nodes that have no labels.
|
protected void |
handleStoreEvent(NodeLabelsStoreEvent event) |
protected void |
initDispatcher(org.apache.hadoop.conf.Configuration conf) |
protected void |
initNodeLabelStore(org.apache.hadoop.conf.Configuration conf) |
protected void |
internalRemoveFromClusterNodeLabels(Collection<String> labelsToRemove) |
protected void |
internalUpdateLabelsOnNodes(Map<org.apache.hadoop.yarn.api.records.NodeId,Set<String>> nodeToLabels,
org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager.NodeLabelUpdateOperation op) |
boolean |
isCentralizedConfiguration() |
boolean |
isExclusiveNodeLabel(String nodeLabel) |
protected boolean |
isInitNodeLabelStoreInProgress() |
protected boolean |
isNodeLabelExplicit(org.apache.hadoop.yarn.api.records.NodeId nodeId) |
protected String |
normalizeLabel(String label) |
protected Map<org.apache.hadoop.yarn.api.records.NodeId,Set<String>> |
normalizeNodeIdToLabels(Map<org.apache.hadoop.yarn.api.records.NodeId,Set<String>> nodeIdToLabels) |
void |
removeFromClusterNodeLabels(Collection<String> labelsToRemove)
Remove multiple node labels from repository
|
void |
removeLabelsFromNode(Map<org.apache.hadoop.yarn.api.records.NodeId,Set<String>> removeLabelsFromNode)
remove labels from nodes, labels being removed most be contained by these
nodes.
|
protected void |
removeLabelsFromNodeInHost(org.apache.hadoop.yarn.api.records.NodeId node,
Set<String> labels) |
protected void |
removeNodeFromLabels(org.apache.hadoop.yarn.api.records.NodeId node,
Set<String> labels) |
void |
replaceLabelsOnNode(Map<org.apache.hadoop.yarn.api.records.NodeId,Set<String>> replaceLabelsToNode)
replace labels to nodes
|
protected void |
serviceInit(org.apache.hadoop.conf.Configuration conf) |
protected void |
serviceStart() |
protected void |
serviceStop() |
void |
setInitNodeLabelStoreInProgress(boolean initNodeLabelStoreInProgress) |
protected void |
startDispatcher() |
protected void |
stopDispatcher() |
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop
protected static final org.slf4j.Logger LOG
public static final Set<org.apache.hadoop.yarn.api.records.NodeLabel> EMPTY_NODELABEL_SET
public static final String ANY
public static final int WILDCARD_PORT
@VisibleForTesting public static final String NODE_LABELS_NOT_ENABLED_ERR
public static final String NO_LABEL
protected Dispatcher dispatcher
protected ConcurrentMap<String,RMNodeLabel> labelCollections
protected ConcurrentMap<String,CommonNodeLabelsManager.Host> nodeCollections
protected RMNodeLabel noNodeLabel
protected final ReentrantReadWriteLock.ReadLock readLock
protected final ReentrantReadWriteLock.WriteLock writeLock
protected NodeLabelsStore store
protected void handleStoreEvent(NodeLabelsStoreEvent event)
protected void initDispatcher(org.apache.hadoop.conf.Configuration conf)
protected void serviceInit(org.apache.hadoop.conf.Configuration conf) throws Exception
serviceInit
in class org.apache.hadoop.service.AbstractService
Exception
protected boolean isInitNodeLabelStoreInProgress()
public boolean isCentralizedConfiguration()
protected void initNodeLabelStore(org.apache.hadoop.conf.Configuration conf) throws Exception
Exception
protected void startDispatcher()
protected void serviceStart() throws Exception
serviceStart
in class org.apache.hadoop.service.AbstractService
Exception
protected void stopDispatcher()
protected void serviceStop() throws Exception
serviceStop
in class org.apache.hadoop.service.AbstractService
Exception
public void addToCluserNodeLabels(Collection<org.apache.hadoop.yarn.api.records.NodeLabel> labels) throws IOException
IOException
@VisibleForTesting public void addToCluserNodeLabelsWithDefaultExclusivity(Set<String> labels) throws IOException
labels
- new node labels addedIOException
- io error occur.protected void checkAddLabelsToNode(Map<org.apache.hadoop.yarn.api.records.NodeId,Set<String>> addedLabelsToNode) throws IOException
IOException
public void addLabelsToNode(Map<org.apache.hadoop.yarn.api.records.NodeId,Set<String>> addedLabelsToNode) throws IOException
addedLabelsToNode
- node -> labels mapIOException
- io error occur.protected void checkRemoveFromClusterNodeLabels(Collection<String> labelsToRemove) throws IOException
IOException
protected void internalRemoveFromClusterNodeLabels(Collection<String> labelsToRemove)
public void removeFromClusterNodeLabels(Collection<String> labelsToRemove) throws IOException
labelsToRemove
- node labels to removeIOException
- io error occur.protected void checkRemoveLabelsFromNode(Map<org.apache.hadoop.yarn.api.records.NodeId,Set<String>> removeLabelsFromNode) throws IOException
IOException
protected void removeNodeFromLabels(org.apache.hadoop.yarn.api.records.NodeId node, Set<String> labels)
protected void removeLabelsFromNodeInHost(org.apache.hadoop.yarn.api.records.NodeId node, Set<String> labels) throws IOException
IOException
protected boolean isNodeLabelExplicit(org.apache.hadoop.yarn.api.records.NodeId nodeId)
protected void internalUpdateLabelsOnNodes(Map<org.apache.hadoop.yarn.api.records.NodeId,Set<String>> nodeToLabels, org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager.NodeLabelUpdateOperation op) throws IOException
IOException
public void removeLabelsFromNode(Map<org.apache.hadoop.yarn.api.records.NodeId,Set<String>> removeLabelsFromNode) throws IOException
removeLabelsFromNode
- node -> labels mapIOException
- io error occur.protected void checkReplaceLabelsOnNode(Map<org.apache.hadoop.yarn.api.records.NodeId,Set<String>> replaceLabelsToNode) throws IOException
IOException
public void replaceLabelsOnNode(Map<org.apache.hadoop.yarn.api.records.NodeId,Set<String>> replaceLabelsToNode) throws IOException
replaceLabelsToNode
- node -> labels mapIOException
- io error occur.public Map<org.apache.hadoop.yarn.api.records.NodeId,Set<String>> getNodeLabels()
public Map<org.apache.hadoop.yarn.api.records.NodeId,Set<org.apache.hadoop.yarn.api.records.NodeLabel>> getNodeLabelsInfo()
public Set<org.apache.hadoop.yarn.api.records.NodeId> getNodesWithoutALabel()
public Map<String,Set<org.apache.hadoop.yarn.api.records.NodeId>> getLabelsToNodes()
public Map<String,Set<org.apache.hadoop.yarn.api.records.NodeId>> getLabelsToNodes(Set<String> labels)
labels
- set of labels for which labels to nodes mapping will be
returned.public Map<org.apache.hadoop.yarn.api.records.NodeLabel,Set<org.apache.hadoop.yarn.api.records.NodeId>> getLabelsInfoToNodes()
public Map<org.apache.hadoop.yarn.api.records.NodeLabel,Set<org.apache.hadoop.yarn.api.records.NodeId>> getLabelsInfoToNodes(Set<String> labels)
labels
- set of nodelabels for which labels to nodes mapping will be
returned.public Set<String> getClusterNodeLabelNames()
public List<org.apache.hadoop.yarn.api.records.NodeLabel> getClusterNodeLabels()
public boolean isExclusiveNodeLabel(String nodeLabel) throws IOException
IOException
protected CommonNodeLabelsManager.Node getNMInNodeSet(org.apache.hadoop.yarn.api.records.NodeId nodeId)
protected CommonNodeLabelsManager.Node getNMInNodeSet(org.apache.hadoop.yarn.api.records.NodeId nodeId, Map<String,CommonNodeLabelsManager.Host> map)
protected CommonNodeLabelsManager.Node getNMInNodeSet(org.apache.hadoop.yarn.api.records.NodeId nodeId, Map<String,CommonNodeLabelsManager.Host> map, boolean checkRunning)
protected Set<String> getLabelsByNode(org.apache.hadoop.yarn.api.records.NodeId nodeId)
protected Set<String> getLabelsByNode(org.apache.hadoop.yarn.api.records.NodeId nodeId, Map<String,CommonNodeLabelsManager.Host> map)
public Set<org.apache.hadoop.yarn.api.records.NodeLabel> getLabelsInfoByNode(org.apache.hadoop.yarn.api.records.NodeId nodeId)
protected void createNodeIfNonExisted(org.apache.hadoop.yarn.api.records.NodeId nodeId) throws IOException
IOException
protected void createHostIfNonExisted(String hostName)
protected Map<org.apache.hadoop.yarn.api.records.NodeId,Set<String>> normalizeNodeIdToLabels(Map<org.apache.hadoop.yarn.api.records.NodeId,Set<String>> nodeIdToLabels)
public void setInitNodeLabelStoreInProgress(boolean initNodeLabelStoreInProgress)
Copyright © 2008–2024 Apache Software Foundation. All rights reserved.