本文整理汇总了Java中org.apache.helix.manager.zk.ZkClient.exists方法的典型用法代码示例。如果您正苦于以下问题:Java ZkClient.exists方法的具体用法?Java ZkClient.exists怎么用?Java ZkClient.exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.helix.manager.zk.ZkClient
的用法示例。
在下文中一共展示了ZkClient.exists方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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;
}
示例3: 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);
}
}
示例4: 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();
}
示例5: 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);
}
示例6: 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"));
}
示例7: getInstancePropertyNameListAsString
import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
public static String getInstancePropertyNameListAsString(ZkClient zkClient, String clusterName,
String instanceName, PropertyType instanceProperty, String key, MediaType mediaType)
throws JsonGenerationException, JsonMappingException, IOException {
String path = PropertyPathBuilder.instanceProperty(clusterName, instanceName, instanceProperty, key);
if (zkClient.exists(path)) {
List<String> recordNames = zkClient.getChildren(path);
return ObjectToJson(recordNames);
}
return ObjectToJson(new ArrayList<String>());
}
示例8: 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);
}
}
}