use of org.apache.helix.manager.zk.ZkClient in project helix by apache.
the class SchedulerTasksResource method getSchedulerTasksRepresentation.
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();
// (ClusterRepresentationUtil.ObjectToJson(instanceConfigs),
StringRepresentation representation = new StringRepresentation("");
return representation;
}
use of org.apache.helix.manager.zk.ZkClient in project helix by apache.
the class StateModelResource method getStateModelRepresentation.
StringRepresentation getStateModelRepresentation(String clusterName, String modelName) throws JsonGenerationException, JsonMappingException, IOException {
Builder keyBuilder = new PropertyKey.Builder(clusterName);
ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
String message = ClusterRepresentationUtil.getClusterPropertyAsString(zkClient, clusterName, keyBuilder.stateModelDef(modelName), MediaType.APPLICATION_JSON);
StringRepresentation representation = new StringRepresentation(message, MediaType.APPLICATION_JSON);
return representation;
}
use of org.apache.helix.manager.zk.ZkClient in project helix by apache.
the class StateModelsResource method post.
@Override
public Representation post(Representation entity) {
try {
String clusterName = (String) getRequest().getAttributes().get("clusterName");
ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
;
JsonParameters jsonParameters = new JsonParameters(entity);
String command = jsonParameters.getCommand();
if (command.equalsIgnoreCase(ClusterSetup.addStateModelDef)) {
ZNRecord newStateModel = jsonParameters.getExtraParameter(JsonParameters.NEW_STATE_MODEL_DEF);
HelixDataAccessor accessor = ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName);
accessor.setProperty(accessor.keyBuilder().stateModelDef(newStateModel.getId()), new StateModelDefinition(newStateModel));
getResponse().setEntity(getStateModelsRepresentation());
} else {
throw new HelixException("Unsupported command: " + command + ". Should be one of [" + ClusterSetup.addStateModelDef + "]");
}
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 posting " + entity, e);
}
return null;
}
use of org.apache.helix.manager.zk.ZkClient in project helix by apache.
the class StatusUpdateResource method getInstanceStatusUpdateRepresentation.
StringRepresentation getInstanceStatusUpdateRepresentation(String clusterName, String instanceName, String resourceGroup) throws JsonGenerationException, JsonMappingException, IOException {
ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
String instanceSessionId = ClusterRepresentationUtil.getInstanceSessionId(zkClient, clusterName, instanceName);
Builder keyBuilder = new PropertyKey.Builder(clusterName);
String message = ClusterRepresentationUtil.getInstancePropertiesAsString(zkClient, clusterName, keyBuilder.stateTransitionStatus(instanceName, instanceSessionId, resourceGroup), // + resourceGroup,
MediaType.APPLICATION_JSON);
StringRepresentation representation = new StringRepresentation(message, MediaType.APPLICATION_JSON);
return representation;
}
use of org.apache.helix.manager.zk.ZkClient in project helix by apache.
the class CurrentStatesResource method getInstanceCurrentStatesRepresentation.
StringRepresentation getInstanceCurrentStatesRepresentation(String clusterName, String instanceName) throws JsonGenerationException, JsonMappingException, IOException {
ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
;
String instanceSessionId = ClusterRepresentationUtil.getInstanceSessionId(zkClient, clusterName, instanceName);
String message = ClusterRepresentationUtil.getInstancePropertyNameListAsString(zkClient, clusterName, instanceName, PropertyType.CURRENTSTATES, instanceSessionId, MediaType.APPLICATION_JSON);
StringRepresentation representation = new StringRepresentation(message, MediaType.APPLICATION_JSON);
return representation;
}
Aggregations