GVKun编程网logo

org.apache.http.impl.conn.ProxySelectorRoutePlanner的实例源码(httpd源码)

4

本文将带您了解关于org.apache.http.impl.conn.ProxySelectorRoutePlanner的实例源码的新内容,同时我们还将为您解释httpd源码的相关知识,另外,我们还将

本文将带您了解关于org.apache.http.impl.conn.ProxySelectorRoutePlanner的实例源码的新内容,同时我们还将为您解释httpd源码的相关知识,另外,我们还将为您提供关于org.apache.commons.httpclient.SimpleHttpConnectionManager的实例源码、org.apache.http.conn.ClientConnectionOperator的实例源码、org.apache.http.conn.ConnectionPoolTimeoutException的实例源码、org.apache.http.conn.ConnectionReleaseTrigger的实例源码的实用信息。

本文目录一览:

org.apache.http.impl.conn.ProxySelectorRoutePlanner的实例源码(httpd源码)

org.apache.http.impl.conn.ProxySelectorRoutePlanner的实例源码(httpd源码)

项目:jira-dvcs-connector    文件:HttpClientProvider.java   
public HttpClientProvider()
{
    httpClient = SystemUtils.createHttpClient();

    httpconnectionParams.setConnectionTimeout(httpClient.getParams(),DEFAULT_CONNECT_TIMEOUT);
    httpconnectionParams.setSoTimeout(httpClient.getParams(),DEFAULT_SOCKET_TIMEOUT);

    ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(httpClient.getConnectionManager().getSchemeRegistry(),ProxySelector.getDefault());
    httpClient.setRoutePlanner(routePlanner);
    httpClient.setKeepAliveStrategy(new ConnectionKeepAliveStrategy(DEFAULT_CONNECTION_KEEP_ALIVE_DURATION));
    cachingHttpClient = new EtagCachingHttpClient(httpClient,createStorage());
}
项目:openbd-core    文件:cfhttpconnection.java   
private void setDefaultProxy() {
    HttpHost currentProxy = ( HttpHost )client.getParams().getParameter( ConnRoutePNames.DEFAULT_PROXY );

    if ( currentProxy == null ) {
        ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner( client.getConnectionManager().getSchemeRegistry(),ProxySelector.getDefault() );
        client.setRoutePlanner( routePlanner );
    }
}
项目:GloboDNS-Client    文件:GloboDns.java   
private static HttpClient newDefaultHttpClient(SSLSocketFactory socketFactory,HttpParams params,ProxySelector proxySelector) {
    SchemeRegistry registry = new SchemeRegistry();
    registry.register(new Scheme("http",PlainSocketFactory.getSocketFactory(),80));
    registry.register(new Scheme("https",socketFactory,443));
    ClientConnectionManager connectionManager = new ThreadSafeClientConnManager(params,registry);
    DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager,params);
    httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0,false));
    httpClient.setRoutePlanner(new ProxySelectorRoutePlanner(registry,proxySelector));
    return httpClient;
}
项目:InSpider    文件:HttpUtils.java   
public static DefaultHttpClient createHttpClient() {
    HttpParams httpParams = new BasicHttpParams();
    httpconnectionParams.setConnectionTimeout(httpParams,60000);// was 10000
    httpconnectionParams.setSoTimeout(httpParams,60000);// was 30000

    DefaultHttpClient httpClient = new DefaultHttpClient(httpParams);
    // http-proxy
    ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(
            httpClient.getConnectionManager().getSchemeRegistry(),ProxySelector.getDefault());
    httpClient.setRoutePlanner(routePlanner);

    return httpClient;
}
项目:opennmszh    文件:NominatimGeocoderService.java   
public NominatimGeocoderService() {
    // Honor the JRE's HTTP proxy settings
    final ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(
        m_httpClient.getConnectionManager().getSchemeRegistry(),ProxySelector.getDefault()
    );
    m_httpClient.setRoutePlanner(routePlanner);
}
项目:spring-restlet    文件:HttpClientHelper.java   
/**
 * Configures the HTTP client. By default,it try to set the retry handler.
 *
 * @param httpClient
 *            The HTTP client to configure.
 */
protected void configure(DefaultHttpClient httpClient) {
    if (getRetryHandler() != null) {
        try {
            HttpRequestRetryHandler retryHandler = (HttpRequestRetryHandler) Engine.loadClass(getRetryHandler()).newInstance();
            this.httpClient.setHttpRequestRetryHandler(retryHandler);
        } catch (Exception e) {
            getLogger().log(Level.WARNING,"An error occurred during the instantiation of the retry handler.",e);
        }
    }
    ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(httpClient.getConnectionManager().getSchemeRegistry(),ProxySelector
            .getDefault());
    httpClient.setRoutePlanner(routePlanner);
}
项目:SensorPlanningService    文件:SimpleHttpClient.java   
private void initProxyAwareClient() {
    ClientConnectionManager connectionManager = httpclient.getConnectionManager();
    SchemeRegistry schemeRegistry = connectionManager.getSchemeRegistry();
    ProxySelector defaultProxySelector = ProxySelector.getDefault();
    ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(schemeRegistry,defaultProxySelector);
    httpclient.setRoutePlanner(routePlanner);
    httpclient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,timeout);
}
项目:lams    文件:SystemDefaultHttpClient.java   
@Override
protected HttpRoutePlanner createHttpRoutePlanner() {
    return new ProxySelectorRoutePlanner(getConnectionManager().getSchemeRegistry(),ProxySelector.getDefault());
}
项目:purecloud-iot    文件:SystemDefaultHttpClient.java   
@Override
protected HttpRoutePlanner createHttpRoutePlanner() {
    return new ProxySelectorRoutePlanner(getConnectionManager().getSchemeRegistry(),ProxySelector.getDefault());
}
项目:BingAds-Java-SDK    文件:HttpClientWebServiceCaller.java   
private DefaultHttpClient createHttpClientWithProxy() {
    DefaultHttpClient client = new DefaultHttpClient();

    ProxySelector proxySelector = ProxySelector.getDefault();

    client.setRoutePlanner(new ProxySelectorRoutePlanner(client.getConnectionManager().getSchemeRegistry(),proxySelector));

    return client;
}

org.apache.commons.httpclient.SimpleHttpConnectionManager的实例源码

org.apache.commons.httpclient.SimpleHttpConnectionManager的实例源码

项目:minxing_java_sdk    文件:HttpClient.java   
public HttpClient(int maxConPerHost,int conTimeOutMs,int soTimeOutMs,int maxSize) {

//      MultiThreadedhttpconnectionManager connectionManager = new MultiThreadedhttpconnectionManager();
        SimplehttpconnectionManager connectionManager = new SimplehttpconnectionManager(true);
        httpconnectionManagerParams params = connectionManager.getParams();
        params.setDefaultMaxConnectionsPerHost(maxConPerHost);
        params.setConnectionTimeout(conTimeOutMs);
        params.setSoTimeout(soTimeOutMs);

        HttpClientParams clientParams = new HttpClientParams();
        clientParams.setCookiePolicy(CookiePolicy.IGnorE_COOKIES);
        client = new org.apache.commons.httpclient.HttpClient(clientParams,connectionManager);
        Protocol myhttps = new Protocol("https",new MySSLSocketFactory(),443);
        Protocol.registerProtocol("https",myhttps);
    }
项目:javacode-demo    文件:HttpReq.java   
private void shutdown(HttpMethodBase method) {
    if (method != null) {
        method.releaseConnection();
    }
    if (!externalConnectionManager) {
        ((SimplehttpconnectionManager) httpconnectionManager).shutdown();
    }
}
项目:diamond    文件:ServerAddressprocessor.java   
private void initHttpClient() {
    HostConfiguration hostConfiguration = new HostConfiguration();

    SimplehttpconnectionManager connectionManager = new SimplehttpconnectionManager();
    connectionManager.closeIdleConnections(5000L);

    httpconnectionManagerParams params = new httpconnectionManagerParams();
    params.setStaleCheckingEnabled(diamondConfigure.isConnectionStaleCheckingEnabled());
    params.setConnectionTimeout(diamondConfigure.getConnectionTimeout());
    connectionManager.setParams(params);

    configHttpClient = new HttpClient(connectionManager);
    configHttpClient.setHostConfiguration(hostConfiguration);
}
项目:cloud-meter    文件:HTTPHC3Impl.java   
/** {@inheritDoc} */
@Override
public boolean interrupt() {
    HttpClient client = savedClient;
    if (client != null) {
        savedClient = null;
        // Todo - not sure this is the best method
        final httpconnectionManager httpconnectionManager = client.gethttpconnectionManager();
        if (httpconnectionManager instanceof SimplehttpconnectionManager) {// Should be true
            ((SimplehttpconnectionManager)httpconnectionManager).shutdown();
        }
    }
    return client != null;
}
项目:diamond-v2.1.1    文件:ServerAddressprocessor.java   
private void initHttpClient() {
    HostConfiguration hostConfiguration = new HostConfiguration();

    SimplehttpconnectionManager connectionManager = new SimplehttpconnectionManager();
    connectionManager.closeIdleConnections(5000L);

    httpconnectionManagerParams params = new httpconnectionManagerParams();
    params.setStaleCheckingEnabled(diamondConfigure.isConnectionStaleCheckingEnabled());
    params.setConnectionTimeout(diamondConfigure.getConnectionTimeout());
    connectionManager.setParams(params);

    configHttpClient = new HttpClient(connectionManager);
    configHttpClient.setHostConfiguration(hostConfiguration);
}
项目:openhab-hdl    文件:CcuClient.java   
/**
 * {@inheritDoc}
 */
