コード例 #1
0
 /**
  * Connect to the zookeeper ensemble. This is an optional method that may be used to force a
  * connect before any other requests are sent.
  */
 public void connect() {
   if (zkStateReader == null) {
     synchronized (this) {
       if (zkStateReader == null) {
         ZkStateReader zk = null;
         try {
           zk = new ZkStateReader(zkHost, zkClientTimeout, zkConnectTimeout);
           zk.createClusterStateWatchersAndUpdate();
           zkStateReader = zk;
         } catch (InterruptedException e) {
           if (zk != null) zk.close();
           Thread.currentThread().interrupt();
           throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e);
         } catch (KeeperException e) {
           if (zk != null) zk.close();
           throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e);
         } catch (IOException e) {
           if (zk != null) zk.close();
           throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e);
         } catch (TimeoutException e) {
           if (zk != null) zk.close();
           throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e);
         } catch (Exception e) {
           if (zk != null) zk.close();
           // do not wrap because clients may be relying on the underlying exception being thrown
           throw e;
         }
       }
     }
   }
 }
コード例 #2
0
  private void closeZK() throws Exception {
    if (zkClient != null) {
      zkClient.close();
    }

    if (reader != null) {
      reader.close();
    }
    zkServer.shutdown();
  }
コード例 #3
0
  @Override
  public void shutdown() {
    if (zkStateReader != null) {
      synchronized (this) {
        if (zkStateReader != null) zkStateReader.close();
        zkStateReader = null;
      }
    }

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

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

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