use of org.apache.helix.task.TaskDriver in project helix by apache.
the class WorkflowAccessor method getWorkflowConfig.
@GET
@Path("{workflowId}/configs")
public Response getWorkflowConfig(@PathParam("clusterId") String clusterId, @PathParam("workflowId") String workflowId) {
TaskDriver taskDriver = getTaskDriver(clusterId);
WorkflowConfig workflowConfig = taskDriver.getWorkflowConfig(workflowId);
ObjectNode workflowConfigNode = JsonNodeFactory.instance.objectNode();
if (workflowConfig != null) {
getWorkflowConfigNode(workflowConfigNode, workflowConfig.getRecord());
}
return JSONRepresentation(workflowConfigNode);
}
use of org.apache.helix.task.TaskDriver in project helix by apache.
the class TestJobAccessor method testCreateJob.
@Test(dependsOnMethods = "testGetJobContext")
public void testCreateJob() throws IOException {
System.out.println("Start test :" + TestHelper.getTestMethodName());
TaskDriver driver = getTaskDriver(CLUSTER_NAME);
// Create JobQueue
JobQueue.Builder jobQueue = new JobQueue.Builder(TEST_QUEUE_NAME).setWorkflowConfig(driver.getWorkflowConfig(WORKFLOW_NAME));
Entity entity = Entity.entity(OBJECT_MAPPER.writeValueAsString(Collections.singletonMap(WorkflowAccessor.WorkflowProperties.WorkflowConfig.name(), jobQueue.build().getWorkflowConfig().getRecord().getSimpleFields())), MediaType.APPLICATION_JSON_TYPE);
put("clusters/" + CLUSTER_NAME + "/workflows/" + TEST_QUEUE_NAME, null, entity, Response.Status.OK.getStatusCode());
// Test enqueue job
entity = Entity.entity(JOB_INPUT, MediaType.APPLICATION_JSON_TYPE);
put("clusters/" + CLUSTER_NAME + "/workflows/" + TEST_QUEUE_NAME + "/jobs/" + TEST_JOB_NAME, null, entity, Response.Status.OK.getStatusCode());
String jobName = TaskUtil.getNamespacedJobName(TEST_QUEUE_NAME, TEST_JOB_NAME);
JobConfig jobConfig = driver.getJobConfig(jobName);
Assert.assertNotNull(jobConfig);
WorkflowConfig workflowConfig = driver.getWorkflowConfig(TEST_QUEUE_NAME);
Assert.assertTrue(workflowConfig.getJobDag().getAllNodes().contains(jobName));
}
use of org.apache.helix.task.TaskDriver 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));
}
use of org.apache.helix.task.TaskDriver in project helix by apache.
the class TestWorkflowAccessor method testUpdateWorkflow.
@Test(dependsOnMethods = "testCreateWorkflow")
public void testUpdateWorkflow() {
System.out.println("Start test :" + TestHelper.getTestMethodName());
TaskDriver driver = getTaskDriver(CLUSTER_NAME);
Entity entity = Entity.entity("", MediaType.APPLICATION_JSON_TYPE);
post("clusters/" + CLUSTER_NAME + "/workflows/" + TEST_QUEUE_NAME, ImmutableMap.of("command", "stop"), entity, Response.Status.OK.getStatusCode());
Assert.assertEquals(driver.getWorkflowConfig(TEST_QUEUE_NAME).getTargetState(), TargetState.STOP);
post("clusters/" + CLUSTER_NAME + "/workflows/" + TEST_QUEUE_NAME, ImmutableMap.of("command", "resume"), entity, Response.Status.OK.getStatusCode());
Assert.assertEquals(driver.getWorkflowConfig(TEST_QUEUE_NAME).getTargetState(), TargetState.START);
}
use of org.apache.helix.task.TaskDriver in project helix by apache.
the class TestWorkflowAccessor method testDeleteWorkflow.
@Test(dependsOnMethods = "testUpdateWorkflow")
public void testDeleteWorkflow() throws InterruptedException {
System.out.println("Start test :" + TestHelper.getTestMethodName());
TaskDriver driver = getTaskDriver(CLUSTER_NAME);
int currentWorkflowNumbers = driver.getWorkflows().size();
delete("clusters/" + CLUSTER_NAME + "/workflows/" + TEST_WORKFLOW_NAME, Response.Status.OK.getStatusCode());
delete("clusters/" + CLUSTER_NAME + "/workflows/" + TEST_QUEUE_NAME, Response.Status.OK.getStatusCode());
Thread.sleep(500);
Assert.assertEquals(driver.getWorkflows().size(), currentWorkflowNumbers - 2);
}
Aggregations