hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1164980 - in /httpcomponents/httpcore/trunk: httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/ httpcore-nio/src/main/java/org/apache/http/nio/pool/ httpcore/src/main/java/org/apache/http/impl/pool/ httpcore/src/main/java/org/apache...
Date Sun, 04 Sep 2011 09:48:35 GMT
Author: olegk
Date: Sun Sep  4 09:48:35 2011
New Revision: 1164980

URL: http://svn.apache.org/viewvc?rev=1164980&view=rev
Log:
Reverted my last commit; added ConnPool interface

Added:
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/ConnPool.java
  (with props)
Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnPool.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/pool/TestBasicConnPool.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java?rev=1164980&r1=1164979&r2=1164980&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java
Sun Sep  4 09:48:35 2011
@@ -42,7 +42,6 @@ import org.apache.http.nio.pool.NIOConnF
 import org.apache.http.nio.reactor.ConnectingIOReactor;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
-import org.apache.http.pool.PoolEntry;
 
 /**
  * Basic non-blocking {@link NHttpClientConnection} pool.
@@ -61,8 +60,7 @@ import org.apache.http.pool.PoolEntry;
  * @since 4.2
  */
 @ThreadSafe
-public class BasicNIOConnPool extends AbstractNIOConnPool<HttpHost, NHttpClientConnection,
-                                            PoolEntry<HttpHost, NHttpClientConnection>>
{
+public class BasicNIOConnPool extends AbstractNIOConnPool<HttpHost, NHttpClientConnection,
BasicNIOPoolEntry> {
 
     private static AtomicLong COUNTER = new AtomicLong();
 
@@ -100,7 +98,7 @@ public class BasicNIOConnPool extends Ab
     }
 
     @Override
-    protected void closeEntry(final PoolEntry<HttpHost, NHttpClientConnection> entry)
{
+    protected void closeEntry(final BasicNIOPoolEntry entry) {
         NHttpClientConnection conn = entry.getConnection();
         try {
             conn.shutdown();
@@ -109,16 +107,16 @@ public class BasicNIOConnPool extends Ab
     }
 
     @Override
-    public Future<PoolEntry<HttpHost, NHttpClientConnection>> lease(
+    public Future<BasicNIOPoolEntry> lease(
             final HttpHost route,
             final Object state,
-            final FutureCallback<PoolEntry<HttpHost, NHttpClientConnection>>
callback) {
+            final FutureCallback<BasicNIOPoolEntry> callback) {
         int connectTimeout = HttpConnectionParams.getConnectionTimeout(this.params);
         return super.lease(route, state, connectTimeout, TimeUnit.MILLISECONDS, callback);
     }
 
     @Override
-    public Future<PoolEntry<HttpHost, NHttpClientConnection>> lease(
+    public Future<BasicNIOPoolEntry> lease(
             final HttpHost route,
             final Object state) {
         int connectTimeout = HttpConnectionParams.getConnectionTimeout(this.params);

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java?rev=1164980&r1=1164979&r2=1164980&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
Sun Sep  4 09:48:35 2011
@@ -48,6 +48,7 @@ import org.apache.http.nio.reactor.Conne
 import org.apache.http.nio.reactor.IOSession;
 import org.apache.http.nio.reactor.SessionRequest;
 import org.apache.http.nio.reactor.SessionRequestCallback;
+import org.apache.http.pool.ConnPool;
 import org.apache.http.pool.ConnPoolControl;
 import org.apache.http.pool.PoolEntry;
 import org.apache.http.pool.PoolStats;
@@ -62,7 +63,8 @@ import org.apache.http.pool.PoolStats;
  * @since 4.2
  */
 @ThreadSafe
-public abstract class AbstractNIOConnPool<T, C, E extends PoolEntry<T, C>> implements
ConnPoolControl<T> {
+public abstract class AbstractNIOConnPool<T, C, E extends PoolEntry<T, C>>
+                                                  implements ConnPool<T, E>, ConnPoolControl<T>
{
 
     private final ConnectingIOReactor ioreactor;
     private final NIOConnFactory<T, C> connFactory;

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnPool.java?rev=1164980&r1=1164979&r2=1164980&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnPool.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnPool.java
Sun Sep  4 09:48:35 2011
@@ -36,14 +36,12 @@ import org.apache.http.annotation.Thread
 import org.apache.http.params.HttpParams;
 import org.apache.http.pool.AbstractConnPool;
 import org.apache.http.pool.ConnFactory;
-import org.apache.http.pool.PoolEntry;
 
 /**
  * @since 4.2
  */
 @ThreadSafe
-public class BasicConnPool extends AbstractConnPool<HttpHost, HttpClientConnection,
-                                                    PoolEntry<HttpHost, HttpClientConnection>>
{
+public class BasicConnPool extends AbstractConnPool<HttpHost, HttpClientConnection, BasicPoolEntry>
{
 
     private static AtomicLong COUNTER = new AtomicLong();
 
@@ -56,14 +54,14 @@ public class BasicConnPool extends Abstr
     }
 
     @Override
-    protected PoolEntry<HttpHost, HttpClientConnection> createEntry(
+    protected BasicPoolEntry createEntry(
             final HttpHost host,
             final HttpClientConnection conn) {
         return new BasicPoolEntry(Long.toString(COUNTER.getAndIncrement()), host, conn);
     }
 
     @Override
-    protected void closeEntry(final PoolEntry<HttpHost, HttpClientConnection> entry)
{
+    protected void closeEntry(final BasicPoolEntry entry) {
         HttpConnection conn = entry.getConnection();
         try {
             conn.close();

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java?rev=1164980&r1=1164979&r2=1164980&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java
Sun Sep  4 09:48:35 2011
@@ -52,7 +52,8 @@ import org.apache.http.annotation.Thread
  * @since 4.2
  */
 @ThreadSafe
-public abstract class AbstractConnPool<T, C, E extends PoolEntry<T, C>> implements
ConnPoolControl<T> {
+public abstract class AbstractConnPool<T, C, E extends PoolEntry<T, C>>
+                                               implements ConnPool<T, E>, ConnPoolControl<T>
{
 
     private final Lock lock;
     private final ConnFactory<T, C> connFactory;

Added: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/ConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/ConnPool.java?rev=1164980&view=auto
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/ConnPool.java
(added)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/ConnPool.java
Sun Sep  4 09:48:35 2011
@@ -0,0 +1,45 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.http.pool;
+
+import java.util.concurrent.Future;
+
+/**
+ * Abstract connection pool.
+ *
+ * @param <T> route
+ * @param <E> pool entry
+ *
+ * @since 4.2
+ */
+public interface ConnPool<T, E> {
+
+    Future<E> lease(final T route, final Object state);
+
+    void release(E entry, boolean reusable);
+
+}

Propchange: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/ConnPool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/ConnPool.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/pool/ConnPool.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/pool/TestBasicConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/pool/TestBasicConnPool.java?rev=1164980&r1=1164979&r2=1164980&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/pool/TestBasicConnPool.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/pool/TestBasicConnPool.java
Sun Sep  4 09:48:35 2011
@@ -39,7 +39,6 @@ import org.apache.http.HttpHost;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.CoreConnectionPNames;
 import org.apache.http.params.HttpParams;
-import org.apache.http.pool.PoolEntry;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -118,7 +117,7 @@ public class TestBasicConnPool {
         host = new HttpHost("localhost", serverPort, "http");
         conn = connFactory.create(host);
 
-        PoolEntry<HttpHost, HttpClientConnection> entry = pool.createEntry(host, conn);
+        BasicPoolEntry entry = pool.createEntry(host, conn);
 
         assertEquals(conn, entry.getConnection());
         assertEquals("localhost", entry.getRoute().getHostName());



Mime
View raw message