当前位置: 首页>>代码示例>>Java>>正文


Java PoolStats类代码示例

本文整理汇总了Java中org.apache.http.pool.PoolStats的典型用法代码示例。如果您正苦于以下问题:Java PoolStats类的具体用法?Java PoolStats怎么用?Java PoolStats使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PoolStats类属于org.apache.http.pool包,在下文中一共展示了PoolStats类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: formatStats

import org.apache.http.pool.PoolStats; //导入依赖的package包/类
private String formatStats(final HttpRoute route) {
    final StringBuilder buf = new StringBuilder();
    final PoolStats totals = this.pool.getTotalStats();
    final PoolStats stats = this.pool.getStats(route);
    buf.append("[total kept alive: ").append(totals.getAvailable()).append("; ");
    buf.append("route allocated: ").append(stats.getLeased() + stats.getAvailable());
    buf.append(" of ").append(stats.getMax()).append("; ");
    buf.append("total allocated: ").append(totals.getLeased() + totals.getAvailable());
    buf.append(" of ").append(totals.getMax()).append("]");
    return buf.toString();
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:12,代码来源:JMeterPoolingClientConnectionManager.java

示例2: getStatistics

import org.apache.http.pool.PoolStats; //导入依赖的package包/类
@Override
public Map<String, String> getStatistics() {
    int i = 0;
    final Map<String, String> data = new LinkedHashMap<String, String>();
    data.put(KEYS[i++], String.valueOf(requestsExecuted.get()));
    data.put(KEYS[i++], humanReadableBytes(bytesSent.get(), false));
    data.put(KEYS[i++], humanReadableBytes(bytesReceived.get(), false));
    data.put(KEYS[i++], humanReadableBytes(bytesFromCache.get(), false));

    final PoolStats cmStats = connectionManager.getTotalStats();
    data.put(KEYS[i++], connectionManager.getClass().getSimpleName());
    data.put(KEYS[i++], String.valueOf(cmStats.getMax()));
    data.put(KEYS[i++], String.valueOf(cmStats.getAvailable()));
    data.put(KEYS[i++], String.valueOf(cmStats.getLeased()));
    data.put(KEYS[i++], String.valueOf(cmStats.getPending()));
    return data;
}
 
开发者ID:apache,项目名称:marmotta,代码行数:18,代码来源:HttpClientServiceImpl.java

示例3: formatStats

import org.apache.http.pool.PoolStats; //导入依赖的package包/类
private String formatStats(final HttpRoute route) {
    StringBuilder buf = new StringBuilder();
    PoolStats totals = this.pool.getTotalStats();
    PoolStats stats = this.pool.getStats(route);
    buf.append("[total kept alive: ").append(totals.getAvailable()).append("; ");
    buf.append("route allocated: ").append(stats.getLeased() + stats.getAvailable());
    buf.append(" of ").append(stats.getMax()).append("; ");
    buf.append("total allocated: ").append(totals.getLeased() + totals.getAvailable());
    buf.append(" of ").append(totals.getMax()).append("]");
    return buf.toString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:PoolingClientConnectionManager.java

示例4: run

import org.apache.http.pool.PoolStats; //导入依赖的package包/类
public void run() {
    PoolStats stats = pool.getTotalStats();

    Metrics.INSTANCE.count("restclient.httpc.pool.available", stats.getAvailable(), "rest_pool:" + poolName, "type:" + getType());
    Metrics.INSTANCE.count("restclient.httpc.pool.leased", stats.getLeased(), "rest_pool:" + poolName, "type:" + getType());
    Metrics.INSTANCE.count("restclient.httpc.pool.pending", stats.getPending(), "rest_pool:" + poolName, "type:" + getType());
}
 
开发者ID:mercadolibre,项目名称:java-restclient,代码行数:8,代码来源:HTTPCClientMonitor.java

示例5: captureConnectionPoolMetrics

import org.apache.http.pool.PoolStats; //导入依赖的package包/类
/**
 * Captures the connection pool metrics.
 */
private void captureConnectionPoolMetrics() {
    if (awsRequestMetrics.isEnabled() &&
        httpClient.getHttpClientConnectionManager() instanceof
                ConnPoolControl<?>) {
        final PoolStats stats = ((ConnPoolControl<?>) httpClient
                .getHttpClientConnectionManager()).getTotalStats();

        awsRequestMetrics
                .withCounter(HttpClientPoolAvailableCount, stats.getAvailable())
                .withCounter(HttpClientPoolLeasedCount, stats.getLeased())
                .withCounter(HttpClientPoolPendingCount, stats.getPending());
    }

}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:18,代码来源:AmazonHttpClient.java

示例6: testReleaseOnEntityConsumeContent

import org.apache.http.pool.PoolStats; //导入依赖的package包/类
@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);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:36,代码来源:TestConnectionAutoRelease.java

示例7: testReleaseOnEntityWriteTo

import org.apache.http.pool.PoolStats; //导入依赖的package包/类
@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, 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);
    final ByteArrayOutputStream outsteam = new ByteArrayOutputStream();
    e.writeTo(outsteam);

    // 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);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:37,代码来源:TestConnectionAutoRelease.java

