Java Code Examples for org.I0Itec.zkclient.ZkClient#deleteRecursive()

The following examples show how to use org.I0Itec.zkclient.ZkClient#deleteRecursive() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RestTestBase.java    From uReplicator with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public void setup() {
  LOGGER.info("Trying to setup");
  ZkStarter.startLocalZkServer();
  kafkaStarter =
      KafkaStarterUtils.startServer(KafkaStarterUtils.DEFAULT_KAFKA_PORT,
          KafkaStarterUtils.DEFAULT_BROKER_ID,
          KafkaStarterUtils.DEFAULT_ZK_STR, KafkaStarterUtils.getDefaultKafkaConfiguration());

  kafkaBrokerTopicObserver =
      new KafkaBrokerTopicObserver("broker0", KafkaStarterUtils.DEFAULT_ZK_STR, 1);
  kafkaBrokerTopicObserver.start();

  ZK_CLIENT = new ZkClient(ZkStarter.DEFAULT_ZK_STR);
  ZK_CLIENT.deleteRecursive("/" + HELIX_CLUSTER_NAME);
  REQUEST_URL = "http://localhost:" + CONTROLLER_PORT;
  CONTROLLER_STARTER = startController(DEPLOYMENT_NAME, HELIX_CLUSTER_NAME, CONTROLLER_PORT);
  try {
    FAKE_INSTANCES.addAll(ControllerTestUtils
        .addFakeDataInstancesToAutoJoinHelixCluster(HELIX_CLUSTER_NAME, ZkStarter.DEFAULT_ZK_STR,
            2, 0));
  } catch (Exception e) {
    throw new RuntimeException("Error during adding fake instances");
  }
}
 
Example 2
Source File: LocalCacheUtil.java    From stategen with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 删除notifyName 对应的监听,基本没用到.
 *
 * @param notifyName the resource name
 * @return true, if successful
 */
public static boolean deleteResourceNode(String notifyName) {
    ZkClient zClient = getZkClient();
    //删除单独一个节点,返回true表示成功  
    //        boolean e1 = zkClient.delete("/testUserNode");  
    //删除含有子节点的节点  
    String resourcePath = getResourcePath(notifyName);
    return zClient.deleteRecursive(resourcePath);
}
 
Example 3
Source File: PistachiosFormatter.java    From Pistachio with Apache License 2.0 5 votes vote down vote up
private static void cleanup(ZKHelixAdmin admin, ZkClient zkClient, String[] hostList, int numPartitions, int numReplicas, String kafkaTopicPrefix, String kafkaZKPath) {
  try {
      // TODO, delete not supported until 0.8.1, we'll enable it later
      for (int i =0; i<numPartitions; i++) {
          //zkClient = new ZkClient(zkConnect, 30000, 30000, ZKStringSerializer);
          zkClient.deleteRecursive(ZkUtils.getTopicPath(kafkaTopicPrefix + i));
      }
      zkClient.close();
      //ZKHelixAdmin admin = new ZKHelixAdmin(args[1]);
      admin.dropCluster("PistachiosCluster");
    } catch(Exception e) {
        logger.info("error:", e);
    }
      logger.info("cleanup finished succeessfully");
}
 
Example 4
Source File: ZkUtil.java    From java-study with Apache License 2.0 2 votes vote down vote up
/**
 * 删除节点
 * 注:如果是该节点包含子节点,也会一并删除
 * @param zk
 * @param path
 * @return
 */
public static boolean delete(ZkClient zk,String path){
	return zk.deleteRecursive(path);
}