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
    Modifier and Type
    Field
    Description
    static final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    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 Summary

    Modifier and Type
    Method
    Description
    void
     
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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 interface io.grpc.stub.StreamObserver<com.apple.foundationdb.relational.jdbc.grpc.v1.TransactionalResponse>
      Parameters:
      transactionResponse - the value passed to the stream
    • onError

      public void onError(Throwable t)
      Got an error from the server. This is closing the connection, and no other calls can be made.
      Specified by:
      onError in interface io.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 interface io.grpc.stub.StreamObserver<com.apple.foundationdb.relational.jdbc.grpc.v1.TransactionalResponse>
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable