Beispiel #1
0
  private SolrServer createUpdateServer(Map<String, Object> properties)
      throws MalformedURLException {
    String url = Utils.toString(properties.get(PROP_SOLR_URL), "http://localhost:8983/solr");

    CommonsHttpSolrServer remoteServer = new CommonsHttpSolrServer(url);
    remoteServer.setSoTimeout(Utils.toInt(properties.get(PROP_SO_TIMEOUT), 1000)); // socket
    // read
    // timeout
    remoteServer.setConnectionTimeout(Utils.toInt(properties.get(PROP_CONNECTION_TIMEOUT), 100));
    remoteServer.setDefaultMaxConnectionsPerHost(
        Utils.toInt(properties.get(PROP_MAX_CONNECTONS_PER_HOST), 100));
    remoteServer.setMaxTotalConnections(
        Utils.toInt(properties.get(PROP_MAX_TOTAL_CONNECTONS), 100));
    remoteServer.setFollowRedirects(
        Utils.toBoolean(properties.get(PROP_FOLLOW), false)); // defaults
    // to
    // false
    // allowCompression defaults to false.
    // Server side must support gzip or deflate for this to have any effect.
    remoteServer.setAllowCompression(Utils.toBoolean(properties.get(PROP_ALLOW_COMPRESSION), true));
    remoteServer.setMaxRetries(Utils.toInt(properties.get(PROP_MAX_RETRIES), 1)); // defaults
    // to 0.
    // > 1
    // not
    // recommended.
    remoteServer.setParser(new BinaryResponseParser()); // binary parser is
    // used by
    // default

    return remoteServer;
  }
 private SolrServer createServer(String name) {
   try {
     // setup the server...
     String url = "http://localhost:" + port + context + "/" + name;
     CommonsHttpSolrServer s = new CommonsHttpSolrServer(url);
     s.setConnectionTimeout(100); // 1/10th sec
     s.setDefaultMaxConnectionsPerHost(100);
     s.setMaxTotalConnections(100);
     return s;
   } catch (Exception ex) {
     throw new RuntimeException(ex);
   }
 }