Class EndpointStateMachine

java.lang.Object
org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine
All Implemented Interfaces:
Closeable, AutoCloseable, EndpointStateMachineMBean

public class EndpointStateMachine extends Object implements Closeable, EndpointStateMachineMBean
Endpoint is used as holder class that keeps state around the RPC endpoint.
  • Constructor Details

  • 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

      public VersionResponse getVersion()
      Returns the version that we read from the server if anyone asks .
      Returns:
      - Version Response.
    • setVersion

      public void setVersion(VersionResponse version)
      Sets the Version response we received from the SCM.
      Parameters:
      version - VersionResponse
    • getState

      Returns the current State this end point is in.
      Specified by:
      getState in interface EndpointStateMachineMBean
      Returns:
      - getState.
    • getVersionNumber

      public int getVersionNumber()
      Specified by:
      getVersionNumber in interface EndpointStateMachineMBean
    • setState

      Sets the endpoint state.
      Parameters:
      epState - - end point state.
    • getExecutorService

      public ExecutorService getExecutorService()
      Returns the endpoint specific ExecutorService.
    • close

      public void close()
      Closes the connection.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • 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:
      getMissedCount in interface EndpointStateMachineMBean
      Returns:
      int
    • getAddressString

      public String getAddressString()
      Specified by:
      getAddressString in interface EndpointStateMachineMBean
    • zeroMissedCount

      public void zeroMissedCount()
    • getAddress

      public InetSocketAddress getAddress()
      Returns the InetAddress of the endPoint.
      Returns:
      - EndPoint.
    • getEndPoint

      Returns real RPC endPoint.
      Returns:
      rpc client.
    • toString

      public String toString()
      Returns the string that represents this endpoint.
      Overrides:
      toString in class Object
      Returns:
      - String
    • logIfNeeded

      public void logIfNeeded(Exception ex)
      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:
      getLastSuccessfulHeartbeat in interface EndpointStateMachineMBean
    • setLastSuccessfulHeartbeat

      public void setLastSuccessfulHeartbeat(ZonedDateTime lastSuccessfulHeartbeat)
    • getType

      public String getType()
      Specified by:
      getType in interface EndpointStateMachineMBean