List of usage examples for org.apache.http.impl.conn PoolingClientConnectionManager PoolingClientConnectionManager
public PoolingClientConnectionManager()
From source file:org.jboss.as.test.integration.jaxrs.validator.cdi.BeanValidationCdiIntegrationTestCase.java
@Test public void testValidRequest() throws Exception { DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager()); HttpGet get = new HttpGet(url + "myjaxrs/order/5"); HttpResponse result = client.execute(get); Assert.assertEquals(200, result.getStatusLine().getStatusCode()); Assert.assertEquals("OrderModel{id=5}", EntityUtils.toString(result.getEntity())); }
From source file:com.pannous.es.reindex.MySearchResponseJson.java
public MySearchResponseJson(String searchHost, int searchPort, String searchIndexName, String searchType, String filter, String credentials, int hitsPerPage, boolean withVersion, int keepTimeInMinutes) { if (!searchHost.startsWith("http")) searchHost = "http://" + searchHost; this.host = searchHost; this.port = searchPort; this.withVersion = withVersion; keepMin = keepTimeInMinutes;//from ww w . j av a 2 s.c om bufferedHits = new ArrayList<MySearchHit>(hitsPerPage); PoolingClientConnectionManager connManager = new PoolingClientConnectionManager(); connManager.setMaxTotal(10); BasicHttpParams params = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(params, timeout); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, "UTF-8"); client = new DefaultHttpClient(connManager, params); // does not work!? client.getParams().setParameter("Authorization", "Basic " + credentials); if (credentials != null) this.credentials = credentials; // initial query to get scroll id for our specific search try { String url = searchHost + ":" + searchPort + "/" + searchIndexName + "/" + searchType + "/_search?search_type=scan&scroll=" + keepMin + "m&size=" + hitsPerPage; String query; if (filter == null || filter.isEmpty()) query = "{ \"query\" : {\"match_all\" : {}}, \"fields\" : [\"_source\", \"_parent\"]}"; else query = "{ \"filter\" : " + filter + ", \"fields\" : [\"_source\", \"_parent\"] }"; JSONObject res = doPost(url, query); scrollId = res.getString("_scroll_id"); totalHits = res.getJSONObject("hits").getLong("total"); } catch (JSONException ex) { throw new RuntimeException(ex); } }
From source file:org.overlord.apiman.service.client.http.HTTPServiceClient.java
/** * {@inheritDoc}//w w w. j a v a2 s .c o m */ public void init() { HttpParams hcParams = new BasicHttpParams(); //readConfigParam(hcParams, ClientPNames.HANDLE_REDIRECTS, Boolean.class); _proxyClient = new DefaultHttpClient(new PoolingClientConnectionManager(), hcParams); }
From source file:com.opower.rest.client.generator.executors.ApacheHttpClient4Executor.java
public ApacheHttpClient4Executor(List<ClientRequestFilter> requestFilters) { this(new DefaultHttpClient(new PoolingClientConnectionManager()), requestFilters); }
From source file:com.twitter.hbc.SitestreamController.java
/** * Construct a sitestream controller using a DefaultHttpClient *///from ww w .j a v a 2s .c o m public SitestreamController(Hosts hosts, Authentication auth) { this.client = new DefaultHttpClient(new PoolingClientConnectionManager()); this.hosts = Preconditions.checkNotNull(hosts); this.auth = Preconditions.checkNotNull(auth); }
From source file:org.zaizi.sensefy.auth.user.acl.ManifoldACLRequester.java
@PostConstruct public void init() { socketTimeOut = 300000;/*www. j a va2s. c o m*/ poolSize = 50; // Initialize the connection pool httpConnectionManager = new PoolingClientConnectionManager(); httpConnectionManager.setMaxTotal(poolSize); httpConnectionManager.setDefaultMaxPerRoute(poolSize); BasicHttpParams params = new BasicHttpParams(); params.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true); params.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false); params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, socketTimeOut); DefaultHttpClient clientAux = new DefaultHttpClient(httpConnectionManager, params); clientAux.setRedirectStrategy(new DefaultRedirectStrategy()); client = clientAux; }
From source file:com.canoo.dolphin.client.ClientConfiguration.java
/** * Default constructor of a client configuration * * @param serverEndpoint the Dolphin Platform server url * @param uiThreadHandler the ui thread handler *//* w w w .j a va 2 s.c o m*/ public ClientConfiguration(URL serverEndpoint, UiThreadHandler uiThreadHandler) { this.serverEndpoint = Assert.requireNonNull(serverEndpoint, "serverEndpoint"); this.uiThreadHandler = Assert.requireNonNull(uiThreadHandler, "uiThreadHandler"); this.dolphinLogLevel = Level.SEVERE; this.connectionTimeout = DEFAULT_CONNECTION_TIMEOUT; httpClient = new DefaultHttpClient(new PoolingClientConnectionManager()); dolphinPlatformThreadFactory = new DolphinPlatformThreadFactoryImpl(); backgroundExecutor = Executors.newCachedThreadPool(dolphinPlatformThreadFactory); }
From source file:edu.cornell.mannlib.vitro.webapp.dao.jena.SparqlGraph.java
/** * Returns a SparqlGraph for a particular named graph in a remote repository * @param endpointURI/* ww w . j ava2 s.c o m*/ * @param graphURI */ public SparqlGraph(String endpointURI, String graphURI) { this.endpointURI = endpointURI; this.graphURI = graphURI; PoolingClientConnectionManager cm = new PoolingClientConnectionManager(); cm.setDefaultMaxPerRoute(50); this.httpClient = new DefaultHttpClient(cm); }
From source file:com.jillesvangurp.httpclientfuture.HttpClientWithFutureTest.java
@BeforeClass public void beforeClass() { webServerExecutor = Executors.newSingleThreadExecutor(); webServer = new WebServer(); webServerExecutor.execute(webServer); clientThreadPool = Executors.newFixedThreadPool(threads); PoolingClientConnectionManager conman = new PoolingClientConnectionManager(); conman.setDefaultMaxPerRoute(threads); conman.setMaxTotal(threads);//from ww w . j a va2 s .c om DefaultHttpClient httpclient = new DefaultHttpClient(conman); client = new HttpClientWithFuture<Boolean>(httpclient, clientThreadPool, new ResponseHandler<Boolean>() { @Override public Boolean handleResponse(HttpResponse response) throws ClientProtocolException, IOException { return response.getStatusLine().getStatusCode() == 200; } }); }
From source file:org.jboss.as.test.integration.jaxrs.validator.BeanValidationIntegrationTestCase.java
@Test public void testInvalidRequest() throws Exception { DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager()); HttpGet get = new HttpGet(url + "myjaxrs/validate/3"); HttpResponse result = client.execute(get); result = client.execute(get);//ww w. j a v a 2 s. com Assert.assertEquals("Parameter constraint violated", 400, result.getStatusLine().getStatusCode()); }