public void flush ( ) throws IOException { try { flushIfPossible ( true ) ; checkState ( pendingRequests . isEmpty ( ) , "pendingRequests should be empty after flush" ) ; checkState ( responseFutures . isEmpty ( ) , "responseFutures should be empty after flush" ) ; } finally { requestsExecutor . shutdown ( ) ; try { if ( ! requestsExecutor . awaitTermination ( 1 , TimeUnit . SECONDS ) ) { logger . atWarning ( ) . log ( "Forcibly shutting down batch helper thread pool." ) ; requestsExecutor . shutdownNow ( ) ; } } catch ( InterruptedException e ) { logger . atFine ( ) . withCause ( e ) . log ( "Failed to await termination: forcibly shutting down batch helper thread pool." ) ; requestsExecutor . shutdownNow ( ) ; } } }
Sends any currently remaining requests in the batch ; should be called at the end of any series of batched requests to ensure everything has been sent .