Class EndpointStateMachine
java.lang.Object
org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine
- All Implemented Interfaces:
Closeable,AutoCloseable,EndpointStateMachineMBean
Endpoint is used as holder class that keeps state around the RPC endpoint.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumStates that an Endpoint can be in. -
Constructor Summary
ConstructorsConstructorDescriptionEndpointStateMachine(InetSocketAddress address, StorageContainerDatanodeProtocolClientSideTranslatorPB endPoint, org.apache.hadoop.hdds.conf.ConfigurationSource conf, String threadNamePrefix) Constructs RPC Endpoints. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the connection.Returns the InetAddress of the endPoint.Returns real RPC endPoint.Returns the endpoint specific ExecutorService.longlongReturns the value of the missed count.getState()Returns the current State this end point is in.getType()Returns the version that we read from the server if anyone asks .intvoidWe maintain a count of how many times we missed communicating with a specific SCM.booleanReturns true if the end point is not an SCM.voidlock()Takes a lock on this EndPoint so that other threads don't use this while we are trying to communicate via this endpoint.voidlogIfNeeded(Exception ex) Logs exception if needed.voidsetLastSuccessfulHeartbeat(ZonedDateTime lastSuccessfulHeartbeat) voidsetPassive(boolean passive) Sets the endpoint state.voidsetVersion(VersionResponse version) Sets the Version response we received from the SCM.toString()Returns the string that represents this endpoint.voidunlock()Unlocks this endpoint.void
-
Constructor Details
-
EndpointStateMachine
public EndpointStateMachine(InetSocketAddress address, StorageContainerDatanodeProtocolClientSideTranslatorPB endPoint, org.apache.hadoop.hdds.conf.ConfigurationSource conf, String threadNamePrefix) Constructs RPC Endpoints.- Parameters:
endPoint- - RPC endPoint.
-
-
Method Details
-
lock
public void lock()Takes a lock on this EndPoint so that other threads don't use this while we are trying to communicate via this endpoint. -
unlock
public void unlock()Unlocks this endpoint. -
getVersion
Returns the version that we read from the server if anyone asks .- Returns:
- - Version Response.
-
setVersion
Sets the Version response we received from the SCM.- Parameters:
version- VersionResponse
-
getState
Returns the current State this end point is in.- Specified by:
getStatein interfaceEndpointStateMachineMBean- Returns:
- - getState.
-
getVersionNumber
public int getVersionNumber()- Specified by:
getVersionNumberin interfaceEndpointStateMachineMBean
-
setState
Sets the endpoint state.- Parameters:
epState- - end point state.
-
getExecutorService
Returns the endpoint specific ExecutorService. -
close
public void close()Closes the connection.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
incMissed
public void incMissed()We maintain a count of how many times we missed communicating with a specific SCM. This is not made atomic since the access to this is always guarded by the read or write lock. That is, it is serialized. -
getMissedCount
public long getMissedCount()Returns the value of the missed count.- Specified by:
getMissedCountin interfaceEndpointStateMachineMBean- Returns:
- int
-
getAddressString
- Specified by:
getAddressStringin interfaceEndpointStateMachineMBean
-
zeroMissedCount
public void zeroMissedCount() -
getAddress
Returns the InetAddress of the endPoint.- Returns:
- - EndPoint.
-
getEndPoint
Returns real RPC endPoint.- Returns:
- rpc client.
-
toString
Returns the string that represents this endpoint. -
logIfNeeded
Logs exception if needed.- Parameters:
ex- - Exception
-
isPassive
public boolean isPassive()Returns true if the end point is not an SCM. A passive endpoint can be a Server that only reads information from Datanode, like Recon.- Returns:
- true/false.
-
setPassive
public void setPassive(boolean passive) -
getLastSuccessfulHeartbeat
public long getLastSuccessfulHeartbeat()- Specified by:
getLastSuccessfulHeartbeatin interfaceEndpointStateMachineMBean
-
setLastSuccessfulHeartbeat
-
getType
- Specified by:
getTypein interfaceEndpointStateMachineMBean
-