Example usage for org.apache.solr.client.solrj.impl HttpSolrClient setSoTimeout

List of usage examples for org.apache.solr.client.solrj.impl HttpSolrClient setSoTimeout

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj.impl HttpSolrClient setSoTimeout.

Prototype

@Deprecated
public void setSoTimeout(int timeout) 

Source Link

Document

Set SoTimeout (read timeout).

Usage

From source file:com.ilscipio.scipio.solr.util.ScipioHttpSolrClient.java

License:Apache License

/**
 * Creates a new client from URL and username/password, where all operations will use
 * the given auth.//from  w  w  w  .ja v  a2  s  . co m
 * <p>
 * DEV NOTE: Implementation must be maintained with the superclass; the default values
 * are taken from {@link HttpSolrClient.Builder} and are subject to change at solrj updates.
 */
public static HttpSolrClient create(String baseURL, HttpClient httpClient, String solrUsername,
        String solrPassword, Integer maxConnections, Integer maxConnectionsPerHost, Integer connectTimeout,
        Integer socketTimeout) {

    if (httpClient == null) {
        ModifiableSolrParams params = new ModifiableSolrParams();
        if (maxConnections != null) {
            params.set(HttpClientUtil.PROP_MAX_CONNECTIONS, maxConnections);
        }
        if (maxConnectionsPerHost != null) {
            params.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, maxConnectionsPerHost);
        }
        params.set(HttpClientUtil.PROP_FOLLOW_REDIRECTS, true);
        httpClient = HttpClientUtil.createClient(params);
    }

    // DEV NOTE: the defaults must match what HttpSolrClient.Builder does! Must keep up to date!
    HttpSolrClient client = new ScipioHttpSolrClient(baseURL, httpClient, new BinaryResponseParser(), false,
            new ModifiableSolrParams(), solrUsername, solrPassword);

    // TODO: In Solr 7, these are deprecated and moved to Builder/constructor 
    if (connectTimeout != null) {
        client.setConnectionTimeout(connectTimeout);
    }
    if (socketTimeout != null) {
        client.setSoTimeout(socketTimeout);
    }

    return client;
}

From source file:org.dbflute.solr.bhv.AbstractSolrBehavior.java

License:Apache License

/**
 * Create HttpSolrClient associated with the assigned URL.
 * @param url URL (NotNull)/*ww w .j a  va2s  .co  m*/
 * @return HttpSolrClient (NotNull)
 */
protected HttpSolrClient createHttpSolrClient(String url) {
    HttpSolrClient client = new HttpSolrClient(url);
    client.setConnectionTimeout(getConnectionTimeout());
    client.setSoTimeout(getSocketTimeout());
    client.setDefaultMaxConnectionsPerHost(getDefaultMaxConnectionsPerHost());
    client.setMaxTotalConnections(getMaxTotalConnections());
    client.setFollowRedirects(false);
    return client;
}

From source file:org.seedstack.solr.internal.SolrPlugin.java

License:Mozilla Public License

private SolrClient buildHttpSolrClient(Configuration solrClientConfiguration, String url) {
    HttpSolrClient httpSolrClient = new HttpSolrClient(url);

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.CONNECTION_TIMEOUT)) {
        httpSolrClient.setConnectionTimeout(
                solrClientConfiguration.getInt(SolrConfigurationConstants.CONNECTION_TIMEOUT));
    }//from www. j  a  va 2s  .  co m

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.QUERY_PARAMS)) {
        httpSolrClient.setQueryParams(Sets
                .newHashSet(solrClientConfiguration.getStringArray(SolrConfigurationConstants.QUERY_PARAMS)));
    }

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.SO_TIMEOUT)) {
        httpSolrClient.setSoTimeout(solrClientConfiguration.getInt(SolrConfigurationConstants.SO_TIMEOUT));
    }

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.ALLOW_COMPRESSION)) {
        httpSolrClient.setAllowCompression(
                solrClientConfiguration.getBoolean(SolrConfigurationConstants.ALLOW_COMPRESSION));
    }

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.MAX_CONNECTIONS_PER_HOST)) {
        httpSolrClient.setDefaultMaxConnectionsPerHost(
                solrClientConfiguration.getInt(SolrConfigurationConstants.MAX_CONNECTIONS_PER_HOST));
    }

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.FOLLOW_REDIRECTS)) {
        httpSolrClient.setFollowRedirects(
                solrClientConfiguration.getBoolean(SolrConfigurationConstants.FOLLOW_REDIRECTS));
    }

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.MAX_TOTAL_CONNECTIONS)) {
        httpSolrClient.setMaxTotalConnections(
                solrClientConfiguration.getInt(SolrConfigurationConstants.MAX_TOTAL_CONNECTIONS));
    }

    if (solrClientConfiguration.containsKey(SolrConfigurationConstants.USE_MULTI_PART_HOST)) {
        httpSolrClient.setUseMultiPartPost(
                solrClientConfiguration.getBoolean(SolrConfigurationConstants.USE_MULTI_PART_HOST));
    }

    return httpSolrClient;
}