use of com.netflix.conductor.common.run.WorkflowSummary in project conductor by Netflix.
the class ElasticSearchRestDAOV6 method indexWorkflow.
@Override
public void indexWorkflow(Workflow workflow) {
try {
long startTime = Instant.now().toEpochMilli();
String workflowId = workflow.getWorkflowId();
WorkflowSummary summary = new WorkflowSummary(workflow);
byte[] docBytes = objectMapper.writeValueAsBytes(summary);
String docType = StringUtils.isBlank(docTypeOverride) ? WORKFLOW_DOC_TYPE : docTypeOverride;
IndexRequest request = new IndexRequest(workflowIndexName, docType, workflowId);
request.source(docBytes, XContentType.JSON);
new RetryUtil<IndexResponse>().retryOnException(() -> {
try {
return elasticSearchClient.index(request);
} catch (IOException e) {
throw new RuntimeException(e);
}
}, null, null, RETRY_COUNT, "Indexing workflow document: " + workflow.getWorkflowId(), "indexWorkflow");
long endTime = Instant.now().toEpochMilli();
logger.debug("Time taken {} for indexing workflow: {}", endTime - startTime, workflowId);
Monitors.recordESIndexTime("index_workflow", WORKFLOW_DOC_TYPE, endTime - startTime);
Monitors.recordWorkerQueueSize("indexQueue", ((ThreadPoolExecutor) executorService).getQueue().size());
} catch (Exception e) {
Monitors.error(className, "indexWorkflow");
logger.error("Failed to index workflow: {}", workflow.getWorkflowId(), e);
}
}
use of com.netflix.conductor.common.run.WorkflowSummary in project conductor by Netflix.
the class TestElasticSearchDAOV6 method shouldUpdateWorkflow.
@Test
public void shouldUpdateWorkflow() {
Workflow workflow = TestUtils.loadWorkflowSnapshot("workflow");
WorkflowSummary summary = new WorkflowSummary(workflow);
indexDAO.indexWorkflow(workflow);
indexDAO.updateWorkflow(workflow.getWorkflowId(), new String[] { "status" }, new Object[] { Workflow.WorkflowStatus.COMPLETED });
summary.setStatus(Workflow.WorkflowStatus.COMPLETED);
assertWorkflowSummary(workflow.getWorkflowId(), summary);
}
use of com.netflix.conductor.common.run.WorkflowSummary in project conductor by Netflix.
the class TestElasticSearchRestDAOV6 method shouldUpdateWorkflow.
@Test
public void shouldUpdateWorkflow() {
Workflow workflow = TestUtils.loadWorkflowSnapshot("workflow");
WorkflowSummary summary = new WorkflowSummary(workflow);
indexDAO.indexWorkflow(workflow);
indexDAO.updateWorkflow(workflow.getWorkflowId(), new String[] { "status" }, new Object[] { Workflow.WorkflowStatus.COMPLETED });
summary.setStatus(Workflow.WorkflowStatus.COMPLETED);
assertWorkflowSummary(workflow.getWorkflowId(), summary);
}
use of com.netflix.conductor.common.run.WorkflowSummary in project conductor by Netflix.
the class TestElasticSearchDAOV6 method shouldIndexWorkflow.
@Test
public void shouldIndexWorkflow() {
Workflow workflow = TestUtils.loadWorkflowSnapshot("workflow");
WorkflowSummary summary = new WorkflowSummary(workflow);
indexDAO.indexWorkflow(workflow);
assertWorkflowSummary(workflow.getWorkflowId(), summary);
}
use of com.netflix.conductor.common.run.WorkflowSummary in project conductor by Netflix.
the class ElasticSearchDAOV6 method indexWorkflow.
@Override
public void indexWorkflow(Workflow workflow) {
try {
long startTime = Instant.now().toEpochMilli();
String id = workflow.getWorkflowId();
WorkflowSummary summary = new WorkflowSummary(workflow);
byte[] doc = objectMapper.writeValueAsBytes(summary);
String docType = StringUtils.isBlank(docTypeOverride) ? WORKFLOW_DOC_TYPE : docTypeOverride;
UpdateRequest req = buildUpdateRequest(id, doc, workflowIndexName, docType);
new RetryUtil<UpdateResponse>().retryOnException(() -> elasticSearchClient.update(req).actionGet(), null, null, RETRY_COUNT, "Indexing workflow document: " + workflow.getWorkflowId(), "indexWorkflow");
long endTime = Instant.now().toEpochMilli();
LOGGER.debug("Time taken {} for indexing workflow: {}", endTime - startTime, workflow.getWorkflowId());
Monitors.recordESIndexTime("index_workflow", WORKFLOW_DOC_TYPE, endTime - startTime);
Monitors.recordWorkerQueueSize("indexQueue", ((ThreadPoolExecutor) executorService).getQueue().size());
} catch (Exception e) {
Monitors.error(CLASS_NAME, "indexWorkflow");
LOGGER.error("Failed to index workflow: {}", workflow.getWorkflowId(), e);
}
}
Aggregations