Search in sources :

Example 1 with InstrumentedHttpRequestExecutor

use of org.apache.solr.util.stats.InstrumentedHttpRequestExecutor in project lucene-solr by apache.

the class HttpShardHandlerFactory method init.

@Override
public void init(PluginInfo info) {
    StringBuilder sb = new StringBuilder();
    NamedList args = info.initArgs;
    this.soTimeout = getParameter(args, HttpClientUtil.PROP_SO_TIMEOUT, soTimeout, sb);
    this.scheme = getParameter(args, INIT_URL_SCHEME, null, sb);
    if (StringUtils.endsWith(this.scheme, "://")) {
        this.scheme = StringUtils.removeEnd(this.scheme, "://");
    }
    String strategy = getParameter(args, "metricNameStrategy", UpdateShardHandlerConfig.DEFAULT_METRICNAMESTRATEGY, sb);
    this.metricNameStrategy = KNOWN_METRIC_NAME_STRATEGIES.get(strategy);
    if (this.metricNameStrategy == null) {
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown metricNameStrategy: " + strategy + " found. Must be one of: " + KNOWN_METRIC_NAME_STRATEGIES.keySet());
    }
    this.connectionTimeout = getParameter(args, HttpClientUtil.PROP_CONNECTION_TIMEOUT, connectionTimeout, sb);
    this.maxConnectionsPerHost = getParameter(args, HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, maxConnectionsPerHost, sb);
    this.maxConnections = getParameter(args, HttpClientUtil.PROP_MAX_CONNECTIONS, maxConnections, sb);
    this.corePoolSize = getParameter(args, INIT_CORE_POOL_SIZE, corePoolSize, sb);
    this.maximumPoolSize = getParameter(args, INIT_MAX_POOL_SIZE, maximumPoolSize, sb);
    this.keepAliveTime = getParameter(args, MAX_THREAD_IDLE_TIME, keepAliveTime, sb);
    this.queueSize = getParameter(args, INIT_SIZE_OF_QUEUE, queueSize, sb);
    this.permittedLoadBalancerRequestsMinimumAbsolute = getParameter(args, LOAD_BALANCER_REQUESTS_MIN_ABSOLUTE, permittedLoadBalancerRequestsMinimumAbsolute, sb);
    this.permittedLoadBalancerRequestsMaximumFraction = getParameter(args, LOAD_BALANCER_REQUESTS_MAX_FRACTION, permittedLoadBalancerRequestsMaximumFraction, sb);
    this.accessPolicy = getParameter(args, INIT_FAIRNESS_POLICY, accessPolicy, sb);
    log.debug("created with {}", sb);
    // magic sysprop to make tests reproducible: set by SolrTestCaseJ4.
    String v = System.getProperty("tests.shardhandler.randomSeed");
    if (v != null) {
        r.setSeed(Long.parseLong(v));
    }
    BlockingQueue<Runnable> blockingQueue = (this.queueSize == -1) ? new SynchronousQueue<Runnable>(this.accessPolicy) : new ArrayBlockingQueue<Runnable>(this.queueSize, this.accessPolicy);
    this.commExecutor = new ExecutorUtil.MDCAwareThreadPoolExecutor(this.corePoolSize, this.maximumPoolSize, this.keepAliveTime, TimeUnit.SECONDS, blockingQueue, new DefaultSolrThreadFactory("httpShardExecutor"));
    ModifiableSolrParams clientParams = getClientParams();
    httpRequestExecutor = new InstrumentedHttpRequestExecutor(this.metricNameStrategy);
    clientConnectionManager = new InstrumentedPoolingHttpClientConnectionManager(HttpClientUtil.getSchemaRegisteryProvider().getSchemaRegistry());
    this.defaultClient = HttpClientUtil.createClient(clientParams, clientConnectionManager, false, httpRequestExecutor);
    this.loadbalancer = createLoadbalancer(defaultClient);
}
Also used : NamedList(org.apache.solr.common.util.NamedList) DefaultSolrThreadFactory(org.apache.solr.util.DefaultSolrThreadFactory) ExecutorUtil(org.apache.solr.common.util.ExecutorUtil) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) InstrumentedHttpRequestExecutor(org.apache.solr.util.stats.InstrumentedHttpRequestExecutor) InstrumentedPoolingHttpClientConnectionManager(org.apache.solr.util.stats.InstrumentedPoolingHttpClientConnectionManager) SolrException(org.apache.solr.common.SolrException)

Aggregations

SolrException (org.apache.solr.common.SolrException)1 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)1 ExecutorUtil (org.apache.solr.common.util.ExecutorUtil)1 NamedList (org.apache.solr.common.util.NamedList)1 DefaultSolrThreadFactory (org.apache.solr.util.DefaultSolrThreadFactory)1 InstrumentedHttpRequestExecutor (org.apache.solr.util.stats.InstrumentedHttpRequestExecutor)1 InstrumentedPoolingHttpClientConnectionManager (org.apache.solr.util.stats.InstrumentedPoolingHttpClientConnectionManager)1