@Override
public void start() throws HomematicclientException {
    logger.info("Starting {}",CcuClient.class.getSimpleName());
    super.start();

    tclregaScripts = loadTclRegaScripts();

    httpClient = new HttpClient(new SimplehttpconnectionManager(true));
    HttpClientParams params = httpClient.getParams();
    Long timeout = context.getConfig().getTimeout() * 1000L;
    params.setConnectionManagerTimeout(timeout);
    params.setSoTimeout(timeout.intValue());
    params.setContentCharset("ISO-8859-1");
}
项目:openhab1-addons    文件:CcuClient.java   
/**
 * {@inheritDoc}
 */
@Override
public void start() throws HomematicclientException {
    logger.info("Starting {}",CcuClient.class.getSimpleName());
    super.start();

    tclregaScripts = loadTclRegaScripts();

    httpClient = new HttpClient(new SimplehttpconnectionManager(true));
    HttpClientParams params = httpClient.getParams();
    Long timeout = context.getConfig().getTimeout() * 1000L;
    params.setConnectionManagerTimeout(timeout);
    params.setSoTimeout(timeout.intValue());
    params.setContentCharset("ISO-8859-1");
}
项目:apache-jmeter-2.10    文件:HTTPHC3Impl.java   
/** {@inheritDoc} */
@Override
public boolean interrupt() {
    HttpClient client = savedClient;
    if (client != null) {
        savedClient = null;
        // Todo - not sure this is the best method
        final httpconnectionManager httpconnectionManager = client.gethttpconnectionManager();
        if (httpconnectionManager instanceof SimplehttpconnectionManager) {// Should be true
            ((SimplehttpconnectionManager)httpconnectionManager).shutdown();
        }
    }
    return client != null;
}
项目:tb_diamond    文件:ServerAddressprocessor.java   
private void initHttpClient() {
    HostConfiguration hostConfiguration = new HostConfiguration();

    SimplehttpconnectionManager connectionManager = new SimplehttpconnectionManager();
    connectionManager.closeIdleConnections(5000L);

    httpconnectionManagerParams params = new httpconnectionManagerParams();
    params.setStaleCheckingEnabled(diamondConfigure
            .isConnectionStaleCheckingEnabled());
    params.setConnectionTimeout(diamondConfigure.getConnectionTimeout());
    connectionManager.setParams(params);

    configHttpClient = new HttpClient(connectionManager);
    configHttpClient.setHostConfiguration(hostConfiguration);
}
项目:jenkins-reviewbot    文件:ConnectionTest.java   
@Test(expected=IOException.class)
public void testFailConnection() throws Exception {
  SimplehttpconnectionManager simple = new SimplehttpconnectionManager();
  HttpClient http = new HttpClient(simple);
  ReviewboardConnection bad =
      new ReviewboardConnection(System.getProperty("reviewboard.url","https://reviewboard.eng.vmware.com/"),System.getProperty("reviewboard.user"),"foobar");
  try {
    ReviewboardOps.ensureAuthentication(bad,http);
  } finally {
    simple.shutdown();
  }

}
项目:s3distcp    文件:S3distCp.java   
private static boolean isGovCloud()
/*     */   {
/* 486 */     if (ec2MetaDataAz != null) {
/* 487 */       return ec2MetaDataAz.startsWith("us-gov-west-1");
/*     */     }
/*     */ 
/* 492 */     String hostname = getHostName();
/* 493 */     int timeout = hostname.startsWith("ip-") ? 30000 : 5000;
/* 494 */     getmethod getmethod = new getmethod("http://169.254.169.254/latest/Meta-data/placement/availability-zone");
/*     */     try {
/* 496 */       httpconnectionManager manager = new SimplehttpconnectionManager();
/* 497 */       httpconnectionManagerParams params = manager.getParams();
/*     */ 
/* 499 */       params.setConnectionTimeout(timeout);
/*     */ 
/* 501 */       params.setSoTimeout(timeout);
/* 502 */       HttpClient httpClient = new HttpClient(manager);
/* 503 */       int status = httpClient.executeMethod(getmethod);
/* 504 */       if ((status < 200) || (status > 299)) {
/* 505 */         LOG.info("error status code" + status + " GET " + "http://169.254.169.254/latest/Meta-data/placement/availability-zone");
/*     */       } else {
/* 507 */         ec2MetaDataAz = getmethod.getResponseBodyAsstring().trim();
/* 508 */         LOG.info("GET http://169.254.169.254/latest/Meta-data/placement/availability-zone result: " + ec2MetaDataAz);
/* 509 */         return ec2MetaDataAz.startsWith("us-gov-west-1");
/*     */       }
/*     */     } catch (Exception e) {
/* 512 */       LOG.info("GET http://169.254.169.254/latest/Meta-data/placement/availability-zone exception ",e);
/*     */     } finally {
/* 514 */       getmethod.releaseConnection();
/*     */     }
/* 516 */     return false;
/*     */   }
项目:dlface    文件:FrdHttpFileDownloadTask.java   
private void initDownloadThread() {
    client.getHTTPClient().sethttpconnectionManager(new SimplehttpconnectionManager());
    client.getHTTPClient().gethttpconnectionManager().closeIdleConnections(0);
}
项目:ALLIN    文件:HttpUtil.java   
/**
 * 通过http的post方式请求数据  connectionTimeOut:建立连接的超时时间,soTimeOut:等待返回结果的超时时间
 * @param urlString
 * @param params
 * @param encode
 * @param connectionTimeOut
 * @param soTimeOut
 * @return
 * @throws IOException 
 * @throws HttpException 
 * @throws Exception
 * @Author YHJ create at 2014年5月14日 下午4:36:02
 */
public static String doPost(String urlString,Map<String,String> params) throws HttpException,IOException {
    PostMethod method = new PostMethod(urlString);
    HttpClient client = null;
    try {
        Set<String> keys = params.keySet();
        NameValuePair[] values = new NameValuePair[keys.size()];
        int i = 0;
        for (String key : keys) {
            NameValuePair v = new NameValuePair();
            v.setName(key);
            v.setValue(params.get(key));
            values[i] = v;
            i++;
        }

        client = new HttpClient();
        client.getHostConfiguration().setHost(urlString,80,"http");
        client.gethttpconnectionManager().getParams().setConnectionTimeout(30000);// 建立连接的超时时间
        client.gethttpconnectionManager().getParams().setSoTimeout(30000);// 等待请求结果的超时时间
        if (StringUtils.isNotBlank(encode))
            client.getParams().setParameter(
                    HttpMethodParams.HTTP_CONTENT_CHARSET,encode);
        method.setRequestBody(values); // 使用 POST 方式提交数据
        int state = client.executeMethod(method);   //返回的状态 
        if(state != HttpStatus.SC_OK){
            throw new RuntimeException("HttpStatus is "+state);
        } 
        return inputStreamToString(method.getResponseBodyAsstream(),encode);
    } finally {
        //releaseConnection方法不能关闭socket连接
           //使用SimplehttpconnectionManager的shutdown方法强制关闭
        method.releaseConnection();
        if (client != null ) {
            httpconnectionManager manager = client.gethttpconnectionManager();
            if (manager instanceof SimplehttpconnectionManager) {
                SimplehttpconnectionManager tmp = (SimplehttpconnectionManager)manager;
                tmp.shutdown();
            }
        }
    }
}
项目:urlrewritefilter    文件:RequestProxy.java   
/**
 * This method performs the proxying of the request to the target address.
 *
 * @param target     The target address. Has to be a fully qualified address. The request is send as-is to this address.
 * @param hsRequest  The request data which should be send to the
 * @param hsResponse The response data which will contain the data returned by the proxied request to target.
 * @throws java.io.IOException Passed on from the connection logic.
 */
