Class DatanodeInfo

java.lang.Object
org.apache.hadoop.hdfs.protocol.DatanodeID
org.apache.hadoop.hdfs.protocol.DatanodeInfo
All Implemented Interfaces:
Comparable<DatanodeID>, org.apache.hadoop.net.Node
Direct Known Subclasses:
DatanodeInfoWithStorage

@Private @Evolving public class DatanodeInfo extends DatanodeID implements org.apache.hadoop.net.Node
This class extends the primary identifier of a Datanode with ephemeral state, eg usage information, current administrative state, and the network location that is communicated to clients.
  • Field Details

  • Constructor Details

    • DatanodeInfo

      protected DatanodeInfo(DatanodeInfo from)
    • DatanodeInfo

      protected DatanodeInfo(DatanodeID nodeID)
    • DatanodeInfo

      protected DatanodeInfo(DatanodeID nodeID, String location)
  • Method Details

    • getName

      public String getName()
      Network location name.
      Specified by:
      getName in interface org.apache.hadoop.net.Node
    • getCapacity

      public long getCapacity()
      The raw capacity.
    • getDfsUsed

      public long getDfsUsed()
      The used space by the data node.
    • getBlockPoolUsed

      public long getBlockPoolUsed()
      The used space by the block pool on data node.
    • getNonDfsUsed

      public long getNonDfsUsed()
      The used space by the data node.
    • getDfsUsedPercent

      public float getDfsUsedPercent()
      The used space by the data node as percentage of present capacity
    • getRemaining

      public long getRemaining()
      The raw free space.
    • getBlockPoolUsedPercent

      public float getBlockPoolUsedPercent()
      Used space by the block pool as percentage of present capacity
    • getRemainingPercent

      public float getRemainingPercent()
      The remaining space as percentage of configured capacity.
    • getCacheCapacity

      public long getCacheCapacity()
      Returns:
      Amount of cache capacity in bytes
    • getCacheUsed

      public long getCacheUsed()
      Returns:
      Amount of cache used in bytes
    • getCacheUsedPercent

      public float getCacheUsedPercent()
      Returns:
      Cache used as a percentage of the datanode's total cache capacity
    • getCacheRemaining

      public long getCacheRemaining()
      Returns:
      Amount of cache remaining in bytes
    • getCacheRemainingPercent

      public float getCacheRemainingPercent()
      Returns:
      Cache remaining as a percentage of the datanode's total cache capacity
    • getLastUpdate

      public long getLastUpdate()
      Get the last update timestamp. Return value is suitable for Date conversion.
    • getLastUpdateMonotonic

      public long getLastUpdateMonotonic()
      The time when this information was accurate.
      Ps: So return value is ideal for calculation of time differences. Should not be used to convert to Date.
    • getNumBlocks

      public int getNumBlocks()
      Returns:
      Num of Blocks
    • setLastUpdateMonotonic

      public void setLastUpdateMonotonic(long lastUpdateMonotonic)
      Set lastUpdate monotonic time
    • getXceiverCount

      public int getXceiverCount()
      number of active connections
    • setCapacity

      public void setCapacity(long capacity)
      Sets raw capacity.
    • setDfsUsed

      public void setDfsUsed(long dfsUsed)
      Sets the used space for the datanode.
    • setNonDfsUsed

      public void setNonDfsUsed(long nonDfsUsed)
      Sets the nondfs-used space for the datanode.
    • setRemaining

      public void setRemaining(long remaining)
      Sets raw free space.
    • setBlockPoolUsed

      public void setBlockPoolUsed(long bpUsed)
      Sets block pool used space
    • setCacheCapacity

      public void setCacheCapacity(long cacheCapacity)
      Sets cache capacity.
    • setCacheUsed

      public void setCacheUsed(long cacheUsed)
      Sets cache used.
    • setLastUpdate

      public void setLastUpdate(long lastUpdate)
      Sets time when this information was accurate.
    • setXceiverCount

      public void setXceiverCount(int xceiverCount)
      Sets number of active connections
    • setNumBlocks

      public void setNumBlocks(int blockCount)
      Sets number of blocks.
    • getNetworkLocation

      public String getNetworkLocation()
      network location
      Specified by:
      getNetworkLocation in interface org.apache.hadoop.net.Node
    • setNetworkLocation

      public void setNetworkLocation(String location)
      Sets the network location
      Specified by:
      setNetworkLocation in interface org.apache.hadoop.net.Node
    • setUpgradeDomain

      public void setUpgradeDomain(String upgradeDomain)
      Sets the upgrade domain
    • getUpgradeDomain

      public String getUpgradeDomain()
      upgrade domain
    • addDependentHostName

      public void addDependentHostName(String hostname)
      Add a hostname to a list of network dependencies
    • getDependentHostNames

      public List<String> getDependentHostNames()
      List of Network dependencies
    • setDependentHostNames

      public void setDependentHostNames(List<String> dependencyList)
      Sets the network dependencies
    • getDatanodeReport

      public String getDatanodeReport()
      A formatted string for reporting the status of the DataNode.
    • dumpDatanode

      public String dumpDatanode()
      A formatted string for printing the status of the DataNode.
    • startDecommission

      public void startDecommission()
      Start decommissioning a node. old state.
    • stopDecommission

      public void stopDecommission()
      Stop decommissioning a node. old state.
    • isDecommissionInProgress

      public boolean isDecommissionInProgress()
      Returns true if the node is in the process of being decommissioned
    • isDecommissioned

      public boolean isDecommissioned()
      Returns true if the node has been decommissioned.
    • setDecommissioned

      public void setDecommissioned()
      Sets the admin state to indicate that decommission is complete.
    • startMaintenance

      public void startMaintenance()
      Start the maintenance operation.
    • setInMaintenance

      public void setInMaintenance()
      Put a node directly to maintenance mode.
    • setMaintenanceExpireTimeInMS

      public void setMaintenanceExpireTimeInMS(long maintenanceExpireTimeInMS)
      Parameters:
      maintenanceExpireTimeInMS - the time that the DataNode is in the maintenance mode until in the unit of milliseconds.
    • getMaintenanceExpireTimeInMS

      public long getMaintenanceExpireTimeInMS()
    • setLastBlockReportTime

      public void setLastBlockReportTime(long lastBlockReportTime)
      Sets the last block report time.
    • setLastBlockReportMonotonic

      public void setLastBlockReportMonotonic(long lastBlockReportMonotonic)
      Sets the last block report monotonic time.
    • getLastBlockReportTime

      public long getLastBlockReportTime()
      Last block report time.
    • getLastBlockReportMonotonic

      public long getLastBlockReportMonotonic()
      Last block report monotonic time.
    • stopMaintenance

      public void stopMaintenance()
      Take the node out of maintenance mode.
    • maintenanceNotExpired

      public static boolean maintenanceNotExpired(long maintenanceExpireTimeInMS)
    • isEnteringMaintenance

      public boolean isEnteringMaintenance()
      Returns true if the node is is entering_maintenance
    • isInMaintenance

      public boolean isInMaintenance()
      Returns true if the node is in maintenance
    • isMaintenance

      public boolean isMaintenance()
      Returns true if the node is entering or in maintenance
    • maintenanceExpired

      public boolean maintenanceExpired()
    • isInService

      public boolean isInService()
    • getAdminState

      public DatanodeInfo.AdminStates getAdminState()
      Retrieves the admin state of this node.
    • isStale

      public boolean isStale(long staleInterval)
      Check if the datanode is in stale state. Here if the namenode has not received heartbeat msg from a datanode for more than staleInterval, the datanode will be treated as stale node.
      Parameters:
      staleInterval - the time interval for marking the node as stale. If the last update time is beyond the given time interval, the node will be marked as stale.
      Returns:
      true if the node is stale
    • setAdminState

      protected void setAdminState(DatanodeInfo.AdminStates newState)
      Sets the admin state of this node.
    • getParent

      public org.apache.hadoop.net.Node getParent()
      Return this node's parent
      Specified by:
      getParent in interface org.apache.hadoop.net.Node
    • setParent

      public void setParent(org.apache.hadoop.net.Node parent)
      Specified by:
      setParent in interface org.apache.hadoop.net.Node
    • getLevel

      public int getLevel()
      Return this node's level in the tree. E.g. the root of a tree returns 0 and its children return 1
      Specified by:
      getLevel in interface org.apache.hadoop.net.Node
    • setLevel

      public void setLevel(int level)
      Specified by:
      setLevel in interface org.apache.hadoop.net.Node
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class DatanodeID
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class DatanodeID
    • getSoftwareVersion

      public String getSoftwareVersion()
    • setSoftwareVersion

      public void setSoftwareVersion(String softwareVersion)