Class BaseNode<N extends BaseNode<N,KeyT>,KeyT>

java.lang.Object
com.hedera.hashgraph.sdk.BaseNode<N,KeyT>
Type Parameters:
N - the n type
KeyT - the key t type
Direct Known Subclasses:
MirrorNode, Node

abstract class BaseNode<N extends BaseNode<N,KeyT>,KeyT> extends Object
Internal utility class.
  • Field Details

    • executor

      protected final ExecutorService executor
    • address

      protected final BaseNodeAddress address
      Address of this node
    • readmitTime

      protected Instant readmitTime
      Timestamp of when this node will be considered healthy again
    • currentBackoff

      protected Duration currentBackoff
      The current backoff duration. Uses exponential backoff so think 1s, 2s, 4s, 8s, etc until maxBackoff is hit
    • minBackoff

      protected Duration minBackoff
      Minimum backoff used by node when receiving a bad gRPC status
    • maxBackoff

      protected Duration maxBackoff
      Maximum backoff used by node when receiving a bad gRPC status
    • badGrpcStatusCount

      protected long badGrpcStatusCount
      Number of times this node has received a bad gRPC status
    • channel

      @Nullable protected io.grpc.ManagedChannel channel
  • Constructor Details

    • BaseNode

      protected BaseNode(BaseNodeAddress address, ExecutorService executor)
      Constructor.
      Parameters:
      address - the node address
      executor - the client
    • BaseNode

      protected BaseNode(N node, BaseNodeAddress address)
      Constructor.
      Parameters:
      node - the node object
      address - the address to assign
  • Method Details

    • getAuthority

      protected String getAuthority()
      Return the local host ip address
      Returns:
      the authority address
    • getKey

      abstract KeyT getKey()
      Extract the key list
      Returns:
      the key list
    • getAddress

      BaseNodeAddress getAddress()
      Get the address of this node
      Returns:
      the address for the node
    • getMinBackoff

      Duration getMinBackoff()
      Get the minimum backoff time
      Returns:
      the minimum backoff time
    • setMinBackoff

      N setMinBackoff(Duration minBackoff)
      Set the minimum backoff tim
      Parameters:
      minBackoff - the minimum backoff time
      Returns:
      this
    • getMaxBackoff

      Duration getMaxBackoff()
      Get the maximum backoff time
      Returns:
      the maximum backoff time
    • setMaxBackoff

      N setMaxBackoff(Duration maxBackoff)
      Set the maximum backoff time
      Parameters:
      maxBackoff - the max backoff time
      Returns:
      this
    • getBadGrpcStatusCount

      long getBadGrpcStatusCount()
      Get the number of times this node has received a bad gRPC status
      Returns:
      the count of bad grpc status
    • unhealthyBackoffRemaining

      long unhealthyBackoffRemaining()
      Extract the unhealthy backoff time remaining.
      Returns:
      the unhealthy backoff time remaining
    • isHealthy

      boolean isHealthy()
      Determines if this is node is healthy. Healthy means the node has either not received any bad gRPC statuses, or if it has received bad gRPC status then the node backed off for a period of time.
      Returns:
      is the node healthy
    • increaseBackoff

      void increaseBackoff()
      Used when a node has received a bad gRPC status
    • decreaseBackoff

      void decreaseBackoff()
      Used when a node has not received a bad gRPC status. This means on each request that doesn't get a bad gRPC status the current backoff will be lowered. The point of this is to allow a node which has been performing poorly (receiving several bad gRPC status) to become used again once it stops receiving bad gRPC statuses.
    • getRemainingTimeForBackoff

      long getRemainingTimeForBackoff()
      Get the amount of time the node has to wait until it's healthy again
      Returns:
      remaining back off time
    • getChannelCredentials

      io.grpc.ChannelCredentials getChannelCredentials()
      Create TLS credentials when transport security is enabled
      Returns:
      the channel credentials
    • getChannel

      io.grpc.ManagedChannel getChannel()
      Get the gRPC channel for this node
      Returns:
      the channel
    • channelFailedToConnect

      boolean channelFailedToConnect()
      Did we fail to connect?
      Returns:
      did we fail to connect
    • channelFailedToConnect

      boolean channelFailedToConnect(Instant timeoutTime)
    • channelFailedToConnectAsync

      CompletableFuture<Boolean> channelFailedToConnectAsync()
      Asynchronously determine if the channel failed to connect.
      Returns:
      did we fail to connect
    • close

      void close(Duration timeout) throws InterruptedException
      Close the current nodes channel
      Parameters:
      timeout - the timeout value
      Throws:
      InterruptedException - thrown when a thread is interrupted while it's waiting, sleeping, or otherwise occupied