use of com.netflix.conductor.common.run.TaskSummary in project conductor by Netflix.
the class ElasticSearchDAOV5 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);
UpdateRequest req = new UpdateRequest(indexName, TASK_DOC_TYPE, id);
req.doc(doc, XContentType.JSON);
req.upsert(doc, XContentType.JSON);
logger.debug("Indexing task document: {} for workflow: {}" + id, task.getWorkflowInstanceId());
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);
}
}
use of com.netflix.conductor.common.run.TaskSummary in project conductor by Netflix.
the class ExecutionService method searchWorkflowByTasks.
public SearchResult<WorkflowSummary> searchWorkflowByTasks(String query, String freeText, int start, int size, List<String> sortOptions) {
SearchResult<TaskSummary> taskSummarySearchResult = searchTasks(query, freeText, start, size, sortOptions);
List<WorkflowSummary> workflowSummaries = taskSummarySearchResult.getResults().stream().parallel().map(taskSummary -> {
try {
String workflowId = taskSummary.getWorkflowId();
return new WorkflowSummary(executionDAOFacade.getWorkflowById(workflowId, false));
} catch (Exception e) {
logger.error("Error fetching workflow by id: {}", taskSummary.getWorkflowId(), e);
return null;
}
}).filter(Objects::nonNull).distinct().collect(Collectors.toList());
int missing = taskSummarySearchResult.getResults().size() - workflowSummaries.size();
long totalHits = taskSummarySearchResult.getTotalHits() - missing;
return new SearchResult<>(totalHits, workflowSummaries);
}
use of com.netflix.conductor.common.run.TaskSummary in project conductor by Netflix.
the class ElasticSearchRestDAOV5 method indexTask.
@Override
public void indexTask(Task task) {
try {
long startTime = Instant.now().toEpochMilli();
String taskId = task.getTaskId();
TaskSummary summary = new TaskSummary(task);
indexObject(indexName, 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);
}
}
use of com.netflix.conductor.common.run.TaskSummary in project conductor by Netflix.
the class ElasticSearchRestDAOV6 method indexTask.
@Override
public void indexTask(Task task) {
try {
long startTime = Instant.now().toEpochMilli();
String taskId = task.getTaskId();
TaskSummary summary = new TaskSummary(task);
String docType = StringUtils.isBlank(docTypeOverride) ? TASK_DOC_TYPE : docTypeOverride;
indexObject(taskIndexName, docType, 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);
}
}
use of com.netflix.conductor.common.run.TaskSummary in project conductor by Netflix.
the class TestElasticSearchDAOV6 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));
}
Aggregations