public abstract class CopycatGrpcConnection extends Object implements io.atomix.catalyst.transport.Connection, io.grpc.stub.StreamObserver<CopycatMessage>
Connection
implementation that uses Alluxio gRPC.Modifier and Type | Class and Description |
---|---|
protected static class |
CopycatGrpcConnection.ConnectionOwner
Defines the owner of connection.
|
protected static class |
CopycatGrpcConnection.ContextualFuture<T>
A future with copycat thread context.
|
protected static class |
CopycatGrpcConnection.HandlerHolder
Holds message handler and copycat thread context.
|
Constructor and Description |
---|
CopycatGrpcConnection(CopycatGrpcConnection.ConnectionOwner connectionOwner,
String transportId,
io.atomix.catalyst.concurrent.ThreadContext context,
ExecutorService executor,
long requestTimeoutMs)
Creates a connection object.
|
Modifier and Type | Method and Description |
---|---|
CompletableFuture<Void> |
close() |
<T,U> io.atomix.catalyst.transport.Connection |
handler(Class<T> type,
java.util.function.Consumer<T> handler) |
<T,U> io.atomix.catalyst.transport.Connection |
handler(Class<T> type,
java.util.function.Function<T,CompletableFuture<U>> handler) |
protected void |
handleResponseMessage(CopycatMessage response) |
io.atomix.catalyst.concurrent.Listener<io.atomix.catalyst.transport.Connection> |
onClose(java.util.function.Consumer<io.atomix.catalyst.transport.Connection> listener) |
void |
onCompleted() |
void |
onError(Throwable t) |
io.atomix.catalyst.concurrent.Listener<Throwable> |
onException(java.util.function.Consumer<Throwable> listener) |
void |
onNext(CopycatMessage message) |
CompletableFuture<Void> |
send(Object request) |
<T,U> CompletableFuture<U> |
sendAndReceive(T request) |
void |
setTargetObserver(io.grpc.stub.StreamObserver<CopycatMessage> targetObserver)
Sets the stream observer for target.
|
String |
toString() |
public CopycatGrpcConnection(CopycatGrpcConnection.ConnectionOwner connectionOwner, String transportId, io.atomix.catalyst.concurrent.ThreadContext context, ExecutorService executor, long requestTimeoutMs)
setTargetObserver(io.grpc.stub.StreamObserver<alluxio.grpc.CopycatMessage>)
should be called explicitly before using the connection.connectionOwner
- owner of connectiontransportId
- transport level Idcontext
- copycat thread contextexecutor
- transport executorrequestTimeoutMs
- timeout in milliseconds for requestspublic void setTargetObserver(io.grpc.stub.StreamObserver<CopycatMessage> targetObserver)
targetObserver
- target's stream observerpublic CompletableFuture<Void> send(Object request)
send
in interface io.atomix.catalyst.transport.Connection
public <T,U> CompletableFuture<U> sendAndReceive(T request)
sendAndReceive
in interface io.atomix.catalyst.transport.Connection
public <T,U> io.atomix.catalyst.transport.Connection handler(Class<T> type, java.util.function.Consumer<T> handler)
handler
in interface io.atomix.catalyst.transport.Connection
public <T,U> io.atomix.catalyst.transport.Connection handler(Class<T> type, java.util.function.Function<T,CompletableFuture<U>> handler)
handler
in interface io.atomix.catalyst.transport.Connection
protected void handleResponseMessage(CopycatMessage response)
public io.atomix.catalyst.concurrent.Listener<Throwable> onException(java.util.function.Consumer<Throwable> listener)
onException
in interface io.atomix.catalyst.transport.Connection
public io.atomix.catalyst.concurrent.Listener<io.atomix.catalyst.transport.Connection> onClose(java.util.function.Consumer<io.atomix.catalyst.transport.Connection> listener)
onClose
in interface io.atomix.catalyst.transport.Connection
public CompletableFuture<Void> close()
close
in interface io.atomix.catalyst.transport.Connection
public void onNext(CopycatMessage message)
onNext
in interface io.grpc.stub.StreamObserver<CopycatMessage>
public void onError(Throwable t)
onError
in interface io.grpc.stub.StreamObserver<CopycatMessage>
public void onCompleted()
onCompleted
in interface io.grpc.stub.StreamObserver<CopycatMessage>
Copyright © 2023. All Rights Reserved.