public static void execute(final String target,final HttpServletRequest hsRequest,final HttpServletResponse hsResponse) throws IOException {
    if ( log.isInfoEnabled() ) {
        log.info("execute,target is " + target);
        log.info("response commit state: " + hsResponse.isCommitted());
    }

    if (StringUtils.isBlank(target)) {
        log.error("The target address is not given. Please provide a target address.");
        return;
    }

    log.info("checking url");
    final URL url;
    try {
        url = new URL(target);
    } catch (MalformedURLException e) {
        log.error("The provided target url is not valid.",e);
        return;
    }

    log.info("seting up the host configuration");

    final HostConfiguration config = new HostConfiguration();

    ProxyHost proxyHost = getUseProxyServer((String) hsRequest.getAttribute("use-proxy"));
    if (proxyHost != null) config.setProxyHost(proxyHost);

    final int port = url.getPort() != -1 ? url.getPort() : url.getDefaultPort();
    config.setHost(url.getHost(),port,url.getProtocol());

    if ( log.isInfoEnabled() ) log.info("config is " + config.toString());

    final HttpMethod targetRequest = setupProxyRequest(hsRequest,url);
    if (targetRequest == null) {
        log.error("Unsupported request method found: " + hsRequest.getmethod());
        return;
    }

    //perform the reqeust to the target server
    final HttpClient client = new HttpClient(new SimplehttpconnectionManager());
    if (log.isInfoEnabled()) {
        log.info("client state" + client.getState());
        log.info("client params" + client.getParams().toString());
        log.info("executeMethod / fetching data ...");
    }

    final int result;
    if (targetRequest instanceof EntityEnclosingMethod) {
        final RequestProxyCustomrequestEntity requestEntity = new RequestProxyCustomrequestEntity(
                hsRequest.getInputStream(),hsRequest.getContentLength(),hsRequest.getContentType());
        final EntityEnclosingMethod entityEnclosingMethod = (EntityEnclosingMethod) targetRequest;
        entityEnclosingMethod.setRequestEntity(requestEntity);
        result = client.executeMethod(config,entityEnclosingMethod);

    } else {
        result = client.executeMethod(config,targetRequest);
    }

    //copy the target response headers to our response
    setupResponseHeaders(targetRequest,hsResponse);

    InputStream originalResponseStream = targetRequest.getResponseBodyAsstream();
    //the body might be null,i.e. for responses with cache-headers which leave out the body
    if (originalResponseStream != null) {
        OutputStream responseStream = hsResponse.getoutputStream();
        copyStream(originalResponseStream,responseStream);
    }

    log.info("set up response,result code was " + result);
}

org.apache.http.conn.ClientConnectionOperator的实例源码

org.apache.http.conn.ClientConnectionOperator的实例源码

项目:lams    文件:ManagedClientConnectionImpl.java   
ManagedClientConnectionImpl(
        final ClientConnectionManager manager,final ClientConnectionoperator operator,final HttpPoolEntry entry) {
    super();
    if (manager == null) {
        throw new IllegalArgumentException("Connection manager may not be null");
    }
    if (operator == null) {
        throw new IllegalArgumentException("Connection operator may not be null");
    }
    if (entry == null) {
        throw new IllegalArgumentException("HTTP pool entry may not be null");
    }
    this.manager = manager;
    this.operator = operator;
    this.poolEntry = entry;
    this.reusable = false;
    this.duration = Long.MAX_VALUE;
}
项目:lams    文件:ConnPoolByRoute.java   
/**
 * @since 4.1
 */
public ConnPoolByRoute(
        final ClientConnectionoperator operator,final ConnPerRoute connPerRoute,int maxTotalConnections,long connTTL,final TimeUnit connTTLTimeUnit) {
    super();
    if (operator == null) {
        throw new IllegalArgumentException("Connection operator may not be null");
    }
    if (connPerRoute == null) {
        throw new IllegalArgumentException("Connections per route may not be null");
    }
    this.poolLock = super.poolLock;
    this.leasedConnections = super.leasedConnections;
    this.operator = operator;
    this.connPerRoute = connPerRoute;
    this.maxTotalConnections = maxTotalConnections;
    this.freeConnections = createFreeConnQueue();
    this.waitingThreads  = createWaitingThreadQueue();
    this.routetoPool     = createRoutetoPoolMap();
    this.connTTL = connTTL;
    this.connTTLTimeUnit = connTTLTimeUnit;
}
项目:lams    文件:ConnPoolByRoute.java   
/**
 * Creates a new pool entry.
 * This method assumes that the new connection will be handed
 * out immediately.
 *
 * @param rospl       the route-specific pool for which to create the entry
 * @param op        the operator for creating a connection
 *
 * @return  the new pool entry for a new connection
 */
protected BasicPoolEntry createEntry(RouteSpecificPool rospl,ClientConnectionoperator op) {

    if (log.isDebugEnabled()) {
        log.debug("Creating new connection [" + rospl.getRoute() + "]");
    }

    // the entry will create the connection when needed
    BasicPoolEntry entry = new BasicPoolEntry(op,rospl.getRoute(),connTTL,connTTLTimeUnit);

    poolLock.lock();
    try {
        rospl.createdEntry(entry);
        numConnections++;
        leasedConnections.add(entry);
    } finally {
        poolLock.unlock();
    }

    return entry;
}
项目:purecloud-iot    文件:ConnPoolByRoute.java   
/**
 * @since 4.1
 */
public ConnPoolByRoute(
        final ClientConnectionoperator operator,final int maxTotalConnections,final long connTTL,final TimeUnit connTTLTimeUnit) {
    super();
    Args.notNull(operator,"Connection operator");
    Args.notNull(connPerRoute,"Connections per route");
    this.poolLock = super.poolLock;
    this.leasedConnections = super.leasedConnections;
    this.operator = operator;
    this.connPerRoute = connPerRoute;
    this.maxTotalConnections = maxTotalConnections;
    this.freeConnections = createFreeConnQueue();
    this.waitingThreads  = createWaitingThreadQueue();
    this.routetoPool     = createRoutetoPoolMap();
    this.connTTL = connTTL;
    this.connTTLTimeUnit = connTTLTimeUnit;
}
项目:purecloud-iot    文件:ConnPoolByRoute.java   
/**
 * Creates a new pool entry.
 * This method assumes that the new connection will be handed
 * out immediately.
 *
 * @param rospl       the route-specific pool for which to create the entry
 * @param op        the operator for creating a connection
 *
 * @return  the new pool entry for a new connection
 */
protected BasicPoolEntry createEntry(final RouteSpecificPool rospl,final ClientConnectionoperator op) {

    if (log.isDebugEnabled()) {
        log.debug("Creating new connection [" + rospl.getRoute() + "]");
    }

    // the entry will create the connection when needed
    final BasicPoolEntry entry = new BasicPoolEntry(op,connTTLTimeUnit);

    poolLock.lock();
    try {
        rospl.createdEntry(entry);
        numConnections++;
        leasedConnections.add(entry);
    } finally {
        poolLock.unlock();
    }

    return entry;
}
项目:cJUnit-mc626    文件:ConnPoolByRoute.java   
/**
 * Creates a new pool entry.
 * This method assumes that the new connection will be handed
 * out immediately.
 *
 * @param rospl       the route-specific pool for which to create the entry
 * @param op        the operator for creating a connection
 *
 * @return  the new pool entry for a new connection
 */
protected BasicPoolEntry createEntry(RouteSpecificPool rospl,rospl.getRoute());

    poolLock.lock();
    try {
        rospl.createdEntry(entry);
        numConnections++;
        leasedConnections.add(entry);
    } finally {
        poolLock.unlock();
    }

    return entry;
}
项目:lams    文件:ConnPoolByRoute.java   
/**
 * Creates a new connection pool,managed by route.
 *
 * @since 4.1
 */
public ConnPoolByRoute(
        final ClientConnectionoperator operator,int maxTotalConnections) {
    this(operator,connPerRoute,maxTotalConnections,-1,TimeUnit.MILLISECONDS);
}
项目:lams    文件:BasicPoolEntry.java   
public BasicPoolEntry(ClientConnectionoperator op,HttpRoute route,ReferenceQueue<Object> queue) {
    super(op,route);
    if (route == null) {
        throw new IllegalArgumentException("HTTP route may not be null");
    }
    this.created = System.currentTimeMillis();
    this.validUntil = Long.MAX_VALUE;
    this.expiry = this.validUntil;
}
项目:lams    文件:BasicPoolEntry.java   
/**
 * Creates a new pool entry with a specified maximum lifetime.
 *
 * @param op        the connection operator
 * @param route     the planned route for the connection
 * @param connTTL   maximum lifetime of this entry,<=0 implies "infinity"
 * @param timeunit  TimeUnit of connTTL
 *
 * @since 4.1
 */
public BasicPoolEntry(ClientConnectionoperator op,TimeUnit timeunit) {
    super(op,route);
    if (route == null) {
        throw new IllegalArgumentException("HTTP route may not be null");
    }
    this.created = System.currentTimeMillis();
    if (connTTL > 0) {
        this.validUntil = this.created + timeunit.toMillis(connTTL);
    } else {
        this.validUntil = Long.MAX_VALUE;
    }
    this.expiry = this.validUntil;
}
项目:lams    文件:AbstractPoolEntry.java   
/**
 * Creates a new pool entry.
 *
 * @param connoperator     the Connection Operator for this entry
 * @param route   the planned route for the connection,*                or <code>null</code>
 */
