Search in sources :

Example 1 with TaskListId

use of com.uber.cadence.internal.testservice.TestWorkflowStore.TaskListId in project cadence-client by uber-java.

the class TestWorkflowMutableStateImpl method query.

@Override
public QueryWorkflowResponse query(QueryWorkflowRequest queryRequest) throws TException {
    QueryId queryId = new QueryId(executionId);
    PollForDecisionTaskResponse task = new PollForDecisionTaskResponse().setTaskToken(queryId.toBytes()).setWorkflowExecution(executionId.getExecution()).setWorkflowType(startRequest.getWorkflowType()).setQuery(queryRequest.getQuery());
    TaskListId taskListId = new TaskListId(queryRequest.getDomain(), startRequest.getTaskList().getName());
    store.sendQueryTask(executionId, taskListId, task);
    CompletableFuture<QueryWorkflowResponse> result = new CompletableFuture<>();
    queries.put(queryId.getQueryId(), result);
    try {
        return result.get();
    } catch (InterruptedException e) {
        return new QueryWorkflowResponse();
    } catch (ExecutionException e) {
        Throwable cause = e.getCause();
        if (cause instanceof TException) {
            throw (TException) cause;
        }
        throw new InternalServiceError(Throwables.getStackTraceAsString(cause));
    }
}
Also used : TException(org.apache.thrift.TException) CompletableFuture(java.util.concurrent.CompletableFuture) QueryWorkflowResponse(com.uber.cadence.QueryWorkflowResponse) TaskListId(com.uber.cadence.internal.testservice.TestWorkflowStore.TaskListId) PollForDecisionTaskResponse(com.uber.cadence.PollForDecisionTaskResponse) InternalServiceError(com.uber.cadence.InternalServiceError) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with TaskListId

use of com.uber.cadence.internal.testservice.TestWorkflowStore.TaskListId in project cadence-client by uber-java.

the class StateMachines method scheduleDecisionTask.

private static void scheduleDecisionTask(RequestContext ctx, DecisionTaskData data, StartWorkflowExecutionRequest request, long notUsed) {
    DecisionTaskScheduledEventAttributes a = new DecisionTaskScheduledEventAttributes().setStartToCloseTimeoutSeconds(request.getTaskStartToCloseTimeoutSeconds()).setTaskList(request.getTaskList()).setAttempt(data.attempt);
    HistoryEvent event = new HistoryEvent().setEventType(EventType.DecisionTaskScheduled).setDecisionTaskScheduledEventAttributes(a);
    long scheduledEventId = ctx.addEvent(event);
    PollForDecisionTaskResponse decisionTaskResponse = new PollForDecisionTaskResponse();
    if (data.previousStartedEventId > 0) {
        decisionTaskResponse.setPreviousStartedEventId(data.previousStartedEventId);
    }
    decisionTaskResponse.setWorkflowExecution(ctx.getExecution());
    decisionTaskResponse.setWorkflowType(request.getWorkflowType());
    decisionTaskResponse.setAttempt(data.attempt);
    TaskListId taskListId = new TaskListId(ctx.getDomain(), request.getTaskList().getName());
    DecisionTask decisionTask = new DecisionTask(taskListId, decisionTaskResponse);
    ctx.setDecisionTask(decisionTask);
    ctx.onCommit((historySize) -> {
        data.scheduledEventId = scheduledEventId;
        data.decisionTask = decisionTaskResponse;
    });
}
Also used : DecisionTask(com.uber.cadence.internal.testservice.TestWorkflowStore.DecisionTask) TaskListId(com.uber.cadence.internal.testservice.TestWorkflowStore.TaskListId) PollForDecisionTaskResponse(com.uber.cadence.PollForDecisionTaskResponse) DecisionTaskScheduledEventAttributes(com.uber.cadence.DecisionTaskScheduledEventAttributes) HistoryEvent(com.uber.cadence.HistoryEvent)

Example 3 with TaskListId

