use of org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor in project jmeter by apache.
the class HttpMetricsSender method setup.
/**
* The HTTP API is the primary means of writing data into InfluxDB, by
* sending POST requests to the /write endpoint. Initiate the HttpClient
* client with a HttpPost request from influxdb url
*
* @param influxdbUrl
* example : http://localhost:8086/write?db=myd&rp=one_week
* @see org.apache.jmeter.visualizers.backend.influxdb.InfluxdbMetricsSender#setup(java.lang.String)
*/
@Override
public void setup(String influxdbUrl) throws Exception {
// Create I/O reactor configuration
IOReactorConfig ioReactorConfig = IOReactorConfig.custom().setIoThreadCount(1).setConnectTimeout(JMeterUtils.getPropDefault("backend_influxdb.connection_timeout", 1000)).setSoTimeout(JMeterUtils.getPropDefault("backend_influxdb.socket_timeout", 3000)).build();
// Create a custom I/O reactor
ConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(ioReactorConfig);
// Create a connection manager with custom configuration.
PoolingNHttpClientConnectionManager connManager = new PoolingNHttpClientConnectionManager(ioReactor);
httpClient = HttpAsyncClientBuilder.create().setConnectionManager(connManager).setMaxConnPerRoute(2).setMaxConnTotal(2).setUserAgent("ApacheJMeter" + JMeterUtils.getJMeterVersion()).disableCookieManagement().disableConnectionState().build();
url = new URL(influxdbUrl);
httpRequest = createRequest(url);
httpClient.start();
}
use of org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor in project cxf by apache.
the class AsyncHTTPConduitFactory method setupNIOClient.
public synchronized void setupNIOClient(HTTPClientPolicy clientPolicy) throws IOReactorException {
if (client != null) {
return;
}
IOReactorConfig config = IOReactorConfig.custom().setIoThreadCount(ioThreadCount).setSelectInterval(selectInterval).setInterestOpQueued(interestOpQueued).setSoLinger(soLinger).setSoTimeout(soTimeout).setSoKeepAlive(soKeepalive).setTcpNoDelay(tcpNoDelay).build();
Registry<SchemeIOSessionStrategy> ioSessionFactoryRegistry = RegistryBuilder.<SchemeIOSessionStrategy>create().register("http", NoopIOSessionStrategy.INSTANCE).register("https", SSLIOSessionStrategy.getSystemDefaultStrategy()).build();
ManagedNHttpClientConnectionFactory connectionFactory = new ManagedNHttpClientConnectionFactory() {
@Override
public ManagedNHttpClientConnection create(final IOSession iosession, final ConnectionConfig config) {
ManagedNHttpClientConnection conn = super.create(iosession, config);
return conn;
}
};
DefaultConnectingIOReactor ioreactor = new DefaultConnectingIOReactor(config);
connectionManager = new PoolingNHttpClientConnectionManager(ioreactor, connectionFactory, ioSessionFactoryRegistry, DefaultSchemePortResolver.INSTANCE, SystemDefaultDnsResolver.INSTANCE, connectionTTL, TimeUnit.MILLISECONDS);
connectionManager.setDefaultMaxPerRoute(maxPerRoute);
connectionManager.setMaxTotal(maxConnections);
ConnectionConfig connectionConfig = ConnectionConfig.custom().setBufferSize(clientPolicy.getChunkLength() > 0 ? clientPolicy.getChunkLength() : 16332).build();
connectionManager.setDefaultConnectionConfig(connectionConfig);
RedirectStrategy redirectStrategy = new RedirectStrategy() {
public boolean isRedirected(HttpRequest request, HttpResponse response, HttpContext context) throws ProtocolException {
return false;
}
public HttpUriRequest getRedirect(HttpRequest request, HttpResponse response, HttpContext context) throws ProtocolException {
return null;
}
};
HttpAsyncClientBuilder httpAsyncClientBuilder = HttpAsyncClients.custom().setConnectionManager(connectionManager).setRedirectStrategy(redirectStrategy).setDefaultCookieStore(new BasicCookieStore() {
private static final long serialVersionUID = 1L;
public void addCookie(Cookie cookie) {
}
});
adaptClientBuilder(httpAsyncClientBuilder);
client = httpAsyncClientBuilder.build();
// Start the client thread
client.start();
if (this.connectionTTL == 0) {
// if the connection does not have an expiry deadline
// use the ConnectionMaxIdle to close the idle connection
new CloseIdleConnectionThread(connectionManager, client).start();
}
}
Aggregations