当前位置: 首页>>代码示例>>Java>>正文


Java ZkClient.deleteRecursive方法代码示例

本文整理汇总了Java中org.apache.helix.manager.zk.ZkClient.deleteRecursive方法的典型用法代码示例。如果您正苦于以下问题:Java ZkClient.deleteRecursive方法的具体用法?Java ZkClient.deleteRecursive怎么用?Java ZkClient.deleteRecursive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.helix.manager.zk.ZkClient的用法示例。


在下文中一共展示了ZkClient.deleteRecursive方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: delete

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
@Override
public Representation delete() {
  String zkPath = getZKPath();
  try {
    ZkClient zkClient =
        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
    zkClient.deleteRecursive(zkPath);

    getResponse().setStatus(Status.SUCCESS_OK);
  } catch (Exception e) {
    getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
        MediaType.APPLICATION_JSON);
    getResponse().setStatus(Status.SUCCESS_OK);
    LOG.error("Error in delete zkPath: " + zkPath, e);
  }
  return null;
}
 
开发者ID:apache,项目名称:helix,代码行数:18,代码来源:ZkPathResource.java

示例2: delete

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
@Override
public Representation delete() {
  String zkPath = getZKPath();
  try {
    ZkClient zkClient =
        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);

    List<String> childNames = zkClient.getChildren(zkPath);
    if (childNames != null) {
      for (String childName : childNames) {
        String childPath = zkPath.equals("/") ? "/" + childName : zkPath + "/" + childName;
        zkClient.deleteRecursive(childPath);
      }
    }

    getResponse().setStatus(Status.SUCCESS_OK);
  } catch (Exception e) {
    getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
        MediaType.APPLICATION_JSON);
    getResponse().setStatus(Status.SUCCESS_OK);
    LOG.error("Error in delete zkChild: " + zkPath, e);
  }
  return null;
}
 
开发者ID:apache,项目名称:helix,代码行数:25,代码来源:ZkChildResource.java