protected AbstractPoolEntry(ClientConnectionoperator connoperator,HttpRoute route) {
    super();
    if (connoperator == null) {
        throw new IllegalArgumentException("Connection operator may not be null");
    }
    this.connoperator = connoperator;
    this.connection = connoperator.createConnection();
    this.route = route;
    this.tracker = null;
}
项目:purecloud-iot    文件:HttpConnPool.java   
public HttpConnPool(final Log log,final ClientConnectionoperator connoperator,final int defaultMaxPerRoute,final int maxTotal,final long timetoLive,final TimeUnit tunit) {
    super(new InternalConnFactory(connoperator),defaultMaxPerRoute,maxTotal);
    this.log = log;
    this.timetoLive = timetoLive;
    this.tunit = tunit;
}
项目:purecloud-iot    文件:ManagedClientConnectionImpl.java   
ManagedClientConnectionImpl(
        final ClientConnectionManager manager,final HttpPoolEntry entry) {
    super();
    Args.notNull(manager,"Connection manager");
    Args.notNull(operator,"Connection operator");
    Args.notNull(entry,"HTTP pool entry");
    this.manager = manager;
    this.operator = operator;
    this.poolEntry = entry;
    this.reusable = false;
    this.duration = Long.MAX_VALUE;
}
项目:purecloud-iot    文件:ConnPoolByRoute.java   
/**
 * Creates a new connection pool,final int maxTotalConnections) {
    this(operator,TimeUnit.MILLISECONDS);
}
项目:purecloud-iot    文件:ConnPoolByRoute.java   
/**
 * Creates a new connection pool,managed by route.
 *
 * @deprecated (4.1)  use {@link ConnPoolByRoute#ConnPoolByRoute(ClientConnectionoperator,ConnPerRoute,int)}
 */
@Deprecated
public ConnPoolByRoute(final ClientConnectionoperator operator,final HttpParams params) {
    this(operator,ConnManagerParams.getMaxConnectionsPerRoute(params),ConnManagerParams.getMaxTotalConnections(params));
}
项目:purecloud-iot    文件:BasicPoolEntry.java   
public BasicPoolEntry(final ClientConnectionoperator op,final HttpRoute route,final ReferenceQueue<Object> queue) {
    super(op,route);
    Args.notNull(route,"HTTP route");
    this.created = System.currentTimeMillis();
    this.validUntil = Long.MAX_VALUE;
    this.expiry = this.validUntil;
}
项目:purecloud-iot    文件:BasicPoolEntry.java   
/**
 * Creates a new pool entry with a specified maximum lifetime.
 *
 * @param op        the connection operator
 * @param route     the planned route for the connection
 * @param connTTL   maximum lifetime of this entry,&lt;=0 implies "infinity"
 * @param timeunit  TimeUnit of connTTL
 *
 * @since 4.1
 */
public BasicPoolEntry(final ClientConnectionoperator op,final TimeUnit timeunit) {
    super(op,"HTTP route");
    this.created = System.currentTimeMillis();
    if (connTTL > 0) {
        this.validUntil = this.created + timeunit.toMillis(connTTL);
    } else {
        this.validUntil = Long.MAX_VALUE;
    }
    this.expiry = this.validUntil;
}
项目:purecloud-iot    文件:AbstractPoolEntry.java   
/**
 * Creates a new pool entry.
 *
 * @param connoperator     the Connection Operator for this entry
 * @param route   the planned route for the connection,*                or {@code null}
 */
protected AbstractPoolEntry(final ClientConnectionoperator connoperator,final HttpRoute route) {
    super();
    Args.notNull(connoperator,"Connection operator");
    this.connoperator = connoperator;
    this.connection = connoperator.createConnection();
    this.route = route;
    this.tracker = null;
}
项目:cJUnit-mc626    文件:ConnPoolByRoute.java   
/**
 * Creates a new connection pool,managed by route.
 */
public ConnPoolByRoute(final ClientConnectionoperator operator,final HttpParams params) {
    super();
    if (operator == null) {
        throw new IllegalArgumentException("Connection operator may not be null");
    }
    this.operator = operator;
    this.params = params;

    freeConnections = createFreeConnQueue();
    waitingThreads  = createWaitingThreadQueue();
    routetoPool     = createRoutetoPoolMap();
}
项目:cJUnit-mc626    文件:BasicPoolEntry.java   
/**
 * @deprecated do not use
 */
@Deprecated
public BasicPoolEntry(ClientConnectionoperator op,route);
    if (route == null) {
        throw new IllegalArgumentException("HTTP route may not be null");
    }
}
项目:cJUnit-mc626    文件:BasicPoolEntry.java   
/**
 * Creates a new pool entry.
 *
 * @param op      the connection operator
 * @param route   the planned route for the connection
 */
public BasicPoolEntry(ClientConnectionoperator op,HttpRoute route) {
    super(op,route);
    if (route == null) {
        throw new IllegalArgumentException("HTTP route may not be null");
    }
}
项目:cJUnit-mc626    文件:AbstractPoolEntry.java   
/**
 * Creates a new pool entry.
 *
 * @param connoperator     the Connection Operator for this entry
 * @param route   the planned route for the connection,HttpRoute route) {
    super();
    if (connoperator == null) {
        throw new IllegalArgumentException("Connection operator may not be null");
    }
    this.connoperator = connoperator;
    this.connection = connoperator.createConnection();
    this.route = route;
    this.tracker = null;
}
项目:ribbon    文件:NamedConnectionPool.java   
@Override
protected BasicPoolEntry createEntry(RouteSpecificPool rospl,ClientConnectionoperator op) {
    createEntryCounter.increment();
    Stopwatch stopWatch = creationTimer.start();
    try {
        return super.createEntry(rospl,op);
    } finally {
        stopWatch.stop();
    }
}
项目:lams    文件:BasicclientConnectionManager.java   
protected ClientConnectionoperator createConnectionoperator(final SchemeRegistry schreg) {
    return new DefaultClientConnectionoperator(schreg);
}
项目:lams    文件:ConnPoolByRoute.java   
/**
 * Creates a new connection pool,int)}
 */
public ConnPoolByRoute(final ClientConnectionoperator operator,ConnManagerParams.getMaxTotalConnections(params));
}
项目:PhET    文件:OperatorConnectDirect.java   
public static void main(String[] args) throws Exception {
    HttpHost target = new HttpHost("jakarta.apache.org",80,"http");

    // some general setup
    // Register the "http" protocol scheme,it is required
    // by the default operator to look up socket factories.
    SchemeRegistry supportedSchemes = new SchemeRegistry();
    SocketFactory sf = PlainSocketFactory.getSocketFactory();
    supportedSchemes.register(new Scheme("http",sf,80));

    // Prepare parameters.
    // Since this example doesn't use the full core framework,// only few parameters are actually required.
    HttpParams params = new BasicHttpParams();
    HttpProtocolParams.setVersion(params,HttpVersion.HTTP_1_1);
    HttpProtocolParams.setUseExpectContinue(params,false);

    // one operator can be used for many connections
    ClientConnectionoperator scop = new DefaultClientConnectionoperator(supportedSchemes);

    HttpRequest req = new BasicHttpRequest("OPTIONS","*",HttpVersion.HTTP_1_1);
    req.addHeader("Host",target.getHostName());

    HttpContext ctx = new BasicHttpContext();

    OperatedClientConnection conn = scop.createConnection();
    try {
        System.out.println("opening connection to " + target);
        scop.openConnection(conn,target,null,ctx,params);
        System.out.println("sending request");
        conn.sendRequestHeader(req);
        // there is no request entity
        conn.flush();

        System.out.println("receiving response header");
        HttpResponse rsp = conn.receiveResponseHeader();

        System.out.println("----------------------------------------");
        System.out.println(rsp.getStatusLine());
        Header[] headers = rsp.getAllHeaders();
        for (int i = 0; i < headers.length; i++) {
            System.out.println(headers[i]);
        }
        System.out.println("----------------------------------------");
    } finally {
        System.out.println("closing connection");
        conn.close();
    }
}
项目:cloud-meter    文件:MeasuringConnectionManager.java   
/**
 * Overriden to use {@link JMeterClientConnectionoperator} and fix SNI issue 
 * @see "https://bz.apache.org/bugzilla/show_bug.cgi?id=57935"
 * @see org.apache.http.impl.conn.PoolingClientConnectionManager#createConnectionoperator(org.apache.http.conn.scheme.SchemeRegistry)
 */
