Ejemplo n.º 1
0
 /**
  * Kills the session.
  *
  * @return A completable future to be completed once the session has been killed.
  */
 public CompletableFuture<Void> kill() {
   return submitter
       .close()
       .thenCompose(v -> listener.close())
       .thenCompose(v -> manager.kill())
       .thenCompose(v -> connection.close());
 }
Ejemplo n.º 2
0
 /**
  * Closes the session.
  *
  * @return A completable future to be completed once the session is closed.
  */
 public CompletableFuture<Void> close() {
   CompletableFuture<Void> future = new CompletableFuture<>();
   submitter
       .close()
       .thenCompose(v -> listener.close())
       .thenCompose(v -> manager.close())
       .whenComplete(
           (managerResult, managerError) -> {
             connection
                 .close()
                 .whenComplete(
                     (connectionResult, connectionError) -> {
                       if (managerError != null) {
                         future.completeExceptionally(managerError);
                       } else if (connectionError != null) {
                         future.completeExceptionally(connectionError);
                       } else {
                         future.complete(null);
                       }
                     });
           });
   return future;
 }