/** * Returns all instances for the given cluster. * * @param helixAdmin The HelixAdmin object used to interact with the Helix cluster * @param clusterName Name of the cluster for which to get all the instances for. * @return Returns a List of strings containing the instance names for the given cluster. */ public static List<String> getAllInstances(HelixAdmin helixAdmin, String clusterName) { return helixAdmin.getInstancesInCluster(clusterName); }
setupTool.getClusterManagementTool().getResourcesInCluster(clusterName); List<String> instances = setupTool.getClusterManagementTool().getInstancesInCluster(clusterName); } else { instances = setupTool.getClusterManagementTool().getInstancesInCluster(clusterName);
public Set<String> getAllBrokerTenantNames() { Set<String> tenantSet = new HashSet<>(); List<String> instancesInCluster = _helixAdmin.getInstancesInCluster(_helixClusterName); for (String instanceName : instancesInCluster) { InstanceConfig config = _helixDataAccessor.getProperty(_keyBuilder.instanceConfig(instanceName)); for (String tag : config.getTags()) { if (tag.equals(CommonConstants.Helix.UNTAGGED_BROKER_INSTANCE) || tag .equals(CommonConstants.Helix.UNTAGGED_SERVER_INSTANCE) || tag .equals(CommonConstants.Minion.UNTAGGED_INSTANCE)) { continue; } if (TagNameUtils.getTenantRoleFromTag(tag) == TenantRole.BROKER) { tenantSet.add(TagNameUtils.getTenantNameFromTag(tag)); } } } return tenantSet; }
setupTool.getClusterManagementTool().getResourcesInCluster(clusterName); List<String> instances = setupTool.getClusterManagementTool().getInstancesInCluster(clusterName); } else { instances = setupTool.getClusterManagementTool().getInstancesInCluster(clusterName);
public Set<String> getAllServerTenantNames() { Set<String> tenantSet = new HashSet<>(); List<String> instancesInCluster = _helixAdmin.getInstancesInCluster(_helixClusterName); for (String instanceName : instancesInCluster) { InstanceConfig config = _helixDataAccessor.getProperty(_keyBuilder.instanceConfig(instanceName)); for (String tag : config.getTags()) { if (tag.equals(CommonConstants.Helix.UNTAGGED_BROKER_INSTANCE) || tag .equals(CommonConstants.Helix.UNTAGGED_SERVER_INSTANCE) || tag .equals(CommonConstants.Minion.UNTAGGED_INSTANCE)) { continue; } if (TagNameUtils.getTenantRoleFromTag(tag) == TenantRole.SERVER) { tenantSet.add(TagNameUtils.getTenantNameFromTag(tag)); } } } return tenantSet; }
List<String> instances = _helixAdmin.getInstancesInCluster(_clusterName); Assert.assertFalse(instances.isEmpty(), "List of instances should not be empty");
public void balanceIdealState(String clusterName, IdealState idealState) { // The new instances are added into the cluster already. So we need to find out the // instances that // already have partitions assigned to them. List<String> instanceNames = _admin.getInstancesInCluster(clusterName); rebalanceResource(clusterName, idealState, instanceNames); }
public void balanceIdealState(String clusterName, IdealState idealState) { // The new instances are added into the cluster already. So we need to find out the // instances that // already have partitions assigned to them. List<String> instanceNames = _admin.getInstancesInCluster(clusterName); rebalanceResource(clusterName, idealState, instanceNames); }
StringRepresentation getSchedulerTasksRepresentation() throws JsonGenerationException, JsonMappingException, IOException { String clusterName = (String) getRequest().getAttributes().get("clusterName"); String instanceName = (String) getRequest().getAttributes().get("instanceName"); ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT); ClusterSetup setupTool = new ClusterSetup(zkClient); List<String> instances = setupTool.getClusterManagementTool().getInstancesInCluster(clusterName); HelixDataAccessor accessor = ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName); LiveInstance liveInstance = accessor.getProperty(accessor.keyBuilder().liveInstance(instanceName)); String sessionId = liveInstance.getSessionId(); StringRepresentation representation = new StringRepresentation("");// (ClusterRepresentationUtil.ObjectToJson(instanceConfigs), // MediaType.APPLICATION_JSON); return representation; }
protected void startParticipantsWithStuckTaskStateModelFactory() { Map<String, TaskFactory> taskFactoryReg = new HashMap<String, TaskFactory>(); taskFactoryReg.put(MockTask.TASK_COMMAND, new TaskFactory() { @Override public Task createNewTask(TaskCallbackContext context) { return new MockTask(context); } }); List<String> instances = _gSetupTool.getClusterManagementTool().getInstancesInCluster(CLUSTER_NAME); _participants[0] = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instances.get(0)); StateMachineEngine stateMachine = _participants[0].getStateMachineEngine(); stateMachine.registerStateModelFactory("Task", new MockTaskStateModelFactory(_participants[0], taskFactoryReg)); _participants[0].syncStart(); _blockedParticipant = _participants[0]; _participants[1] = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instances.get(1)); stateMachine = _participants[1].getStateMachineEngine(); stateMachine.registerStateModelFactory("Task", new TaskStateModelFactory(_participants[1], taskFactoryReg)); _participants[1].syncStart(); _normalParticipant = _participants[1]; }
"OnlineOffline", false); // dont rebalance List<String> instancesInCluster = _gSetupTool.getClusterManagementTool().getInstancesInCluster(clusterName); String resourceName = "TestResource"; CustomModeISBuilder customModeISBuilder = new CustomModeISBuilder(resourceName);
StringRepresentation getClusterRepresentation(String clusterName) throws JsonGenerationException, JsonMappingException, IOException { ZkClient zkClient = ResourceUtil.getAttributeFromCtx(getContext(), ResourceUtil.ContextKey.ZKCLIENT); ClusterSetup setupTool = new ClusterSetup(zkClient); List<String> instances = setupTool.getClusterManagementTool().getInstancesInCluster(clusterName); ZNRecord clusterSummayRecord = new ZNRecord("Cluster Summary"); clusterSummayRecord.setListField("participants", instances); List<String> resources = setupTool.getClusterManagementTool().getResourcesInCluster(clusterName); clusterSummayRecord.setListField("resources", resources); List<String> models = setupTool.getClusterManagementTool().getStateModelDefs(clusterName); clusterSummayRecord.setListField("stateModelDefs", models); HelixDataAccessor accessor = ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName); Builder keyBuilder = accessor.keyBuilder(); LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader()); if (leader != null) { clusterSummayRecord.setSimpleField("LEADER", leader.getInstanceName()); } else { clusterSummayRecord.setSimpleField("LEADER", ""); } StringRepresentation representation = new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(clusterSummayRecord), MediaType.APPLICATION_JSON); return representation; }