java.lang.Object
org.apache.hadoop.hdfs.server.federation.store.records.BaseRecord
org.apache.hadoop.hdfs.server.federation.store.records.MembershipState
All Implemented Interfaces:
Comparable<BaseRecord>, FederationNamenodeContext
Direct Known Subclasses:
MembershipStatePBImpl

public abstract class MembershipState extends BaseRecord implements FederationNamenodeContext
Data schema for storing NN registration information in the StateStoreService.
  • Field Details

  • Constructor Details

    • MembershipState

      public MembershipState()
      Constructors.
  • Method Details

    • newInstance

      public static MembershipState newInstance()
      Create a new membership instance.
      Returns:
      Membership instance.
    • newInstance

      public static MembershipState newInstance(String router, String nameservice, String namenode, String clusterId, String blockPoolId, String rpcAddress, String serviceAddress, String lifelineAddress, String webScheme, String webAddress, FederationNamenodeServiceState state, boolean safemode)
      Create a new membership instance.
      Parameters:
      router - Identifier of the router.
      nameservice - Identifier of the nameservice.
      namenode - Identifier of the namenode.
      clusterId - Identifier of the cluster.
      blockPoolId - Identifier of the blockpool.
      rpcAddress - RPC address.
      serviceAddress - Service RPC address.
      lifelineAddress - Lifeline RPC address.
      webScheme - Scheme of Web Address, HTTP or HTTPS.
      webAddress - HTTP(s) address.
      state - State of the federation.
      safemode - If the safe mode is enabled.
      Returns:
      Membership instance.
    • setRouterId

      public abstract void setRouterId(String routerId)
    • getRouterId

      public abstract String getRouterId()
    • setNameserviceId

      public abstract void setNameserviceId(String nameserviceId)
    • setNamenodeId

      public abstract void setNamenodeId(String namenodeId)
    • setWebAddress

      public abstract void setWebAddress(String webAddress)
    • setRpcAddress

      public abstract void setRpcAddress(String rpcAddress)
    • setServiceAddress

      public abstract void setServiceAddress(String serviceAddress)
    • setLifelineAddress

      public abstract void setLifelineAddress(String lifelineAddress)
    • setIsSafeMode

      public abstract void setIsSafeMode(boolean isSafeMode)
    • setClusterId

      public abstract void setClusterId(String clusterId)
    • setBlockPoolId

      public abstract void setBlockPoolId(String blockPoolId)
    • setState

      public abstract void setState(FederationNamenodeServiceState state)
    • setWebScheme

      public abstract void setWebScheme(String webScheme)
    • getNameserviceId

      public abstract String getNameserviceId()
      Description copied from interface: FederationNamenodeContext
      Identifier for the nameservice/namespace.
      Specified by:
      getNameserviceId in interface FederationNamenodeContext
      Returns:
      Namenode nameservice identifier.
    • getNamenodeId

      public abstract String getNamenodeId()
      Description copied from interface: FederationNamenodeContext
      Identifier for the namenode.
      Specified by:
      getNamenodeId in interface FederationNamenodeContext
      Returns:
      String
    • getClusterId

      public abstract String getClusterId()
    • getBlockPoolId

      public abstract String getBlockPoolId()
    • getRpcAddress

      public abstract String getRpcAddress()
      Description copied from interface: FederationNamenodeContext
      Get the RPC server address of the namenode.
      Specified by:
      getRpcAddress in interface FederationNamenodeContext
      Returns:
      RPC server address in the form of host:port.
    • getServiceAddress

      public abstract String getServiceAddress()
      Description copied from interface: FederationNamenodeContext
      Get the Service RPC server address of the namenode.
      Specified by:
      getServiceAddress in interface FederationNamenodeContext
      Returns:
      Service RPC server address in the form of host:port.
    • getLifelineAddress

      public abstract String getLifelineAddress()
      Description copied from interface: FederationNamenodeContext
      Get the Lifeline RPC server address of the namenode.
      Specified by:
      getLifelineAddress in interface FederationNamenodeContext
      Returns:
      Lifeline RPC server address in the form of host:port.
    • getWebAddress

      public abstract String getWebAddress()
      Description copied from interface: FederationNamenodeContext
      Get the HTTP(s) server address of the namenode.
      Specified by:
      getWebAddress in interface FederationNamenodeContext
      Returns:
      HTTP(s) address in the form of host:port.
    • getIsSafeMode

      public abstract boolean getIsSafeMode()
    • getWebScheme

      public abstract String getWebScheme()
      Description copied from interface: FederationNamenodeContext
      Get the Scheme of web address of the namenode.
      Specified by:
      getWebScheme in interface FederationNamenodeContext
      Returns:
      Scheme of web address (HTTP/HTTPS).
    • getState

      public abstract FederationNamenodeServiceState getState()
      Description copied from interface: FederationNamenodeContext
      The current state of the namenode (active, standby, etc).
      Specified by:
      getState in interface FederationNamenodeContext
      Returns:
      FederationNamenodeServiceState State of the namenode.
    • setStats

      public abstract void setStats(MembershipStats stats)
    • getStats

      public abstract MembershipStats getStats()
    • setLastContact

      public abstract void setLastContact(long contact)
    • getLastContact

      public abstract long getLastContact()
    • like

      public boolean like(BaseRecord o)
      Description copied from class: BaseRecord
      Check if this record matches a partial record.
      Overrides:
      like in class BaseRecord
      Parameters:
      o - Partial record.
      Returns:
      If this record matches.
    • toString

      public String toString()
      Overrides:
      toString in class BaseRecord
    • getPrimaryKeys

      public SortedMap<String,String> getPrimaryKeys()
      Description copied from class: BaseRecord
      Map of primary key names to values for the record. The primary key can be a combination of 1-n different State Store serialized values.
      Specified by:
      getPrimaryKeys in class BaseRecord
      Returns:
      Map of key/value pairs that constitute this object's primary key.
    • isAvailable

      public boolean isAvailable()
      Check if the namenode is available.
      Returns:
      If the namenode is available.
    • validate

      public void validate()
      Validates the entry. Throws an IllegalArgementException if the data record is missing required information.
      Overrides:
      validate in class BaseRecord
    • overrideState

      public void overrideState(FederationNamenodeServiceState newState)
      Overrides the cached getBlockPoolId() with an update. The state will be reset when the cache is flushed
      Parameters:
      newState - Service state of the namenode.
    • compareNameTo

      public int compareNameTo(MembershipState other)
      Sort by nameservice, namenode, and router.
      Parameters:
      other - Another membership to compare to.
      Returns:
      If this object goes before the parameter.
    • getNamenodeKey

      public String getNamenodeKey()
      Get the identifier of this namenode registration.
      Specified by:
      getNamenodeKey in interface FederationNamenodeContext
      Returns:
      Identifier of the namenode.
    • getNamenodeKey

      public static String getNamenodeKey(String nsId, String nnId)
      Generate the identifier for a Namenode in the HDFS federation.
      Parameters:
      nsId - Nameservice of the Namenode.
      nnId - Namenode within the Nameservice (HA).
      Returns:
      Namenode identifier within the federation.
    • checkExpired

      public boolean checkExpired(long currentTime)
      Description copied from class: BaseRecord
      Called when the modification time and current time is available, checks for expirations.
      Overrides:
      checkExpired in class BaseRecord
      Parameters:
      currentTime - The current timestamp in ms from the data store, to be compared against the modification and creation dates of the object.
      Returns:
      boolean True if the record has been updated and should be committed to the data store. Override for customized behavior.
    • getExpirationMs

      public long getExpirationMs()
      Description copied from class: BaseRecord
      Get the expiration time for the record.
      Specified by:
      getExpirationMs in class BaseRecord
      Returns:
      Expiration time for the record.
    • setExpirationMs

      public static void setExpirationMs(long time)
      Set the expiration time for this class.
      Parameters:
      time - Expiration time in milliseconds.
    • isExpired

      public boolean isExpired()
      Description copied from class: BaseRecord
      Check if this record is expired. The default is false. Override for customized behavior.
      Overrides:
      isExpired in class BaseRecord
      Returns:
      True if the record is expired.
    • getDeletionMs

      public long getDeletionMs()
      Description copied from class: BaseRecord
      Get the deletion time for the expired record. The default is disabled. Override for customized behavior.
      Overrides:
      getDeletionMs in class BaseRecord
      Returns:
      Deletion time for the expired record.
    • setDeletionMs

      public static void setDeletionMs(long time)
      Set the deletion time for this class.
      Parameters:
      time - Deletion time in milliseconds.
    • compareTo

      public int compareTo(BaseRecord record)
      First use the comparator of the BaseRecord to compare the date modified. If they are equal, compare their primary keys to ensure that MembershipStates with the same date modified but reported by different routers will not be judged as equal.
      Specified by:
      compareTo in interface Comparable<BaseRecord>
      Overrides:
      compareTo in class BaseRecord
      Parameters:
      record - the MembershipState object to be compared.
      Returns:
      a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.