/// <summary>Get mapping of labels to nodes for specified set of labels.</summary> /// <param name="labels"> /// set of labels for which labels to nodes mapping will be /// returned. /// </param> /// <returns>labels to nodes map</returns> public virtual IDictionary <string, ICollection <NodeId> > GetLabelsToNodes(ICollection <string> labels) { try { readLock.Lock(); IDictionary <string, ICollection <NodeId> > labelsToNodes = new Dictionary <string, ICollection <NodeId> >(); foreach (string label in labels) { if (label.Equals(NoLabel)) { continue; } NodeLabel nodeLabelInfo = labelCollections[label]; if (nodeLabelInfo != null) { ICollection <NodeId> nodeIds = nodeLabelInfo.GetAssociatedNodeIds(); if (!nodeIds.IsEmpty()) { labelsToNodes[label] = nodeIds; } } else { Log.Warn("getLabelsToNodes : Label [" + label + "] cannot be found"); } } return(Sharpen.Collections.UnmodifiableMap(labelsToNodes)); } finally { readLock.Unlock(); } }
/// <exception cref="System.Exception"/> protected override void ServiceInit(Configuration conf) { // set if node labels enabled nodeLabelsEnabled = conf.GetBoolean(YarnConfiguration.NodeLabelsEnabled, YarnConfiguration .DefaultNodeLabelsEnabled); labelCollections[NoLabel] = new NodeLabel(NoLabel); }