src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/Connection.java
branchJDK-8188051-branch
changeset 56797 fb523d4d9185
parent 56475 e700edfac7ad
--- a/src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/Connection.java	Wed Jun 20 15:12:52 2018 -0400
+++ b/src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/Connection.java	Wed Jun 20 15:38:40 2018 -0400
@@ -259,12 +259,15 @@
      * Return a {@link Connection} with the attributes specified. Note that the
      * {@link Connection} may not be connected to a server. Call one of the
      * {@link connect} convenience methods to connect the {@link Connection} to
-     * a server. The lifecycle of the new {@link Connection} is {@link Lifecycle#NEW}.
+     * a server. The lifecycle of the new {@link Connection} is
+     * {@link Lifecycle#NEW}.
      *
      * @return a {@link Connection}
      * @throws IllegalStateException if this method has already been called or
      * if the implementation cannot create a Connection with the specified
      * {@link ConnectionProperty}s.
+     * @throws IllegalStateException if the {@link DataSource} that created this
+     * {@link Builder} is closed
      */
     public Connection build();
   }
@@ -471,13 +474,14 @@
   
   /**
    * Create an endTransaction {@link Operation}, set it to rollback only,
-   * and submit it. Convenience method.
+   * and submit it. The endTransaction is never skipped. Convenience method.
    *
    * @return this {@link OperationGroup}
    */
   public default CompletionStage<TransactionOutcome> rollback() {
     Transaction t = transaction();
     t.setRollbackOnly();
+    catchErrors();
     return this.endTransactionOperation(t).submit().getCompletionStage();
   }
 
@@ -547,6 +551,29 @@
   public ShardingKey.Builder shardingKeyBuilder();
 
   /**
+   * Provide a method that this {@link Connection} will call to control the rate
+   * of {@link Operation} submission. This {@link Connection} will call
+   * {@code request} with a positive argument when the {@link Connection} is
+   * able to accept more {@link Operation} submissions. The difference between
+   * the sum of all arguments passed to {@code request} and the number of
+   * {@link Operation}s submitted after this method is called is the
+   * <i>demand</i>. The demand must always be non-negative. If an
+   * {@link Operation} is submitted that would make the demand negative the call
+   * to {@link Operation#submit} throws {@link IllegalStateException}. Prior to
+   * a call to {@code requestHook}, the demand is defined to be infinite.
+   * After a call to {@code requestHook}, the demand is defined to be
+   * zero and is subsequently computed as described previously.
+   * {@link Operation}s submitted prior to the call to {@code requestHook} do
+   * not affect the demand.
+   *
+   * @param request accepts calls to increase the demand. Not null.
+   * @return this {@link Connection}
+   * @throws IllegalStateException if this method has been called previously or
+   * this {@link Connection} is not active.
+   */
+  public Connection requestHook(Consumer<Long> request);
+
+  /**
    * Make this {@link Connection} ready for use. A newly created
    * {@link Connection} is active. Calling this method on a {@link Connection}
    * that is active is a no-op. If the lifecycle is {@link Lifecycle#INACTIVE}