use of com.netflix.conductor.common.run.Workflow in project conductor by Netflix.
the class TestWorkflowExecutor method testTerminateCompletedWorkflow.
@Test(expected = ApplicationException.class)
public void testTerminateCompletedWorkflow() {
Workflow workflow = new Workflow();
workflow.setWorkflowId("testTerminateTerminalWorkflow");
workflow.setStatus(Workflow.WorkflowStatus.COMPLETED);
when(executionDAOFacade.getWorkflowById(anyString(), anyBoolean())).thenReturn(workflow);
workflowExecutor.terminateWorkflow(workflow.getWorkflowId(), "test terminating terminal workflow");
}
use of com.netflix.conductor.common.run.Workflow in project conductor by Netflix.
the class WorkflowServiceImpl method getWorkflowStatus.
@Override
public void getWorkflowStatus(WorkflowServicePb.GetWorkflowStatusRequest req, StreamObserver<WorkflowPb.Workflow> response) {
try {
Workflow workflow = workflowService.getExecutionStatus(req.getWorkflowId(), req.getIncludeTasks());
response.onNext(PROTO_MAPPER.toProto(workflow));
response.onCompleted();
} catch (Exception e) {
GRPC_HELPER.onError(response, e);
}
}
use of com.netflix.conductor.common.run.Workflow in project conductor by Netflix.
the class WorkflowServiceImplTest method searchV2Test.
@Test
public void searchV2Test() throws InterruptedException {
CountDownLatch streamAlive = new CountDownLatch(1);
AtomicReference<WorkflowServicePb.WorkflowSearchResult> result = new AtomicReference<>();
SearchPb.Request req = SearchPb.Request.newBuilder().setStart(1).setSize(1).setSort("strings").setQuery("").setFreeText("").build();
StreamObserver<WorkflowServicePb.WorkflowSearchResult> streamObserver = new StreamObserver<WorkflowServicePb.WorkflowSearchResult>() {
@Override
public void onNext(WorkflowServicePb.WorkflowSearchResult value) {
result.set(value);
}
@Override
public void onError(Throwable t) {
streamAlive.countDown();
}
@Override
public void onCompleted() {
streamAlive.countDown();
}
};
Workflow workflow = new Workflow();
SearchResult<Workflow> searchResult = new SearchResult<>();
searchResult.setTotalHits(1);
searchResult.setResults(Collections.singletonList(workflow));
when(workflowService.searchWorkflowsV2(1, 1, Collections.singletonList("strings"), "*", "")).thenReturn(searchResult);
workflowServiceImpl.searchV2(req, streamObserver);
streamAlive.await(10, TimeUnit.MILLISECONDS);
WorkflowServicePb.WorkflowSearchResult workflowSearchResult = result.get();
assertEquals(1, workflowSearchResult.getTotalHits());
assertEquals(WorkflowPb.Workflow.newBuilder().build(), workflowSearchResult.getResultsList().get(0));
}
use of com.netflix.conductor.common.run.Workflow in project conductor by Netflix.
the class AbstractProtoMapper method fromProto.
public Workflow fromProto(WorkflowPb.Workflow from) {
Workflow to = new Workflow();
to.setStatus(fromProto(from.getStatus()));
to.setEndTime(from.getEndTime());
to.setWorkflowId(from.getWorkflowId());
to.setParentWorkflowId(from.getParentWorkflowId());
to.setParentWorkflowTaskId(from.getParentWorkflowTaskId());
to.setTasks(from.getTasksList().stream().map(this::fromProto).collect(Collectors.toCollection(ArrayList::new)));
Map<String, Object> inputMap = new HashMap<String, Object>();
for (Map.Entry<String, Value> pair : from.getInputMap().entrySet()) {
inputMap.put(pair.getKey(), fromProto(pair.getValue()));
}
to.setInput(inputMap);
Map<String, Object> outputMap = new HashMap<String, Object>();
for (Map.Entry<String, Value> pair : from.getOutputMap().entrySet()) {
outputMap.put(pair.getKey(), fromProto(pair.getValue()));
}
to.setOutput(outputMap);
to.setWorkflowType(from.getWorkflowType());
to.setVersion(from.getVersion());
to.setCorrelationId(from.getCorrelationId());
to.setReRunFromWorkflowId(from.getReRunFromWorkflowId());
to.setReasonForIncompletion(from.getReasonForIncompletion());
to.setSchemaVersion(from.getSchemaVersion());
to.setEvent(from.getEvent());
to.setTaskToDomain(from.getTaskToDomainMap());
to.setFailedReferenceTaskNames(from.getFailedReferenceTaskNamesList().stream().collect(Collectors.toCollection(HashSet::new)));
if (from.hasWorkflowDefinition()) {
to.setWorkflowDefinition(fromProto(from.getWorkflowDefinition()));
}
to.setExternalInputPayloadStoragePath(from.getExternalInputPayloadStoragePath());
to.setExternalOutputPayloadStoragePath(from.getExternalOutputPayloadStoragePath());
to.setPriority(from.getPriority());
Map<String, Object> variablesMap = new HashMap<String, Object>();
for (Map.Entry<String, Value> pair : from.getVariablesMap().entrySet()) {
variablesMap.put(pair.getKey(), fromProto(pair.getValue()));
}
to.setVariables(variablesMap);
to.setLastRetriedTime(from.getLastRetriedTime());
return to;
}
use of com.netflix.conductor.common.run.Workflow in project conductor by Netflix.
the class AbstractProtoMapper method toProto.
public WorkflowPb.Workflow toProto(Workflow from) {
WorkflowPb.Workflow.Builder to = WorkflowPb.Workflow.newBuilder();
if (from.getStatus() != null) {
to.setStatus(toProto(from.getStatus()));
}
to.setEndTime(from.getEndTime());
if (from.getWorkflowId() != null) {
to.setWorkflowId(from.getWorkflowId());
}
if (from.getParentWorkflowId() != null) {
to.setParentWorkflowId(from.getParentWorkflowId());
}
if (from.getParentWorkflowTaskId() != null) {
to.setParentWorkflowTaskId(from.getParentWorkflowTaskId());
}
for (Task elem : from.getTasks()) {
to.addTasks(toProto(elem));
}
for (Map.Entry<String, Object> pair : from.getInput().entrySet()) {
to.putInput(pair.getKey(), toProto(pair.getValue()));
}
for (Map.Entry<String, Object> pair : from.getOutput().entrySet()) {
to.putOutput(pair.getKey(), toProto(pair.getValue()));
}
if (from.getWorkflowType() != null) {
to.setWorkflowType(from.getWorkflowType());
}
to.setVersion(from.getVersion());
if (from.getCorrelationId() != null) {
to.setCorrelationId(from.getCorrelationId());
}
if (from.getReRunFromWorkflowId() != null) {
to.setReRunFromWorkflowId(from.getReRunFromWorkflowId());
}
if (from.getReasonForIncompletion() != null) {
to.setReasonForIncompletion(from.getReasonForIncompletion());
}
to.setSchemaVersion(from.getSchemaVersion());
if (from.getEvent() != null) {
to.setEvent(from.getEvent());
}
to.putAllTaskToDomain(from.getTaskToDomain());
to.addAllFailedReferenceTaskNames(from.getFailedReferenceTaskNames());
if (from.getWorkflowDefinition() != null) {
to.setWorkflowDefinition(toProto(from.getWorkflowDefinition()));
}
if (from.getExternalInputPayloadStoragePath() != null) {
to.setExternalInputPayloadStoragePath(from.getExternalInputPayloadStoragePath());
}
if (from.getExternalOutputPayloadStoragePath() != null) {
to.setExternalOutputPayloadStoragePath(from.getExternalOutputPayloadStoragePath());
}
to.setPriority(from.getPriority());
for (Map.Entry<String, Object> pair : from.getVariables().entrySet()) {
to.putVariables(pair.getKey(), toProto(pair.getValue()));
}
to.setLastRetriedTime(from.getLastRetriedTime());
return to.build();
}
Aggregations