Interface Transport
-
public interface Transport
Used for communicating Raft nodes with each other.Transport implementations must be non-blocking. A Raft node must be able to send a Raft message to another Raft node and continue without blocking. This is required because Raft nodes run concurrently with the Actor model.
Transport implementations must be able to serialize
RaftMessage
objects created byRaftModelFactory
.A
Transport
implementation can implementRaftNodeLifecycleAware
to perform initialization and clean up work duringRaftNode
startup and termination.RaftNode
callsRaftNodeLifecycleAware.onRaftNodeStart()
before calling any other method onTransport
, and finally callsRaftNodeLifecycleAware.onRaftNodeTerminate()
on termination.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
isReachable(RaftEndpoint endpoint)
Returns true if the given endpoint is supposedly reachable by the time this method is called, false otherwise.void
send(RaftEndpoint target, RaftMessage message)
Sends the givenRaftMessage
object to the given endpoint.
-
-
-
Method Detail
-
send
void send(@Nonnull RaftEndpoint target, @Nonnull RaftMessage message)
Sends the givenRaftMessage
object to the given endpoint. This method must not block the caller Raft node instance and return promptly so that the caller can continue its execution.This method must not throw an exception, for example if the given
RaftMessage
object has not been sent to the given endpoint or an internal error has occurred. The handling ofRaftMessage
objects are designed idempotently. Therefore, if aRaftMessage
object is not sent to the given endpoint, it implies that the source Raft node will not receive aRaftMessage
as response, hence it will re-send the failedRaftMessage
again.- Parameters:
target
- the target endpoint to send the Raft messagemessage
- the Raft message object to be sent
-
isReachable
boolean isReachable(@Nonnull RaftEndpoint endpoint)
Returns true if the given endpoint is supposedly reachable by the time this method is called, false otherwise.This method is not required to return a precise information. For instance, the Transport implementation does not need to ping the given endpoint to check if it is reachable when this method is called. Instead, the local Raft node could use a local information, such as recency of a message sent by or having a TCP connection to the given Raft endpoint.
- Parameters:
endpoint
- the Raft endpoint to check reachability- Returns:
- true if given endpoint is reachable, false otherwise
-
-