@Override
protected ClientConnectionoperator createConnectionoperator(
        SchemeRegistry schreg) {
    return new JMeterClientConnectionoperator(schreg);
}
项目:purecloud-iot    文件:HttpConnPool.java   
InternalConnFactory(final ClientConnectionoperator connoperator) {
    this.connoperator = connoperator;
}
项目:purecloud-iot    文件:BasicclientConnectionManager.java   
protected ClientConnectionoperator createConnectionoperator(final SchemeRegistry schreg) {
    return new DefaultClientConnectionoperator(schreg);
}
项目:FMTech    文件:ElegantThreadSafeConnManager.java   
public ElegantPool(ClientConnectionoperator paramClientConnectionoperator,HttpParams paramHttpParams)
{
  super(paramHttpParams);
}
项目:MediaPlayerProxy    文件:HttpUtils.java   
@Override
protected ClientConnectionoperator createConnectionoperator(final SchemeRegistry sr) {
    return new MyClientConnectionoperator(sr);
}
项目:cJUnit-mc626    文件:OperatorConnectDirect.java   
public static void main(String[] args) throws Exception {
    HttpHost target = new HttpHost("jakarta.apache.org",params);
        System.out.println("sending request");
        conn.sendRequestHeader(req);
        // there is no request entity
        conn.flush();

        System.out.println("receiving response header");
        HttpResponse rsp = conn.receiveResponseHeader();

        System.out.println("----------------------------------------");
        System.out.println(rsp.getStatusLine());
        Header[] headers = rsp.getAllHeaders();
        for (int i = 0; i < headers.length; i++) {
            System.out.println(headers[i]);
        }
        System.out.println("----------------------------------------");
    } finally {
        System.out.println("closing connection");
        conn.close();
    }
}
项目:olingo-odata4    文件:CustomConnectionsHttpClientFactory.java   
@Override
protected ClientConnectionoperator createConnectionoperator(final SchemeRegistry registry) {
  return new MyClientConnectionoperator(registry);
}
项目:ribbon    文件:NamedConnectionPool.java   
public NamedConnectionPool(String name,ClientConnectionoperator operator,ConnPerRoute connPerRoute,TimeUnit connTTLTimeUnit) {
    super(operator,connTTLTimeUnit);
    initMonitors(name);
}
项目:ribbon    文件:NamedConnectionPool.java   
public NamedConnectionPool(String name,int maxTotalConnections) {
    super(operator,maxTotalConnections);
    initMonitors(name);
}
项目:ribbon    文件:NamedConnectionPool.java   
public NamedConnectionPool(String name,HttpParams params) {
    super(operator,params);
    initMonitors(name);
}
项目:ribbon    文件:NamedConnectionPool.java   
NamedConnectionPool(ClientConnectionoperator operator,connTTLTimeUnit);
}
项目:ribbon    文件:NamedConnectionPool.java   
NamedConnectionPool(ClientConnectionoperator operator,maxTotalConnections);
}
项目:ribbon    文件:NamedConnectionPool.java   
NamedConnectionPool(ClientConnectionoperator operator,params);
}
项目:cougar    文件:CougarClientConnManager.java   
private CougarConnPoolByRoute(ClientConnectionoperator operator,connTTLTimeUnit);
}
项目:LibraryH3lp-Transfer-Bot    文件:OperatorConnectDirect.java   
public static void main(String[] args) throws Exception {
    HttpHost target = new HttpHost("jakarta.apache.org",it is required
    // by the default operator to look up socket factories.
    SchemeRegistry supportedSchemes = new SchemeRegistry();
    supportedSchemes.register(new Scheme("http",PlainSocketFactory.getSocketFactory()));

    // Prepare parameters.
    // Since this example doesn't use the full core framework,// only few parameters are actually required.
    HttpParams params = new SyncBasicHttpParams();
    HttpProtocolParams.setVersion(params,params);
        System.out.println("sending request");
        conn.sendRequestHeader(req);
        // there is no request entity
        conn.flush();

        System.out.println("receiving response header");
        HttpResponse rsp = conn.receiveResponseHeader();

        System.out.println("----------------------------------------");
        System.out.println(rsp.getStatusLine());
        Header[] headers = rsp.getAllHeaders();
        for (int i = 0; i < headers.length; i++) {
            System.out.println(headers[i]);
        }
        System.out.println("----------------------------------------");
    } finally {
        System.out.println("closing connection");
        conn.close();
    }
}

org.apache.http.conn.ConnectionPoolTimeoutException的实例源码

org.apache.http.conn.ConnectionPoolTimeoutException的实例源码

