diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/store/op/NodeLabelMirrorOp.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/store/op/NodeLabelMirrorOp.java index 9500486645..64400fe6e6 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/store/op/NodeLabelMirrorOp.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/store/op/NodeLabelMirrorOp.java @@ -27,6 +27,8 @@ .AddToClusterNodeLabelsRequestPBImpl; import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb .ReplaceLabelsOnNodeRequestPBImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.io.InputStream; @@ -40,6 +42,8 @@ */ public class NodeLabelMirrorOp extends FSNodeStoreLogOp { + private static final Logger LOG = LoggerFactory.getLogger( + NodeLabelMirrorOp.class); public NodeLabelMirrorOp() { super(); @@ -66,15 +70,20 @@ public void recover(InputStream is, CommonNodeLabelsManager mgr) .parseDelimitedFrom(is)).getNodeLabels(); mgr.addToCluserNodeLabels(labels); - if (mgr.isCentralizedConfiguration()) { - // Only load node to labels mapping while using centralized - // configuration - Map> nodeToLabels = - new ReplaceLabelsOnNodeRequestPBImpl( - YarnServerResourceManagerServiceProtos - .ReplaceLabelsOnNodeRequestProto - .parseDelimitedFrom(is)).getNodeToLabels(); - mgr.replaceLabelsOnNode(nodeToLabels); + try { + if (mgr.isCentralizedConfiguration() && is.available() != 0) { + // Only load node to labels mapping while using centralized + // configuration + Map> nodeToLabels = + new ReplaceLabelsOnNodeRequestPBImpl( + YarnServerResourceManagerServiceProtos + .ReplaceLabelsOnNodeRequestProto + .parseDelimitedFrom(is)).getNodeToLabels(); + mgr.replaceLabelsOnNode(nodeToLabels); + } + } catch (Exception e) { + LOG.error("Errors on loading node to labels mapping while using " + + "centralized configuration", e); } }