本文整理汇总了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();
}
示例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;
}
示例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();
}
示例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());
}
示例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());
}
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
示例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;
}
示例12: getPoolStats
import org.apache.http.pool.PoolStats; //导入依赖的package包/类
public PoolStats getPoolStats(){
return connectionManager.getTotalStats();
}
示例13: getTotalStats
import org.apache.http.pool.PoolStats; //导入依赖的package包/类
public PoolStats getTotalStats() {
return this.pool.getTotalStats();
}
示例14: getStats
import org.apache.http.pool.PoolStats; //导入依赖的package包/类
public PoolStats getStats(final HttpRoute route) {
return this.pool.getStats(route);
}
示例15: getTotalStats
import org.apache.http.pool.PoolStats; //导入依赖的package包/类
@Override
public PoolStats getTotalStats() {
return this.pool.getTotalStats();
}