Search in sources :

Example 6 with WorkflowSummary

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);
    }
}
Also used : WorkflowSummary(com.netflix.conductor.common.run.WorkflowSummary) IndexResponse(org.elasticsearch.action.index.IndexResponse) IOException(java.io.IOException) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) IndexRequest(org.elasticsearch.action.index.IndexRequest) CreateIndexRequest(org.elasticsearch.client.indices.CreateIndexRequest) 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 7 with WorkflowSummary

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);
}
Also used : WorkflowSummary(com.netflix.conductor.common.run.WorkflowSummary) Workflow(com.netflix.conductor.common.run.Workflow) Test(org.junit.Test)

Example 8 with WorkflowSummary

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);
}
Also used : WorkflowSummary(com.netflix.conductor.common.run.WorkflowSummary) Workflow(com.netflix.conductor.common.run.Workflow) Test(org.junit.Test)

Example 9 with WorkflowSummary

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);
}
Also used : WorkflowSummary(com.netflix.conductor.common.run.WorkflowSummary) Workflow(com.netflix.conductor.common.run.Workflow) Test(org.junit.Test)

Example 10 with WorkflowSummary

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);
    }
}
Also used : WorkflowSummary(com.netflix.conductor.common.run.WorkflowSummary) UpdateResponse(org.elasticsearch.action.update.UpdateResponse) UpdateRequest(org.elasticsearch.action.update.UpdateRequest) 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)

Aggregations

WorkflowSummary (com.netflix.conductor.common.run.WorkflowSummary)30 Test (org.junit.Test)22 Workflow (com.netflix.conductor.common.run.Workflow)19 SearchResult (com.netflix.conductor.common.run.SearchResult)7 ApplicationException (com.netflix.conductor.core.execution.ApplicationException)6 IOException (java.io.IOException)5 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)4 Task (com.netflix.conductor.common.metadata.tasks.Task)4 WorkflowDef (com.netflix.conductor.common.metadata.workflow.WorkflowDef)4 Message (com.netflix.conductor.core.events.queue.Message)4 ParserException (com.netflix.conductor.elasticsearch.query.parser.ParserException)4 TaskResult (com.netflix.conductor.common.metadata.tasks.TaskResult)3 WorkflowTask (com.netflix.conductor.common.metadata.workflow.WorkflowTask)3 Collections (java.util.Collections)3 LinkedList (java.util.LinkedList)3 TaskDef (com.netflix.conductor.common.metadata.tasks.TaskDef)2 StartWorkflowRequest (com.netflix.conductor.common.metadata.workflow.StartWorkflowRequest)2 SearchPb (com.netflix.conductor.grpc.SearchPb)2 WorkflowServicePb (com.netflix.conductor.grpc.WorkflowServicePb)2