项目:lams    文件:PoolingClientConnectionManager.java   
public ClientConnectionRequest requestConnection(
        final HttpRoute route,final Object state) {
    if (route == null) {
        throw new IllegalArgumentException("HTTP route may not be null");
    }
    if (this.log.isDebugEnabled()) {
        this.log.debug("Connection request: " + format(route,state) + formatStats(route));
    }
    final Future<HttpPoolEntry> future = this.pool.lease(route,state);

    return new ClientConnectionRequest() {

        public void abortRequest() {
            future.cancel(true);
        }

        public ManagedClientConnection getConnection(
                final long timeout,final TimeUnit tunit) throws InterruptedException,ConnectionPoolTimeoutException {
            return leaseConnection(future,timeout,tunit);
        }

    };

}
项目:ibm-cos-sdk-java    文件:ConnectionPoolMaxConnectionsIntegrationTest.java   
@Test(timeout = 60 * 1000)
public void leasing_a_new_connection_fails_with_connection_pool_timeout()
        throws Exception {

    String localhostEndpoint = "http://localhost:" + server.getPort();

    AmazonHttpClient httpClient = new AmazonHttpClient(
            new ClientConfiguration()
                    .withMaxConnections(1)
                    .withConnectionTimeout(100)
                    .withMaxErrorRetry(0));

    Request<?> request = new EmptyHttpRequest(localhostEndpoint,HttpMethodName.GET);

    // Block the first connection in the pool with this request.
    httpClient.requestExecutionBuilder().request(request).execute(new EmptyAWSResponseHandler());

    try {
        // A new connection will be leased here which would fail in
        // ConnectionPoolTimeoutException.
        httpClient.requestExecutionBuilder().request(request).execute();
        Assert.fail("Connection pool timeout exception is expected!");
    } catch (AmazonClientException e) {
        Assert.assertTrue(e.getCause() instanceof ConnectionPoolTimeoutException);
    }
}
项目:remote-files-sync    文件:PoolingHttpClientConnectionManager.java   
public ConnectionRequest requestConnection(
        final HttpRoute route,final Object state) {
    Args.notNull(route,"HTTP route");
    if (Log.isLoggable(TAG,Log.DEBUG)) {
        Log.d(TAG,"Connection request: " + format(route,state) + formatStats(route));
    }
    final Future<CPoolEntry> future = this.pool.lease(route,state,null);
    return new ConnectionRequest() {

        public boolean cancel() {
            return future.cancel(true);
        }

        public HttpClientConnection get(
                final long timeout,ExecutionException,tunit);
        }

    };

}
项目:remote-files-sync    文件:PoolingHttpClientConnectionManager.java   
protected HttpClientConnection leaseConnection(
        final Future<CPoolEntry> future,final long timeout,ConnectionPoolTimeoutException {
    final CPoolEntry entry;
    try {
        entry = future.get(timeout,tunit);
        if (entry == null || future.isCancelled()) {
            throw new InterruptedException();
        }
        Asserts.check(entry.getConnection() != null,"Pool entry with no connection");
        if (Log.isLoggable(TAG,Log.DEBUG)) {
            Log.d(TAG,"Connection leased: " + format(entry) + formatStats(entry.getRoute()));
        }
        return CPoolProxy.newProxy(entry);
    } catch (final TimeoutException ex) {
        throw new ConnectionPoolTimeoutException("Timeout waiting for connection from pool");
    }
}
项目:cloud-meter    文件:JMeterPoolingClientConnectionManager.java   
@Override
public ClientConnectionRequest requestConnection(
        final HttpRoute route,"HTTP route");
    if (this.log.isDebugEnabled()) {
        this.log.debug("Connection request: " + format(route,state);

    return new ClientConnectionRequest() {
        @Override
        public void abortRequest() {
            future.cancel(true);
        }
        @Override
        public ManagedClientConnection getConnection(
                final long timeout,tunit);
        }

    };

}
项目:purecloud-iot    文件:PoolingHttpClientConnectionManager.java   
@Override
public ConnectionRequest requestConnection(
        final HttpRoute route,null);
    return new ConnectionRequest() {

        @Override
        public boolean cancel() {
            return future.cancel(true);
        }

        @Override
        public HttpClientConnection get(
                final long timeout,tunit);
        }

    };

}
项目:purecloud-iot    文件:PoolingHttpClientConnectionManager.java   
protected HttpClientConnection leaseConnection(
        final Future<CPoolEntry> future,"Pool entry with no connection");
        if (this.log.isDebugEnabled()) {
            this.log.debug("Connection leased: " + format(entry) + formatStats(entry.getRoute()));
        }
        return CPoolProxy.newProxy(entry);
    } catch (final TimeoutException ex) {
        throw new ConnectionPoolTimeoutException("Timeout waiting for connection from pool");
    }
}
项目:FMTech    文件:ElegantThreadSafeConnManager.java   
public final ClientConnectionRequest requestConnection(final HttpRoute paramHttpRoute,Object paramObject)
{
  new ClientConnectionRequest()
  {
    public final void abortRequest()
    {
      this.val$poolRequest.abortRequest();
    }

    public final ManagedClientConnection getConnection(long paramAnonymousLong,TimeUnit paramAnonymousTimeUnit)
      throws InterruptedException,ConnectionPoolTimeoutException
    {
      if (paramHttpRoute == null) {
        throw new IllegalArgumentException("Route may not be null.");
      }
      BasicPoolEntry localBasicPoolEntry = this.val$poolRequest.getPoolEntry(paramAnonymousLong,paramAnonymousTimeUnit);
      return new ElegantThreadSafeConnManager.ElegantBasicPooledConnAdapter(ElegantThreadSafeConnManager.this,localBasicPoolEntry);
    }
  };
}
项目:FMTech    文件:ElegantThreadSafeConnManager.java   
public final PoolEntryRequest requestPoolEntry(final HttpRoute paramHttpRoute,final Object paramObject)
{
  new PoolEntryRequest()
  {
    public final void abortRequest()
    {
      ElegantThreadSafeConnManager.ElegantPool.this.poolLock.lock();
      try
      {
        this.val$aborter.abort();
        return;
      }
      finally
      {
        ElegantThreadSafeConnManager.ElegantPool.this.poolLock.unlock();
      }
    }

    public final BasicPoolEntry getPoolEntry(long paramAnonymousLong,ConnectionPoolTimeoutException
    {
      return ElegantThreadSafeConnManager.ElegantPool.this.getEntryBlocking(paramHttpRoute,paramObject,paramAnonymousLong,paramAnonymousTimeUnit,this.val$aborter);
    }
  };
}
项目:WeiboWeiBaTong    文件:RetryRequestSample.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // The following exceptions will be whitelisted,i.e.: When an exception
    // of this type is raised,the request will be retried.
    AsyncHttpClient.allowRetryExceptionClass(IOException.class);
    AsyncHttpClient.allowRetryExceptionClass(SocketTimeoutException.class);
    AsyncHttpClient.allowRetryExceptionClass(ConnectTimeoutException.class);

    // The following exceptions will be blacklisted,the request will not be retried and it will
    // fail immediately.
    AsyncHttpClient.blockRetryExceptionClass(UnkNownHostException.class);
    AsyncHttpClient.blockRetryExceptionClass(ConnectionPoolTimeoutException.class);
}
项目:Visit    文件:PoolingHttpClientConnectionManager.java   
public ConnectionRequest requestConnection(
        final HttpRoute route,tunit);
        }

    };

}
项目:Visit    文件:PoolingHttpClientConnectionManager.java   
protected HttpClientConnection leaseConnection(
        final Future<CPoolEntry> future,"Connection leased: " + format(entry) + formatStats(entry.getRoute()));
        }
        return CPoolProxy.newProxy(entry);
    } catch (final TimeoutException ex) {
        throw new ConnectionPoolTimeoutException("Timeout waiting for connection from pool");
    }
}
项目:welshare    文件:GooglePlusService.java   
private void handleException(String message,Exception e,User user) {
    if (e instanceof HttpClientErrorException) {
        String responseBody = ((HttpClientErrorException) e).getResponseBodyAsstring();
        // if unauthorized
        if (((HttpClientErrorException) e).getStatusCode() == HttpStatus.UNAUTHORIZED) {
            logger.info("Auth problem with user " + user + ". Resetting token. The problem is due to exception: " + e.getMessage() + "; Response body: " + responseBody);
            user.getGooglePlusSettings().setdisconnectReason(e.getMessage());
            helper.forciblydisconnect(this,user);
        } else {
            logger.warn(message + ": " + e.getMessage() + " : " + ExceptionUtils.getRootCauseMessage(e) + "; Response body: " + responseBody);
        }

    } else if (e.getCause() instanceof ConnectionPoolTimeoutException || e.getCause() instanceof SocketTimeoutException) {
        logger.warn("Google+ timeout (for user: " + user + ") " + ExceptionUtils.getRootCauseMessage(e));
    } else {
        logger.warn(message,e);
    }
}
项目:ZTLib    文件:PoolingHttpClientConnectionManager.java   
public ConnectionRequest requestConnection(
        final HttpRoute route,tunit);
        }

    };

}
项目:ZTLib    文件:PoolingHttpClientConnectionManager.java   
protected HttpClientConnection leaseConnection(
        final Future<CPoolEntry> future,"Connection leased: " + format(entry) + formatStats(entry.getRoute()));
        }
        return CPoolProxy.newProxy(entry);
    } catch (final TimeoutException ex) {
        throw new ConnectionPoolTimeoutException("Timeout waiting for connection from pool");
    }
}
项目:lams    文件:ConnPoolByRoute.java   
@Override
public PoolEntryRequest requestPoolEntry(
        final HttpRoute route,final Object state) {

    final WaitingThreadAborter aborter = new WaitingThreadAborter();

    return new PoolEntryRequest() {

        public void abortRequest() {
            poolLock.lock();
            try {
                aborter.abort();
            } finally {
                poolLock.unlock();
            }
        }

        public BasicPoolEntry getPoolEntry(
                long timeout,TimeUnit tunit)
                    throws InterruptedException,ConnectionPoolTimeoutException {
            return getEntryBlocking(route,tunit,aborter);
        }

    };
}
项目:lams    文件:ThreadSafeClientConnManager.java   
public ClientConnectionRequest requestConnection(
        final HttpRoute route,final Object state) {

    final PoolEntryRequest poolRequest = pool.requestPoolEntry(
            route,state);

    return new ClientConnectionRequest() {

        public void abortRequest() {
            poolRequest.abortRequest();
        }

        public ManagedClientConnection getConnection(
                long timeout,TimeUnit tunit) throws InterruptedException,ConnectionPoolTimeoutException {
            if (route == null) {
                throw new IllegalArgumentException("Route may not be null.");
            }

            if (log.isDebugEnabled()) {
                log.debug("Get connection: " + route + ",timeout = " + timeout);
            }

            BasicPoolEntry entry = poolRequest.getPoolEntry(timeout,tunit);
            return new BasicPooledConnAdapter(ThreadSafeClientConnManager.this,entry);
        }

    };

}
项目:aws-sdk-java-v2    文件:ConnectionPoolMaxConnectionsIntegrationTest.java   
@Test(timeout = 60 * 1000)
public void leasing_a_new_connection_fails_with_connection_pool_timeout() throws Exception {

    String localhostEndpoint = "http://localhost:" + server.getPort();

    AmazonHttpClient httpClient = HttpTestUtils.testClientBuilder()
                                               .clientExecutionTimeout(null)
                                               .retryPolicy(RetryPolicy.NONE)
                                               .httpClient(ApacheSdkHttpClientFactory.builder()
                                                                                     .connectionTimeout(
                                                                                             Duration.ofMillis(100))
                                                                                     .maxConnections(1)
                                                                                     .build()
                                                                                     .createHttpClient())
                                               .build();

    Request<?> request = new EmptyHttpRequest(localhostEndpoint,HttpMethodName.GET);

    // Block the first connection in the pool with this request.
    httpClient.requestExecutionBuilder()
              .request(request)
              .originalRequest(NoopTestAwsRequest.builder().build())
              .executionContext(executionContext(SdkHttpFullRequestAdapter.toHttpFullRequest(request)))
              .execute(new EmptyAWSResponseHandler());

    try {
        // A new connection will be leased here which would fail in
        // ConnectionPoolTimeoutException.
        httpClient.requestExecutionBuilder()
                  .request(request)
                  .originalRequest(NoopTestAwsRequest.builder().build())
                  .executionContext(executionContext(SdkHttpFullRequestAdapter.toHttpFullRequest(request)))
                  .execute();
        Assert.fail("Connection pool timeout exception is expected!");
    } catch (SdkClientException e) {
        Assert.assertTrue(e.getCause() instanceof ConnectionPoolTimeoutException);
    }
}
项目:purecloud-iot    文件:PoolingClientConnectionManager.java   
@Override
public ClientConnectionRequest requestConnection(
        final HttpRoute route,state);

    return new ClientConnectionRequest() {

        @Override
        public void abortRequest() {
            future.cancel(true);
        }

        @Override
        public ManagedClientConnection getConnection(
                final long timeout,tunit);
        }

    };

}
项目:purecloud-iot    文件:ConnPoolByRoute.java   
@Override
public PoolEntryRequest requestPoolEntry(
        final HttpRoute route,final Object state) {

    final WaitingThreadAborter aborter = new WaitingThreadAborter();

    return new PoolEntryRequest() {

        @Override
        public void abortRequest() {
            poolLock.lock();
            try {
                aborter.abort();
            } finally {
                poolLock.unlock();
            }
        }

        @Override
        public BasicPoolEntry getPoolEntry(
                final long timeout,final TimeUnit tunit)
                    throws InterruptedException,aborter);
        }

    };
}
项目:purecloud-iot    文件:ThreadSafeClientConnManager.java   
@Override
public ClientConnectionRequest requestConnection(
        final HttpRoute route,state);

    return new ClientConnectionRequest() {

        @Override
        public void abortRequest() {
            poolRequest.abortRequest();
        }

        @Override
        public ManagedClientConnection getConnection(
                final long timeout,ConnectionPoolTimeoutException {
            Args.notNull(route,"Route");

            if (log.isDebugEnabled()) {
                log.debug("Get connection: " + route + ",timeout = " + timeout);
            }

            final BasicPoolEntry entry = poolRequest.getPoolEntry(timeout,entry);
        }

    };

}
项目:purecloud-iot    文件:TestConnectionAutoRelease.java   
@Test
public void testReleaSEOnEntityConsumeContent() throws Exception {
    this.connManager.setDefaultMaxPerRoute(1);
    this.connManager.setMaxTotal(1);

    // Zero connections in the pool
    PoolStats stats = this.connManager.getTotalStats();
    Assert.assertEquals(0,stats.getAvailable());

    final HttpHost target = start();
    // Get some random data
    final HttpGet httpget = new HttpGet("/random/20000");
    final HttpResponse response = this.httpclient.execute(target,httpget);

    ConnectionRequest connreq = this.connManager.requestConnection(new HttpRoute(target),null);
    try {
        connreq.get(250,TimeUnit.MILLISECONDS);
        Assert.fail("ConnectionPoolTimeoutException should have been thrown");
    } catch (final ConnectionPoolTimeoutException expected) {
    }

    final httpentity e = response.getEntity();
    Assert.assertNotNull(e);
    EntityUtils.consume(e);

    // Expect one connection in the pool
    stats = this.connManager.getTotalStats();
    Assert.assertEquals(1,stats.getAvailable());

    // Make sure one connection is available
    connreq = this.connManager.requestConnection(new HttpRoute(target),null);
    final HttpClientConnection conn = connreq.get(250,TimeUnit.MILLISECONDS);

    this.connManager.releaseConnection(conn,null,-1,null);
}
项目:purecloud-iot    文件:TestConnectionAutoRelease.java   
@Test
public void testReleaSEOnEntityWriteto() throws Exception {
    this.connManager.setDefaultMaxPerRoute(1);
    this.connManager.setMaxTotal(1);

    // Zero connections in the pool
    PoolStats stats = this.connManager.getTotalStats();
    Assert.assertEquals(0,TimeUnit.MILLISECONDS);
        Assert.fail("ConnectionPoolTimeoutException should have been thrown");
    } catch (final ConnectionPoolTimeoutException expected) {
    }

    final httpentity e = response.getEntity();
    Assert.assertNotNull(e);
    final ByteArrayOutputStream outsteam = new ByteArrayOutputStream();
    e.writeto(outsteam);

    // Expect one connection in the pool
    stats = this.connManager.getTotalStats();
    Assert.assertEquals(1,null);
}
项目:purecloud-iot    文件:TestConnectionAutoRelease.java   
@Test
public void testReleaSEOnAbort() throws Exception {
    this.connManager.setDefaultMaxPerRoute(1);
    this.connManager.setMaxTotal(1);

    // Zero connections in the pool
    final PoolStats stats = this.connManager.getTotalStats();
    Assert.assertEquals(0,stats.getAvailable());

    final HttpHost target = start();

    // Get some random data
    final HttpGet httpget = new HttpGet("/random/20000");
    final HttpResponse response = this.httpclient.execute(target,TimeUnit.MILLISECONDS);
        Assert.fail("ConnectionPoolTimeoutException should have been thrown");
    } catch (final ConnectionPoolTimeoutException expected) {
    }

    final httpentity e = response.getEntity();
    Assert.assertNotNull(e);
    httpget.abort();

    // Expect zero connections in the pool
    Assert.assertEquals(0,this.connManager.getTotalStats().getAvailable());

    // Make sure one connection is available
    connreq = this.connManager.requestConnection(new HttpRoute(target),null);
}
项目:purecloud-iot    文件:TestConnectionManagement.java   
private static HttpClientConnection getConnection(
        final HttpClientConnectionManager mgr,final HttpRoute route,final TimeUnit unit) throws ConnectionPoolTimeoutException,InterruptedException {
    final ConnectionRequest connRequest = mgr.requestConnection(route,null);
    return connRequest.get(timeout,unit);
}
项目:purecloud-iot    文件:TestAbortHandling.java   
@Override
public ConnectionRequest requestConnection(final HttpRoute route,final Object state) {
    // If this is the redirect route,stub the return value
    // so-as to pretend the host is waiting on a slot...
    if(route.getTargetHost().getHostName().equals("localhost")) {
        final Thread currentThread = Thread.currentThread();

        return new ConnectionRequest() {

            @Override
            public boolean cancel() {
                currentThread.interrupt();
                return true;
            }

            @Override
            public HttpClientConnection get(
                    final long timeout,ConnectionPoolTimeoutException {
                connLatch.countDown(); // notify waiter that we're getting a connection

                // zero usually means sleep forever,but CountDownLatch doesn't interpret it that way.
                if(!awaitLatch.await(timeout > 0 ? timeout : Integer.MAX_VALUE,tunit)) {
                    throw new ConnectionPoolTimeoutException();
                }

                return Mockito.mock(HttpClientConnection.class);
            }
        };
    } else {
        return super.requestConnection(route,state);
    }
}
项目:purecloud-iot    文件:TestAbortHandling.java   
@Override
public ConnectionRequest requestConnection(
        final HttpRoute route,final Object state) {

    final Thread currentThread = Thread.currentThread();

    return new ConnectionRequest() {

        @Override
        public boolean cancel() {
            currentThread.interrupt();
            return true;
        }

        @Override
        public HttpClientConnection get(
                final long timeout,ConnectionPoolTimeoutException {
            connLatch.countDown(); // notify waiter that we're getting a connection

            // zero usually means sleep forever,but CountDownLatch doesn't interpret it that way.
            if(!awaitLatch.await(timeout > 0 ? timeout : Integer.MAX_VALUE,tunit)) {
                throw new ConnectionPoolTimeoutException();
            }

            return Mockito.mock(HttpClientConnection.class);
        }

    };
}
项目:purecloud-iot    文件:TestPoolingHttpClientConnectionManager.java   
@Test(expected=ConnectionPoolTimeoutException.class)
public void testLeaseFutureTimeout() throws Exception {
    final HttpHost target = new HttpHost("localhost",80);
    final HttpRoute route = new HttpRoute(target);

    Mockito.when(future.isCancelled()).thenReturn(Boolean.TRUE);
    Mockito.when(future.get(1,TimeUnit.SECONDS)).thenThrow(new TimeoutException());
    Mockito.when(pool.lease(route,null)).thenReturn(future);

    final ConnectionRequest connRequest1 = mgr.requestConnection(route,null);
    connRequest1.get(1,TimeUnit.SECONDS);
}
项目:cJUnit-mc626    文件:ConnPoolByRoute.java   
@Override
public PoolEntryRequest requestPoolEntry(
        final HttpRoute route,aborter);
        }

    };
}
项目:cJUnit-mc626    文件:ThreadSafeClientConnManager.java   
public ClientConnectionRequest requestConnection(
        final HttpRoute route,final Object state) {

    final PoolEntryRequest poolRequest = connectionPool.requestPoolEntry(
            route,entry);
        }

    };

}
项目:eduinfinity-translateHelper    文件:StartActivity.java   
@Override
protected void onResume() {
    super.onResume();
    List<Model> projectList = center.getProjectList();
    projectList.clear();
    center.setContext(this.getApplicationContext());
    JsonUtils.parseProjectList("/",Config.ProjectConfig,projectList);
    if (projectList.size() > 0) {
        Project project = (Project) projectList.get(0);
        center.setCurrentProject(project);
        Log.i("START","" + projectList.size());
    }

    AsyncHttpClient.allowRetryExceptionClass(IOException.class);
    AsyncHttpClient.allowRetryExceptionClass(SocketTimeoutException.class);
    AsyncHttpClient.allowRetryExceptionClass(ConnectTimeoutException.class);

    // The following exceptions will be blacklisted,the request will not be retried and it will
    // fail immediately.
    AsyncHttpClient.blockRetryExceptionClass(UnkNownHostException.class);
    AsyncHttpClient.blockRetryExceptionClass(ConnectionPoolTimeoutException.class);

    new Handler().postDelayed(r,2000);// 2秒后关闭,并跳转到主页面

    center.setIsFirstLoad(firstLoad());
}
项目:ribbon    文件:NamedConnectionPool.java   
@Override
protected BasicPoolEntry getEntryBlocking(HttpRoute route,Object state,long timeout,TimeUnit tunit,WaitingThreadAborter aborter)
        throws ConnectionPoolTimeoutException,InterruptedException {
    Stopwatch stopWatch = requestTimer.start();
    try {
        return super.getEntryBlocking(route,aborter);
    } finally {
        stopWatch.stop();
    }
}
项目:ibm-cos-sdk-java    文件:ClientConnectionRequestFactoryTest.java   
@Override
public HttpClientConnection get(long timeout,ConnectionPoolTimeoutException {
    return null;
}
项目:navi    文件:NaviHttpRequestRetryHandler.java   
@Override
public boolean retryRequest(IOException exception,int executionCount,HttpContext context) {
    if (exception == null) {
        throw new IllegalArgumentException(
            "Exception parameter may not be null");
    }
    if (context == null) {
        throw new IllegalArgumentException("HTTP context may not be null");
    }
    if (executionCount > getRetryCount()) {
        // Do not retry if over max retry count
        return false;
    }
    if (exception instanceof ConnectTimeoutException) {
        //连接超时,重试
        return true;
    }

    if (exception instanceof InterruptedioException) {
        //连接池等待超时
        if (exception instanceof ConnectionPoolTimeoutException) {
            return true;
        }
        // Timeout
        return false;
    }
    if (exception instanceof UnkNownHostException) {
        // UnkNown host
        return false;
    }
    if (exception instanceof ConnectException) {
        // Connection refused
        return false;
    }
    if (exception instanceof SSLException) {
        // SSL handshake exception
        return false;
    }

    HttpRequest request = (HttpRequest) context
        .getAttribute(ExecutionContext.HTTP_Request);

    if (requestIsAborted(request)) {
        return false;
    }

    //NoHttpResponseException
    if (handleAsIdempotent(request)) {
        // Retry if the request is considered idempotent
        return true;
    }

    Boolean b = (Boolean) context.getAttribute(ExecutionContext.HTTP_REQ_SENT);
    boolean sent = (b != null && b);

    if (!sent || isRequestSentRetryEnabled()) {
        // Retry if the request has not been sent fully or
        // if it's OK to retry methods that have been sent
        return true;
    }

    // otherwise do not retry
    return false;
}
项目:cloud-meter    文件:MeasuringConnectionManager.java   
@Override
public ManagedClientConnection getConnection(long timeout,ConnectionPoolTimeoutException {
    ManagedClientConnection res = handler.getConnection(timeout,tunit);
    return new MeasuredConnection(res);
}
项目:purecloud-iot    文件:TestConnectionManagement.java   
private static HttpClientConnection getConnection(
        final HttpClientConnectionManager mgr,final HttpRoute route) throws ConnectionPoolTimeoutException,null);
    return connRequest.get(0,TimeUnit.MILLISECONDS);
}
项目:purecloud-iot    文件:TestConnectionManagement.java   
/**
 * Tests releasing connection from #abort method called from the
 * main execution thread while there is no blocking I/O operation.
 */
