Class NodeAttributesManager

java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.yarn.nodelabels.NodeAttributesManager
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.hadoop.service.Service

public abstract class NodeAttributesManager extends org.apache.hadoop.service.AbstractService
This class captures all interactions for Attributes with RM.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.apache.hadoop.service.Service

    org.apache.hadoop.service.Service.STATE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    addNodeAttributes(Map<String,Set<org.apache.hadoop.yarn.api.records.NodeAttribute>> nodeAttributeMapping)
    It adds or updates the attribute mapping for a given node with out impacting other existing attribute mapping.
    abstract Map<org.apache.hadoop.yarn.api.records.NodeAttribute,AttributeValue>
    NodeAttribute to AttributeValue Map.
    abstract Map<org.apache.hadoop.yarn.api.records.NodeAttributeKey,Map<String,AttributeValue>>
    getAttributesToNodes(Set<org.apache.hadoop.yarn.api.records.NodeAttributeKey> attributes)
    Return a map of Nodes to attribute value for the given NodeAttributeKeys.
    abstract Set<org.apache.hadoop.yarn.api.records.NodeAttribute>
    Returns a set of node attributes whose prefix is one of the given prefixes; if the prefix set is null or empty, all attributes are returned; if prefix set is given but no mapping could be found, an empty set is returned.
    abstract Map<String,Set<org.apache.hadoop.yarn.api.records.NodeAttribute>>
    Get all node to Attributes mapping.
    abstract List<org.apache.hadoop.yarn.server.api.protocolrecords.NodeToAttributes>
    Get All node to Attributes list based on filter.
    abstract void
    refreshNodeAttributesToScheduler(org.apache.hadoop.yarn.api.records.NodeId nodeId)
    Refresh node attributes on a given node during RM recovery.
    abstract void
    removeNodeAttributes(Map<String,Set<org.apache.hadoop.yarn.api.records.NodeAttribute>> nodeAttributeMapping)
    It removes the specified attribute mapping for a given node with out impacting other existing attribute mapping.
    abstract void
    replaceNodeAttributes(String prefix, Map<String,Set<org.apache.hadoop.yarn.api.records.NodeAttribute>> nodeAttributeMapping)
    To completely replace the mappings for a given node with the new Set of Attributes which are under a given prefix.

    Methods inherited from class org.apache.hadoop.service.AbstractService

    close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, serviceInit, serviceStart, serviceStop, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • NodeAttributesManager

      public NodeAttributesManager(String name)
  • Method Details

    • replaceNodeAttributes

      public abstract void replaceNodeAttributes(String prefix, Map<String,Set<org.apache.hadoop.yarn.api.records.NodeAttribute>> nodeAttributeMapping) throws IOException
      To completely replace the mappings for a given node with the new Set of Attributes which are under a given prefix. If the mapping contains an attribute whose type does not match a previously existing Attribute under the same prefix (name space) then exception is thrown. Key would be name of the node and value would be set of Attributes to be mapped. If the prefix is null, then all node attributes will be replaced regardless of what prefix they have.
      Parameters:
      prefix - node attribute prefix
      nodeAttributeMapping - host name to a set of node attributes mapping
      Throws:
      IOException - if failed to replace attributes
    • addNodeAttributes

      public abstract void addNodeAttributes(Map<String,Set<org.apache.hadoop.yarn.api.records.NodeAttribute>> nodeAttributeMapping) throws IOException
      It adds or updates the attribute mapping for a given node with out impacting other existing attribute mapping. Key would be name of the node and value would be set of Attributes to be mapped.
      Parameters:
      nodeAttributeMapping - host name to a set of node attributes mapping.
      Throws:
      IOException - io error occur.
    • removeNodeAttributes

      public abstract void removeNodeAttributes(Map<String,Set<org.apache.hadoop.yarn.api.records.NodeAttribute>> nodeAttributeMapping) throws IOException
      It removes the specified attribute mapping for a given node with out impacting other existing attribute mapping. Key would be name of the node and value would be set of Attributes to be removed.
      Parameters:
      nodeAttributeMapping - host name to a set of node attributes mapping.
      Throws:
      IOException - io error occur.
    • getClusterNodeAttributes

      public abstract Set<org.apache.hadoop.yarn.api.records.NodeAttribute> getClusterNodeAttributes(Set<String> prefix)
      Returns a set of node attributes whose prefix is one of the given prefixes; if the prefix set is null or empty, all attributes are returned; if prefix set is given but no mapping could be found, an empty set is returned.
      Parameters:
      prefix - set of prefix string's for which the attributes needs to returned
      Returns:
      Set of node Attributes
    • getAttributesToNodes

      public abstract Map<org.apache.hadoop.yarn.api.records.NodeAttributeKey,Map<String,AttributeValue>> getAttributesToNodes(Set<org.apache.hadoop.yarn.api.records.NodeAttributeKey> attributes)
      Return a map of Nodes to attribute value for the given NodeAttributeKeys. If the attributeKeys set is null or empty, then mapping for all attributes are returned.
      Parameters:
      attributes - attributes set.
      Returns:
      a Map of attributeKeys to a map of hostnames to its attribute values.
    • getAttributesForNode

      public abstract Map<org.apache.hadoop.yarn.api.records.NodeAttribute,AttributeValue> getAttributesForNode(String hostName)
      NodeAttribute to AttributeValue Map.
      Parameters:
      hostName - host name.
      Returns:
      Map of NodeAttribute to AttributeValue.
    • getNodeToAttributes

      public abstract List<org.apache.hadoop.yarn.server.api.protocolrecords.NodeToAttributes> getNodeToAttributes(Set<String> prefix)
      Get All node to Attributes list based on filter.
      Parameters:
      prefix - filter prefix set.
      Returns:
      List of NodeToAttributes matching filter. If empty or null is passed as argument will return all.
    • getNodesToAttributes

      public abstract Map<String,Set<org.apache.hadoop.yarn.api.records.NodeAttribute>> getNodesToAttributes(Set<String> hostNames)
      Get all node to Attributes mapping.
      Parameters:
      hostNames - host names.
      Returns:
      Map of String to Set of nodesToAttributes matching filter. If empty or null is passed as argument will return all.
    • refreshNodeAttributesToScheduler

      public abstract void refreshNodeAttributesToScheduler(org.apache.hadoop.yarn.api.records.NodeId nodeId)
      Refresh node attributes on a given node during RM recovery.
      Parameters:
      nodeId - Node Id