@After
 public void tearDown() {
   client.close();
   for (VoldemortServer vs : this.vservers.values()) {
     vs.stop();
   }
   for (SocketStoreFactory ssf : this.socketStoreFactories.values()) {
     ssf.close();
   }
   ClusterTestUtils.reset();
 }
예제 #2
0
  @Override
  protected void stopInner() {
    /*
     * We may end up closing a given store more than once, but that is cool
     * because close() is idempotent
     */

    Exception lastException = null;
    logger.info("Closing all stores.");
    /* This will also close the node stores including local stores */
    for (Store<ByteArray, byte[], byte[]> store : this.storeRepository.getAllRoutedStores()) {
      logger.info("Closing routed store for " + store.getName());
      try {
        store.close();
      } catch (Exception e) {
        logger.error(e);
        lastException = e;
      }
    }
    /* This will also close the storage engines */
    for (Store<ByteArray, byte[], byte[]> store : this.storeRepository.getAllStorageEngines()) {
      logger.info("Closing storage engine for " + store.getName());
      try {
        store.close();
      } catch (Exception e) {
        logger.error(e);
        lastException = e;
      }
    }
    logger.info("All stores closed.");

    /* Close slop store if necessary */
    if (this.storeRepository.hasSlopStore()) {
      try {
        this.storeRepository.getSlopStore().close();
      } catch (Exception e) {
        logger.error(e);
        lastException = e;
      }
    }

    /* Close all storage configs */
    logger.info("Closing storage configurations.");
    for (StorageConfiguration config : storageConfigs.values()) {
      logger.info("Closing " + config.getType() + " storage config.");
      try {
        config.close();
      } catch (Exception e) {
        logger.error(e);
        lastException = e;
      }
    }

    this.clientThreadPool.shutdown();

    try {
      if (!this.clientThreadPool.awaitTermination(10, TimeUnit.SECONDS))
        this.clientThreadPool.shutdownNow();
    } catch (InterruptedException e) {
      // okay, fine, playing nice didn't work
      this.clientThreadPool.shutdownNow();
    }

    logger.info("Closed client threadpool.");

    storeFactory.close();

    if (this.failureDetector != null) {
      try {
        this.failureDetector.destroy();
      } catch (Exception e) {
        lastException = e;
      }
    }
    logger.info("Closed failure detector.");

    // shut down the proxy put thread pool
    this.proxyPutWorkerPool.shutdown();
    try {
      if (!this.proxyPutWorkerPool.awaitTermination(10, TimeUnit.SECONDS))
        this.proxyPutWorkerPool.shutdownNow();
    } catch (InterruptedException e) {
      this.proxyPutWorkerPool.shutdownNow();
    }
    logger.info("Closed proxy put thread pool.");

    /* If there is an exception, throw it */
    if (lastException instanceof VoldemortException) throw (VoldemortException) lastException;
    else if (lastException != null) throw new VoldemortException(lastException);
  }