@Test
public void testReleaseConnectionOnAbort() throws Exception {

    this.connManager.setMaxTotal(1);

    final HttpHost target = start();
    final HttpRoute route = new HttpRoute(target,false);
    final int      rsplen = 8;
    final String      uri = "/random/" + rsplen;
    final HttpContext context = new BasicHttpContext();

    final HttpRequest request =
        new BasicHttpRequest("GET",uri,HttpVersion.HTTP_1_1);

    HttpClientConnection conn = getConnection(this.connManager,route);
    this.connManager.connect(conn,route,context);
    this.connManager.routeComplete(conn,context);

    context.setAttribute(HttpCoreContext.HTTP_CONNECTION,conn);
    context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST,target);

    final HttpProcessor httpProcessor = new ImmutableHttpProcessor(
            new HttpRequestInterceptor[] { new RequestContent(),new RequestConnControl() });

    final HttpRequestExecutor exec = new HttpRequestExecutor();
    exec.preProcess(request,httpProcessor,context);
    final HttpResponse response = exec.execute(request,conn,context);

    Assert.assertEquals("wrong status in first response",HttpStatus.SC_OK,response.getStatusLine().getStatusCode());

    // check that there are no connections available
    try {
        // this should fail quickly,connection has not been released
        getConnection(this.connManager,100L,TimeUnit.MILLISECONDS);
        Assert.fail("ConnectionPoolTimeoutException should have been thrown");
    } catch (final ConnectionPoolTimeoutException e) {
        // expected
    }

    // abort the connection
    Assert.assertTrue(conn instanceof HttpClientConnection);
    conn.shutdown();
    this.connManager.releaseConnection(conn,null);

    // the connection is expected to be released back to the manager
    conn = getConnection(this.connManager,5L,TimeUnit.SECONDS);
    Assert.assertFalse("connection should have been closed",conn.isopen());

    this.connManager.releaseConnection(conn,null);
    this.connManager.shutdown();
}
项目:purecloud-iot    文件:TestDefaultBackoffStrategy.java   
@Test
public void doesNotBackOffForConnectionManagerTimeout() {
    assertFalse(impl.shouldBackoff(new ConnectionPoolTimeoutException()));
}
项目:nexus-public    文件:BlockingHttpClient.java   
private boolean isRemoteUnavailable(final Exception e) {
  if (e instanceof ConnectionPoolTimeoutException) {
    return false;
  }
  return true;
}

