Java Code Examples for org.apache.solr.client.solrj.impl.HttpSolrServer#setConnectionTimeout()

The following examples show how to use org.apache.solr.client.solrj.impl.HttpSolrServer#setConnectionTimeout() . 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: SolrTarget04.java    From datacollector with Apache License 2.0 6 votes vote down vote up
private SolrServer getSolrClient() throws MalformedURLException {
  if(kerberosAuth) {
    // set kerberos before create SolrClient
    addSecurityProperties();
  }

  if (SolrInstanceAPIType.SINGLE_NODE.toString().equals(this.instanceType)) {
    HttpSolrServer httpSolrServer = new HttpSolrServer(this.solrURI);
    httpSolrServer.setConnectionTimeout(connectionTimeout);
    httpSolrServer.setSoTimeout(socketTimeout);
    return httpSolrServer;
  } else {
    CloudSolrServer cloudSolrClient = new CloudSolrServer(this.zookeeperConnect);
    cloudSolrClient.setDefaultCollection(this.defaultCollection);
    return cloudSolrClient;
  }
}
 
Example 2
Source File: SolrJSupport.java    From brooklyn-library with Apache License 2.0 4 votes vote down vote up
public SolrJSupport(String hostname, int solrPort, String core) {
    server = new HttpSolrServer(String.format("http://%s:%d/solr/%s", hostname, solrPort, core));
    server.setMaxRetries(1);
    server.setConnectionTimeout(5000);
    server.setSoTimeout(5000);
}