requiredPaths.add(PropertyPathBuilder.resourceConfig(clusterName)); requiredPaths.add(PropertyPathBuilder.propertyStore(clusterName)); requiredPaths.add(PropertyPathBuilder.liveInstance(clusterName)); requiredPaths.add(PropertyPathBuilder.instance(clusterName)); requiredPaths.add(PropertyPathBuilder.externalView(clusterName));
requiredPaths.add(PropertyPathBuilder.resourceConfig(clusterName)); requiredPaths.add(PropertyPathBuilder.propertyStore(clusterName)); requiredPaths.add(PropertyPathBuilder.liveInstance(clusterName)); requiredPaths.add(PropertyPathBuilder.instance(clusterName)); requiredPaths.add(PropertyPathBuilder.externalView(clusterName));
String liPath = PropertyPathBuilder.liveInstance(clusterName); int listenerNb = ZkTestHelper.numberOfListeners(ZK_ADDR, liPath);
@Override public void dropInstance(String clusterName, InstanceConfig instanceConfig) { logger.info("Drop instance {} from cluster {}.", instanceConfig.getInstanceName(), clusterName); String instanceName = instanceConfig.getInstanceName(); String instanceConfigPath = PropertyPathBuilder.instanceConfig(clusterName, instanceName); if (!_zkClient.exists(instanceConfigPath)) { throw new HelixException( "Node " + instanceName + " does not exist in config for cluster " + clusterName); } String instancePath = PropertyPathBuilder.instance(clusterName, instanceName); if (!_zkClient.exists(instancePath)) { throw new HelixException( "Node " + instanceName + " does not exist in instances for cluster " + clusterName); } String liveInstancePath = PropertyPathBuilder.liveInstance(clusterName, instanceName); if (_zkClient.exists(liveInstancePath)) { throw new HelixException( "Node " + instanceName + " is still alive for cluster " + clusterName + ", can't drop."); } // delete config path String instanceConfigsPath = PropertyPathBuilder.instanceConfig(clusterName); ZKUtil.dropChildren(_zkClient, instanceConfigsPath, instanceConfig.getRecord()); // delete instance path _zkClient.deleteRecursively(instancePath); }
@Override public void dropInstance(String clusterName, InstanceConfig instanceConfig) { logger.info("Drop instance {} from cluster {}.", instanceConfig.getInstanceName(), clusterName); String instanceName = instanceConfig.getInstanceName(); String instanceConfigPath = PropertyPathBuilder.instanceConfig(clusterName, instanceName); if (!_zkClient.exists(instanceConfigPath)) { throw new HelixException( "Node " + instanceName + " does not exist in config for cluster " + clusterName); } String instancePath = PropertyPathBuilder.instance(clusterName, instanceName); if (!_zkClient.exists(instancePath)) { throw new HelixException( "Node " + instanceName + " does not exist in instances for cluster " + clusterName); } String liveInstancePath = PropertyPathBuilder.liveInstance(clusterName, instanceName); if (_zkClient.exists(liveInstancePath)) { throw new HelixException( "Node " + instanceName + " is still alive for cluster " + clusterName + ", can't drop."); } // delete config path String instanceConfigsPath = PropertyPathBuilder.instanceConfig(clusterName); ZKUtil.dropChildren(_zkClient, instanceConfigsPath, instanceConfig.getRecord()); // delete instance path _zkClient.deleteRecursively(instancePath); }
public void post(String zkServer, Message message, String clusterName, String instanceName) { ZkClient client = new ZkClient(zkServer); client.setZkSerializer(new ZNRecordSerializer()); String path = PropertyPathBuilder.instanceMessage(clusterName, instanceName, message.getId()); client.delete(path); ZNRecord record = client.readData(PropertyPathBuilder.liveInstance(clusterName, instanceName)); message.setTgtSessionId(record.getSimpleField(LiveInstanceProperty.SESSION_ID.toString())); message.setTgtName(record.getId()); // System.out.println(message); client.createPersistent(path, message.getRecord()); }
void sendMessage(String msgId, String instanceName, String fromState, String toState, String partitionKey, int partitionId) throws InterruptedException, JsonGenerationException, JsonMappingException, IOException { Message message = new Message(MessageType.STATE_TRANSITION, msgId); message.setMsgId(msgId); message.setSrcName(srcName); message.setTgtName(instanceName); message.setMsgState(MessageState.NEW); message.setFromState(fromState); message.setToState(toState); // message.setPartitionId(partitionId); message.setPartitionName(partitionKey); String path = PropertyPathBuilder.instanceMessage(clusterName, instanceName, message.getId()); ObjectMapper mapper = new ObjectMapper(); StringWriter sw = new StringWriter(); mapper.writeValueUsingView(sw, message, Message.class); System.out.println(sw.toString()); client.delete(path); Thread.sleep(10000); ZNRecord record = client.readData(PropertyPathBuilder.liveInstance(clusterName, instanceName)); message.setTgtSessionId(record.getSimpleField(LiveInstanceProperty.SESSION_ID.toString()) .toString()); client.createPersistent(path, message); }
public void post(String zkServer, Message message, String clusterName, String instanceName) { HelixZkClient client = SharedZkClientFactory.getInstance().buildZkClient(new HelixZkClient.ZkConnectionConfig( zkServer)); client.setZkSerializer(new ZNRecordSerializer()); String path = PropertyPathBuilder.instanceMessage(clusterName, instanceName, message.getId()); client.delete(path); ZNRecord record = client.readData(PropertyPathBuilder.liveInstance(clusterName, instanceName)); message.setTgtSessionId(record.getSimpleField(LiveInstanceProperty.SESSION_ID.toString())); message.setTgtName(record.getId()); // System.out.println(message); client.createPersistent(path, message.getRecord()); }
_zkClient.createPersistent(path); _zkClient.createPersistent(PropertyPathBuilder.liveInstance(clusterName));
_zkClient.createPersistent(path); _zkClient.createPersistent(PropertyPathBuilder.liveInstance(clusterName));
.create(PropertyPathBuilder.liveInstance(clusterName), new ZNRecord(clusterName), 0);