@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; } }
FakeHelixManager(String clusterName, String instanceName, InstanceType instanceType, String zkAddress) { super(clusterName, instanceName, instanceType, zkAddress); super._zkclient = new ZkClient(StringUtil.join("/", StringUtils.chomp(ZkStarter.DEFAULT_ZK_STR, "/")), ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer()); _zkclient.deleteRecursive("/" + clusterName + "/PROPERTYSTORE"); _zkclient.createPersistent("/" + clusterName + "/PROPERTYSTORE", true); setPropertyStore(clusterName); }
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); } startControllerStarter(config); _helixManager = _helixResourceManager.getHelixZkManager(); _helixAdmin = _helixResourceManager.getHelixAdmin(); _propertyStore = _helixResourceManager.getPropertyStore(); }
@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); }
/** * sync remove */ @Override public boolean remove(String path, int options) { try { // optimize on common path return _zkClient.delete(path); } catch (ZkException e) { LOG.warn(String.format("Caught exception when deleting %s with options %s.", path, options), e); return _zkClient.deleteRecursive(path); } }