Example #1
0
  @Test
  public void testZkClientWhenZKIsDownAndRestarts() throws Exception {

    // Iterate updating the timestamp and check the final value
    long previousMaxTimestamp = INITIAL_MAX_TS_VALUE;
    for (int i = 0; i < ITERATION_COUNT; i++) {
      long newMaxTimestamp = previousMaxTimestamp + 1_000_000;
      storage.updateMaxTimestamp(previousMaxTimestamp, newMaxTimestamp);
      previousMaxTimestamp = newMaxTimestamp;
    }
    assertEquals(storage.getMaxTimestamp(), 1_000_000 * ITERATION_COUNT);

    // Stop ZK Server, expect the IO exception, reconnect and get the right value
    LOG.info("Stopping ZK Server");
    zkServer.stop();
    LOG.info("ZK Server Stopped");

    try {
      storage.getMaxTimestamp();
      fail();
    } catch (IOException ioe) {
      LOG.info("Expected exception", ioe);
    }

    LOG.info("Restarting ZK again");
    zkServer.restart();
    assertEquals(storage.getMaxTimestamp(), 1_000_000 * ITERATION_COUNT);
  }
  public void stopTFS() throws Exception {
    mClientPool.close();

    mWorker.stop();
    for (int k = 0; k < mNumOfMasters; k++) {
      mMasters.get(k).stop();
    }
    mCuratorServer.stop();
  }
Example #3
0
 public void stop() throws IOException {
   if (zkClient != null) {
     zkClient.close();
   }
   if (kafkaServer != null) {
     kafkaServer.shutdown();
   }
   if (zkServer != null) {
     zkServer.stop();
   }
 }
  public void stopTFS() throws Exception {
    mClientPool.close();

    mWorker.stop();
    if (LineageUtils.isLineageEnabled(WorkerContext.getConf())) {
      mLineageWorker.stop();
    }
    for (int k = 0; k < mNumOfMasters; k++) {
      mMasters.get(k).stop();
    }
    mCuratorServer.stop();
  }
  @Override
  public void shutdown() {
    if (brokers != null) {
      for (KafkaServer broker : brokers) {
        if (broker != null) {
          broker.shutdown();
        }
      }
      brokers.clear();
    }

    if (zookeeper != null) {
      try {
        zookeeper.stop();
        zookeeper.close();
      } catch (Exception e) {
        LOG.warn("ZK.stop() failed", e);
      }
      zookeeper = null;
    }

    // clean up the temp spaces

    if (tmpKafkaParent != null && tmpKafkaParent.exists()) {
      try {
        FileUtils.deleteDirectory(tmpKafkaParent);
      } catch (Exception e) {
        // ignore
      }
    }
    if (tmpZkDir != null && tmpZkDir.exists()) {
      try {
        FileUtils.deleteDirectory(tmpZkDir);
      } catch (Exception e) {
        // ignore
      }
    }
  }
Example #6
0
 public void stop() throws IOException {
   if (zkClient != null) zkClient.close();
   if (kafkaServer != null) kafkaServer.shutdown();
   if (zkServer != null) zkServer.stop();
   LOGGER.debug("Zookeeper / Kafka services stopped!");
 }