Example #1
0
 /// <summary>
 /// Check queue label expression, check if node label in queue's
 /// node-label-expression existed in clusterNodeLabels if rmContext != null
 /// </summary>
 public static bool CheckQueueLabelExpression(ICollection <string> queueLabels, string
                                              labelExpression, RMContext rmContext)
 {
     // if label expression is empty, we can allocate container on any node
     if (labelExpression == null)
     {
         return(true);
     }
     foreach (string str in labelExpression.Split("&&"))
     {
         str = str.Trim();
         if (!str.Trim().IsEmpty())
         {
             // check queue label
             if (queueLabels == null)
             {
                 return(false);
             }
             else
             {
                 if (!queueLabels.Contains(str) && !queueLabels.Contains(RMNodeLabelsManager.Any))
                 {
                     return(false);
                 }
             }
             // check node label manager contains this label
             if (null != rmContext)
             {
                 RMNodeLabelsManager nlm = rmContext.GetNodeLabelManager();
                 if (nlm != null && !nlm.ContainsNodeLabel(str))
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
Example #2
0
 /// <exception cref="System.IO.IOException"/>
 public static void CheckIfLabelInClusterNodeLabels(RMNodeLabelsManager mgr, ICollection
                                                    <string> labels)
 {
     if (mgr == null)
     {
         if (labels != null && !labels.IsEmpty())
         {
             throw new IOException("NodeLabelManager is null, please check");
         }
         return;
     }
     if (labels != null)
     {
         foreach (string label in labels)
         {
             if (!label.Equals(RMNodeLabelsManager.Any) && !mgr.ContainsNodeLabel(label))
             {
                 throw new IOException("NodeLabelManager doesn't include label = " + label + ", please check."
                                       );
             }
         }
     }
 }