示例8: testReleaseOnAbort

import org.apache.http.pool.PoolStats; //导入依赖的package包/类
@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, 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);
    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);
    final HttpClientConnection conn = connreq.get(250, TimeUnit.MILLISECONDS);

    this.connManager.releaseConnection(conn, null, -1, null);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:36,代码来源:TestConnectionAutoRelease.java

示例9: getPoolStats

import org.apache.http.pool.PoolStats; //导入依赖的package包/类
@Override
public HttpClientPoolStats getPoolStats() {
    PoolStats totalStats = connPoolControl.getTotalStats();
    return new HttpClientPoolStats(totalStats.getLeased(),
        totalStats.getPending(),
        totalStats.getAvailable(),
        totalStats.getMax());
}
 
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:9,代码来源:ApacheHttpClient441BackedHttpClient.java

示例10: release

import org.apache.http.pool.PoolStats; //导入依赖的package包/类
public void release(final BasicNIOPoolEntry entry, boolean reusable) {
    System.out.println("[proxy->origin] connection released " + entry.getConnection());
    ConsoleFactory.printToConsole("[proxy->origin] connection released " + entry.getConnection(),true);
    super.release(entry, reusable);
    StringBuilder buf = new StringBuilder();
    PoolStats totals = getTotalStats();
    buf.append("[total kept alive: ").append(totals.getAvailable()).append("; ");
    buf.append("total allocated: ").append(totals.getLeased() + totals.getAvailable());
    buf.append(" of ").append(totals.getMax()).append("]");
    System.out.println("[proxy->origin] " + buf.toString());
    ConsoleFactory.printToConsole("[proxy->origin] " + buf.toString(),true);
}
 
开发者ID:HuaweiSNC,项目名称:OpsDev,代码行数:13,代码来源:NHttpReverseProxy.java

示例11: getConnectionPoolStats

import org.apache.http.pool.PoolStats; //导入依赖的package包/类
public static Map<String, Integer> getConnectionPoolStats() {
    Map<String, Integer> stats = new HashMap<>();
    PoolStats poolStats = pool.getTotalStats();
    stats.put("availableConnections", poolStats.getAvailable());
    stats.put("maxConnections", poolStats.getMax());
    stats.put("leasedConnections", poolStats.getLeased());
    stats.put("pendingConnections", poolStats.getPending());
    stats.put("defaultMaxPerRoute", pool.getDefaultMaxPerRoute());
    return stats;
}
 
开发者ID:srikalyc,项目名称:Sql4D,代码行数:11,代码来源:DruidNodeAccessor.java

示例12: getPoolStats

import org.apache.http.pool.PoolStats; //导入依赖的package包/类
public PoolStats getPoolStats(){
	return connectionManager.getTotalStats();
}
 
开发者ID:hotpads,项目名称:datarouter,代码行数:4,代码来源:DatarouterHttpClient.java

示例13: getTotalStats

import org.apache.http.pool.PoolStats; //导入依赖的package包/类
public PoolStats getTotalStats() {
    return this.pool.getTotalStats();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:PoolingClientConnectionManager.java

示例14: getStats

import org.apache.http.pool.PoolStats; //导入依赖的package包/类
public PoolStats getStats(final HttpRoute route) {
    return this.pool.getStats(route);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:PoolingClientConnectionManager.java

示例15: getTotalStats

import org.apache.http.pool.PoolStats; //导入依赖的package包/类
@Override
public PoolStats getTotalStats() {
    return this.pool.getTotalStats();
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:5,代码来源:JMeterPoolingClientConnectionManager.java


注:本文中的org.apache.http.pool.PoolStats类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。