public class InstantTransport extends java.lang.Object implements RaftTransport
RaftTransport.Type| Constructor and Description |
|---|
InstantTransport() |
| Modifier and Type | Method and Description |
|---|---|
void |
bind(RaftAlgorithm listener)
Register a listener for RPCs.
|
java.util.Collection<RaftAlgorithm> |
boundAlgorithms()
Get the collection of algorithms that have been bound to this transport.
|
void |
broadcastTransport(java.lang.String sender,
EloquentRaftProto.RaftMessage message)
Broadcast an RPC request over the transport to all members of the cluster.
|
static void |
burnInJIT()
We use this to burn in the important routines in Raft
|
Span |
expectedNetworkDelay()
The expected delay, in milliseconds, for a round-trip on this transport.
|
void |
rpcTransport(java.lang.String sender,
java.lang.String destination,
EloquentRaftProto.RaftMessage message,
java.util.function.Consumer<EloquentRaftProto.RaftMessage> onResponseReceived,
java.lang.Runnable onTimeout,
long timeout)
Send an RPC request over the transport, expecting a reply.
|
void |
schedule(SafeTimerTask timerTask,
long delay)
Schedule an event every |period| seconds.
|
void |
scheduleAtFixedRate(SafeTimerTask timerTask,
long period)
Schedule an event every |period| seconds.
|
void |
sendTransport(java.lang.String sender,
java.lang.String destination,
EloquentRaftProto.RaftMessage message)
Send an RPC request over the transport, not necessarily expecting a reply.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbroadcastTransport, create, getFuture, messageType, mkRaftMessage, mkRaftMessage, mkRaftRPC, now, rpcTransport, rpcTransportAsFuture, rpcTransportAsFuture, sendTransport, sleep, start, stop, threadsCanBlockpublic void bind(RaftAlgorithm listener)
RaftTransportbind in interface RaftTransportlistener - The listener that should be called on all received RPC requests.public java.util.Collection<RaftAlgorithm> boundAlgorithms()
RaftTransportboundAlgorithms in interface RaftTransportpublic void rpcTransport(java.lang.String sender,
java.lang.String destination,
EloquentRaftProto.RaftMessage message,
java.util.function.Consumer<EloquentRaftProto.RaftMessage> onResponseReceived,
java.lang.Runnable onTimeout,
long timeout)
RaftTransportrpcTransport in interface RaftTransportsender - The name of the node sending the message. In many implementations, this is redundant.destination - The destination we are sending the message to.
This is a server name
on the same cluster as the node this transport is bound to.message - The message to send, as a EloquentRaftProto.RaftMessage.onResponseReceived - The callback to run when a response is received from the server
for the RPC. Either this or onTimeout is always called.onTimeout - Called when no response is received in the given timeout threshold.timeout - The number of milliseconds to wait before considering an RPC timed out.public void sendTransport(java.lang.String sender,
java.lang.String destination,
EloquentRaftProto.RaftMessage message)
RaftTransportsendTransport in interface RaftTransportsender - The name of the node sending the message. In many implementations, this is redundant.destination - The destination we are sending the message to.
This is a server name
on the same cluster as the node this transport is bound to.message - The message to send, as a EloquentRaftProto.RaftMessage.public void broadcastTransport(java.lang.String sender,
EloquentRaftProto.RaftMessage message)
RaftTransportbroadcastTransport in interface RaftTransportsender - The name of the node sending the message. In many implementations, this is redundant.message - The message to send, as a EloquentRaftProto.RaftMessage.public Span expectedNetworkDelay()
RaftTransportexpectedNetworkDelay in interface RaftTransportpublic void scheduleAtFixedRate(SafeTimerTask timerTask, long period)
SafeTimer.scheduleAtFixedRate(SafeTimerTask, long, long), but mockablescheduleAtFixedRate in interface RaftTransportpublic void schedule(SafeTimerTask timerTask, long delay)
SafeTimer.schedule(SafeTimerTask, long), but mockableschedule in interface RaftTransportpublic static void burnInJIT()