Search in sources :

Example 21 with StreamController

use of com.google.api.gax.rpc.StreamController in project java-bigquerystorage by googleapis.

the class ReadRowsAttemptCallable method onRequest.

/**
 * Called when the outer {@link ResponseObserver} is ready for more data.
 *
 * @see StreamController#request(int)
 */
private void onRequest(int count) {
    Preconditions.checkState(!autoFlowControl, "Automatic flow control is enabled");
    Preconditions.checkArgument(count > 0, "Count must be > 0");
    final StreamController localInnerController;
    synchronized (lock) {
        int maxInc = Integer.MAX_VALUE - pendingRequests;
        count = Math.min(maxInc, count);
        pendingRequests += count;
        localInnerController = this.innerController;
    }
    // ignore it and the current controller will pick it up onStart.
    if (localInnerController != null) {
        localInnerController.request(count);
    }
}
Also used : StreamController(com.google.api.gax.rpc.StreamController)

Aggregations

StreamController (com.google.api.gax.rpc.StreamController)21 Duration (org.threeten.bp.Duration)4 ServerStreamingAttemptException (com.google.api.gax.retrying.ServerStreamingAttemptException)3 ApiCallContext (com.google.api.gax.rpc.ApiCallContext)3 CancellationException (java.util.concurrent.CancellationException)3 Test (org.junit.Test)3 GrpcCallContext (com.google.api.gax.grpc.GrpcCallContext)2 Duration (com.google.protobuf.Duration)2 StatusRuntimeException (io.grpc.StatusRuntimeException)2 ArrayList (java.util.ArrayList)2 AudioFormat (javax.sound.sampled.AudioFormat)2 DataLine (javax.sound.sampled.DataLine)2 Info (javax.sound.sampled.DataLine.Info)2 TargetDataLine (javax.sound.sampled.TargetDataLine)2 AbortedException (com.google.api.gax.rpc.AbortedException)1 ApiStreamObserver (com.google.api.gax.rpc.ApiStreamObserver)1 BidiStreamObserver (com.google.api.gax.rpc.BidiStreamObserver)1 ClientStream (com.google.api.gax.rpc.ClientStream)1 ResponseObserver (com.google.api.gax.rpc.ResponseObserver)1 ServerStream (com.google.api.gax.rpc.ServerStream)1