Return-Path: X-Original-To: apmail-hc-commits-archive@www.apache.org Delivered-To: apmail-hc-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EC0F1C5F6 for ; Tue, 11 Jun 2013 14:10:58 +0000 (UTC) Received: (qmail 25032 invoked by uid 500); 11 Jun 2013 14:10:58 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 24985 invoked by uid 500); 11 Jun 2013 14:10:57 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 24978 invoked by uid 99); 11 Jun 2013 14:10:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Jun 2013 14:10:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Jun 2013 14:10:52 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4216F2388847 for ; Tue, 11 Jun 2013 14:10:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1491801 - in /httpcomponents/httpclient/trunk/httpclient/src: examples/org/apache/http/examples/client/ main/java/org/apache/http/impl/client/ test/java/org/apache/http/impl/client/ Date: Tue, 11 Jun 2013 14:10:32 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130611141032.4216F2388847@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: olegk Date: Tue Jun 11 14:10:31 2013 New Revision: 1491801 URL: http://svn.apache.org/r1491801 Log: Removed #executeMultiple from FutureRequestExecutionService Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientWithRequestFuture.java httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestFutureRequestExecutionService.java Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientWithRequestFuture.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientWithRequestFuture.java?rev=1491801&r1=1491800&r2=1491801&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientWithRequestFuture.java (original) +++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientWithRequestFuture.java Tue Jun 11 14:10:31 2013 @@ -27,11 +27,9 @@ package org.apache.http.examples.client; import java.io.IOException; -import java.util.List; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import org.apache.http.HttpResponse; @@ -112,20 +110,6 @@ public class ClientWithRequestFuture { HttpClientContext.create(), handler, callback); Boolean wasItOk4 = futureTask4.get(10, TimeUnit.SECONDS); System.out.println("It was ok? " + wasItOk4); - - // Multiple requests, with a callback - HttpGet request5 = new HttpGet("http://google.com"); - HttpGet request6 = new HttpGet("http://bing.com"); - HttpGet request7 = new HttpGet("http://yahoo.com"); - // using a null HttpContext here since it is optional - // the callback will be called for each request as their responses come back. - List> futureTask = requestExecService.executeMultiple( - HttpClientContext.create(), handler, callback, - 20,TimeUnit.SECONDS, request5, request6, request7); - // you can still access the futures directly, if you want. The futures are in the same order as the requests. - for (Future future : futureTask) { - System.out.println("another result " + future.get()); - } } finally { requestExecService.close(); } Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java?rev=1491801&r1=1491800&r2=1491801&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java (original) +++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java Tue Jun 11 14:10:31 2013 @@ -28,19 +28,13 @@ package org.apache.http.impl.client; import java.io.Closeable; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.http.annotation.ThreadSafe; import org.apache.http.client.HttpClient; import org.apache.http.client.ResponseHandler; import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.concurrent.FutureCallback; import org.apache.http.protocol.HttpContext; @@ -132,63 +126,6 @@ public class FutureRequestExecutionServi } /** - * Schedule multiple requests for execution. - * - * @param - * - * @param responseHandler - * handler that will process the responses. - * @param requests - * one or more requests. - * @return a list of HttpAsyncClientFutureTask for the scheduled requests. - * @throws InterruptedException - */ - public List> executeMultiple( - final ResponseHandler responseHandler, - final HttpUriRequest... requests) throws InterruptedException { - return executeMultiple(HttpClientContext.create(), responseHandler, null, -1, null, requests); - } - - /** - * Schedule multiple requests for execution with a timeout. - * - * @param - * - * @param context - * optional context; use null if not needed. - * @param responseHandler - * handler that will process the responses. - * @param callback - * callback handler that will be called when requests are scheduled, - * started, completed, failed, or cancelled. - * @param timeout - * @param timeUnit - * @param requests - * one or more requests. - * @return a list of HttpAsyncClientFutureTask for the scheduled requests. - * @throws InterruptedException - */ - public List> executeMultiple( - final HttpContext context, - final ResponseHandler responseHandler, - final FutureCallback callback, - final long timeout, final TimeUnit timeUnit, - final HttpUriRequest... requests) throws InterruptedException { - metrics.getScheduledConnections().incrementAndGet(); - final List> callables = new ArrayList>(); - for (final HttpUriRequest request : requests) { - final HttpRequestTaskCallable callable = new HttpRequestTaskCallable( - httpclient, request, context, responseHandler, callback, metrics); - callables.add(callable); - } - if (timeout > 0) { - return executorService.invokeAll(callables, timeout, timeUnit); - } else { - return executorService.invokeAll(callables); - } - } - - /** * @return metrics gathered for this instance. * @see FutureRequestExecutionMetrics */ Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestFutureRequestExecutionService.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestFutureRequestExecutionService.java?rev=1491801&r1=1491800&r2=1491801&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestFutureRequestExecutionService.java (original) +++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestFutureRequestExecutionService.java Tue Jun 11 14:10:31 2013 @@ -28,7 +28,8 @@ package org.apache.http.impl.client; import java.io.IOException; import java.net.InetSocketAddress; -import java.util.List; +import java.util.LinkedList; +import java.util.Queue; import java.util.concurrent.CancellationException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; @@ -126,29 +127,30 @@ public class TestFutureRequestExecutionS @Test public void shouldExecuteMultipleCalls() throws InterruptedException, ExecutionException { - final HttpGet[] requests= new HttpGet[100]; - for(int i=0;i<100;i++) { - requests[i]=new HttpGet(uri); + final int reqNo = 100; + final Queue> tasks = new LinkedList>(); + for(int i = 0; i < reqNo; i++) { + final Future task = httpAsyncClientWithFuture.execute( + new HttpGet(uri), HttpClientContext.create(), new OkidokiHandler()); + tasks.add(task); } - final List> tasks = httpAsyncClientWithFuture.executeMultiple( - new OkidokiHandler(), requests); for (final Future task : tasks) { - Assert.assertTrue("request should have returned OK", task.get().booleanValue()); + final Boolean b = task.get(); + Assert.assertNotNull(b); + Assert.assertTrue("request should have returned OK", b.booleanValue()); } } @Test public void shouldExecuteMultipleCallsAndCallback() throws InterruptedException { final int reqNo = 100; - final HttpGet[] requests= new HttpGet[reqNo]; - for(int i = 0; i < reqNo; i++) { - requests[i] = new HttpGet(uri); - } final CountDownLatch latch = new CountDownLatch(reqNo); final CountingCallback callback = new CountingCallback(latch); - httpAsyncClientWithFuture.executeMultiple(null, - new OkidokiHandler(), callback , 10, TimeUnit.SECONDS, requests); - + for(int i = 0; i < reqNo; i++) { + httpAsyncClientWithFuture.execute( + new HttpGet(uri), HttpClientContext.create(), + new OkidokiHandler(), callback); + } latch.await(10, TimeUnit.SECONDS); Assert.assertEquals(100, callback.completed.get()); @@ -188,7 +190,8 @@ public class TestFutureRequestExecutionS private final class OkidokiHandler implements ResponseHandler { - public Boolean handleResponse(final HttpResponse response) throws ClientProtocolException, IOException { + public Boolean handleResponse( + final HttpResponse response) throws ClientProtocolException, IOException { return response.getStatusLine().getStatusCode() == 200; } }