Class MembershipState
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
Data schema for storing NN registration information in the
StateStoreService.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Comparator<MembershipState>Comparator based on the name.Fields inherited from class org.apache.hadoop.hdfs.server.federation.store.records.BaseRecord
ERROR_MSG_CREATION_TIME_NEGATIVE, ERROR_MSG_MODIFICATION_TIME_NEGATIVE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckExpired(long currentTime) Called when the modification time and current time is available, checks for expirations.intcompareNameTo(MembershipState other) Sort by nameservice, namenode, and router.intcompareTo(BaseRecord record) First use the comparator of the BaseRecord to compare the date modified.abstract Stringabstract StringlongGet the deletion time for the expired record.longGet the expiration time for the record.abstract booleanabstract longabstract StringGet the Lifeline RPC server address of the namenode.abstract StringIdentifier for the namenode.Get the identifier of this namenode registration.static StringgetNamenodeKey(String nsId, String nnId) Generate the identifier for a Namenode in the HDFS federation.abstract StringIdentifier for the nameservice/namespace.Map of primary key names to values for the record.abstract Stringabstract StringGet the RPC server address of the namenode.abstract StringGet the Service RPC server address of the namenode.abstract FederationNamenodeServiceStategetState()The current state of the namenode (active, standby, etc).abstract MembershipStatsgetStats()abstract StringGet the HTTP(s) server address of the namenode.abstract StringGet the Scheme of web address of the namenode.booleanCheck if the namenode is available.booleanCheck if this record is expired.booleanlike(BaseRecord o) Check if this record matches a partial record.static MembershipStateCreate a new membership instance.static MembershipStatenewInstance(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.voidoverrideState(FederationNamenodeServiceState newState) Overrides the cached getBlockPoolId() with an update.abstract voidsetBlockPoolId(String blockPoolId) abstract voidsetClusterId(String clusterId) static voidsetDeletionMs(long time) Set the deletion time for this class.static voidsetExpirationMs(long time) Set the expiration time for this class.abstract voidsetIsSafeMode(boolean isSafeMode) abstract voidsetLastContact(long contact) abstract voidsetLifelineAddress(String lifelineAddress) abstract voidsetNamenodeId(String namenodeId) abstract voidsetNameserviceId(String nameserviceId) abstract voidsetRouterId(String routerId) abstract voidsetRpcAddress(String rpcAddress) abstract voidsetServiceAddress(String serviceAddress) abstract voidabstract voidsetStats(MembershipStats stats) abstract voidsetWebAddress(String webAddress) abstract voidsetWebScheme(String webScheme) toString()voidvalidate()Validates the entry.Methods inherited from class org.apache.hadoop.hdfs.server.federation.store.records.BaseRecord
equals, generateMashupKey, getDateCreated, getDateModified, getPrimaryKey, hashCode, hasOtherFields, init, setDateCreated, setDateModified, shouldBeDeletedMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.hadoop.hdfs.server.federation.resolver.FederationNamenodeContext
getDateModified
-
Field Details
-
ERROR_MSG_NO_NS_SPECIFIED
- See Also:
-
ERROR_MSG_NO_WEB_ADDR_SPECIFIED
- See Also:
-
ERROR_MSG_NO_RPC_ADDR_SPECIFIED
- See Also:
-
ERROR_MSG_NO_BP_SPECIFIED
- See Also:
-
NAME_COMPARATOR
Comparator based on the name.
-
-
Constructor Details
-
MembershipState
public MembershipState()Constructors.
-
-
Method Details
-
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
-
getRouterId
-
setNameserviceId
-
setNamenodeId
-
setWebAddress
-
setRpcAddress
-
setServiceAddress
-
setLifelineAddress
-
setIsSafeMode
public abstract void setIsSafeMode(boolean isSafeMode) -
setClusterId
-
setBlockPoolId
-
setState
-
setWebScheme
-
getNameserviceId
Description copied from interface:FederationNamenodeContextIdentifier for the nameservice/namespace.- Specified by:
getNameserviceIdin interfaceFederationNamenodeContext- Returns:
- Namenode nameservice identifier.
-
getNamenodeId
Description copied from interface:FederationNamenodeContextIdentifier for the namenode.- Specified by:
getNamenodeIdin interfaceFederationNamenodeContext- Returns:
- String
-
getClusterId
-
getBlockPoolId
-
getRpcAddress
Description copied from interface:FederationNamenodeContextGet the RPC server address of the namenode.- Specified by:
getRpcAddressin interfaceFederationNamenodeContext- Returns:
- RPC server address in the form of host:port.
-
getServiceAddress
Description copied from interface:FederationNamenodeContextGet the Service RPC server address of the namenode.- Specified by:
getServiceAddressin interfaceFederationNamenodeContext- Returns:
- Service RPC server address in the form of host:port.
-
getLifelineAddress
Description copied from interface:FederationNamenodeContextGet the Lifeline RPC server address of the namenode.- Specified by:
getLifelineAddressin interfaceFederationNamenodeContext- Returns:
- Lifeline RPC server address in the form of host:port.
-
getWebAddress
Description copied from interface:FederationNamenodeContextGet the HTTP(s) server address of the namenode.- Specified by:
getWebAddressin interfaceFederationNamenodeContext- Returns:
- HTTP(s) address in the form of host:port.
-
getIsSafeMode
public abstract boolean getIsSafeMode() -
getWebScheme
Description copied from interface:FederationNamenodeContextGet the Scheme of web address of the namenode.- Specified by:
getWebSchemein interfaceFederationNamenodeContext- Returns:
- Scheme of web address (HTTP/HTTPS).
-
getState
Description copied from interface:FederationNamenodeContextThe current state of the namenode (active, standby, etc).- Specified by:
getStatein interfaceFederationNamenodeContext- Returns:
- FederationNamenodeServiceState State of the namenode.
-
setStats
-
getStats
-
setLastContact
public abstract void setLastContact(long contact) -
getLastContact
public abstract long getLastContact() -
like
Description copied from class:BaseRecordCheck if this record matches a partial record.- Overrides:
likein classBaseRecord- Parameters:
o- Partial record.- Returns:
- If this record matches.
-
toString
- Overrides:
toStringin classBaseRecord
-
getPrimaryKeys
Description copied from class:BaseRecordMap 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:
getPrimaryKeysin classBaseRecord- 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:
validatein classBaseRecord
-
overrideState
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
Sort by nameservice, namenode, and router.- Parameters:
other- Another membership to compare to.- Returns:
- If this object goes before the parameter.
-
getNamenodeKey
Get the identifier of this namenode registration.- Specified by:
getNamenodeKeyin interfaceFederationNamenodeContext- Returns:
- Identifier of the namenode.
-
getNamenodeKey
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:BaseRecordCalled when the modification time and current time is available, checks for expirations.- Overrides:
checkExpiredin classBaseRecord- 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:BaseRecordGet the expiration time for the record.- Specified by:
getExpirationMsin classBaseRecord- 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:BaseRecordCheck if this record is expired. The default is false. Override for customized behavior.- Overrides:
isExpiredin classBaseRecord- Returns:
- True if the record is expired.
-
getDeletionMs
public long getDeletionMs()Description copied from class:BaseRecordGet the deletion time for the expired record. The default is disabled. Override for customized behavior.- Overrides:
getDeletionMsin classBaseRecord- 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
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:
compareToin interfaceComparable<BaseRecord>- Overrides:
compareToin classBaseRecord- 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.
-