Java Code Examples for org.apache.solr.client.solrj.impl.HttpSolrClient#setSoTimeout()

The following examples show how to use org.apache.solr.client.solrj.impl.HttpSolrClient#setSoTimeout() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SolrTarget06.java    From datacollector with Apache License 2.0 6 votes vote down vote up
private SolrClient getSolrClient() throws MalformedURLException {
  if(kerberosAuth) {
    // set kerberos before create SolrClient
    addSecurityProperties();
  }

  if (SolrInstanceAPIType.SINGLE_NODE.toString().equals(this.instanceType)) {
    HttpSolrClient solrClient = new HttpSolrClient.Builder(this.solrURI).build();
    solrClient.setConnectionTimeout(this.connectionTimeout);
    solrClient.setSoTimeout(this.socketTimeout);
    return solrClient;
  } else {
    CloudSolrClient cloudSolrClient = new CloudSolrClient.Builder().withZkHost(this.zookeeperConnect).build();
    cloudSolrClient.setDefaultCollection(this.defaultCollection);
    return cloudSolrClient;
  }
}
 
Example 2
Source File: SolrITInitializer.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected static SolrClient createNewSolrClient(String url)
{
    try
    {
        HttpSolrClient client = new HttpSolrClient(url);
        client.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT1);
        client.setSoTimeout(CLIENT_SO_TIMEOUT);
        client.setDefaultMaxConnectionsPerHost(100);
        client.setMaxTotalConnections(100);
        return client;
    } catch (Exception ex)
    {
        throw new RuntimeException(ex);
    }
}
 
Example 3
Source File: ScipioHttpSolrClient.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new client from URL and username/password, where all operations will use
 * the given auth.
 * <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.
 */
@SuppressWarnings("deprecation")
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;
}
 
Example 4
Source File: SolrDao.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * DO NOT CALL! use Spring instead.
 * @param geocoder_conf geocoder's configuration object.
 */
public SolrDao(GeocoderConfiguration geocoder_conf)
{
    geocoder = new CachedGeocoder(new NominatimGeocoder(geocoder_conf));
    solrClient = new HttpSolrClient("");
    solrClient.setConnectionTimeout(INNER_TIMEOUT);
    solrClient.setSoTimeout(INNER_TIMEOUT);
}