Search in sources :

Example 1 with TaskSummary

use of com.netflix.conductor.common.run.TaskSummary in project conductor by Netflix.

the class TestElasticSearchRestDAOV7 method shouldIndexTask.

@Test
public void shouldIndexTask() {
    Workflow workflow = TestUtils.loadWorkflowSnapshot("workflow");
    Task task = workflow.getTasks().get(0);
    TaskSummary summary = new TaskSummary(task);
    indexDAO.indexTask(task);
    List<String> tasks = tryFindResults(() -> searchTasks(workflow));
    assertEquals(summary.getTaskId(), tasks.get(0));
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) TaskSummary(com.netflix.conductor.common.run.TaskSummary) Workflow(com.netflix.conductor.common.run.Workflow) Test(org.junit.Test)

Example 2 with TaskSummary

use of com.netflix.conductor.common.run.TaskSummary in project conductor by Netflix.

the class TestElasticSearchRestDAOV7 method shouldIndexTaskAsync.

@Test
public void shouldIndexTaskAsync() throws Exception {
    Workflow workflow = TestUtils.loadWorkflowSnapshot("workflow");
    Task task = workflow.getTasks().get(0);
    TaskSummary summary = new TaskSummary(task);
    indexDAO.asyncIndexTask(task).get();
    List<String> tasks = tryFindResults(() -> searchTasks(workflow));
    assertEquals(summary.getTaskId(), tasks.get(0));
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) TaskSummary(com.netflix.conductor.common.run.TaskSummary) Workflow(com.netflix.conductor.common.run.Workflow) Test(org.junit.Test)

Example 3 with TaskSummary

use of com.netflix.conductor.common.run.TaskSummary in project conductor by Netflix.

the class ElasticSearchDAOV6 method indexTask.

@Override
public void indexTask(Task task) {
    try {
        long startTime = Instant.now().toEpochMilli();
        String id = task.getTaskId();
        TaskSummary summary = new TaskSummary(task);
        byte[] doc = objectMapper.writeValueAsBytes(summary);
        String docType = StringUtils.isBlank(docTypeOverride) ? TASK_DOC_TYPE : docTypeOverride;
        UpdateRequest req = new UpdateRequest(taskIndexName, docType, id);
        req.doc(doc, XContentType.JSON);
        req.upsert(doc, XContentType.JSON);
        indexObject(req, TASK_DOC_TYPE);
        long endTime = Instant.now().toEpochMilli();
        LOGGER.debug("Time taken {} for  indexing task:{} in workflow: {}", endTime - startTime, task.getTaskId(), task.getWorkflowInstanceId());
        Monitors.recordESIndexTime("index_task", TASK_DOC_TYPE, endTime - startTime);
        Monitors.recordWorkerQueueSize("indexQueue", ((ThreadPoolExecutor) executorService).getQueue().size());
    } catch (Exception e) {
        LOGGER.error("Failed to index task: {}", task.getTaskId(), e);
    }
}
Also used : UpdateRequest(org.elasticsearch.action.update.UpdateRequest) TaskSummary(com.netflix.conductor.common.run.TaskSummary) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) IndexNotFoundException(org.elasticsearch.index.IndexNotFoundException) ParserException(com.netflix.conductor.elasticsearch.query.parser.ParserException) ResourceAlreadyExistsException(org.elasticsearch.ResourceAlreadyExistsException) ApplicationException(com.netflix.conductor.core.execution.ApplicationException) IOException(java.io.IOException)

Example 4 with TaskSummary

use of com.netflix.conductor.common.run.TaskSummary in project conductor by Netflix.

the class ElasticSearchRestDAOV7 method indexTask.

@Override
public void indexTask(Task task) {
    try {
        long startTime = Instant.now().toEpochMilli();
        String taskId = task.getTaskId();
        TaskSummary summary = new TaskSummary(task);
        indexObject(taskIndexName, TASK_DOC_TYPE, taskId, summary);
        long endTime = Instant.now().toEpochMilli();
        logger.debug("Time taken {} for  indexing task:{} in workflow: {}", endTime - startTime, taskId, task.getWorkflowInstanceId());
        Monitors.recordESIndexTime("index_task", TASK_DOC_TYPE, endTime - startTime);
        Monitors.recordWorkerQueueSize("indexQueue", ((ThreadPoolExecutor) executorService).getQueue().size());
    } catch (Exception e) {
        logger.error("Failed to index task: {}", task.getTaskId(), e);
    }
}
Also used : TaskSummary(com.netflix.conductor.common.run.TaskSummary) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) ParserException(com.netflix.conductor.elasticsearch.query.parser.ParserException) ApplicationException(com.netflix.conductor.core.execution.ApplicationException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException)

Example 5 with TaskSummary

use of com.netflix.conductor.common.run.TaskSummary in project conductor by Netflix.

the class TestElasticSearchRestDAOV6 method shouldIndexTaskAsync.

@Test
public void shouldIndexTaskAsync() throws Exception {
    Workflow workflow = TestUtils.loadWorkflowSnapshot("workflow");
    Task task = workflow.getTasks().get(0);
    TaskSummary summary = new TaskSummary(task);
    indexDAO.asyncIndexTask(task).get();
    List<String> tasks = tryFindResults(() -> searchTasks(workflow));
    assertEquals(summary.getTaskId(), tasks.get(0));
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) TaskSummary(com.netflix.conductor.common.run.TaskSummary) Workflow(com.netflix.conductor.common.run.Workflow) Test(org.junit.Test)

Aggregations

TaskSummary (com.netflix.conductor.common.run.TaskSummary)13 Task (com.netflix.conductor.common.metadata.tasks.Task)8 Workflow (com.netflix.conductor.common.run.Workflow)7 Test (org.junit.Test)7 ApplicationException (com.netflix.conductor.core.execution.ApplicationException)6 IOException (java.io.IOException)5 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)5 ParserException (com.netflix.conductor.elasticsearch.query.parser.ParserException)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 SearchResult (com.netflix.conductor.common.run.SearchResult)2 ArrayList (java.util.ArrayList)2 ResourceAlreadyExistsException (org.elasticsearch.ResourceAlreadyExistsException)2 UpdateRequest (org.elasticsearch.action.update.UpdateRequest)2 ResponseException (org.elasticsearch.client.ResponseException)2 IndexNotFoundException (org.elasticsearch.index.IndexNotFoundException)2 Trace (com.netflix.conductor.annotations.Trace)1 EventExecution (com.netflix.conductor.common.metadata.events.EventExecution)1 PollData (com.netflix.conductor.common.metadata.tasks.PollData)1 Status (com.netflix.conductor.common.metadata.tasks.Task.Status)1 TaskDef (com.netflix.conductor.common.metadata.tasks.TaskDef)1