Package org.jgroups.raft.client
Class ClientStub
java.lang.Object
org.jgroups.raft.client.ClientStub
- All Implemented Interfaces:
Closeable,AutoCloseable,Settable
Client stub which accesses a remote server via the
CLIENT protocol through a socket. Forwards all requests
to the remote server and receives the responses.- Since:
- 1.0.0
- Author:
- Bela Ban
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected InetAddressprotected DataInputStreamprotected final org.jgroups.logging.Logprotected DataOutputStreamprotected intprotected final Map<Integer, CompletableFuture<byte[]>> protected org.jgroups.util.Runnerprotected Socket -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()CompletableFuture<byte[]> Asynchronous get operation that returns immediately without blocking.getHost()intgetPort()protected voidCompletableFuture<byte[]> Asynchronous set, returns immediately with a CompletableFuture.CompletableFuture<byte[]> setAsync(CLIENT.RequestType type, byte[] buf, int offset, int length) setPort(int p) start()stop()toString()
-
Field Details
-
host
-
port
protected int port -
sock
-
in
-
out
-
current_request_id
protected int current_request_id -
requests
-
runner
protected org.jgroups.util.Runner runner -
log
protected final org.jgroups.logging.Log log
-
-
Constructor Details
-
ClientStub
-
-
Method Details
-
getHost
-
setHost
-
getPort
public int getPort() -
setPort
-
start
- Throws:
Exception
-
stop
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
setAsync
public CompletableFuture<byte[]> setAsync(byte[] buf, int offset, int length, Options ignored) 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 offsetignored- 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 ignored) 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.
-
setAsync
public CompletableFuture<byte[]> setAsync(CLIENT.RequestType type, byte[] buf, int offset, int length) throws Exception - Throws:
Exception
-
readResponse
protected void readResponse() -
toString
-