NettyHttpServiceClient implements ServiceClient { @Override public ServiceClient setConnectionLimitPerTag(String tag, int limit) { this.channelPool.setConnectionLimitPerTag(tag, limit); if (this.sslChannelPool != null) { this.sslChannelPool.setConnectionLimitPerTag(tag, limit); } if (this.http2ChannelPool != null) { this.http2ChannelPool.setConnectionLimitPerTag(tag, limit); } if (this.http2SslChannelPool != null) { this.http2SslChannelPool.setConnectionLimitPerTag(tag, limit); } return this; }  static ServiceClient create(String userAgent,
            ExecutorService executor,
            ScheduledExecutorService scheduledExecutor); static ServiceClient create(String userAgent,
            ExecutorService executor,
            ScheduledExecutorService scheduledExecutor,
            ServiceHost host); @Override void start(); @Override void stop(); ServiceClient setHttpProxy(URI proxy); @Override void send(Operation op); @Override void sendRequest(Operation op); @Override void handleMaintenance(Operation op); @Override ServiceClient setPendingRequestQueueLimit(int limit); @Override int getPendingRequestQueueLimit(); @Override ServiceClient setConnectionLimitPerTag(String tag, int limit); @Override int getConnectionLimitPerTag(String tag); ServiceClient setHttp2SslContext(SslContext context); SslContext getHttp2SslContext(); @Override ServiceClient setSSLContext(SSLContext context); @Override SSLContext getSSLContext(); NettyChannelPool getChannelPool(); NettyChannelPool getHttp2ChannelPool(); NettyChannelPool getSslChannelPool(); NettyChannelContext getInUseHttp2SslContext(String tag, String host, int port); NettyChannelContext getInUseHttp2Context(String tag, String host, int port); @Override ConnectionPoolMetrics getConnectionPoolMetrics(boolean http2); @Override ConnectionPoolMetrics getConnectionPoolMetricsPerTag(String tag); int getInUseContextCount(String tag, String host, int port); void clearCookieJar(); @Override int getRequestPayloadSizeLimit(); @Override ServiceClient setRequestPayloadSizeLimit(int limit); static final int DEFAULT_CONNECTIONS_PER_HOST; static final Logger LOGGER; }
@Test public void throughputPutRemote() throws Throwable { List<Service> services = this.host.doThroughputServiceStart(this.serviceCount, MinimalTestService.class, this.host.buildMinimalTestState(), null, null); String tag = ServiceClient.CONNECTION_TAG_DEFAULT; if (!this.host.isStressTest()) { this.host.log("Single connection runs"); this.host.doPutPerService( this.requestCount, EnumSet.of(TestProperty.FORCE_REMOTE), services); validateTagInfo(this.host, tag); } else { this.host.setOperationTimeOutMicros( TimeUnit.SECONDS.toMicros(this.host.getTimeoutSeconds())); } int limit = NettyHttpServiceClient.DEFAULT_CONNECTIONS_PER_HOST; this.host.connectionTag = null; this.host.log("Using client global connection limit %d", limit); for (int i = 0; i < 5; i++) { double throughput = this.host.doPutPerService( this.requestCount, EnumSet.of(TestProperty.FORCE_REMOTE), services); this.testResults.getReport().all("HTTP1.1 JSON PUTS/sec", throughput); this.host.waitForGC(); throughput = this.host.doPutPerService( this.requestCount, EnumSet.of(TestProperty.FORCE_REMOTE, TestProperty.BINARY_SERIALIZATION), services); this.testResults.getReport().all("HTTP1.1 binary PUTS/sec", throughput); this.host.waitForGC(); } limit = 8; this.host.connectionTag = "http1.1test"; this.host.log("Using tag specific connection limit %d", limit); this.host.getClient().setConnectionLimitPerTag(this.host.connectionTag, limit); this.host.doPutPerService( this.requestCount, EnumSet.of(TestProperty.FORCE_REMOTE), services); tag = this.host.connectionTag; validateTagInfo(this.host, tag); }
@Test public void testConnectionLimitWithOperationTimeout() throws Throwable { List<Service> services = this.host.doThroughputServiceStart(this.serviceCount, MinimalTestService.class, this.host.buildMinimalTestState(), null, null); this.host.connectionTag = "connectionLimitWithOperationTimeoutTag"; this.host.getClient().setConnectionLimitPerTag(this.host.connectionTag, ServiceClient.DEFAULT_CONNECTION_LIMIT_PER_HOST); for (int i = 0; i < this.iterationCount; i++) { doConnectionLimitWithOperationTimeout(services); } }