@Test public void basicGetTest() throws Exception { HttpGet request = new HttpGet("http: ConstrainedHttpClient httpClient = new ConstrainedHttpClient(1); byte[] response = httpClient.execute(request, 10000).getBody(); assertNotNull("null response", response); assertTrue("zero response length", response.length > 0); }
public HttpResponse execute(HttpRequestBase request, int timeoutms) throws ServiceUnavailableException, IOException { if (semaphore.tryAcquire()) { try { logger.trace("Semaphore was acquired. Remaining: {} ", semaphore.availablePermits()); return HttpUtil.execute(request, timeoutms); } finally { semaphore.release(); } } else { throw new ServiceUnavailableException("Reached limit of " + getCurrentRequests() + " concurrent requests"); } }
ConstrainedHttpClient { public HttpResponse execute(HttpRequestBase request, int timeoutms) throws ServiceUnavailableException, IOException { if (semaphore.tryAcquire()) { try { logger.trace("Semaphore was acquired. Remaining: {} ", semaphore.availablePermits()); return HttpUtil.execute(request, timeoutms); } finally { semaphore.release(); } } else { throw new ServiceUnavailableException("Reached limit of " + getCurrentRequests() + " concurrent requests"); } } }
ConstrainedHttpClient { public HttpResponse execute(HttpRequestBase request, int timeoutms) throws ServiceUnavailableException, IOException { if (semaphore.tryAcquire()) { try { logger.trace("Semaphore was acquired. Remaining: {} ", semaphore.availablePermits()); return HttpUtil.execute(request, timeoutms); } finally { semaphore.release(); } } else { throw new ServiceUnavailableException("Reached limit of " + getCurrentRequests() + " concurrent requests"); } } ConstrainedHttpClient(int maxConcurrentRequests); }
ConstrainedHttpClient { public HttpResponse execute(HttpRequestBase request, int timeoutms) throws ServiceUnavailableException, IOException { if (semaphore.tryAcquire()) { try { logger.trace("Semaphore was acquired. Remaining: {} ", semaphore.availablePermits()); return HttpUtil.execute(request, timeoutms); } finally { semaphore.release(); } } else { throw new ServiceUnavailableException("Reached limit of " + getCurrentRequests() + " concurrent requests"); } } ConstrainedHttpClient(int maxConcurrentRequests); HttpResponse execute(HttpRequestBase request, int timeoutms); int getCurrentRequests(); void setMaxConcurrentRequests(int maxConcurrentRequests); }
ConstrainedHttpClient { public HttpResponse execute(HttpRequestBase request, int timeoutms) throws ServiceUnavailableException, IOException { if (semaphore.tryAcquire()) { try { logger.trace("Semaphore was acquired. Remaining: {} ", semaphore.availablePermits()); return HttpUtil.execute(request, timeoutms); } finally { semaphore.release(); } } else { throw new ServiceUnavailableException("Reached limit of " + getCurrentRequests() + " concurrent requests"); } } ConstrainedHttpClient(int maxConcurrentRequests); HttpResponse execute(HttpRequestBase request, int timeoutms); int getCurrentRequests(); void setMaxConcurrentRequests(int maxConcurrentRequests);  }