Search in sources :

Example 26 with WorkflowConfig

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

the class TestJobAccessor method testDeleteJob.

@Test(dependsOnMethods = "testCreateJob")
public void testDeleteJob() {
    System.out.println("Start test :" + TestHelper.getTestMethodName());
    TaskDriver driver = getTaskDriver(CLUSTER_NAME);
    delete("clusters/" + CLUSTER_NAME + "/workflows/" + TEST_QUEUE_NAME + "/jobs/" + TEST_JOB_NAME, Response.Status.OK.getStatusCode());
    String jobName = TaskUtil.getNamespacedJobName(TEST_QUEUE_NAME, TEST_JOB_NAME);
    JobConfig jobConfig = driver.getJobConfig(jobName);
    Assert.assertNull(jobConfig);
    WorkflowConfig workflowConfig = driver.getWorkflowConfig(TEST_QUEUE_NAME);
    Assert.assertTrue(!workflowConfig.getJobDag().getAllNodes().contains(jobName));
}
Also used : WorkflowConfig(org.apache.helix.task.WorkflowConfig) TaskDriver(org.apache.helix.task.TaskDriver) JobConfig(org.apache.helix.task.JobConfig) Test(org.testng.annotations.Test)

Example 27 with WorkflowConfig

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

the class JobAccessor method getJobs.

@GET
public Response getJobs(@PathParam("clusterId") String clusterId, @PathParam("workflowName") String workflowName) {
    TaskDriver driver = getTaskDriver(clusterId);
    WorkflowConfig workflowConfig = driver.getWorkflowConfig(workflowName);
    ObjectNode root = JsonNodeFactory.instance.objectNode();
    if (workflowConfig == null) {
        return badRequest(String.format("Workflow %s is not found!", workflowName));
    }
    Set<String> jobs = workflowConfig.getJobDag().getAllNodes();
    root.put(Properties.id.name(), JobProperties.Jobs.name());
    ArrayNode jobsNode = root.putArray(JobProperties.Jobs.name());
    if (jobs != null) {
        jobsNode.addAll((ArrayNode) OBJECT_MAPPER.valueToTree(jobs));
    }
    return JSONRepresentation(root);
}
Also used : WorkflowConfig(org.apache.helix.task.WorkflowConfig) ObjectNode(org.codehaus.jackson.node.ObjectNode) TaskDriver(org.apache.helix.task.TaskDriver) ArrayNode(org.codehaus.jackson.node.ArrayNode) GET(javax.ws.rs.GET)

Example 28 with WorkflowConfig

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

the class TaskDataCache method refresh.

/**
 * This refreshes the cluster data by re-fetching the data from zookeeper in an efficient way
 *
 * @param accessor
 *
 * @return
 */
public synchronized boolean refresh(HelixDataAccessor accessor, Map<String, ResourceConfig> resourceConfigMap) {
    refreshJobContexts(accessor);
    // update workflow and job configs.
    _workflowConfigMap.clear();
    _jobConfigMap.clear();
    for (Map.Entry<String, ResourceConfig> entry : resourceConfigMap.entrySet()) {
        if (entry.getValue().getRecord().getSimpleFields().containsKey(WorkflowConfig.WorkflowConfigProperty.Dag.name())) {
            _workflowConfigMap.put(entry.getKey(), new WorkflowConfig(entry.getValue()));
        } else if (entry.getValue().getRecord().getSimpleFields().containsKey(WorkflowConfig.WorkflowConfigProperty.WorkflowID.name())) {
            _jobConfigMap.put(entry.getKey(), new JobConfig(entry.getValue()));
        }
    }
    return true;
}
Also used : WorkflowConfig(org.apache.helix.task.WorkflowConfig) ResourceConfig(org.apache.helix.model.ResourceConfig) HashMap(java.util.HashMap) Map(java.util.Map) JobConfig(org.apache.helix.task.JobConfig)

Aggregations

WorkflowConfig (org.apache.helix.task.WorkflowConfig)28 Test (org.testng.annotations.Test)14 JobQueue (org.apache.helix.task.JobQueue)13 WorkflowContext (org.apache.helix.task.WorkflowContext)12 JobConfig (org.apache.helix.task.JobConfig)11 TaskDriver (org.apache.helix.task.TaskDriver)11 JobContext (org.apache.helix.task.JobContext)7 ArrayList (java.util.ArrayList)6 Map (java.util.Map)4 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 JobDag (org.apache.helix.task.JobDag)4 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 HelixDataAccessor (org.apache.helix.HelixDataAccessor)3 HelixException (org.apache.helix.HelixException)3 PropertyKey (org.apache.helix.PropertyKey)3 ObjectNode (org.codehaus.jackson.node.ObjectNode)3 Calendar (java.util.Calendar)2 HashSet (java.util.HashSet)2