use of com.netflix.conductor.common.run.WorkflowSummary in project conductor by Netflix.
the class ElasticSearchRestDAOV7 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);
IndexRequest request = new IndexRequest(workflowIndexName).id(workflowId).source(docBytes, XContentType.JSON);
new RetryUtil<IndexResponse>().retryOnException(() -> {
try {
return elasticSearchClient.index(request, RequestOptions.DEFAULT);
} 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 TestElasticSearchRestDAOV6 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 TestElasticSearchDAOV6 method shouldIndexWorkflowAsync.
@Test
public void shouldIndexWorkflowAsync() throws Exception {
Workflow workflow = TestUtils.loadWorkflowSnapshot("workflow");
WorkflowSummary summary = new WorkflowSummary(workflow);
indexDAO.asyncIndexWorkflow(workflow).get();
assertWorkflowSummary(workflow.getWorkflowId(), summary);
}
use of com.netflix.conductor.common.run.WorkflowSummary in project conductor by Netflix.
the class TestElasticSearchDAOV6 method shouldAsyncUpdateWorkflow.
@Test
public void shouldAsyncUpdateWorkflow() throws Exception {
Workflow workflow = TestUtils.loadWorkflowSnapshot("workflow");
WorkflowSummary summary = new WorkflowSummary(workflow);
indexDAO.indexWorkflow(workflow);
indexDAO.asyncUpdateWorkflow(workflow.getWorkflowId(), new String[] { "status" }, new Object[] { Workflow.WorkflowStatus.FAILED }).get();
summary.setStatus(Workflow.WorkflowStatus.FAILED);
assertWorkflowSummary(workflow.getWorkflowId(), summary);
}
use of com.netflix.conductor.common.run.WorkflowSummary in project conductor by Netflix.
the class ElasticSearchDAOV5 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);
UpdateRequest request = new UpdateRequest(indexName, WORKFLOW_DOC_TYPE, id);
request.doc(doc, XContentType.JSON);
request.upsert(doc, XContentType.JSON);
request.retryOnConflict(5);
new RetryUtil<UpdateResponse>().retryOnException(() -> elasticSearchClient.update(request).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(className, "indexWorkflow");
logger.error("Failed to index workflow: {}", workflow.getWorkflowId(), e);
}
}
Aggregations