lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 穆 俊峰 <Kent...@live.cn>
Subject questions for the method "shutdown" of CloudSolrServer
Date Fri, 01 Jul 2016 11:43:59 GMT
hi all,


I create a CloudSolrServer Connection by singleton pattern like this


public synchronized static CloudSolrServer getSolrCloudReadServer() {
        if (reviewSolrCloudServer == null) {
        ModifiableSolrParams params = new ModifiableSolrParams();
        params.set(HttpClientUtil.PROP_MAX_CONNECTIONS, 10000);
        params.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, 500);
        HttpClient client = HttpClientUtil.createClient(params);
        LBHttpSolrServer lbServer = new LBHttpSolrServer(client);
        lbServer.setConnectionTimeout(ReviewProperties.getCloudConnectionTimeOut());
        lbServer.setSoTimeout(ReviewProperties.getCloudSoTimeOut());

        reviewSolrCloudServer = new CloudSolrServer(ReviewProperties.getZkHost(),lbServer);
        reviewSolrCloudServer.setDefaultCollection("commodityReview");
        reviewSolrCloudServer.setZkClientTimeout(ReviewProperties.getZkClientTimeout());
        reviewSolrCloudServer.setZkConnectTimeout(ReviewProperties.getZkConnectTimeout());
        reviewSolrCloudServer.connect();
        }
        return reviewSolrCloudServer;
    }



and I see the solrj API, the method to create an instance, and the method of shutdown

  public CloudSolrServer(String zkHost, LBHttpSolrServer lbServer) {
    this.zkHost = zkHost;
    this.lbServer = lbServer;
    this.updatesToLeaders = true;
    shutdownLBHttpSolrServer = false;
  }

  public void shutdown() {
    if (zkStateReader != null) {
      synchronized(this) {
        if (zkStateReader!= null)
          zkStateReader.close();
        zkStateReader = null;
      }
    }

    if (shutdownLBHttpSolrServer) {
      lbServer.shutdown();
    }

    if (myClient!=null) {
      myClient.getConnectionManager().shutdown();
    }

    if(this.threadPool != null && !this.threadPool.isShutdown()) {
      this.threadPool.shutdown();
    }
  }




this kind of method by create an instance with a LBHttpSolrServer does not need to release
LBHttpSolrServer  and HttpClient??

look forward to your reply!

Best Regards!
Kent Mu
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message