示例3: startController

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
protected void startController(ControllerConf config) {
  Assert.assertNotNull(config);
  Assert.assertNull(_controllerStarter);

  _controllerPort = Integer.valueOf(config.getControllerPort());
  _controllerBaseApiUrl = "http://localhost:" + _controllerPort;
  _controllerRequestURLBuilder = ControllerRequestURLBuilder.baseUrl(_controllerBaseApiUrl);
  _controllerDataDir = config.getDataDir();

  String helixClusterName = getHelixClusterName();
  config.setHelixClusterName(helixClusterName);

  String zkStr = config.getZkStr();
  _zkClient = new ZkClient(zkStr);
  if (_zkClient.exists("/" + helixClusterName)) {
    _zkClient.deleteRecursive("/" + helixClusterName);
  }

  _controllerStarter = new ControllerStarter(config);
  _controllerStarter.start();

  _helixResourceManager = _controllerStarter.getHelixResourceManager();
  _helixManager = _helixResourceManager.getHelixZkManager();
  _helixAdmin = _helixResourceManager.getHelixAdmin();
  _propertyStore = _helixResourceManager.getPropertyStore();
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:27,代码来源:ControllerTest.java

示例4: execute

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
@Override
public boolean execute() throws Exception {
  LOGGER.info("Connecting to Zookeeper at address: {}", _zkAddress);
  ZkClient zkClient = new ZkClient(_zkAddress, 5000);
  String helixClusterName = "/" + _clusterName;

  LOGGER.info("Executing command: " + toString());
  if (!zkClient.exists(helixClusterName)) {
    LOGGER.error("Cluster {} does not exist.", _clusterName);
    return false;
  }

  zkClient.deleteRecursive(helixClusterName);
  return true;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:16,代码来源:DeleteClusterCommand.java

示例5: beforeTest

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
@BeforeTest
public void beforeTest() {
  ZkStarter.startLocalZkServer();

  _zkClient =
      new ZkClient(StringUtil.join("/", StringUtils.chomp(ZkStarter.DEFAULT_ZK_STR, "/")),
          ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
  String helixClusterName = "TestTimeBoundaryService";
  _zkClient.deleteRecursive("/" + helixClusterName + "/PROPERTYSTORE");
  _zkClient.createPersistent("/" + helixClusterName + "/PROPERTYSTORE", true);
  _propertyStore =
      new ZkHelixPropertyStore<ZNRecord>(new ZkBaseDataAccessor<ZNRecord>(_zkClient), "/" + helixClusterName
          + "/PROPERTYSTORE", null);

}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:16,代码来源:TimeBoundaryServiceTest.java

示例6: beforeClass

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
@BeforeClass()
public void beforeClass() {
  System.out.println("START " + getShortClassName() + " at "
      + new Date(System.currentTimeMillis()));

  _zkClient = new ZkClient(ZK_ADDR);
  _zkClient.setZkSerializer(new ZNRecordSerializer());
  if (_zkClient.exists(PREFIX)) {
    _zkClient.deleteRecursive(PREFIX);
  }

}
 
开发者ID:apache,项目名称:helix,代码行数:13,代码来源:TestZnodeModify.java

示例7: setupCluster

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
public static void setupCluster(String clusterName, String ZkAddr, int startPort,
    String participantNamePrefix, String resourceNamePrefix, int resourceNb, int partitionNb,
    int nodesNb, int replica, String stateModelDef, RebalanceMode mode, boolean doRebalance)
    throws Exception {
  ZkClient zkClient = new ZkClient(ZkAddr);
  if (zkClient.exists("/" + clusterName)) {
    LOG.warn("Cluster already exists:" + clusterName + ". Deleting it");
    zkClient.deleteRecursive("/" + clusterName);
  }

  ClusterSetup setupTool = new ClusterSetup(ZkAddr);
  setupTool.addCluster(clusterName, true);

  for (int i = 0; i < nodesNb; i++) {
    int port = startPort + i;
    setupTool.addInstanceToCluster(clusterName, participantNamePrefix + "_" + port);
  }

  for (int i = 0; i < resourceNb; i++) {
    String resourceName = resourceNamePrefix + i;
    setupTool.addResourceToCluster(clusterName, resourceName, partitionNb, stateModelDef,
        mode.toString());
    if (doRebalance) {
      setupTool.rebalanceStorageCluster(clusterName, resourceName, replica);
    }
  }
  zkClient.close();
}
 
开发者ID:apache,项目名称:helix,代码行数:29,代码来源:TestHelper.java

示例8: dropCluster

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
public static void dropCluster(String clusterName, ZkClient zkClient) throws Exception {
  if (!zkClient.exists("/" + clusterName)) {
    LOG.warn("Cluster does not exist:" + clusterName + ". Deleting it");
    zkClient.deleteRecursive("/" + clusterName);
  }

  ClusterSetup setupTool = new ClusterSetup(zkClient);
  setupTool.deleteCluster(clusterName);
}
 
开发者ID:apache,项目名称:helix,代码行数:10,代码来源:TestHelper.java

示例9: beforeClass

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
@BeforeClass()
public void beforeClass() throws Exception {
  _zkClient = new ZkClient(ZK_ADDR);
  _zkClient.setZkSerializer(new ZNRecordSerializer());
  if (_zkClient.exists("/" + clusterName)) {
    _zkClient.deleteRecursive("/" + clusterName);
  }

  ClusterSetup.processCommandLineArgs(createArgs("-zkSvr " + ZK_ADDR + " -addCluster "
      + clusterName));
  // ClusterSetup
  // .processCommandLineArgs(createArgs("-zkSvr " + ZK_ADDR +
  // " -addCluster relay-cluster-12345"));
  ClusterSetup.processCommandLineArgs(createArgs("-zkSvr " + ZK_ADDR + " -addResource "
      + clusterName + " db-12345 120 MasterSlave"));
  ClusterSetup.processCommandLineArgs(createArgs("-zkSvr " + ZK_ADDR + " -addNode " + clusterName
      + " localhost:8900"));
  ClusterSetup.processCommandLineArgs(createArgs("-zkSvr " + ZK_ADDR + " -addNode " + clusterName
      + " localhost:8901"));
  ClusterSetup.processCommandLineArgs(createArgs("-zkSvr " + ZK_ADDR + " -addNode " + clusterName
      + " localhost:8902"));
  ClusterSetup.processCommandLineArgs(createArgs("-zkSvr " + ZK_ADDR + " -addNode " + clusterName
      + " localhost:8903"));
  ClusterSetup.processCommandLineArgs(createArgs("-zkSvr " + ZK_ADDR + " -addNode " + clusterName
      + " localhost:8904"));
  ClusterSetup.processCommandLineArgs(createArgs("-zkSvr " + ZK_ADDR + " -rebalance "
      + clusterName + " db-12345 3"));
}
 
开发者ID:apache,项目名称:helix,代码行数:29,代码来源:TestZKCallback.java

示例10: testHierarchicalDataStore

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
@Test(groups = {
  "unitTest"
})
public void testHierarchicalDataStore() {
  _zkClientString = new ZkClient(ZK_ADDR, 1000, 3000);

  String path = "/tmp/testHierarchicalDataStore";
  FileFilter filter = null;
  // _zkClient.setZkSerializer(new ZNRecordSerializer());

  _zkClientString.deleteRecursive(path);
  HierarchicalDataHolder<ZNRecord> dataHolder =
      new HierarchicalDataHolder<ZNRecord>(_zkClientString, path, filter);
  dataHolder.print();
  AssertJUnit.assertFalse(dataHolder.refreshData());

  // write data
  add(path, "root data");
  AssertJUnit.assertTrue(dataHolder.refreshData());
  dataHolder.print();

  // add some children
  add(path + "/child1", "child 1 data");
  add(path + "/child2", "child 2 data");
  AssertJUnit.assertTrue(dataHolder.refreshData());
  dataHolder.print();

  // add some grandchildren
  add(path + "/child1" + "/grandchild1", "grand child 1 data");
  add(path + "/child1" + "/grandchild2", "grand child 2 data");
  AssertJUnit.assertTrue(dataHolder.refreshData());
  dataHolder.print();

  AssertJUnit.assertFalse(dataHolder.refreshData());

  set(path + "/child1", "new child 1 data");
  AssertJUnit.assertTrue(dataHolder.refreshData());
  dataHolder.print();
}
 
开发者ID:apache,项目名称:helix,代码行数:40,代码来源:TestHierarchicalDataStore.java

示例11: post

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
@Override
public Representation post(Representation entity) {
  String zkPath = getZKPath();

  try {
    JsonParameters jsonParameters = new JsonParameters(entity);
    String command = jsonParameters.getCommand();

    ZkClient zkClient =
        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);

    if (command.equalsIgnoreCase(JsonParameters.ZK_DELETE_CHILDREN)) {
      List<String> childNames = zkClient.getChildren(zkPath);
      if (childNames != null) {
        for (String childName : childNames) {
          String childPath = zkPath.equals("/") ? "/" + childName : zkPath + "/" + childName;
          zkClient.deleteRecursive(childPath);
        }
      }
    } else {
      throw new HelixException("Unsupported command: " + command + ". Should be one of ["
          + JsonParameters.ZK_DELETE_CHILDREN + "]");
    }

    getResponse().setStatus(Status.SUCCESS_OK);
  } catch (Exception e) {
    getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
        MediaType.APPLICATION_JSON);
    getResponse().setStatus(Status.SUCCESS_OK);
    LOG.error("Error in post zkPath: " + zkPath, e);
  }
  return null;
}
 
开发者ID:apache,项目名称:helix,代码行数:34,代码来源:ZkPathResource.java

示例12: beforeTest

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
@BeforeTest
public void beforeTest() {
  _zookeeperInstance = ZkStarter.startLocalZkServer();

  _zkClient = new ZkClient(StringUtil.join("/", StringUtils.chomp(ZkStarter.DEFAULT_ZK_STR, "/")),
      ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
  String helixClusterName = "TestTimeBoundaryService";
  _zkClient.deleteRecursive("/" + helixClusterName + "/PROPERTYSTORE");
  _zkClient.createPersistent("/" + helixClusterName + "/PROPERTYSTORE", true);
  _propertyStore = new ZkHelixPropertyStore<>(new ZkBaseDataAccessor<ZNRecord>(_zkClient),
      "/" + helixClusterName + "/PROPERTYSTORE", null);
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:13,代码来源:TimeBoundaryServiceTest.java

示例13: setupCluster

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
public static void setupCluster(String uniqClusterName, String zkAddr, int numResources,
    int numPartitionsPerResource, int numInstances, int replica, boolean doRebalance)
    throws Exception {
  ZkClient zkClient = new ZkClient(zkAddr);
  zkClient.setZkSerializer(new ZNRecordSerializer());

  // String clusterName = CLUSTER_PREFIX + "_" + uniqClusterName;
  String clusterName = uniqClusterName;
  if (zkClient.exists("/" + clusterName)) {
    LOG.warn("test cluster already exists:" + clusterName + ", test name:" + uniqClusterName
        + " is not unique or test has been run without cleaning up zk; deleting it");
    zkClient.deleteRecursive("/" + clusterName);
  }

  if (_testInfoMap.containsKey(uniqClusterName)) {
    LOG.warn("test info already exists:" + uniqClusterName
        + " is not unique or test has been run without cleaning up test info map; removing it");
    _testInfoMap.remove(uniqClusterName);
  }
  TestInfo testInfo =
      new TestInfo(clusterName, zkClient, numResources, numPartitionsPerResource, numInstances,
          replica);
  _testInfoMap.put(uniqClusterName, testInfo);

  ClusterSetup setupTool = new ClusterSetup(zkAddr);
  setupTool.addCluster(clusterName, true);

  for (int i = 0; i < numInstances; i++) {
    int port = START_PORT + i;
    setupTool.addInstanceToCluster(clusterName, PARTICIPANT_PREFIX + "_" + port);
  }

  for (int i = 0; i < numResources; i++) {
    String dbName = TEST_DB_PREFIX + i;
    setupTool.addResourceToCluster(clusterName, dbName, numPartitionsPerResource, STATE_MODEL);
    if (doRebalance) {
      setupTool.rebalanceStorageCluster(clusterName, dbName, replica);

      // String idealStatePath = "/" + clusterName + "/" +
      // PropertyType.IDEALSTATES.toString() + "/"
      // + dbName;
      // ZNRecord idealState = zkClient.<ZNRecord> readData(idealStatePath);
      // testInfo._idealStateMap.put(dbName, idealState);
    }
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:47,代码来源:TestDriver.java


注:本文中的org.apache.helix.manager.zk.ZkClient.deleteRecursive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。