Class NodeLabelUtil
java.lang.Object
org.apache.hadoop.yarn.nodelabels.NodeLabelUtil
Utility class for all NodeLabel and NodeAttribute operations.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckAndThrowAttributeName(String attributeName) static voidcheckAndThrowAttributePrefix(String prefix) static voidstatic voidcheckAndThrowLabelName(String label) static Set<org.apache.hadoop.yarn.api.records.NodeAttribute>filterAttributesByPrefix(Set<org.apache.hadoop.yarn.api.records.NodeAttribute> attributeSet, String prefix) Filter a set of node attributes by a given prefix.static booleanisNodeAttributesEquals(Set<org.apache.hadoop.yarn.api.records.NodeAttribute> leftNodeAttributes, Set<org.apache.hadoop.yarn.api.records.NodeAttribute> rightNodeAttributes) Are these two input node attributes the same.static voidvalidateNodeAttributes(Set<org.apache.hadoop.yarn.api.records.NodeAttribute> attributeSet) Validate if a given set of attributes are valid.
-
Method Details
-
checkAndThrowLabelName
- Throws:
IOException
-
checkAndThrowAttributeName
- Throws:
IOException
-
checkAndThrowAttributeValue
- Throws:
IOException
-
checkAndThrowAttributePrefix
- Throws:
IOException
-
validateNodeAttributes
public static void validateNodeAttributes(Set<org.apache.hadoop.yarn.api.records.NodeAttribute> attributeSet) throws IOException Validate if a given set of attributes are valid. Attributes could be invalid if any of following conditions is met:- Missing prefix: the attribute doesn't have prefix defined
- Malformed attribute prefix: the prefix is not in valid format
- Parameters:
attributeSet- node attribute set.- Throws:
IOException- io error occur.
-
filterAttributesByPrefix
public static Set<org.apache.hadoop.yarn.api.records.NodeAttribute> filterAttributesByPrefix(Set<org.apache.hadoop.yarn.api.records.NodeAttribute> attributeSet, String prefix) Filter a set of node attributes by a given prefix. Returns a filtered set of node attributes whose prefix equals the given prefix. If the prefix is null or empty, then the original set is returned.- Parameters:
attributeSet- node attribute setprefix- node attribute prefix- Returns:
- a filtered set of node attributes
-
isNodeAttributesEquals
public static boolean isNodeAttributesEquals(Set<org.apache.hadoop.yarn.api.records.NodeAttribute> leftNodeAttributes, Set<org.apache.hadoop.yarn.api.records.NodeAttribute> rightNodeAttributes) Are these two input node attributes the same.- Parameters:
leftNodeAttributes- left node attribute.rightNodeAttributes- right node attribute.- Returns:
- true if they are the same
-