org.apache.http.conn.ConnectionReleaseTrigger的实例源码

org.apache.http.conn.ConnectionReleaseTrigger的实例源码

项目:purecloud-iot    文件:AbstractExecutionAwareRequest.java   
@Override
@Deprecated
public void setReleaseTrigger(final ConnectionReleaseTrigger releaseTrigger) {
    setCancellable(new Cancellable() {

        @Override
        public boolean cancel() {
            try {
                releaseTrigger.abortConnection();
                return true;
            } catch (final IOException ex) {
                return false;
            }
        }

    });
}
项目:lams    文件:HttpRequestBase.java   
public void setReleaseTrigger(final ConnectionReleaseTrigger releaseTrigger)
        throws IOException {
    if (this.aborted) {
        throw new IOException("Request already aborted");
    }
    this.abortLock.lock();
    try {
        this.releaseTrigger = releaseTrigger;
    } finally {
        this.abortLock.unlock();
    }
}
项目:remote-files-sync    文件:AbstractExecutionAwareRequest.java   
@Deprecated
public void setReleaseTrigger(final ConnectionReleaseTrigger releaseTrigger) {
    setCancellable(new Cancellable() {

        public boolean cancel() {
            try {
                releaseTrigger.abortConnection();
                return true;
            } catch (final IOException ex) {
                return false;
            }
        }

    });
}
项目:FMTech    文件:jsi.java   
public static void a(InputStream paramInputStream)
{
  if ((paramInputStream instanceof ConnectionReleaseTrigger)) {}
  try
  {
    ((ConnectionReleaseTrigger)paramInputStream).abortConnection();
    return;
  }
  catch (Throwable localThrowable) {}
}
项目:riptide    文件:RestAsyncclientHttpResponse.java   
@Override
public InputStream getBody() throws IOException {
    final InputStream body = response.getBody();
    return new FilterInputStream(body) {
        @Override
        public void close() throws IOException {
            if (body instanceof ConnectionReleaseTrigger) {
                // effectively releasing the connection back to the pool in order to prevent starvation
                ConnectionReleaseTrigger.class.cast(body).abortConnection();
            }
            super.close();
        }
    };
}
项目:Visit    文件:AbstractExecutionAwareRequest.java   
@Deprecated
public void setReleaseTrigger(final ConnectionReleaseTrigger releaseTrigger) {
    setCancellable(new Cancellable() {

        public boolean cancel() {
            try {
                releaseTrigger.abortConnection();
                return true;
            } catch (final IOException ex) {
                return false;
            }
        }

    });
}
项目:cJUnit-mc626    文件:HttpRequestBase.java   
public void setReleaseTrigger(final ConnectionReleaseTrigger releaseTrigger)
        throws IOException {
    this.abortLock.lock();
    try {
        if (this.aborted) {
            throw new IOException("Request already aborted");
        }

        this.connRequest = null;
        this.releaseTrigger = releaseTrigger;
    } finally {
        this.abortLock.unlock();
    }
}
项目:cJUnit-mc626    文件:HttpRequestBase.java   
public void abort() {
    ClientConnectionRequest localRequest;
    ConnectionReleaseTrigger localTrigger;

    this.abortLock.lock();
    try {
        if (this.aborted) {
            return;
        }            
        this.aborted = true;

        localRequest = connRequest;
        localTrigger = releaseTrigger;
    } finally {
        this.abortLock.unlock();
    }        

    // Trigger the callbacks outside of the lock,to prevent
    // deadlocks in the scenario where the callbacks have
    // their own locks that may be used while calling
    // setReleaseTrigger or setConnectionRequest.
    if (localRequest != null) {
        localRequest.abortRequest();
    }
    if (localTrigger != null) {
        try {
            localTrigger.abortConnection();
        } catch (IOException ex) {
            // ignore
        }
    }
}
项目:ZTLib    文件:AbstractExecutionAwareRequest.java   
@Deprecated
public void setReleaseTrigger(final ConnectionReleaseTrigger releaseTrigger) {
    setCancellable(new Cancellable() {

        public boolean cancel() {
            try {
                releaseTrigger.abortConnection();
                return true;
            } catch (final IOException ex) {
                return false;
            }
        }

    });
}
项目:lams    文件:AbortableHttpRequest.java   
/**
 * Sets the {@link ConnectionReleaseTrigger} callback that can
 * be used to abort an active connection.
 * Typically,this will be the {@link ManagedClientConnection} itself.
 * If the request is already aborted,throws an {@link IOException}.
 */
void setReleaseTrigger(ConnectionReleaseTrigger releaseTrigger) throws IOException;
项目:purecloud-iot    文件:AbortableHttpRequest.java   
/**
 * Sets the {@link ConnectionReleaseTrigger} callback that can
 * be used to abort an active connection.
 * Typically,this will be the
 *   {@link org.apache.http.conn.ManagedClientConnection} itself.
 * If the request is already aborted,throws an {@link IOException}.
 */
void setReleaseTrigger(ConnectionReleaseTrigger releaseTrigger) throws IOException;
项目:cJUnit-mc626    文件:AbortableHttpRequest.java   
/**
 * Sets the {@link ConnectionReleaseTrigger} callback that can
 * be used to abort an active connection.
 * Typically,throws an {@link IOException}.
 */
void setReleaseTrigger(ConnectionReleaseTrigger releaseTrigger) throws IOException;

关于org.apache.http.impl.conn.ProxySelectorRoutePlanner的实例源码httpd源码的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于org.apache.commons.httpclient.SimpleHttpConnectionManager的实例源码、org.apache.http.conn.ClientConnectionOperator的实例源码、org.apache.http.conn.ConnectionPoolTimeoutException的实例源码、org.apache.http.conn.ConnectionReleaseTrigger的实例源码等相关内容,可以在本站寻找。

本文标签: