|
@@ -84,10 +84,12 @@ public class NodesListManager extends CompositeService implements
|
|
|
private Resolver resolver;
|
|
|
private Timer removalTimer;
|
|
|
private int nodeRemovalCheckInterval;
|
|
|
+ private Set<RMNode> gracefulDecommissionableNodes;
|
|
|
|
|
|
public NodesListManager(RMContext rmContext) {
|
|
|
super(NodesListManager.class.getName());
|
|
|
this.rmContext = rmContext;
|
|
|
+ this.gracefulDecommissionableNodes = ConcurrentHashMap.newKeySet();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -115,7 +117,7 @@ public class NodesListManager extends CompositeService implements
|
|
|
this.hostsReader =
|
|
|
createHostsFileReader(this.includesFile, this.excludesFile);
|
|
|
setDecommissionedNMs();
|
|
|
- printConfiguredHosts();
|
|
|
+ printConfiguredHosts(false);
|
|
|
} catch (YarnException ex) {
|
|
|
disableHostsFileReader(ex);
|
|
|
} catch (IOException ioe) {
|
|
@@ -187,7 +189,7 @@ public class NodesListManager extends CompositeService implements
|
|
|
removalTimer.cancel();
|
|
|
}
|
|
|
|
|
|
- private void printConfiguredHosts() {
|
|
|
+ private void printConfiguredHosts(boolean graceful) {
|
|
|
if (!LOG.isDebugEnabled()) {
|
|
|
return;
|
|
|
}
|
|
@@ -198,7 +200,12 @@ public class NodesListManager extends CompositeService implements
|
|
|
conf.get(YarnConfiguration.RM_NODES_EXCLUDE_FILE_PATH,
|
|
|
YarnConfiguration.DEFAULT_RM_NODES_EXCLUDE_FILE_PATH));
|
|
|
|
|
|
- HostDetails hostDetails = hostsReader.getHostDetails();
|
|
|
+ HostDetails hostDetails;
|
|
|
+ if (graceful) {
|
|
|
+ hostDetails = hostsReader.getLazyLoadedHostDetails();
|
|
|
+ } else {
|
|
|
+ hostDetails = hostsReader.getHostDetails();
|
|
|
+ }
|
|
|
for (String include : hostDetails.getIncludedHosts()) {
|
|
|
LOG.debug("include: " + include);
|
|
|
}
|
|
@@ -235,8 +242,15 @@ public class NodesListManager extends CompositeService implements
|
|
|
yarnConf.get(YarnConfiguration.RM_NODES_EXCLUDE_FILE_PATH,
|
|
|
YarnConfiguration.DEFAULT_RM_NODES_EXCLUDE_FILE_PATH);
|
|
|
LOG.info("refreshNodes excludesFile " + excludesFile);
|
|
|
- hostsReader.refresh(includesFile, excludesFile);
|
|
|
- printConfiguredHosts();
|
|
|
+
|
|
|
+ if (graceful) {
|
|
|
+ // update hosts, but don't make it visible just yet
|
|
|
+ hostsReader.lazyRefresh(includesFile, excludesFile);
|
|
|
+ } else {
|
|
|
+ hostsReader.refresh(includesFile, excludesFile);
|
|
|
+ }
|
|
|
+
|
|
|
+ printConfiguredHosts(graceful);
|
|
|
|
|
|
LOG.info("hostsReader include:{" +
|
|
|
StringUtils.join(",", hostsReader.getHosts()) +
|
|
@@ -270,7 +284,14 @@ public class NodesListManager extends CompositeService implements
|
|
|
// Nodes need to be decommissioned (graceful or forceful);
|
|
|
List<RMNode> nodesToDecom = new ArrayList<RMNode>();
|
|
|
|
|
|
- HostDetails hostDetails = hostsReader.getHostDetails();
|
|
|
+ HostDetails hostDetails;
|
|
|
+ gracefulDecommissionableNodes.clear();
|
|
|
+ if (graceful) {
|
|
|
+ hostDetails = hostsReader.getLazyLoadedHostDetails();
|
|
|
+ } else {
|
|
|
+ hostDetails = hostsReader.getHostDetails();
|
|
|
+ }
|
|
|
+
|
|
|
Set<String> includes = hostDetails.getIncludedHosts();
|
|
|
Map<String, Integer> excludes = hostDetails.getExcludedMap();
|
|
|
|
|
@@ -298,11 +319,13 @@ public class NodesListManager extends CompositeService implements
|
|
|
s != NodeState.DECOMMISSIONING) {
|
|
|
LOG.info("Gracefully decommission " + nodeStr);
|
|
|
nodesToDecom.add(n);
|
|
|
+ gracefulDecommissionableNodes.add(n);
|
|
|
} else if (s == NodeState.DECOMMISSIONING &&
|
|
|
!Objects.equals(n.getDecommissioningTimeout(),
|
|
|
timeoutToUse)) {
|
|
|
LOG.info("Update " + nodeStr + " timeout to be " + timeoutToUse);
|
|
|
nodesToDecom.add(n);
|
|
|
+ gracefulDecommissionableNodes.add(n);
|
|
|
} else {
|
|
|
LOG.info("No action for " + nodeStr);
|
|
|
}
|
|
@@ -315,6 +338,10 @@ public class NodesListManager extends CompositeService implements
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (graceful) {
|
|
|
+ hostsReader.finishRefresh();
|
|
|
+ }
|
|
|
+
|
|
|
for (RMNode n : nodesToRecom) {
|
|
|
RMNodeEvent e = new RMNodeEvent(
|
|
|
n.getNodeID(), RMNodeEventType.RECOMMISSION);
|
|
@@ -466,6 +493,10 @@ public class NodesListManager extends CompositeService implements
|
|
|
hostDetails.getExcludedHosts());
|
|
|
}
|
|
|
|
|
|
+ boolean isGracefullyDecommissionableNode(RMNode node) {
|
|
|
+ return gracefulDecommissionableNodes.contains(node);
|
|
|
+ }
|
|
|
+
|
|
|
private boolean isValidNode(
|
|
|
String hostName, Set<String> hostsList, Set<String> excludeList) {
|
|
|
String ip = resolver.resolve(hostName);
|