public abstract class GrpcMessagingConnection extends Object implements io.atomix.catalyst.transport.Connection, io.grpc.stub.StreamObserver<TransportMessage>
Connection
implementation based on Alluxio gRPC messaging.Modifier and Type | Class and Description |
---|---|
protected static class |
GrpcMessagingConnection.ConnectionOwner
Defines the owner of connection.
|
protected static class |
GrpcMessagingConnection.ContextualFuture<T>
A future with catalyst thread context.
|
protected static class |
GrpcMessagingConnection.HandlerHolder
Holds message handler and catalyst thread context.
|
Constructor and Description |
---|
GrpcMessagingConnection(GrpcMessagingConnection.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(TransportMessage 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(TransportMessage message) |
CompletableFuture<Void> |
send(Object request) |
<T,U> CompletableFuture<U> |
sendAndReceive(T request) |
void |
setTargetObserver(io.grpc.stub.StreamObserver<TransportMessage> targetObserver)
Sets the stream observer for target.
|
String |
toString() |
public GrpcMessagingConnection(GrpcMessagingConnection.ConnectionOwner connectionOwner, String transportId, io.atomix.catalyst.concurrent.ThreadContext context, ExecutorService executor, long requestTimeoutMs)
setTargetObserver(io.grpc.stub.StreamObserver<alluxio.grpc.TransportMessage>)
should be called explicitly before using the connection.connectionOwner
- owner of connectiontransportId
- transport level Idcontext
- catalyst thread contextexecutor
- transport executorrequestTimeoutMs
- timeout in milliseconds for requestspublic void setTargetObserver(io.grpc.stub.StreamObserver<TransportMessage> 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(TransportMessage 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(TransportMessage message)
onNext
in interface io.grpc.stub.StreamObserver<TransportMessage>
public void onError(Throwable t)
onError
in interface io.grpc.stub.StreamObserver<TransportMessage>
public void onCompleted()
onCompleted
in interface io.grpc.stub.StreamObserver<TransportMessage>
Copyright © 2023. All Rights Reserved.