YARN-10479. Can't remove all node labels after add node label without
nodemanager port, broken by YARN-10647. Contributed by D M Murali Krishna Reddy
(cherry picked from commit 6857a05d6a
)
This commit is contained in:
parent
7ad844ee9e
commit
951ce9b371
|
@ -94,6 +94,8 @@ public class CommonNodeLabelsManager extends AbstractService {
|
||||||
new ConcurrentHashMap<String, RMNodeLabel>();
|
new ConcurrentHashMap<String, RMNodeLabel>();
|
||||||
protected ConcurrentMap<String, Host> nodeCollections =
|
protected ConcurrentMap<String, Host> nodeCollections =
|
||||||
new ConcurrentHashMap<String, Host>();
|
new ConcurrentHashMap<String, Host>();
|
||||||
|
private ConcurrentMap<NodeId, Boolean> isNodeLabelFromHost =
|
||||||
|
new ConcurrentHashMap<NodeId, Boolean>();
|
||||||
|
|
||||||
protected RMNodeLabel noNodeLabel;
|
protected RMNodeLabel noNodeLabel;
|
||||||
|
|
||||||
|
@ -602,6 +604,11 @@ public class CommonNodeLabelsManager extends AbstractService {
|
||||||
addLabelsToNodeInHost(node, newLabels);
|
addLabelsToNodeInHost(node, newLabels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isNodeLabelExplicit(NodeId nodeId) {
|
||||||
|
return !isNodeLabelFromHost.containsKey(nodeId) ||
|
||||||
|
isNodeLabelFromHost.get(nodeId);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected void internalUpdateLabelsOnNodes(
|
protected void internalUpdateLabelsOnNodes(
|
||||||
Map<NodeId, Set<String>> nodeToLabels, NodeLabelUpdateOperation op)
|
Map<NodeId, Set<String>> nodeToLabels, NodeLabelUpdateOperation op)
|
||||||
|
@ -636,6 +643,7 @@ public class CommonNodeLabelsManager extends AbstractService {
|
||||||
node.labels.addAll(labels);
|
node.labels.addAll(labels);
|
||||||
}
|
}
|
||||||
addNodeToLabels(node.nodeId, labels);
|
addNodeToLabels(node.nodeId, labels);
|
||||||
|
isNodeLabelFromHost.put(node.nodeId, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case REPLACE:
|
case REPLACE:
|
||||||
|
@ -645,10 +653,9 @@ public class CommonNodeLabelsManager extends AbstractService {
|
||||||
host.labels.addAll(labels);
|
host.labels.addAll(labels);
|
||||||
for (Node node : host.nms.values()) {
|
for (Node node : host.nms.values()) {
|
||||||
replaceNodeForLabels(node.nodeId, node.labels, labels);
|
replaceNodeForLabels(node.nodeId, node.labels, labels);
|
||||||
if (node.labels != null) {
|
|
||||||
replaceLabelsForNode(node.nodeId, node.labels, labels);
|
replaceLabelsForNode(node.nodeId, node.labels, labels);
|
||||||
}
|
|
||||||
node.labels = null;
|
node.labels = null;
|
||||||
|
isNodeLabelFromHost.put(node.nodeId, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -668,6 +675,7 @@ public class CommonNodeLabelsManager extends AbstractService {
|
||||||
nm.labels = new HashSet<String>();
|
nm.labels = new HashSet<String>();
|
||||||
}
|
}
|
||||||
nm.labels.addAll(labels);
|
nm.labels.addAll(labels);
|
||||||
|
isNodeLabelFromHost.put(nm.nodeId, false);
|
||||||
break;
|
break;
|
||||||
case REPLACE:
|
case REPLACE:
|
||||||
oldLabels = getLabelsByNode(nodeId);
|
oldLabels = getLabelsByNode(nodeId);
|
||||||
|
@ -678,6 +686,7 @@ public class CommonNodeLabelsManager extends AbstractService {
|
||||||
}
|
}
|
||||||
nm.labels.clear();
|
nm.labels.clear();
|
||||||
nm.labels.addAll(labels);
|
nm.labels.addAll(labels);
|
||||||
|
isNodeLabelFromHost.put(nm.nodeId, false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -280,7 +280,7 @@ public class RMNodeLabelsManager extends CommonNodeLabelsManager {
|
||||||
Map<String, Host> before = cloneNodeMap(ImmutableSet.of(nodeId));
|
Map<String, Host> before = cloneNodeMap(ImmutableSet.of(nodeId));
|
||||||
Node nm = getNMInNodeSet(nodeId);
|
Node nm = getNMInNodeSet(nodeId);
|
||||||
if (null != nm) {
|
if (null != nm) {
|
||||||
if (null == nm.labels) {
|
if (isNodeLabelExplicit(nm.nodeId)) {
|
||||||
// When node deactivated, remove the nm from node collection if no
|
// When node deactivated, remove the nm from node collection if no
|
||||||
// labels explicitly set for this particular nm
|
// labels explicitly set for this particular nm
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue