use of com.uber.cadence.internal.testservice.StateMachines.ActivityTaskData in project cadence-client by uber-java.
the class TestWorkflowMutableStateImpl method startActivityTask.
@Override
public void startActivityTask(PollForActivityTaskResponse task, PollForActivityTaskRequest pollRequest) throws InternalServiceError, EntityNotExistsError, BadRequestError {
update(ctx -> {
String activityId = task.getActivityId();
StateMachine<ActivityTaskData> activity = getActivity(activityId);
activity.action(StateMachines.Action.START, ctx, pollRequest, 0);
ActivityTaskData data = activity.getData();
int startToCloseTimeout = data.scheduledEvent.getStartToCloseTimeoutSeconds();
int heartbeatTimeout = data.scheduledEvent.getHeartbeatTimeoutSeconds();
if (startToCloseTimeout > 0) {
ctx.addTimer(startToCloseTimeout, () -> timeoutActivity(activityId, TimeoutType.START_TO_CLOSE));
}
updateHeartbeatTimer(ctx, activityId, activity, startToCloseTimeout, heartbeatTimeout);
});
}
use of com.uber.cadence.internal.testservice.StateMachines.ActivityTaskData in project cadence-client by uber-java.
the class TestWorkflowMutableStateImpl method heartbeatActivityTask.
@Override
public RecordActivityTaskHeartbeatResponse heartbeatActivityTask(String activityId, RecordActivityTaskHeartbeatRequest request) throws InternalServiceError, EntityNotExistsError, BadRequestError {
RecordActivityTaskHeartbeatResponse result = new RecordActivityTaskHeartbeatResponse();
try {
update(ctx -> {
StateMachine<ActivityTaskData> activity = getActivity(activityId);
activity.action(StateMachines.Action.UPDATE, ctx, request, 0);
if (activity.getState() == StateMachines.State.CANCELLATION_REQUESTED) {
result.setCancelRequested(true);
}
ActivityTaskData data = activity.getData();
data.lastHeartbeatTime = clock.getAsLong();
int startToCloseTimeout = data.scheduledEvent.getStartToCloseTimeoutSeconds();
int heartbeatTimeout = data.scheduledEvent.getHeartbeatTimeoutSeconds();
updateHeartbeatTimer(ctx, activityId, activity, startToCloseTimeout, heartbeatTimeout);
});
} catch (InternalServiceError | EntityNotExistsError e) {
throw e;
} catch (Exception e) {
throw new InternalServiceError(Throwables.getStackTraceAsString(e));
}
return result;
}
Aggregations