Search in sources :

Example 1 with ConnectingIOReactor

use of org.apache.http.nio.reactor.ConnectingIOReactor 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();
}
Also used : IOReactorConfig(org.apache.http.impl.nio.reactor.IOReactorConfig) ConnectingIOReactor(org.apache.http.nio.reactor.ConnectingIOReactor) DefaultConnectingIOReactor(org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor) DefaultConnectingIOReactor(org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor) PoolingNHttpClientConnectionManager(org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager) URL(java.net.URL)

Aggregations

URL (java.net.URL)1 PoolingNHttpClientConnectionManager (org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager)1 DefaultConnectingIOReactor (org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor)1 IOReactorConfig (org.apache.http.impl.nio.reactor.IOReactorConfig)1 ConnectingIOReactor (org.apache.http.nio.reactor.ConnectingIOReactor)1