You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2017/01/07 11:16:26 UTC

svn commit: r1777764 - in /httpcomponents/httpcore/trunk: httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/ httpcore5/src/examples/org/apache/hc/core5/http/examples/ httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/

Author: olegk
Date: Sat Jan  7 11:16:26 2017
New Revision: 1777764

URL: http://svn.apache.org/viewvc?rev=1777764&view=rev
Log:
Better method names for PooledClientEndpoint

Modified:
    httpcomponents/httpcore/trunk/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2MultiStreamExecutionExample.java
    httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncPipelinedRequestExecutionExample.java
    httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/PooledClientEndpoint.java

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2MultiStreamExecutionExample.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2MultiStreamExecutionExample.java?rev=1777764&r1=1777763&r2=1777764&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2MultiStreamExecutionExample.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2MultiStreamExecutionExample.java Sat Jan  7 11:16:26 2017
@@ -144,7 +144,7 @@ public class Http2MultiStreamExecutionEx
         latch.await();
 
         // Manually release client endpoint when done !!!
-        clientEndpoint.releaseResources();
+        clientEndpoint.releaseAndDiscard();
 
         System.out.println("Shutting down I/O reactor");
         requester.initiateShutdown();

Modified: httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncPipelinedRequestExecutionExample.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncPipelinedRequestExecutionExample.java?rev=1777764&r1=1777763&r2=1777764&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncPipelinedRequestExecutionExample.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncPipelinedRequestExecutionExample.java Sat Jan  7 11:16:26 2017
@@ -136,7 +136,7 @@ public class AsyncPipelinedRequestExecut
         latch.await();
 
         // Manually release client endpoint when done !!!
-        clientEndpoint.releaseResources();
+        clientEndpoint.releaseAndDiscard();
 
         System.out.println("Shutting down I/O reactor");
         requester.initiateShutdown();

Modified: httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java?rev=1777764&r1=1777763&r2=1777764&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java Sat Jan  7 11:16:26 2017
@@ -667,7 +667,7 @@ public class AsyncReverseProxyExample {
                 exchangeState.requestDataChannel = null;
                 exchangeState.responseCapacityChannel = null;
             }
-            clientEndpoint.releaseResources();
+            clientEndpoint.releaseAndReuse();
         }
 
     }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/PooledClientEndpoint.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/PooledClientEndpoint.java?rev=1777764&r1=1777763&r2=1777764&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/PooledClientEndpoint.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/bootstrap/PooledClientEndpoint.java Sat Jan  7 11:16:26 2017
@@ -37,19 +37,19 @@ import org.apache.hc.core5.http.impl.Poo
 import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler;
 import org.apache.hc.core5.http.nio.AsyncRequestProducer;
 import org.apache.hc.core5.http.nio.AsyncResponseConsumer;
-import org.apache.hc.core5.http.nio.ResourceHolder;
 import org.apache.hc.core5.http.protocol.HttpContext;
 import org.apache.hc.core5.util.Asserts;
 
 /**
  * Client endpoint leased from a pool of connections.
  * <p>
- * Once the endpoint is no longer needed it MUST be released with {@link #releaseResources()}.
+ * Once the endpoint is no longer needed it MUST be released with {@link #releaseAndReuse()}
+ * or {@link #releaseAndDiscard()}.
  *
  * @since 5.0
  */
 @Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL)
-public final class PooledClientEndpoint implements ResourceHolder {
+public final class PooledClientEndpoint {
 
     private final PoolEntryHolder<HttpHost, ClientEndpoint> poolEntryHolder;
 
@@ -67,7 +67,8 @@ public final class PooledClientEndpoint
     /**
      * Initiates a message exchange using the given handler.
      * <p>
-     * Once the endpoint is no longer needed it MUST be released with {@link #releaseResources()}.
+     * Once the endpoint is no longer needed it MUST be released with {@link #releaseAndReuse()}
+     * or {@link #releaseAndDiscard()}.
      */
     public void execute(final AsyncClientExchangeHandler exchangeHandler, final HttpContext context) {
         getClientEndpoint().execute(exchangeHandler, context);
@@ -76,7 +77,8 @@ public final class PooledClientEndpoint
     /**
      * Initiates message exchange using the given request producer and response consumer.
      * <p>
-     * Once the endpoint is no longer needed it MUST be released with {@link #releaseResources()}.
+     * Once the endpoint is no longer needed it MUST be released with {@link #releaseAndReuse()}
+     * or {@link #releaseAndDiscard()}.
      */
     public <T> Future<T> execute(
             final AsyncRequestProducer requestProducer,
@@ -89,7 +91,8 @@ public final class PooledClientEndpoint
     /**
      * Initiates a message exchange using the given request producer and response consumer.
      * <p>
-     * Once the endpoint is no longer needed it MUST be released with {@link #releaseResources()}.
+     * Once the endpoint is no longer needed it MUST be released with {@link #releaseAndReuse()}
+     * or {@link #releaseAndDiscard()}.
      */
     public <T> Future<T> execute(
             final AsyncRequestProducer requestProducer,
@@ -100,7 +103,7 @@ public final class PooledClientEndpoint
 
     /**
      * Initiates a message exchange using the given request producer and response consumer and
-     * automatically invokes {@link #releaseResources()} upon its completion.
+     * automatically invokes {@link #releaseAndReuse()} upon its successful completion.
      */
     public <T> Future<T> executeAndRelease(
             final AsyncRequestProducer requestProducer,
@@ -116,7 +119,7 @@ public final class PooledClientEndpoint
                         callback.completed(result);
                     }
                 } finally {
-                    releaseResources();
+                    releaseAndReuse();
                 }
             }
 
@@ -127,7 +130,7 @@ public final class PooledClientEndpoint
                         callback.failed(ex);
                     }
                 } finally {
-                    releaseResources();
+                    releaseAndDiscard();
                 }
             }
 
@@ -138,7 +141,7 @@ public final class PooledClientEndpoint
                         callback.cancelled();
                     }
                 } finally {
-                    releaseResources();
+                    releaseAndDiscard();
                 }
             }
 
@@ -147,7 +150,7 @@ public final class PooledClientEndpoint
 
     /**
      * Initiates a message exchange using the given request producer and response consumer and
-     * automatically invokes {@link #releaseResources()} upon its completion.
+     * automatically invokes {@link #releaseAndReuse()} upon its successful completion.
      */
     public <T> Future<T> executeAndRelease(
             final AsyncRequestProducer requestProducer,
@@ -157,10 +160,9 @@ public final class PooledClientEndpoint
     }
 
     /**
-     * Releases the underlying connection back to the connection pool.
+     * Releases the underlying connection back to the connection pool as re-usable.
      */
-    @Override
-    public void releaseResources() {
+    public void releaseAndReuse() {
         poolEntryHolder.markReusable();
         poolEntryHolder.releaseConnection();
     }
@@ -168,7 +170,7 @@ public final class PooledClientEndpoint
     /**
      * Shuts down the underlying connection and removes it from the connection pool.
      */
-    public void shutdown() {
+    public void releaseAndDiscard() {
         poolEntryHolder.abortConnection();
     }