Package org.jgroups.raft.testfwk
Class RaftNode
java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.raft.testfwk.RaftNode
- All Implemented Interfaces:
Closeable,AutoCloseable,org.jgroups.Lifecycle,Settable
public class RaftNode
extends org.jgroups.stack.Protocol
implements org.jgroups.Lifecycle, Settable, Closeable
- Since:
- 1.0.5
- Author:
- Bela Ban
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final MockRaftClusterprotected final BaseElectionprotected final org.jgroups.stack.Protocol[]protected final RAFTFields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, local_addr, log, policies, stack, stats, up_prot -
Constructor Summary
ConstructorsConstructorDescriptionRaftNode(MockRaftCluster cluster, org.jgroups.stack.Protocol[] protocols) RaftNode(RaftCluster cluster, RAFT raft) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voiddestroy()down(org.jgroups.Event evt) down(org.jgroups.Message msg) election()protected <T extends org.jgroups.stack.Protocol>
Torg.jgroups.AddressCompletableFuture<byte[]> Asynchronous get operation that returns immediately without blocking.voidhandleView(org.jgroups.View v) voidinit()protected org.jgroups.Addressorg.jgroups.stack.Protocol[]raft()CompletableFuture<byte[]> Asynchronous set, returns immediately with a CompletableFuture.voidstart()voidstop()toString()up(org.jgroups.Message msg) Methods inherited from class org.jgroups.stack.Protocol
accept, addPolicy, addr, addr, afterCreationHook, down, enableStats, getComponents, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getPolicies, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, policies, providedDownServices, providedUpServices, removePolicy, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setAddress, setDownProtocol, setErgonomics, setId, setLevel, setPolicies, setProtocolStack, setSocketFactory, setUpProtocol, setValue, statsEnabled, up, up
-
Field Details
-
prots
protected final org.jgroups.stack.Protocol[] prots -
raft
-
election
-
cluster
-
-
Constructor Details
-
RaftNode
-
RaftNode
-
-
Method Details
-
protocols
public org.jgroups.stack.Protocol[] protocols() -
getAddress
public org.jgroups.Address getAddress()- Overrides:
getAddressin classorg.jgroups.stack.Protocol
-
init
- Specified by:
initin interfaceorg.jgroups.Lifecycle- Overrides:
initin classorg.jgroups.stack.Protocol- Throws:
Exception
-
start
- Specified by:
startin interfaceorg.jgroups.Lifecycle- Overrides:
startin classorg.jgroups.stack.Protocol- Throws:
Exception
-
stop
public void stop()- Specified by:
stopin interfaceorg.jgroups.Lifecycle- Overrides:
stopin classorg.jgroups.stack.Protocol
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
destroy
public void destroy()- Specified by:
destroyin interfaceorg.jgroups.Lifecycle- Overrides:
destroyin classorg.jgroups.stack.Protocol
-
handleView
public void handleView(org.jgroups.View v) -
down
- Overrides:
downin classorg.jgroups.stack.Protocol
-
down
- Overrides:
downin classorg.jgroups.stack.Protocol
-
up
- Overrides:
upin classorg.jgroups.stack.Protocol
-
setAsync
public CompletableFuture<byte[]> setAsync(byte[] buf, int offset, int length, Options options) throws Exception Description copied from interface:SettableAsynchronous set, returns immediately with a CompletableFuture. To wait for the result,CompletableFuture.get()orCompletableFuture.get(long, TimeUnit)can be called.- Specified by:
setAsyncin interfaceSettable- Parameters:
buf- The buffer (usually a serialized command) which represent the change to be applied to all state machinesoffset- The offset into the bufferlength- he number of bytes to be used in the buffer, starting at offsetoptions- Options to pass to the call, may be null- Returns:
- A CompletableFuture which can be used to fetch the result.
- Throws:
Exception
-
getAsync
public CompletableFuture<byte[]> getAsync(byte[] buf, int offset, int length, Options options) throws Exception Description copied from interface:SettableAsynchronous get operation that returns immediately without blocking.This method submits a read-only operation to the state machine. Read-only operations are treated differently by the replication algorithm. Since read-only operations do not change the state-machine state, these operations are not appended to the replicated log.
Warning: Do not change the state-machine state by operations submitted through this method. Otherwise, the state-machine will diverge and lead to an undefined state.
- Specified by:
getAsyncin interfaceSettable- Parameters:
buf- The buffer representing the read-only operation to submit to the state machine.offset- The offset to skip the bytes in the buffer.length- The number of bytes to use from the buffer starting at offset.- Returns:
- A buffer representing the result after submitting the read-only operation.
- Throws:
Exception- Thrown if the operation could not be submitted.
-
toString
- Overrides:
toStringin classorg.jgroups.stack.Protocol
-
find
-
localAddress
protected org.jgroups.Address localAddress() -
raft
-
election
-