use of com.uber.cadence.internal.testservice.TestWorkflowStore.TaskListId in project cadence-client by uber-java.

the class StateMachines method scheduleActivityTask.

private static void scheduleActivityTask(RequestContext ctx, ActivityTaskData data, ScheduleActivityTaskDecisionAttributes d, long decisionTaskCompletedEventId) {
    ActivityTaskScheduledEventAttributes a = new ActivityTaskScheduledEventAttributes().setInput(d.getInput()).setActivityId(d.getActivityId()).setActivityType(d.getActivityType()).setDomain(d.getDomain() == null ? ctx.getDomain() : d.getDomain()).setHeartbeatTimeoutSeconds(d.getHeartbeatTimeoutSeconds()).setScheduleToCloseTimeoutSeconds(d.getScheduleToCloseTimeoutSeconds()).setScheduleToStartTimeoutSeconds(d.getScheduleToStartTimeoutSeconds()).setStartToCloseTimeoutSeconds(d.getStartToCloseTimeoutSeconds()).setTaskList(d.getTaskList()).setDecisionTaskCompletedEventId(decisionTaskCompletedEventId);
    HistoryEvent event = new HistoryEvent().setEventType(EventType.ActivityTaskScheduled).setActivityTaskScheduledEventAttributes(a);
    long scheduledEventId = ctx.addEvent(event);
    PollForActivityTaskResponse taskResponse = new PollForActivityTaskResponse().setActivityType(d.getActivityType()).setWorkflowExecution(ctx.getExecution()).setActivityId(d.getActivityId()).setInput(d.getInput()).setHeartbeatTimeoutSeconds(d.getHeartbeatTimeoutSeconds()).setScheduleToCloseTimeoutSeconds(d.getScheduleToCloseTimeoutSeconds()).setStartToCloseTimeoutSeconds(d.getStartToCloseTimeoutSeconds()).setScheduledTimestamp(ctx.currentTimeInNanoseconds());
    TaskListId taskListId = new TaskListId(ctx.getDomain(), d.getTaskList().getName());
    ActivityTask activityTask = new ActivityTask(taskListId, taskResponse);
    ctx.addActivityTask(activityTask);
    ctx.onCommit((historySize) -> {
        data.scheduledEvent = a;
        data.scheduledEventId = scheduledEventId;
        data.activityTask = taskResponse;
    });
}
Also used : ActivityTaskScheduledEventAttributes(com.uber.cadence.ActivityTaskScheduledEventAttributes) ActivityTask(com.uber.cadence.internal.testservice.TestWorkflowStore.ActivityTask) PollForActivityTaskResponse(com.uber.cadence.PollForActivityTaskResponse) TaskListId(com.uber.cadence.internal.testservice.TestWorkflowStore.TaskListId) HistoryEvent(com.uber.cadence.HistoryEvent)

Aggregations

TaskListId (com.uber.cadence.internal.testservice.TestWorkflowStore.TaskListId)3 HistoryEvent (com.uber.cadence.HistoryEvent)2 PollForDecisionTaskResponse (com.uber.cadence.PollForDecisionTaskResponse)2 ActivityTaskScheduledEventAttributes (com.uber.cadence.ActivityTaskScheduledEventAttributes)1 DecisionTaskScheduledEventAttributes (com.uber.cadence.DecisionTaskScheduledEventAttributes)1 InternalServiceError (com.uber.cadence.InternalServiceError)1 PollForActivityTaskResponse (com.uber.cadence.PollForActivityTaskResponse)1 QueryWorkflowResponse (com.uber.cadence.QueryWorkflowResponse)1 ActivityTask (com.uber.cadence.internal.testservice.TestWorkflowStore.ActivityTask)1 DecisionTask (com.uber.cadence.internal.testservice.TestWorkflowStore.DecisionTask)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ExecutionException (java.util.concurrent.ExecutionException)1 TException (org.apache.thrift.TException)1