Search in sources :

Example 31 with WorkflowContext

use of org.apache.helix.task.WorkflowContext in project helix by apache.

the class JobQueueResource method getHostedEntitiesRepresentation.

StringRepresentation getHostedEntitiesRepresentation(String clusterName, String jobQueueName) throws Exception {
    ZkClient zkClient = ResourceUtil.getAttributeFromCtx(getContext(), ResourceUtil.ContextKey.ZKCLIENT);
    HelixDataAccessor accessor = ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName);
    PropertyKey.Builder keyBuilder = accessor.keyBuilder();
    TaskDriver taskDriver = new TaskDriver(zkClient, clusterName);
    // Get job queue config
    // TODO: fix this to use workflowConfig.
    ResourceConfig jobQueueConfig = accessor.getProperty(keyBuilder.resourceConfig(jobQueueName));
    // Get job queue context
    WorkflowContext ctx = taskDriver.getWorkflowContext(jobQueueName);
    // Create the result
    ZNRecord hostedEntitiesRecord = new ZNRecord(jobQueueName);
    if (jobQueueConfig != null) {
        hostedEntitiesRecord.merge(jobQueueConfig.getRecord());
    }
    if (ctx != null) {
        hostedEntitiesRecord.merge(ctx.getRecord());
    }
    StringRepresentation representation = new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(hostedEntitiesRecord), MediaType.APPLICATION_JSON);
    return representation;
}
Also used : ZkClient(org.apache.helix.manager.zk.ZkClient) HelixDataAccessor(org.apache.helix.HelixDataAccessor) StringRepresentation(org.restlet.representation.StringRepresentation) TaskDriver(org.apache.helix.task.TaskDriver) WorkflowContext(org.apache.helix.task.WorkflowContext) ResourceConfig(org.apache.helix.model.ResourceConfig) PropertyKey(org.apache.helix.PropertyKey) ZNRecord(org.apache.helix.ZNRecord)

Aggregations

WorkflowContext (org.apache.helix.task.WorkflowContext)31 Test (org.testng.annotations.Test)19 JobConfig (org.apache.helix.task.JobConfig)12 JobQueue (org.apache.helix.task.JobQueue)12 WorkflowConfig (org.apache.helix.task.WorkflowConfig)12 JobContext (org.apache.helix.task.JobContext)9 ArrayList (java.util.ArrayList)6 Workflow (org.apache.helix.task.Workflow)6 TaskDriver (org.apache.helix.task.TaskDriver)4 PropertyPathBuilder (org.apache.helix.PropertyPathBuilder)3 ZNRecord (org.apache.helix.ZNRecord)3 TaskConfig (org.apache.helix.task.TaskConfig)3 TaskState (org.apache.helix.task.TaskState)3 Calendar (java.util.Calendar)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 HelixException (org.apache.helix.HelixException)2 PropertyKey (org.apache.helix.PropertyKey)2