Class StatefulServerConnection
java.lang.Object
com.apple.foundationdb.relational.jdbc.StatefulServerConnection
- All Implemented Interfaces:
io.grpc.stub.StreamObserver<com.apple.foundationdb.relational.jdbc.grpc.v1.TransactionalResponse>
,AutoCloseable
public class StatefulServerConnection
extends Object
implements io.grpc.stub.StreamObserver<com.apple.foundationdb.relational.jdbc.grpc.v1.TransactionalResponse>, AutoCloseable
A class that handles a stateful connection to the server.
This is the client's local state that corresponds to the server's transaction state. It is created
when the client connection enters autoCommit=off state and is closed when the client exits that mode
or when the connection is closed.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStatefulServerConnection
(Function<io.grpc.stub.StreamObserver<com.apple.foundationdb.relational.jdbc.grpc.v1.TransactionalResponse>, io.grpc.stub.StreamObserver<com.apple.foundationdb.relational.jdbc.grpc.v1.TransactionalRequest>> connectionFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
void
Got an error from the server.void
onNext
(com.apple.foundationdb.relational.jdbc.grpc.v1.TransactionalResponse transactionResponse) Got a response from the server.com.apple.foundationdb.relational.jdbc.grpc.v1.TransactionalResponse
sendRequest
(com.apple.foundationdb.relational.jdbc.grpc.v1.TransactionalRequest request) Send a request to the server, wait for a response.
-
Field Details
-
TIMEOUT_IN_SECONDS
public static final long TIMEOUT_IN_SECONDS- See Also:
-
-
Constructor Details
-
StatefulServerConnection
public StatefulServerConnection(Function<io.grpc.stub.StreamObserver<com.apple.foundationdb.relational.jdbc.grpc.v1.TransactionalResponse>, io.grpc.stub.StreamObserver<com.apple.foundationdb.relational.jdbc.grpc.v1.TransactionalRequest>> connectionFactory)
-
-
Method Details
-
sendRequest
public com.apple.foundationdb.relational.jdbc.grpc.v1.TransactionalResponse sendRequest(com.apple.foundationdb.relational.jdbc.grpc.v1.TransactionalRequest request) Send a request to the server, wait for a response. This method serializes a request-response flow between the client and the server. Since we implement a single request-response protocol, sending a request will wait for a response (similar to the way a synchronized RPC does), returning the response (or error), hiding the fact that this is an async protocol.- Parameters:
request
- the request to send- Returns:
- the response returned by the server
-
onNext
public void onNext(com.apple.foundationdb.relational.jdbc.grpc.v1.TransactionalResponse transactionResponse) Got a response from the server.- Specified by:
onNext
in interfaceio.grpc.stub.StreamObserver<com.apple.foundationdb.relational.jdbc.grpc.v1.TransactionalResponse>
- Parameters:
transactionResponse
- the value passed to the stream
-
onError
Got an error from the server. This is closing the connection, and no other calls can be made.- Specified by:
onError
in interfaceio.grpc.stub.StreamObserver<com.apple.foundationdb.relational.jdbc.grpc.v1.TransactionalResponse>
- Parameters:
t
- the error occurred on the stream
-
onCompleted
public void onCompleted()- Specified by:
onCompleted
in interfaceio.grpc.stub.StreamObserver<com.apple.foundationdb.relational.jdbc.grpc.v1.TransactionalResponse>
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-