Search in sources :

Example 21 with EventExecution

use of com.netflix.conductor.common.metadata.events.EventExecution in project conductor by Netflix.

the class TestElasticSearchRestDAOV6 method createEventExecution.

private EventExecution createEventExecution(String event) {
    EventExecution execution = new EventExecution(uuid(), uuid());
    execution.setName("name");
    execution.setEvent(event);
    execution.setCreated(System.currentTimeMillis());
    execution.setStatus(EventExecution.Status.COMPLETED);
    execution.setAction(EventHandler.Action.Type.start_workflow);
    execution.setOutput(ImmutableMap.of("a", 1, "b", 2, "c", 3));
    return execution;
}
Also used : EventExecution(com.netflix.conductor.common.metadata.events.EventExecution)

Example 22 with EventExecution

use of com.netflix.conductor.common.metadata.events.EventExecution in project conductor by Netflix.

the class TestElasticSearchRestDAOV6 method shouldAsyncAddEventExecution.

@Test
public void shouldAsyncAddEventExecution() throws Exception {
    String event = "event2";
    EventExecution execution1 = createEventExecution(event);
    EventExecution execution2 = createEventExecution(event);
    indexDAO.asyncAddEventExecution(execution1).get();
    indexDAO.asyncAddEventExecution(execution2).get();
    List<EventExecution> indexedExecutions = tryFindResults(() -> indexDAO.getEventExecutions(event), 2);
    assertEquals(2, indexedExecutions.size());
    assertTrue("Not all event executions was indexed", indexedExecutions.containsAll(Arrays.asList(execution1, execution2)));
}
Also used : EventExecution(com.netflix.conductor.common.metadata.events.EventExecution) Test(org.junit.Test)

Example 23 with EventExecution

use of com.netflix.conductor.common.metadata.events.EventExecution in project conductor by Netflix.

the class ElasticSearchRestDAOV7 method mapEventExecutionsResponse.

private List<EventExecution> mapEventExecutionsResponse(SearchResponse response) throws IOException {
    SearchHit[] hits = response.getHits().getHits();
    List<EventExecution> executions = new ArrayList<>(hits.length);
    for (SearchHit hit : hits) {
        String source = hit.getSourceAsString();
        EventExecution tel = objectMapper.readValue(source, EventExecution.class);
        executions.add(tel);
    }
    return executions;
}
Also used : SearchHit(org.elasticsearch.search.SearchHit) EventExecution(com.netflix.conductor.common.metadata.events.EventExecution) ArrayList(java.util.ArrayList)

Example 24 with EventExecution

use of com.netflix.conductor.common.metadata.events.EventExecution in project conductor by Netflix.

the class TestElasticSearchRestDAOV7 method createEventExecution.

private EventExecution createEventExecution(String event) {
    EventExecution execution = new EventExecution(uuid(), uuid());
    execution.setName("name");
    execution.setEvent(event);
    execution.setCreated(System.currentTimeMillis());
    execution.setStatus(EventExecution.Status.COMPLETED);
    execution.setAction(EventHandler.Action.Type.start_workflow);
    execution.setOutput(ImmutableMap.of("a", 1, "b", 2, "c", 3));
    return execution;
}
Also used : EventExecution(com.netflix.conductor.common.metadata.events.EventExecution)

Example 25 with EventExecution

use of com.netflix.conductor.common.metadata.events.EventExecution in project conductor by Netflix.

the class RedisExecutionDAO method getEventExecutions.

public List<EventExecution> getEventExecutions(String eventHandlerName, String eventName, String messageId, int max) {
    try {
        String key = nsKey(EVENT_EXECUTION, eventHandlerName, eventName, messageId);
        logger.info("getting event execution {}", key);
        List<EventExecution> executions = new LinkedList<>();
        for (int i = 0; i < max; i++) {
            String field = messageId + "_" + i;
            String value = dynoClient.hget(key, field);
            if (value == null) {
                break;
            }
            recordRedisDaoEventRequests("getEventExecution", eventHandlerName);
            recordRedisDaoPayloadSize("getEventExecution", value.length(), eventHandlerName, "n/a");
            EventExecution eventExecution = objectMapper.readValue(value, EventExecution.class);
            executions.add(eventExecution);
        }
        return executions;
    } catch (Exception e) {
        throw new ApplicationException(Code.BACKEND_ERROR, "Unable to get event executions for " + eventHandlerName, e);
    }
}
Also used : ApplicationException(com.netflix.conductor.core.execution.ApplicationException) EventExecution(com.netflix.conductor.common.metadata.events.EventExecution) LinkedList(java.util.LinkedList) ApplicationException(com.netflix.conductor.core.execution.ApplicationException)

Aggregations

EventExecution (com.netflix.conductor.common.metadata.events.EventExecution)28 Test (org.junit.Test)13 ApplicationException (com.netflix.conductor.core.execution.ApplicationException)7 ArrayList (java.util.ArrayList)7 SearchHit (org.elasticsearch.search.SearchHit)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Action (com.netflix.conductor.common.metadata.events.EventHandler.Action)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 EventHandler (com.netflix.conductor.common.metadata.events.EventHandler)4 Message (com.netflix.conductor.core.events.queue.Message)4 ObservableQueue (com.netflix.conductor.core.events.queue.ObservableQueue)4 JsonUtils (com.netflix.conductor.core.utils.JsonUtils)4 ExecutionService (com.netflix.conductor.service.ExecutionService)4 MetadataService (com.netflix.conductor.service.MetadataService)4 Collections (java.util.Collections)4 TimeUnit (java.util.concurrent.TimeUnit)4 Uninterruptibles (com.google.common.util.concurrent.Uninterruptibles)3 Type (com.netflix.conductor.common.metadata.events.EventHandler.Action.Type)3 StartWorkflow (com.netflix.conductor.common.metadata.events.EventHandler.StartWorkflow)3