Module com.hedera.hashgraph.sdk
Package com.hedera.hashgraph.sdk
Class BaseNode<N extends BaseNode<N,KeyT>,KeyT>
java.lang.Object
com.hedera.hashgraph.sdk.BaseNode<N,KeyT>
- Type Parameters:
N- the n typeKeyT- the key t type
- Direct Known Subclasses:
MirrorNode,Node
Internal utility class.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classMetadata interceptor for the client. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final BaseNodeAddressAddress of this nodeprotected longNumber of times this node has received a bad gRPC statusprotected io.grpc.ManagedChannelprotected DurationThe current backoff duration.protected final ExecutorServiceprotected DurationMaximum backoff used by node when receiving a bad gRPC statusprotected DurationMinimum backoff used by node when receiving a bad gRPC statusprotected InstantTimestamp of when this node will be considered healthy again -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseNode(BaseNodeAddress address, ExecutorService executor) Constructor.protectedBaseNode(N node, BaseNodeAddress address) Constructor. -
Method Summary
Modifier and TypeMethodDescription(package private) booleanDid we fail to connect?(package private) booleanchannelFailedToConnect(Instant timeoutTime) (package private) CompletableFuture<Boolean> Asynchronously determine if the channel failed to connect.(package private) voidClose the current nodes channel(package private) voidUsed when a node has not received a bad gRPC status.(package private) BaseNodeAddressGet the address of this nodeprotected StringReturn the local host ip address(package private) longGet the number of times this node has received a bad gRPC status(package private) io.grpc.ManagedChannelGet the gRPC channel for this node(package private) io.grpc.ChannelCredentialsCreate TLS credentials when transport security is enabled(package private) abstract KeyTgetKey()Extract the key list(package private) DurationGet the maximum backoff time(package private) DurationGet the minimum backoff time(package private) longGet the amount of time the node has to wait until it's healthy again(package private) voidUsed when a node has received a bad gRPC status(package private) booleanDetermines if this is node is healthy.(package private) NsetMaxBackoff(Duration maxBackoff) Set the maximum backoff time(package private) NsetMinBackoff(Duration minBackoff) Set the minimum backoff tim(package private) longExtract the unhealthy backoff time remaining.
-
Field Details
-
executor
-
address
Address of this node -
readmitTime
Timestamp of when this node will be considered healthy again -
currentBackoff
The current backoff duration. Uses exponential backoff so think 1s, 2s, 4s, 8s, etc until maxBackoff is hit -
minBackoff
Minimum backoff used by node when receiving a bad gRPC status -
maxBackoff
Maximum backoff used by node when receiving a bad gRPC status -
badGrpcStatusCount
protected long badGrpcStatusCountNumber of times this node has received a bad gRPC status -
channel
@Nullable protected io.grpc.ManagedChannel channel
-
-
Constructor Details
-
BaseNode
Constructor.- Parameters:
address- the node addressexecutor- the client
-
BaseNode
Constructor.- Parameters:
node- the node objectaddress- the address to assign
-
-
Method Details
-
getAuthority
Return the local host ip address- Returns:
- the authority address
-
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
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
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
-
channelFailedToConnectAsync
CompletableFuture<Boolean> channelFailedToConnectAsync()Asynchronously determine if the channel failed to connect.- Returns:
- did we fail to connect
-
close
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
-