From 0a183e02b29b06e9324b740af40daff9193c9290 Mon Sep 17 00:00:00 2001 From: amazonwebservices Date: Tue, 21 Feb 2012 17:17:25 -0800 Subject: [PATCH] Version 1.3.3 of the AWS Java SDK This release adds support for working with the Amazon Simple Workflow Service, both with a low-level client object, and the high-level AWS Flow Framework. It also resolves several issues with the DynamoDB client and Object Persistence Model. --- META-INF/MANIFEST.MF | 2 +- NOTICE.txt | 2 +- pom.xml | 36 +- .../dynamodb/datamodeling/DynamoDBMapper.java | 169 +- .../datamodeling/DynamoDBReflector.java | 16 +- .../dynamodb/datamodeling/PaginatedList.java | 367 ++ .../{internal => }/PaginatedQueryList.java | 34 +- .../{internal => }/PaginatedScanList.java | 31 +- .../datamodeling/internal/PaginatedList.java | 261 -- .../internal/UnmodifiableIterator.java | 41 - .../AttributeValueJsonUnmarshaller.java | 4 +- .../BatchGetItemResultJsonUnmarshaller.java | 4 +- .../BatchResponseJsonUnmarshaller.java | 4 +- .../CreateTableResultJsonUnmarshaller.java | 4 +- .../DeleteItemResultJsonUnmarshaller.java | 4 +- .../DeleteTableResultJsonUnmarshaller.java | 4 +- .../DescribeTableResultJsonUnmarshaller.java | 4 +- .../GetItemResultJsonUnmarshaller.java | 4 +- .../model/transform/KeyJsonUnmarshaller.java | 4 +- .../KeySchemaElementJsonUnmarshaller.java | 4 +- .../transform/KeySchemaJsonUnmarshaller.java | 4 +- .../KeysAndAttributesJsonUnmarshaller.java | 4 +- .../ListTablesResultJsonUnmarshaller.java | 4 +- ...ThroughputDescriptionJsonUnmarshaller.java | 4 +- .../PutItemResultJsonUnmarshaller.java | 4 +- .../QueryResultJsonUnmarshaller.java | 4 +- .../transform/ScanResultJsonUnmarshaller.java | 4 +- .../TableDescriptionJsonUnmarshaller.java | 4 +- .../UpdateItemResultJsonUnmarshaller.java | 4 +- .../UpdateTableResultJsonUnmarshaller.java | 4 +- .../amazonaws/services/s3/AmazonS3Client.java | 13 + .../ProgressReportingInputStream.java | 48 +- .../services/s3/model/GetObjectRequest.java | 195 +- .../simpleworkflow/AmazonSimpleWorkflow.java | 1424 ++++++++ .../AmazonSimpleWorkflowAsync.java | 1332 ++++++++ .../AmazonSimpleWorkflowAsyncClient.java | 1705 ++++++++++ .../AmazonSimpleWorkflowClient.java | 1657 +++++++++ .../simpleworkflow/flow/ActivitiesClient.java | 27 + .../flow/ActivitiesClientBase.java | 66 + .../flow/ActivityExecutionContext.java | 81 + .../ActivityExecutionContextProvider.java | 30 + .../ActivityExecutionContextProviderImpl.java | 32 + .../flow/ActivityFailureException.java | 68 + .../flow/ActivitySchedulingOptions.java | 94 + .../flow/ActivityTaskException.java | 60 + .../flow/ActivityTaskFailedException.java | 48 + .../flow/ActivityTaskTimedOutException.java | 64 + .../simpleworkflow/flow/ActivityWorker.java | 266 ++ .../flow/ChildWorkflowException.java | 60 + .../flow/ChildWorkflowFailedException.java | 51 + .../ChildWorkflowTerminatedException.java | 35 + .../flow/ChildWorkflowTimedOutException.java | 35 + .../simpleworkflow/flow/DataConverter.java | 49 + .../flow/DataConverterException.java | 51 + .../simpleworkflow/flow/DecisionContext.java | 35 + .../flow/DecisionContextProvider.java | 22 + .../flow/DecisionContextProviderImpl.java | 27 + .../flow/DecisionException.java | 48 + .../flow/DynamicActivitiesClient.java | 28 + .../flow/DynamicActivitiesClientImpl.java | 164 + .../simpleworkflow/flow/DynamicClient.java | 104 + .../flow/DynamicWorkflowClient.java | 30 + .../flow/DynamicWorkflowClientExternal.java | 28 + .../DynamicWorkflowClientExternalImpl.java | 183 + .../flow/DynamicWorkflowClientImpl.java | 282 ++ .../flow/JsonDataConverter.java | 107 + .../flow/ManualActivityCompletionClient.java | 31 + ...ManualActivityCompletionClientFactory.java | 23 + ...alActivityCompletionClientFactoryImpl.java | 57 + .../ManualActivityCompletionClientImpl.java | 79 + .../ScheduleActivityTaskFailedException.java | 52 + .../flow/SignalExternalWorkflowException.java | 59 + .../StartChildWorkflowFailedException.java | 51 + .../flow/StartTimerFailedException.java | 51 + .../flow/StartWorkflowOptions.java | 76 + .../simpleworkflow/flow/Suspendable.java | 23 + .../flow/SuspendableWorker.java | 20 + .../flow/SynchronousActivityWorker.java | 143 + .../flow/SynchronousWorkflowWorker.java | 109 + .../simpleworkflow/flow/TimerException.java | 57 + .../simpleworkflow/flow/WorkerBase.java | 77 + .../simpleworkflow/flow/WorkerLifecycle.java | 31 + .../simpleworkflow/flow/WorkflowClient.java | 38 + .../flow/WorkflowClientBase.java | 79 + .../flow/WorkflowClientExternal.java | 35 + .../flow/WorkflowClientExternalBase.java | 115 + .../flow/WorkflowClientFactory.java | 44 + .../flow/WorkflowClientFactoryBase.java | 124 + .../flow/WorkflowClientFactoryExternal.java | 41 + .../WorkflowClientFactoryExternalBase.java | 112 + .../simpleworkflow/flow/WorkflowClock.java | 60 + .../simpleworkflow/flow/WorkflowContext.java | 34 + .../flow/WorkflowException.java | 39 + .../flow/WorkflowExecutionLocal.java | 121 + .../simpleworkflow/flow/WorkflowReplayer.java | 333 ++ .../flow/WorkflowSelfClient.java | 33 + .../flow/WorkflowSelfClientBase.java | 78 + .../flow/WorkflowTypeRegistrationOptions.java | 86 + .../simpleworkflow/flow/WorkflowWorker.java | 242 ++ .../flow/annotations/Activities.java | 72 + .../flow/annotations/Activity.java | 49 + .../ActivityRegistrationOptions.java | 75 + .../flow/annotations/Asynchronous.java | 46 + .../flow/annotations/Execute.java | 50 + .../flow/annotations/ExponentialRetry.java | 81 + .../flow/annotations/GetState.java | 43 + .../annotations/ManualActivityCompletion.java | 38 + .../flow/annotations/NoWait.java | 48 + .../flow/annotations/NullDataConverter.java | 41 + .../flow/annotations/Signal.java | 46 + .../annotations/SkipTypeRegistration.java | 41 + .../simpleworkflow/flow/annotations/Wait.java | 36 + .../flow/annotations/Workflow.java | 68 + .../WorkflowRegistrationOptions.java | 76 + .../flow/aspectj/AsynchronousAspect.java | 110 + .../flow/aspectj/AsynchronousAspectTask.java | 55 + .../flow/aspectj/ExponentialRetryAspect.java | 79 + .../flow/common/FlowConstants.java | 36 + .../flow/common/FlowDefaults.java | 22 + .../flow/common/FlowHelpers.java | 55 + .../flow/common/FlowValueConstraint.java | 64 + .../flow/common/WorkflowExecutionUtils.java | 635 ++++ .../simpleworkflow/flow/core/AndPromise.java | 94 + .../flow/core/AsyncContextAware.java | 22 + .../flow/core/AsyncContextBase.java | 113 + .../flow/core/AsyncEventLoop.java | 50 + .../flow/core/AsyncParentContext.java | 48 + .../simpleworkflow/flow/core/AsyncScope.java | 92 + .../flow/core/AsyncScopeContext.java | 195 ++ .../flow/core/AsyncStackTrace.java | 144 + .../flow/core/AsyncTaskInfo.java | 118 + .../simpleworkflow/flow/core/Cancelable.java | 24 + .../flow/core/ExternalTask.java | 64 + .../core/ExternalTaskCancellationHandler.java | 29 + .../core/ExternalTaskCompletionHandle.java | 34 + .../flow/core/ExternalTaskContext.java | 238 ++ .../simpleworkflow/flow/core/Functor.java | 52 + .../simpleworkflow/flow/core/OrPromise.java | 74 + .../simpleworkflow/flow/core/Promise.java | 106 + .../simpleworkflow/flow/core/Promises.java | 86 + .../simpleworkflow/flow/core/Settable.java | 223 ++ .../simpleworkflow/flow/core/Task.java | 110 + .../simpleworkflow/flow/core/TaskContext.java | 138 + .../simpleworkflow/flow/core/TryCatch.java | 41 + .../flow/core/TryCatchFinally.java | 301 ++ .../flow/core/TryCatchFinallyContext.java | 302 ++ .../simpleworkflow/flow/core/TryFinally.java | 42 + .../flow/generic/ActivityImplementation.java | 67 + .../generic/ActivityImplementationBase.java | 79 + .../ActivityImplementationFactory.java | 25 + ...tinueAsNewWorkflowExecutionParameters.java | 172 + .../generic/ExecuteActivityParameters.java | 444 +++ .../flow/generic/GenericActivityClient.java | 54 + .../flow/generic/GenericWorkflowClient.java | 46 + .../GenericWorkflowClientExternal.java | 34 + .../SignalExternalWorkflowParameters.java | 104 + ...StartChildWorkflowExecutionParameters.java | 221 ++ .../flow/generic/StartChildWorkflowReply.java | 26 + .../StartWorkflowExecutionParameters.java | 406 +++ .../TerminateWorkflowExecutionParameters.java | 79 + .../flow/generic/WorkflowDefinition.java | 84 + .../generic/WorkflowDefinitionFactory.java | 37 + .../WorkflowDefinitionFactoryFactory.java | 32 + .../flow/interceptors/Decorator.java | 22 + .../interceptors/ExponentialRetryPolicy.java | 138 + .../flow/interceptors/RetryCallable.java | 21 + .../flow/interceptors/RetryDecorator.java | 100 + .../flow/interceptors/RetryInterceptor.java | 6 + .../interceptors/RetryInterceptorBase.java | 19 + .../interceptors/RetryInterceptorVoid.java | 96 + .../RetryInterceptorWithResult.java | 115 + .../flow/interceptors/RetryPolicy.java | 25 + .../flow/interceptors/RetryPolicyBase.java | 109 + .../flow/junit/AsyncAssert.java | 465 +++ .../junit/FlowBlockJUnit4ClassRunner.java | 72 + .../flow/junit/GenericWorkflowTest.java | 43 + .../flow/junit/WorkflowTest.java | 128 + .../flow/junit/WorkflowTestBase.java | 233 ++ .../flow/junit/WorkflowTestStatement.java | 185 + .../spring/FlowSpringJUnit4ClassRunner.java | 76 + ...owImplementationGenericWorkflowClient.java | 144 + .../flow/junit/spring/SpringWorkflowTest.java | 159 + .../flow/pojo/MethodConverterPair.java | 38 + .../flow/pojo/POJOActivityImplementation.java | 119 + .../POJOActivityImplementationFactory.java | 420 +++ .../flow/pojo/POJOWorkflowDefinition.java | 182 + .../pojo/POJOWorkflowDefinitionFactory.java | 81 + .../POJOWorkflowDefinitionFactoryFactory.java | 341 ++ .../POJOWorkflowImplementationFactory.java | 25 + .../flow/spring/SpringActivityWorker.java | 295 ++ ...pringWorkflowDefinitionFactoryFactory.java | 94 + .../flow/spring/SpringWorkflowWorker.java | 295 ++ .../flow/spring/WorkflowScope.java | 146 + .../flow/spring/WorkflowScopeBeanNames.java | 48 + .../flow/test/TestDecisionContext.java | 55 + .../flow/test/TestGenericActivityClient.java | 200 ++ .../flow/test/TestGenericWorkflowClient.java | 443 +++ ...tyImplementationGenericActivityClient.java | 47 + .../TestPOJOActivityImplementationWorker.java | 88 + ...owImplementationGenericWorkflowClient.java | 106 + .../flow/test/TestWorkflowClock.java | 178 + .../flow/test/TestWorkflowContext.java | 62 + .../worker/ActivityDecisionStateMachine.java | 94 + .../worker/ActivityExecutionContextImpl.java | 101 + .../flow/worker/ActivityTaskPoller.java | 142 + .../worker/ActivityTypeExecutionOptions.java | 77 + .../ActivityTypeRegistrationOptions.java | 90 + .../flow/worker/AsyncDecider.java | 569 ++++ .../flow/worker/AsyncDecisionTaskHandler.java | 114 + .../flow/worker/BackoffThrottler.java | 102 + .../flow/worker/BlockCallerPolicy.java | 34 + .../ChildWorkflowDecisionStateMachine.java | 136 + .../flow/worker/CircularLongBuffer.java | 70 + .../worker/CompleteWorkflowStateMachine.java | 103 + .../CurrentActivityExecutionContext.java | 61 + .../flow/worker/CurrentDecisionContext.java | 66 + .../flow/worker/DecisionContextImpl.java | 62 + .../flow/worker/DecisionId.java | 62 + .../flow/worker/DecisionState.java | 39 + .../flow/worker/DecisionStateMachine.java | 51 + .../flow/worker/DecisionStateMachineBase.java | 196 ++ .../flow/worker/DecisionTarget.java | 23 + .../flow/worker/DecisionTaskHandler.java | 62 + .../flow/worker/DecisionTaskPoller.java | 270 ++ .../flow/worker/DecisionsHelper.java | 549 +++ .../worker/ExponentialRetryParameters.java | 122 + .../worker/GenericActivityClientImpl.java | 216 ++ .../flow/worker/GenericActivityWorker.java | 164 + .../flow/worker/GenericWorker.java | 508 +++ .../GenericWorkflowClientExternalImpl.java | 119 + .../worker/GenericWorkflowClientImpl.java | 403 +++ .../flow/worker/GenericWorkflowWorker.java | 145 + .../flow/worker/HistoryHelper.java | 139 + .../flow/worker/OpenRequestInfo.java | 56 + .../worker/SignalDecisionStateMachine.java | 158 + ...impleWorkflowDefinitionFactoryFactory.java | 62 + .../worker/SynchronousActivityTaskPoller.java | 312 ++ .../flow/worker/SynchronousRetrier.java | 89 + .../flow/worker/TaskPoller.java | 30 + .../simpleworkflow/flow/worker/Throttler.java | 134 + .../worker/TimerDecisionStateMachine.java | 119 + .../flow/worker/WorkflowClockImpl.java | 178 + .../flow/worker/WorkfowContextImpl.java | 63 + .../simpleworkflow/model/ActivityTask.java | 389 +++ ...ityTaskCancelRequestedEventAttributes.java | 187 + .../ActivityTaskCanceledEventAttributes.java | 307 ++ .../ActivityTaskCompletedEventAttributes.java | 243 ++ .../ActivityTaskFailedEventAttributes.java | 298 ++ .../ActivityTaskScheduledEventAttributes.java | 644 ++++ .../ActivityTaskStartedEventAttributes.java | 193 ++ .../model/ActivityTaskStatus.java | 112 + .../ActivityTaskTimedOutEventAttributes.java | 352 ++ .../model/ActivityTaskTimeoutType.java | 62 + .../simpleworkflow/model/ActivityType.java | 184 + .../model/ActivityTypeConfiguration.java | 575 ++++ .../model/ActivityTypeDetail.java | 195 ++ .../model/ActivityTypeInfo.java | 360 ++ .../model/ActivityTypeInfos.java | 207 ++ .../model/CancelTimerDecisionAttributes.java | 115 + .../model/CancelTimerFailedCause.java | 53 + .../CancelTimerFailedEventAttributes.java | 292 ++ ...elWorkflowExecutionDecisionAttributes.java | 116 + .../CancelWorkflowExecutionFailedCause.java | 53 + ...orkflowExecutionFailedEventAttributes.java | 238 ++ .../simpleworkflow/model/ChildPolicy.java | 59 + ...kflowExecutionCanceledEventAttributes.java | 337 ++ ...flowExecutionCompletedEventAttributes.java | 337 ++ ...orkflowExecutionFailedEventAttributes.java | 392 +++ ...rkflowExecutionStartedEventAttributes.java | 218 ++ ...lowExecutionTerminatedEventAttributes.java | 282 ++ ...kflowExecutionTimedOutEventAttributes.java | 388 +++ .../simpleworkflow/model/CloseStatus.java | 68 + .../model/CloseStatusFilter.java | 167 + ...teWorkflowExecutionDecisionAttributes.java | 123 + .../CompleteWorkflowExecutionFailedCause.java | 53 + ...orkflowExecutionFailedEventAttributes.java | 238 ++ ...ewWorkflowExecutionDecisionAttributes.java | 856 +++++ ...inueAsNewWorkflowExecutionFailedCause.java | 68 + ...orkflowExecutionFailedEventAttributes.java | 238 ++ .../CountClosedWorkflowExecutionsRequest.java | 543 +++ .../CountOpenWorkflowExecutionsRequest.java | 373 ++ .../CountPendingActivityTasksRequest.java | 165 + .../CountPendingDecisionTasksRequest.java | 165 + .../simpleworkflow/model/Decision.java | 903 +++++ .../simpleworkflow/model/DecisionTask.java | 493 +++ .../DecisionTaskCompletedEventAttributes.java | 243 ++ .../DecisionTaskScheduledEventAttributes.java | 186 + .../DecisionTaskStartedEventAttributes.java | 193 ++ .../DecisionTaskTimedOutEventAttributes.java | 294 ++ .../model/DecisionTaskTimeoutType.java | 53 + .../simpleworkflow/model/DecisionType.java | 86 + .../model/DefaultUndefinedException.java | 36 + .../model/DeprecateActivityTypeRequest.java | 169 + .../model/DeprecateDomainRequest.java | 128 + .../model/DeprecateWorkflowTypeRequest.java | 170 + .../model/DescribeActivityTypeRequest.java | 164 + .../model/DescribeDomainRequest.java | 120 + .../DescribeWorkflowExecutionRequest.java | 167 + .../model/DescribeWorkflowTypeRequest.java | 164 + .../model/DomainAlreadyExistsException.java | 39 + .../model/DomainConfiguration.java | 115 + .../model/DomainDeprecatedException.java | 38 + .../simpleworkflow/model/DomainDetail.java | 146 + .../simpleworkflow/model/DomainInfo.java | 320 ++ .../simpleworkflow/model/DomainInfos.java | 207 ++ .../simpleworkflow/model/EventType.java | 188 + .../simpleworkflow/model/ExecutionStatus.java | 56 + .../model/ExecutionTimeFilter.java | 148 + ...ecutionCancelRequestedEventAttributes.java | 196 ++ ...kflowExecutionSignaledEventAttributes.java | 175 + ...ilWorkflowExecutionDecisionAttributes.java | 170 + .../FailWorkflowExecutionFailedCause.java | 53 + ...orkflowExecutionFailedEventAttributes.java | 238 ++ .../GetWorkflowExecutionHistoryRequest.java | 398 +++ .../simpleworkflow/model/History.java | 210 ++ .../simpleworkflow/model/HistoryEvent.java | 3024 +++++++++++++++++ .../model/LimitExceededException.java | 40 + .../model/ListActivityTypesRequest.java | 503 +++ .../ListClosedWorkflowExecutionsRequest.java | 802 +++++ .../model/ListDomainsRequest.java | 387 +++ .../ListOpenWorkflowExecutionsRequest.java | 604 ++++ .../model/ListWorkflowTypesRequest.java | 500 +++ .../model/MarkerRecordedEventAttributes.java | 234 ++ .../model/OperationNotPermittedException.java | 39 + .../model/PendingTaskCount.java | 185 + .../model/PollForActivityTaskRequest.java | 280 ++ .../model/PollForDecisionTaskRequest.java | 557 +++ .../model/PredefinedDuration.java | 8 + .../RecordActivityTaskHeartbeatRequest.java | 240 ++ .../model/RecordMarkerDecisionAttributes.java | 170 + .../model/RegisterActivityTypeRequest.java | 862 +++++ .../model/RegisterDomainRequest.java | 320 ++ .../model/RegisterWorkflowTypeRequest.java | 892 +++++ .../model/RegistrationStatus.java | 56 + ...tCancelActivityTaskDecisionAttributes.java | 116 + .../RequestCancelActivityTaskFailedCause.java | 53 + ...ncelActivityTaskFailedEventAttributes.java | 300 ++ ...alWorkflowExecutionDecisionAttributes.java | 240 ++ ...lExternalWorkflowExecutionFailedCause.java | 56 + ...orkflowExecutionFailedEventAttributes.java | 489 +++ ...flowExecutionInitiatedEventAttributes.java | 318 ++ ...RequestCancelWorkflowExecutionRequest.java | 245 ++ .../RespondActivityTaskCanceledRequest.java | 214 ++ .../RespondActivityTaskCompletedRequest.java | 222 ++ .../RespondActivityTaskFailedRequest.java | 263 ++ .../RespondDecisionTaskCompletedRequest.java | 307 ++ .../services/simpleworkflow/model/Run.java | 129 + ...cheduleActivityTaskDecisionAttributes.java | 902 +++++ .../ScheduleActivityTaskFailedCause.java | 80 + ...duleActivityTaskFailedEventAttributes.java | 343 ++ ...alWorkflowExecutionDecisionAttributes.java | 364 ++ ...lExternalWorkflowExecutionFailedCause.java | 56 + ...orkflowExecutionFailedEventAttributes.java | 482 +++ ...flowExecutionInitiatedEventAttributes.java | 421 +++ .../model/SignalWorkflowExecutionRequest.java | 366 ++ ...ldWorkflowExecutionDecisionAttributes.java | 1083 ++++++ ...tartChildWorkflowExecutionFailedCause.java | 80 + ...orkflowExecutionFailedEventAttributes.java | 463 +++ ...flowExecutionInitiatedEventAttributes.java | 868 +++++ .../model/StartTimerDecisionAttributes.java | 274 ++ .../model/StartTimerFailedCause.java | 59 + .../StartTimerFailedEventAttributes.java | 292 ++ .../model/StartWorkflowExecutionRequest.java | 1128 ++++++ .../simpleworkflow/model/TagFilter.java | 123 + .../simpleworkflow/model/TaskList.java | 115 + .../TerminateWorkflowExecutionRequest.java | 606 ++++ .../model/TimerCanceledEventAttributes.java | 236 ++ .../model/TimerFiredEventAttributes.java | 172 + .../model/TimerStartedEventAttributes.java | 310 ++ .../model/TypeAlreadyExistsException.java | 41 + .../model/TypeDeprecatedException.java | 39 + .../model/UnknownResourceException.java | 41 + .../model/WorkflowExecution.java | 170 + ...kflowExecutionAlreadyStartedException.java | 39 + ...WorkflowExecutionCancelRequestedCause.java | 53 + ...ecutionCancelRequestedEventAttributes.java | 331 ++ ...kflowExecutionCanceledEventAttributes.java | 186 + ...flowExecutionCompletedEventAttributes.java | 194 ++ .../model/WorkflowExecutionConfiguration.java | 477 +++ ...xecutionContinuedAsNewEventAttributes.java | 785 +++++ .../model/WorkflowExecutionCount.java | 186 + .../model/WorkflowExecutionDetail.java | 343 ++ ...orkflowExecutionFailedEventAttributes.java | 241 ++ .../model/WorkflowExecutionFilter.java | 117 + .../model/WorkflowExecutionInfo.java | 761 +++++ .../model/WorkflowExecutionInfos.java | 207 ++ .../model/WorkflowExecutionOpenCounts.java | 295 ++ ...kflowExecutionSignaledEventAttributes.java | 319 ++ ...rkflowExecutionStartedEventAttributes.java | 878 +++++ .../WorkflowExecutionTerminatedCause.java | 59 + ...lowExecutionTerminatedEventAttributes.java | 482 +++ ...kflowExecutionTimedOutEventAttributes.java | 338 ++ .../model/WorkflowExecutionTimeoutType.java | 53 + .../simpleworkflow/model/WorkflowType.java | 198 ++ .../model/WorkflowTypeConfiguration.java | 605 ++++ .../model/WorkflowTypeDetail.java | 202 ++ .../model/WorkflowTypeFilter.java | 172 + .../model/WorkflowTypeInfo.java | 353 ++ .../model/WorkflowTypeInfos.java | 215 ++ .../simpleworkflow/model/package-info.java | 6 + ...uestedEventAttributesJsonUnmarshaller.java | 70 + ...nceledEventAttributesJsonUnmarshaller.java | 78 + ...pletedEventAttributesJsonUnmarshaller.java | 74 + ...FailedEventAttributesJsonUnmarshaller.java | 78 + .../ActivityTaskJsonUnmarshaller.java | 86 + ...eduledEventAttributesJsonUnmarshaller.java | 102 + ...tartedEventAttributesJsonUnmarshaller.java | 70 + .../ActivityTaskStatusJsonUnmarshaller.java | 66 + ...medOutEventAttributesJsonUnmarshaller.java | 78 + ...vityTypeConfigurationJsonUnmarshaller.java | 82 + .../ActivityTypeDetailJsonUnmarshaller.java | 70 + .../ActivityTypeInfoJsonUnmarshaller.java | 82 + .../ActivityTypeInfosJsonUnmarshaller.java | 69 + .../ActivityTypeJsonUnmarshaller.java | 70 + ...FailedEventAttributesJsonUnmarshaller.java | 74 + ...FailedEventAttributesJsonUnmarshaller.java | 70 + ...nceledEventAttributesJsonUnmarshaller.java | 82 + ...pletedEventAttributesJsonUnmarshaller.java | 82 + ...FailedEventAttributesJsonUnmarshaller.java | 86 + ...tartedEventAttributesJsonUnmarshaller.java | 74 + ...inatedEventAttributesJsonUnmarshaller.java | 78 + ...medOutEventAttributesJsonUnmarshaller.java | 82 + ...FailedEventAttributesJsonUnmarshaller.java | 70 + ...FailedEventAttributesJsonUnmarshaller.java | 70 + ...edWorkflowExecutionsRequestMarshaller.java | 142 + ...enWorkflowExecutionsRequestMarshaller.java | 119 + ...PendingActivityTasksRequestMarshaller.java | 83 + ...PendingDecisionTasksRequestMarshaller.java | 83 + ...pletedEventAttributesJsonUnmarshaller.java | 74 + .../DecisionTaskJsonUnmarshaller.java | 89 + ...eduledEventAttributesJsonUnmarshaller.java | 70 + ...tartedEventAttributesJsonUnmarshaller.java | 70 + ...medOutEventAttributesJsonUnmarshaller.java | 74 + ...DefaultUndefinedExceptionUnmarshaller.java | 43 + ...eprecateActivityTypeRequestMarshaller.java | 86 + .../DeprecateDomainRequestMarshaller.java | 73 + ...eprecateWorkflowTypeRequestMarshaller.java | 86 + ...DescribeActivityTypeRequestMarshaller.java | 86 + .../DescribeDomainRequestMarshaller.java | 73 + ...ibeWorkflowExecutionRequestMarshaller.java | 86 + ...DescribeWorkflowTypeRequestMarshaller.java | 86 + ...ainAlreadyExistsExceptionUnmarshaller.java | 43 + .../DomainConfigurationJsonUnmarshaller.java | 66 + ...DomainDeprecatedExceptionUnmarshaller.java | 43 + .../DomainDetailJsonUnmarshaller.java | 70 + .../transform/DomainInfoJsonUnmarshaller.java | 74 + .../DomainInfosJsonUnmarshaller.java | 69 + ...uestedEventAttributesJsonUnmarshaller.java | 70 + ...gnaledEventAttributesJsonUnmarshaller.java | 70 + ...FailedEventAttributesJsonUnmarshaller.java | 70 + ...flowExecutionHistoryRequestMarshaller.java | 95 + .../HistoryEventJsonUnmarshaller.java | 258 ++ .../transform/HistoryJsonUnmarshaller.java | 69 + .../LimitExceededExceptionUnmarshaller.java | 43 + .../ListActivityTypesRequestMarshaller.java | 88 + ...edWorkflowExecutionsRequestMarshaller.java | 151 + .../ListDomainsRequestMarshaller.java | 82 + ...enWorkflowExecutionsRequestMarshaller.java | 128 + .../ListWorkflowTypesRequestMarshaller.java | 88 + ...cordedEventAttributesJsonUnmarshaller.java | 74 + ...tionNotPermittedExceptionUnmarshaller.java | 43 + .../PendingTaskCountJsonUnmarshaller.java | 70 + .../PollForActivityTaskRequestMarshaller.java | 86 + .../PollForDecisionTaskRequestMarshaller.java | 95 + ...ctivityTaskHeartbeatRequestMarshaller.java | 76 + ...RegisterActivityTypeRequestMarshaller.java | 104 + .../RegisterDomainRequestMarshaller.java | 79 + ...RegisterWorkflowTypeRequestMarshaller.java | 101 + ...FailedEventAttributesJsonUnmarshaller.java | 74 + ...FailedEventAttributesJsonUnmarshaller.java | 86 + ...tiatedEventAttributesJsonUnmarshaller.java | 78 + ...celWorkflowExecutionRequestMarshaller.java | 79 + ...ActivityTaskCanceledRequestMarshaller.java | 76 + ...ctivityTaskCompletedRequestMarshaller.java | 76 + ...ndActivityTaskFailedRequestMarshaller.java | 79 + ...ecisionTaskCompletedRequestMarshaller.java | 376 ++ .../model/transform/RunJsonUnmarshaller.java | 66 + ...FailedEventAttributesJsonUnmarshaller.java | 78 + ...FailedEventAttributesJsonUnmarshaller.java | 86 + ...tiatedEventAttributesJsonUnmarshaller.java | 86 + ...nalWorkflowExecutionRequestMarshaller.java | 85 + ...FailedEventAttributesJsonUnmarshaller.java | 86 + ...tiatedEventAttributesJsonUnmarshaller.java | 101 + ...FailedEventAttributesJsonUnmarshaller.java | 74 + ...artWorkflowExecutionRequestMarshaller.java | 125 + .../transform/TaskListJsonUnmarshaller.java | 66 + ...ateWorkflowExecutionRequestMarshaller.java | 88 + ...nceledEventAttributesJsonUnmarshaller.java | 74 + ...rFiredEventAttributesJsonUnmarshaller.java | 70 + ...tartedEventAttributesJsonUnmarshaller.java | 78 + ...ypeAlreadyExistsExceptionUnmarshaller.java | 43 + .../TypeDeprecatedExceptionUnmarshaller.java | 43 + .../UnknownResourceExceptionUnmarshaller.java | 43 + ...onAlreadyStartedExceptionUnmarshaller.java | 43 + ...uestedEventAttributesJsonUnmarshaller.java | 74 + ...nceledEventAttributesJsonUnmarshaller.java | 70 + ...pletedEventAttributesJsonUnmarshaller.java | 70 + ...xecutionConfigurationJsonUnmarshaller.java | 78 + ...dAsNewEventAttributesJsonUnmarshaller.java | 97 + ...orkflowExecutionCountJsonUnmarshaller.java | 70 + ...rkflowExecutionDetailJsonUnmarshaller.java | 82 + ...FailedEventAttributesJsonUnmarshaller.java | 74 + ...WorkflowExecutionInfoJsonUnmarshaller.java | 97 + ...orkflowExecutionInfosJsonUnmarshaller.java | 69 + .../WorkflowExecutionJsonUnmarshaller.java | 70 + ...owExecutionOpenCountsJsonUnmarshaller.java | 78 + ...gnaledEventAttributesJsonUnmarshaller.java | 78 + ...tartedEventAttributesJsonUnmarshaller.java | 101 + ...inatedEventAttributesJsonUnmarshaller.java | 78 + ...medOutEventAttributesJsonUnmarshaller.java | 70 + ...flowTypeConfigurationJsonUnmarshaller.java | 78 + .../WorkflowTypeDetailJsonUnmarshaller.java | 70 + .../WorkflowTypeInfoJsonUnmarshaller.java | 82 + .../WorkflowTypeInfosJsonUnmarshaller.java | 69 + .../WorkflowTypeJsonUnmarshaller.java | 70 + .../model/transform/package-info.java | 6 + .../services/simpleworkflow/package-info.java | 310 ++ .../transform/JsonUnmarshallerContext.java | 62 +- .../amazonaws/transform/MapUnmarshaller.java | 3 +- .../com/amazonaws/sdk/versionInfo.properties | 2 +- src/samples/AwsFlowFramework/README.html | 200 ++ .../AwsFlowFramework/access.properties | 44 + src/samples/AwsFlowFramework/build.xml | 69 + src/samples/AwsFlowFramework/log4j.properties | 9 + .../AwsFlowFramework/src/META-INF/aop.xml | 13 + .../flow/examples/booking/ActivityHost.java | 121 + .../examples/booking/BookingActivities.java | 35 + .../booking/BookingActivitiesImpl.java | 33 + .../examples/booking/BookingConfigKeys.java | 24 + .../examples/booking/BookingWorkflow.java | 28 + .../examples/booking/BookingWorkflowImpl.java | 37 + .../examples/booking/BookingWorklfowTest.java | 112 + .../booking/WorkflowExecutionStarter.java | 43 + .../flow/examples/booking/WorkflowHost.java | 105 + .../flow/examples/common/ConfigHelper.java | 135 + .../flow/examples/common/ConfigKeys.java | 29 + .../examples/common/RegistrationDefaults.java | 32 + .../flow/examples/common/SampleConstants.java | 23 + .../WorkflowExecutionFlowThreadDumper.java | 62 + .../common/WorkflowExecutionGetState.java | 53 + .../WorkflowExecutionHistoryPrinter.java | 46 + .../common/WorkflowExecutionReplayer.java | 58 + .../flow/examples/deployment/AppServer.java | 62 + .../flow/examples/deployment/AppStack1.xml | 135 + .../examples/deployment/ApplicationStack.java | 56 + .../flow/examples/deployment/Database.java | 35 + .../flow/examples/deployment/Deployable.java | 38 + .../examples/deployment/DeployableBase.java | 73 + .../deployment/DeploymentActivities.java | 56 + .../deployment/DeploymentActivitiesImpl.java | 41 + .../deployment/DeploymentCommon-context.xml | 42 + .../deployment/DeploymentHost-context.xml | 55 + .../examples/deployment/DeploymentHost.java | 30 + .../DeploymentInitiator-context.xml | 19 + .../deployment/DeploymentInitiator.java | 67 + .../deployment/DeploymentTest-context.xml | 89 + .../examples/deployment/DeploymentTest.java | 128 + .../deployment/DeploymentWorkflow.java | 33 + .../deployment/DeploymentWorkflowImpl.java | 42 + .../examples/deployment/LoadBalancer.java | 61 + .../flow/examples/deployment/WebServer.java | 83 + .../examples/fileprocessing/ActivityHost.java | 95 + .../FileProcessingActivities.java | 29 + .../FileProcessingActivitiesZipImpl.java | 78 + .../FileProcessingConfigKeys.java | 29 + .../FileProcessingWorkflow.java | 38 + .../FileProcessingWorkflowZipImpl.java | 131 + .../fileprocessing/SimpleStoreActivities.java | 60 + .../SimpleStoreActivitiesS3Impl.java | 173 + .../WorkflowExecutionStarter.java | 55 + .../examples/fileprocessing/WorkflowHost.java | 70 + .../examples/helloworld/ActivityHost.java | 71 + .../helloworld/HelloWorldActivities.java | 31 + .../helloworld/HelloWorldActivitiesImpl.java | 27 + .../examples/helloworld/HelloWorldTest.java | 114 + .../helloworld/HelloWorldWorkflow.java | 31 + .../helloworld/HelloWorldWorkflowImpl.java | 30 + .../helloworld/WorkflowExecutionStarter.java | 41 + .../examples/helloworld/WorkflowHost.java | 65 + .../periodicworkflow/ActivityHost.java | 73 + .../ErrorReportingActivities.java | 28 + .../ErrorReportingActivitiesImpl.java | 42 + .../periodicworkflow/PeriodicWorkflow.java | 37 + .../PeriodicWorkflowActivities.java | 28 + .../PeriodicWorkflowActivitiesImpl.java | 54 + .../PeriodicWorkflowImpl.java | 135 + .../PeriodicWorkflowOptions.java | 74 + .../PeriodicWorkflowTest.java | 154 + .../WorkflowExecutionStarter.java | 75 + .../periodicworkflow/WorkflowHost.java | 64 + .../examples/splitmerge/ActivityHost.java | 73 + .../AverageCalculatorActivities.java | 36 + .../AverageCalculatorActivitiesImpl.java | 90 + .../splitmerge/AverageCalculatorWorkflow.java | 29 + .../AverageCalculatorWorkflowImpl.java | 28 + .../PartitionedAverageCalculator.java | 25 + .../PartitionedAverageCalculatorImpl.java | 72 + .../splitmerge/SplitMergeConfigKeys.java | 23 + .../splitmerge/WorkflowExecutionStarter.java | 51 + .../examples/splitmerge/WorkflowHost.java | 66 + 600 files changed, 90704 insertions(+), 556 deletions(-) create mode 100644 src/main/java/com/amazonaws/services/dynamodb/datamodeling/PaginatedList.java rename src/main/java/com/amazonaws/services/dynamodb/datamodeling/{internal => }/PaginatedQueryList.java (65%) rename src/main/java/com/amazonaws/services/dynamodb/datamodeling/{internal => }/PaginatedScanList.java (66%) delete mode 100644 src/main/java/com/amazonaws/services/dynamodb/datamodeling/internal/PaginatedList.java delete mode 100644 src/main/java/com/amazonaws/services/dynamodb/datamodeling/internal/UnmodifiableIterator.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/AmazonSimpleWorkflow.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/AmazonSimpleWorkflowAsync.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/AmazonSimpleWorkflowAsyncClient.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/AmazonSimpleWorkflowClient.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivitiesClient.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivitiesClientBase.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityExecutionContext.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityExecutionContextProvider.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityExecutionContextProviderImpl.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityFailureException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivitySchedulingOptions.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityTaskException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityTaskFailedException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityTaskTimedOutException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityWorker.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/ChildWorkflowException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/ChildWorkflowFailedException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/ChildWorkflowTerminatedException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/ChildWorkflowTimedOutException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/DataConverter.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/DataConverterException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/DecisionContext.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/DecisionContextProvider.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/DecisionContextProviderImpl.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/DecisionException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicActivitiesClient.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicActivitiesClientImpl.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicClient.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicWorkflowClient.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicWorkflowClientExternal.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicWorkflowClientExternalImpl.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicWorkflowClientImpl.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/JsonDataConverter.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/ManualActivityCompletionClient.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/ManualActivityCompletionClientFactory.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/ManualActivityCompletionClientFactoryImpl.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/ManualActivityCompletionClientImpl.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/ScheduleActivityTaskFailedException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/SignalExternalWorkflowException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/StartChildWorkflowFailedException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/StartTimerFailedException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/StartWorkflowOptions.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/Suspendable.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/SuspendableWorker.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/SynchronousActivityWorker.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/SynchronousWorkflowWorker.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/TimerException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkerBase.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkerLifecycle.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClient.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientBase.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientExternal.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientExternalBase.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientFactory.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientFactoryBase.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientFactoryExternal.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientFactoryExternalBase.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClock.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowContext.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowExecutionLocal.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowReplayer.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowSelfClient.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowSelfClientBase.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowTypeRegistrationOptions.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowWorker.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Activities.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Activity.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/ActivityRegistrationOptions.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Asynchronous.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Execute.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/ExponentialRetry.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/GetState.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/ManualActivityCompletion.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/NoWait.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/NullDataConverter.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Signal.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/SkipTypeRegistration.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Wait.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Workflow.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/WorkflowRegistrationOptions.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/AsynchronousAspect.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/AsynchronousAspectTask.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/ExponentialRetryAspect.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowConstants.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowDefaults.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowHelpers.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowValueConstraint.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/common/WorkflowExecutionUtils.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AndPromise.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncContextAware.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncContextBase.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncEventLoop.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncParentContext.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncScope.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncScopeContext.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncStackTrace.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncTaskInfo.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Cancelable.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/ExternalTask.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/ExternalTaskCancellationHandler.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/ExternalTaskCompletionHandle.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/ExternalTaskContext.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Functor.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/OrPromise.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Promise.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Promises.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Settable.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Task.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/TaskContext.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/TryCatch.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/TryCatchFinally.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/TryCatchFinallyContext.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/core/TryFinally.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/ActivityImplementation.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/ActivityImplementationBase.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/ActivityImplementationFactory.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/ContinueAsNewWorkflowExecutionParameters.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/ExecuteActivityParameters.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/GenericActivityClient.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/GenericWorkflowClient.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/GenericWorkflowClientExternal.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/SignalExternalWorkflowParameters.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/StartChildWorkflowExecutionParameters.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/StartChildWorkflowReply.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/StartWorkflowExecutionParameters.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/TerminateWorkflowExecutionParameters.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/WorkflowDefinition.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/WorkflowDefinitionFactory.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/WorkflowDefinitionFactoryFactory.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/Decorator.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/ExponentialRetryPolicy.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryCallable.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryDecorator.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryInterceptor.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryInterceptorBase.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryInterceptorVoid.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryInterceptorWithResult.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryPolicy.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryPolicyBase.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/AsyncAssert.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/FlowBlockJUnit4ClassRunner.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/GenericWorkflowTest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/WorkflowTest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/WorkflowTestBase.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/WorkflowTestStatement.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/spring/FlowSpringJUnit4ClassRunner.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/spring/SpringTestPOJOWorkflowImplementationGenericWorkflowClient.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/spring/SpringWorkflowTest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/MethodConverterPair.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOActivityImplementation.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOActivityImplementationFactory.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOWorkflowDefinition.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOWorkflowDefinitionFactory.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOWorkflowDefinitionFactoryFactory.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOWorkflowImplementationFactory.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/SpringActivityWorker.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/SpringWorkflowDefinitionFactoryFactory.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/SpringWorkflowWorker.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/WorkflowScope.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/WorkflowScopeBeanNames.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestDecisionContext.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestGenericActivityClient.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestGenericWorkflowClient.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestPOJOActivityImplementationGenericActivityClient.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestPOJOActivityImplementationWorker.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestPOJOWorkflowImplementationGenericWorkflowClient.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestWorkflowClock.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestWorkflowContext.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityDecisionStateMachine.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityExecutionContextImpl.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityTaskPoller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityTypeExecutionOptions.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityTypeRegistrationOptions.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/AsyncDecider.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/AsyncDecisionTaskHandler.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/BackoffThrottler.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/BlockCallerPolicy.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ChildWorkflowDecisionStateMachine.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/CircularLongBuffer.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/CompleteWorkflowStateMachine.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/CurrentActivityExecutionContext.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/CurrentDecisionContext.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionContextImpl.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionId.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionState.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionStateMachine.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionStateMachineBase.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionTarget.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionTaskHandler.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionTaskPoller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionsHelper.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ExponentialRetryParameters.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericActivityClientImpl.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericActivityWorker.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericWorker.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericWorkflowClientExternalImpl.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericWorkflowClientImpl.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericWorkflowWorker.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/HistoryHelper.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/OpenRequestInfo.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SignalDecisionStateMachine.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SimpleWorkflowDefinitionFactoryFactory.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SynchronousActivityTaskPoller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SynchronousRetrier.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/TaskPoller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/Throttler.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/TimerDecisionStateMachine.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/WorkflowClockImpl.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/WorkfowContextImpl.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTask.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskCancelRequestedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskCanceledEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskCompletedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskFailedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskScheduledEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskStartedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskStatus.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskTimedOutEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskTimeoutType.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityType.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTypeConfiguration.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTypeDetail.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTypeInfo.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTypeInfos.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/CancelTimerDecisionAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/CancelTimerFailedCause.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/CancelTimerFailedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/CancelWorkflowExecutionDecisionAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/CancelWorkflowExecutionFailedCause.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/CancelWorkflowExecutionFailedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ChildPolicy.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionCanceledEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionCompletedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionFailedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionStartedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionTerminatedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionTimedOutEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/CloseStatus.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/CloseStatusFilter.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/CompleteWorkflowExecutionDecisionAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/CompleteWorkflowExecutionFailedCause.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/CompleteWorkflowExecutionFailedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ContinueAsNewWorkflowExecutionDecisionAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ContinueAsNewWorkflowExecutionFailedCause.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ContinueAsNewWorkflowExecutionFailedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/CountClosedWorkflowExecutionsRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/CountOpenWorkflowExecutionsRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/CountPendingActivityTasksRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/CountPendingDecisionTasksRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/Decision.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTask.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTaskCompletedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTaskScheduledEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTaskStartedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTaskTimedOutEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTaskTimeoutType.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionType.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DefaultUndefinedException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DeprecateActivityTypeRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DeprecateDomainRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DeprecateWorkflowTypeRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DescribeActivityTypeRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DescribeDomainRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DescribeWorkflowExecutionRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DescribeWorkflowTypeRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DomainAlreadyExistsException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DomainConfiguration.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DomainDeprecatedException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DomainDetail.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DomainInfo.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/DomainInfos.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/EventType.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ExecutionStatus.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ExecutionTimeFilter.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ExternalWorkflowExecutionCancelRequestedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ExternalWorkflowExecutionSignaledEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/FailWorkflowExecutionDecisionAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/FailWorkflowExecutionFailedCause.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/FailWorkflowExecutionFailedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/GetWorkflowExecutionHistoryRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/History.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/HistoryEvent.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/LimitExceededException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ListActivityTypesRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ListClosedWorkflowExecutionsRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ListDomainsRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ListOpenWorkflowExecutionsRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ListWorkflowTypesRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/MarkerRecordedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/OperationNotPermittedException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/PendingTaskCount.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/PollForActivityTaskRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/PollForDecisionTaskRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/PredefinedDuration.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/RecordActivityTaskHeartbeatRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/RecordMarkerDecisionAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/RegisterActivityTypeRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/RegisterDomainRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/RegisterWorkflowTypeRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/RegistrationStatus.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelActivityTaskDecisionAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelActivityTaskFailedCause.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelActivityTaskFailedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelExternalWorkflowExecutionDecisionAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelExternalWorkflowExecutionFailedCause.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelExternalWorkflowExecutionFailedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelExternalWorkflowExecutionInitiatedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelWorkflowExecutionRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/RespondActivityTaskCanceledRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/RespondActivityTaskCompletedRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/RespondActivityTaskFailedRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/RespondDecisionTaskCompletedRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/Run.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ScheduleActivityTaskDecisionAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ScheduleActivityTaskFailedCause.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/ScheduleActivityTaskFailedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/SignalExternalWorkflowExecutionDecisionAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/SignalExternalWorkflowExecutionFailedCause.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/SignalExternalWorkflowExecutionFailedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/SignalExternalWorkflowExecutionInitiatedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/SignalWorkflowExecutionRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/StartChildWorkflowExecutionDecisionAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/StartChildWorkflowExecutionFailedCause.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/StartChildWorkflowExecutionFailedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/StartChildWorkflowExecutionInitiatedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/StartTimerDecisionAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/StartTimerFailedCause.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/StartTimerFailedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/StartWorkflowExecutionRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/TagFilter.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/TaskList.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/TerminateWorkflowExecutionRequest.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/TimerCanceledEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/TimerFiredEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/TimerStartedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/TypeAlreadyExistsException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/TypeDeprecatedException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/UnknownResourceException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecution.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionAlreadyStartedException.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionCancelRequestedCause.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionCancelRequestedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionCanceledEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionCompletedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionConfiguration.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionContinuedAsNewEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionCount.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionDetail.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionFailedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionFilter.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionInfo.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionInfos.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionOpenCounts.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionSignaledEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionStartedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionTerminatedCause.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionTerminatedEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionTimedOutEventAttributes.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionTimeoutType.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowType.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowTypeConfiguration.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowTypeDetail.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowTypeFilter.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowTypeInfo.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowTypeInfos.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/package-info.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskCancelRequestedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskCanceledEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskCompletedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskFailedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskScheduledEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskStartedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskStatusJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskTimedOutEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTypeConfigurationJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTypeDetailJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTypeInfoJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTypeInfosJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTypeJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CancelTimerFailedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CancelWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionCanceledEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionCompletedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionStartedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionTerminatedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionTimedOutEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CompleteWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ContinueAsNewWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CountClosedWorkflowExecutionsRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CountOpenWorkflowExecutionsRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CountPendingActivityTasksRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CountPendingDecisionTasksRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DecisionTaskCompletedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DecisionTaskJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DecisionTaskScheduledEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DecisionTaskStartedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DecisionTaskTimedOutEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DefaultUndefinedExceptionUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DeprecateActivityTypeRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DeprecateDomainRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DeprecateWorkflowTypeRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DescribeActivityTypeRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DescribeDomainRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DescribeWorkflowExecutionRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DescribeWorkflowTypeRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainAlreadyExistsExceptionUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainConfigurationJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainDeprecatedExceptionUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainDetailJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainInfoJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainInfosJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ExternalWorkflowExecutionCancelRequestedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ExternalWorkflowExecutionSignaledEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/FailWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/GetWorkflowExecutionHistoryRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/HistoryEventJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/HistoryJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/LimitExceededExceptionUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ListActivityTypesRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ListClosedWorkflowExecutionsRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ListDomainsRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ListOpenWorkflowExecutionsRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ListWorkflowTypesRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/MarkerRecordedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/OperationNotPermittedExceptionUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/PendingTaskCountJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/PollForActivityTaskRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/PollForDecisionTaskRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RecordActivityTaskHeartbeatRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RegisterActivityTypeRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RegisterDomainRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RegisterWorkflowTypeRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RequestCancelActivityTaskFailedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RequestCancelExternalWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RequestCancelExternalWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RequestCancelWorkflowExecutionRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RespondActivityTaskCanceledRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RespondActivityTaskCompletedRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RespondActivityTaskFailedRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RespondDecisionTaskCompletedRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RunJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ScheduleActivityTaskFailedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/SignalExternalWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/SignalExternalWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/SignalWorkflowExecutionRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/StartChildWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/StartChildWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/StartTimerFailedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/StartWorkflowExecutionRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TaskListJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TerminateWorkflowExecutionRequestMarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TimerCanceledEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TimerFiredEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TimerStartedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TypeAlreadyExistsExceptionUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TypeDeprecatedExceptionUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/UnknownResourceExceptionUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionAlreadyStartedExceptionUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionCancelRequestedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionCanceledEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionCompletedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionConfigurationJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionContinuedAsNewEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionCountJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionDetailJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionFailedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionInfoJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionInfosJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionOpenCountsJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionSignaledEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionStartedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionTerminatedEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionTimedOutEventAttributesJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowTypeConfigurationJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowTypeDetailJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowTypeInfoJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowTypeInfosJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowTypeJsonUnmarshaller.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/model/transform/package-info.java create mode 100644 src/main/java/com/amazonaws/services/simpleworkflow/package-info.java create mode 100644 src/samples/AwsFlowFramework/README.html create mode 100644 src/samples/AwsFlowFramework/access.properties create mode 100644 src/samples/AwsFlowFramework/build.xml create mode 100644 src/samples/AwsFlowFramework/log4j.properties create mode 100644 src/samples/AwsFlowFramework/src/META-INF/aop.xml create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/ActivityHost.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingActivities.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingActivitiesImpl.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingConfigKeys.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingWorkflow.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingWorkflowImpl.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingWorklfowTest.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/WorkflowExecutionStarter.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/WorkflowHost.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/ConfigHelper.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/ConfigKeys.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/RegistrationDefaults.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/SampleConstants.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/WorkflowExecutionFlowThreadDumper.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/WorkflowExecutionGetState.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/WorkflowExecutionHistoryPrinter.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/WorkflowExecutionReplayer.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/AppServer.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/AppStack1.xml create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/ApplicationStack.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/Database.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/Deployable.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeployableBase.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentActivities.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentActivitiesImpl.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentCommon-context.xml create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentHost-context.xml create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentHost.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentInitiator-context.xml create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentInitiator.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentTest-context.xml create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentTest.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentWorkflow.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentWorkflowImpl.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/LoadBalancer.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/WebServer.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/ActivityHost.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/FileProcessingActivities.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/FileProcessingActivitiesZipImpl.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/FileProcessingConfigKeys.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/FileProcessingWorkflow.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/FileProcessingWorkflowZipImpl.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/SimpleStoreActivities.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/SimpleStoreActivitiesS3Impl.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/WorkflowExecutionStarter.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/WorkflowHost.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/ActivityHost.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/HelloWorldActivities.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/HelloWorldActivitiesImpl.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/HelloWorldTest.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/HelloWorldWorkflow.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/HelloWorldWorkflowImpl.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/WorkflowExecutionStarter.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/WorkflowHost.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/ActivityHost.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/ErrorReportingActivities.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/ErrorReportingActivitiesImpl.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflow.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflowActivities.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflowActivitiesImpl.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflowImpl.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflowOptions.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflowTest.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/WorkflowExecutionStarter.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/WorkflowHost.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/ActivityHost.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/AverageCalculatorActivities.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/AverageCalculatorActivitiesImpl.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/AverageCalculatorWorkflow.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/AverageCalculatorWorkflowImpl.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/PartitionedAverageCalculator.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/PartitionedAverageCalculatorImpl.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/SplitMergeConfigKeys.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/WorkflowExecutionStarter.java create mode 100644 src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/WorkflowHost.java diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF index 770871fe87ac..142d428dfed8 100644 --- a/META-INF/MANIFEST.MF +++ b/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: AWS SDK for Java Bundle-SymbolicName: com.amazonaws.sdk;singleton:=true -Bundle-Version: 1.3.2 +Bundle-Version: 1.3.3 Bundle-Vendor: Amazon Technologies, Inc Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Require-Bundle: org.apache.commons.codec;bundle-version="1.3.0", diff --git a/NOTICE.txt b/NOTICE.txt index 02954e3ccd8c..cb62c6fa8383 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1,5 +1,5 @@ AWS SDK for Java -Copyright 2010 Amazon.com, Inc. or its affiliates. All Rights Reserved. +Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. This product includes software developed by Amazon Technologies, Inc (http://www.amazon.com/). diff --git a/pom.xml b/pom.xml index e514f8cb4e0a..7878e5aae031 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ aws-java-sdk jar AWS SDK for Java - 1.3.2 + 1.3.3 The Amazon Web Services SDK for Java provides Java APIs for building software on AWS’ cost-effective, scalable, and reliable infrastructure products. The AWS Java SDK allows developers to code against APIs for all of Amazon's infrastructure web services (Amazon S3, Amazon EC2, Amazon SQS, Amazon Relational Database Service, Amazon AutoScaling, etc). http://aws.amazon.com/sdkforjava @@ -64,6 +64,40 @@ + + + org.freemarker + freemarker + [2.3,) + true + + + org.springframework + spring-beans + [3.0,) + true + + + org.springframework + spring-core + [3.0,) + true + + + org.springframework + spring-context + [3.0,) + true + + + org.aspectj + aspectjrt + [1.6,) + true + + + diff --git a/src/main/java/com/amazonaws/services/dynamodb/datamodeling/DynamoDBMapper.java b/src/main/java/com/amazonaws/services/dynamodb/datamodeling/DynamoDBMapper.java index 48513e06d47d..84d9e028d12f 100644 --- a/src/main/java/com/amazonaws/services/dynamodb/datamodeling/DynamoDBMapper.java +++ b/src/main/java/com/amazonaws/services/dynamodb/datamodeling/DynamoDBMapper.java @@ -17,6 +17,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.text.ParseException; +import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -28,8 +29,6 @@ import com.amazonaws.services.dynamodb.AmazonDynamoDB; import com.amazonaws.services.dynamodb.datamodeling.DynamoDBMapperConfig.ConsistentReads; import com.amazonaws.services.dynamodb.datamodeling.DynamoDBMapperConfig.SaveBehavior; -import com.amazonaws.services.dynamodb.datamodeling.internal.PaginatedQueryList; -import com.amazonaws.services.dynamodb.datamodeling.internal.PaginatedScanList; import com.amazonaws.services.dynamodb.model.AttributeValue; import com.amazonaws.services.dynamodb.model.AttributeValueUpdate; import com.amazonaws.services.dynamodb.model.ConditionalCheckFailedException; @@ -119,6 +118,9 @@ * exceptions will always be propagated as {@link AmazonClientException}, and * DynamoDB-specific subclasses such as {@link ConditionalCheckFailedException} * will be used when possible. + *

+ * This class is thread-safe and can be shared between threads. It's also very + * lightweight, so it doesn't need to be. * * @see DynamoDBTable * @see DynamoDBHashKey @@ -137,10 +139,9 @@ public class DynamoDBMapper { private static final DynamoDBReflector reflector = new DynamoDBReflector(); /** - * User agent for requests made using the {@link DynamoDBMapper}. Intended - * for internal use only. + * User agent for requests made using the {@link DynamoDBMapper}. */ - public static final String USER_AGENT = DynamoDBMapper.class.getName() + "/" + VersionInfoUtils.getVersion(); + private static final String USER_AGENT = DynamoDBMapper.class.getName() + "/" + VersionInfoUtils.getVersion(); /** * Constructs a new mapper with the service object given, using the default @@ -255,29 +256,11 @@ private String getTableName(Class clazz, DynamoDBMapperConfig config) { } private AttributeValue getHashKeyElement(Object hashKey, Method hashKeyGetter) { - AttributeValue hashKeyElement = new AttributeValue(); - Class hashKeyMethodReturnType = hashKeyGetter.getReturnType(); - if ( hashKeyMethodReturnType.isPrimitive() || Number.class.isAssignableFrom(hashKeyMethodReturnType) ) { - hashKeyElement.setN(String.valueOf(hashKey)); - } else if ( String.class.isAssignableFrom(hashKeyMethodReturnType) ) { - hashKeyElement.setS(String.valueOf(hashKey)); - } else { - throw new DynamoDBMappingException("Hash key property must be either a Number or a String"); - } - return hashKeyElement; + return reflector.getArgumentMarshaller(hashKeyGetter).marshall(hashKey); } - private AttributeValue getRangeKeyElement(Object rangeKey, Method rangeKeyMethod) { - AttributeValue rangeKeyElement = new AttributeValue(); - Class rangeKeyMethodReturnType = rangeKeyMethod.getReturnType(); - if ( rangeKeyMethodReturnType.isPrimitive() || Number.class.isAssignableFrom(rangeKeyMethodReturnType) ) { - rangeKeyElement.setN(String.valueOf(rangeKey)); - } else if ( String.class.isAssignableFrom(rangeKeyMethodReturnType) ) { - rangeKeyElement.setS(String.valueOf(rangeKey)); - } else { - throw new DynamoDBMappingException("Range key property must be either a Number or a String"); - } - return rangeKeyElement; + private AttributeValue getRangeKeyElement(Object rangeKey, Method rangeKeyGetter) { + return reflector.getArgumentMarshaller(rangeKeyGetter).marshall(rangeKey); } /** @@ -315,6 +298,19 @@ public T marshallIntoObject(Class clazz, Map item return toReturn; } + + /** + * Marshalls the list of item attributes into objects of type clazz + * + * @see DynamoDBMapper#marshallIntoObject(Class, Map) + */ + public List marshallIntoObjects(Class clazz, List> itemAttributes) { + List result = new ArrayList(); + for (Map item : itemAttributes) { + result.add(marshallIntoObject(clazz, item)); + } + return result; + } /** * Sets the value in the return object corresponding to the service result. @@ -397,9 +393,11 @@ public void save(T object, DynamoDBMapperConfig config) { Map updateValues = new HashMap(); Map expectedValues = new HashMap(); - // Look at every getter and construct an update object for it boolean forcePut = false; + boolean nonKeyAttributePresent = false; List inMemoryUpdates = new LinkedList(); + + // Look at every getter and construct an update object for it for ( Method method : reflector.getRelevantGetters(clazz) ) { Object getterResult = safeInvoke(method, object); @@ -440,6 +438,14 @@ else if ( getterResult == null && reflector.isAssignableKey(method) ) { updateValues .put(attributeName, new AttributeValueUpdate().withAction("PUT").withValue(newVersionValue)); inMemoryUpdates.add(new ValueUpdate(method, newVersionValue)); + + if ( config.getSaveBehavior() != SaveBehavior.CLOBBER ) { + // Add an expect clause to make sure that the item doesn't + // already exist, since it's supposed to be new. + ExpectedAttributeValue expected = new ExpectedAttributeValue(); + expected.setExists(false); + expectedValues.put(attributeName, expected); + } } /* @@ -448,6 +454,7 @@ else if ( getterResult == null && reflector.isAssignableKey(method) ) { */ else if ( config.getSaveBehavior() == SaveBehavior.CLOBBER || (!method.equals(hashKeyGetter) && !method.equals(rangeKeyGetter)) ) { + nonKeyAttributePresent = true; AttributeValue currentValue = getSimpleAttributeValue(method, getterResult); if ( currentValue != null ) { updateValues.put(attributeName, new AttributeValueUpdate().withValue(currentValue) @@ -455,7 +462,7 @@ else if ( config.getSaveBehavior() == SaveBehavior.CLOBBER } else if ( config.getSaveBehavior() != SaveBehavior.CLOBBER ) { updateValues.put(attributeName, new AttributeValueUpdate().withAction("DELETE")); } - } + } } /* @@ -465,6 +472,8 @@ else if ( config.getSaveBehavior() == SaveBehavior.CLOBBER if ( config.getSaveBehavior() == SaveBehavior.CLOBBER || forcePut ) { db.putItem(applyUserAgent(new PutItemRequest().withTableName(tableName).withItem(convertToItem(updateValues)) .withExpected(expectedValues))); + } else if ( !nonKeyAttributePresent ) { + keyOnlyPut(tableName, objectKey, hashKeyGetter, rangeKeyGetter); } else { db.updateItem(applyUserAgent(new UpdateItemRequest().withTableName(tableName).withKey(objectKey) .withAttributeUpdates(updateValues).withExpected(expectedValues))); @@ -479,6 +488,34 @@ else if ( config.getSaveBehavior() == SaveBehavior.CLOBBER } } + /** + * Edge case to deal with the problem reported here: + * https://forums.aws.amazon.com/thread.jspa?threadID=86798&tstart=25 + *

+ * DynamoDB cannot process an updateItem request that only contains the key + * attribute(s), so we have to do a putItem. Somewhat confusingly, we also + * insist that an item with the key(s) given doesn't already exist. This + * isn't perfect, but we should be doing a putItem at all in this case, so + * it's the best we can do. + */ + private void keyOnlyPut(String tableName, Key objectKey, Method hashKeyGetter, Method rangeKeyGetter) { + Map attributes = new HashMap(); + Map expectedValues = new HashMap(); + + String hashKeyAttributeName = reflector.getAttributeName(hashKeyGetter); + attributes.put(hashKeyAttributeName, objectKey.getHashKeyElement()); + expectedValues.put(hashKeyAttributeName, new ExpectedAttributeValue().withExists(false)); + + if (rangeKeyGetter != null) { + String rangeKeyAttributeName = reflector.getAttributeName(rangeKeyGetter); + attributes.put(rangeKeyAttributeName, objectKey.getRangeKeyElement()); + expectedValues.put(rangeKeyAttributeName, new ExpectedAttributeValue().withExists(false)); + } + + db.putItem(applyUserAgent(new PutItemRequest().withTableName(tableName).withItem(attributes) + .withExpected(expectedValues))); + } + /** * Deletes the given object from its DynamoDB table. */ @@ -615,36 +652,28 @@ private AttributeValue getAutoGeneratedKeyAttributeValue(Method getter, Object g * Callers should be aware that the returned list is unmodifiable, and any * attempts to modify the list will result in an * UnsupportedOperationException. - * + *

+ * The unmodifiable list returned is lazily loaded when possible, so calls + * to DynamoDB will be made only as needed. + * * @param * The type of the objects being returned. - * * @param clazz * The class annotated with DynamoDB annotations describing how * to store the object data in AWS DynamoDB. * @param scanExpression * Details on how to run the scan, including any filters to apply * to limit results. - * * @return An unmodifiable list of the objects constructed from the results * of the scan operation. - * - * @throws Exception - * If there were any problems loading the data from AWS - * DynamoDB. + * + * @see PaginatedScanList */ - public List scan(Class clazz, DynamoDBScanExpression scanExpression) throws Exception { + public PaginatedScanList scan(Class clazz, DynamoDBScanExpression scanExpression) { ScanRequest scanRequest = createScanRequestFromExpression(clazz, scanExpression); ScanResult scanResult = db.scan(applyUserAgent(scanRequest)); - int count = scanResult.getCount(); - - // If the results are truncated, figure out the count - if (scanResult.getLastEvaluatedKey() != null) { - count = count(clazz, scanExpression); - } - - return new PaginatedScanList(this, clazz, db, count, scanRequest, scanResult); + return new PaginatedScanList(this, clazz, db, scanRequest, scanResult); } /** @@ -658,55 +687,45 @@ public List scan(Class clazz, DynamoDBScanExpression scanExpression) t * Callers should be aware that the returned list is unmodifiable, and any * attempts to modify the list will result in an * UnsupportedOperationException. + *

+ * The unmodifiable list returned is lazily loaded when possible, so calls + * to DynamoDB will be made only as needed. * * @param * The type of the objects being returned. - * * @param clazz * The class annotated with DynamoDB annotations describing how * to store the object data in AWS DynamoDB. * @param queryExpression * Details on how to run the query, including any filters to * apply to limit the results. - * * @return An unmodifiable list of the objects constructed from the results * of the query operation. - * - * @throws Exception - * If there were any problems loading the data from AWS - * DynamoDB. + * + * @see PaginatedQueryList */ - public List query(Class clazz, DynamoDBQueryExpression queryExpression) throws Exception { + public PaginatedQueryList query(Class clazz, DynamoDBQueryExpression queryExpression) { QueryRequest queryRequest = createQueryRequestFromExpression(clazz, queryExpression); QueryResult queryResult = db.query(applyUserAgent(queryRequest)); - int count = queryResult.getCount(); - - // If the results are truncated, figure out the count - if (queryResult.getLastEvaluatedKey() != null) { - count = count(clazz, queryExpression); - } - - return new PaginatedQueryList(this, clazz, db, count, queryRequest, queryResult); + return new PaginatedQueryList(this, clazz, db, queryRequest, queryResult); } /** * Evaluates the specified scan expression and returns the count of matching * items, without returning any of the actual item data. - * + *

+ * This operation will scan your entire table, and can therefore be very + * expensive. Use with caution. + * * @param clazz * The class mapped to a DynamoDB table. * @param scanExpression * The parameters for running the scan. - * * @return The count of matching items, without returning any of the actual * item data. - * - * @throws Exception - * If any problems were encountered making the request to AWS - * DynamoDB. */ - public int count(Class clazz, DynamoDBScanExpression scanExpression) throws Exception { + public int count(Class clazz, DynamoDBScanExpression scanExpression) { ScanRequest scanRequest = createScanRequestFromExpression(clazz, scanExpression); scanRequest.setCount(true); @@ -722,7 +741,19 @@ public int count(Class clazz, DynamoDBScanExpression scanExpression) throws E return count; } - public int count(Class clazz, DynamoDBQueryExpression queryExpression) throws Exception { + /** + * Evaluates the specified query expression and returns the count of matching + * items, without returning any of the actual item data. + * + * @param clazz + * The class mapped to a DynamoDB table. + * @param scanExpression + * The parameters for running the scan. + * + * @return The count of matching items, without returning any of the actual + * item data. + */ + public int count(Class clazz, DynamoDBQueryExpression queryExpression) { QueryRequest queryRequest = createQueryRequestFromExpression(clazz, queryExpression); queryRequest.setCount(true); @@ -739,8 +770,6 @@ public int count(Class clazz, DynamoDBQueryExpression queryExpression) throws } private ScanRequest createScanRequestFromExpression(Class clazz, DynamoDBScanExpression scanExpression) { - DynamoDBTable table = reflector.getTable(clazz); - ScanRequest scanRequest = new ScanRequest(); scanRequest.setTableName(getTableName(clazz, config)); scanRequest.setScanFilter(scanExpression.getScanFilter()); @@ -749,8 +778,6 @@ private ScanRequest createScanRequestFromExpression(Class clazz, DynamoDBScan } private QueryRequest createQueryRequestFromExpression(Class clazz, DynamoDBQueryExpression queryExpression) { - DynamoDBTable table = reflector.getTable(clazz); - QueryRequest queryRequest = new QueryRequest(); queryRequest.setConsistentRead(queryExpression.isConsistentRead()); queryRequest.setTableName(getTableName(clazz, config)); diff --git a/src/main/java/com/amazonaws/services/dynamodb/datamodeling/DynamoDBReflector.java b/src/main/java/com/amazonaws/services/dynamodb/datamodeling/DynamoDBReflector.java index 1de844a28309..a2af465c3697 100644 --- a/src/main/java/com/amazonaws/services/dynamodb/datamodeling/DynamoDBReflector.java +++ b/src/main/java/com/amazonaws/services/dynamodb/datamodeling/DynamoDBReflector.java @@ -90,7 +90,7 @@ Collection getRelevantGetters(Class clazz) { private boolean isRelevantGetter(Method m) { return (m.getName().startsWith("get") || m.getName().startsWith("is")) && m.getParameterTypes().length == 0 && m.getDeclaringClass().getAnnotation(DynamoDBTable.class) != null - && m.getAnnotation(DynamoDBIgnore.class) == null; + && !m.isAnnotationPresent(DynamoDBIgnore.class); } /** @@ -102,7 +102,7 @@ Method getRangeKeyGetter(Class clazz) { if ( !rangeKeyGetterCache.containsKey(clazz) ) { Method rangeKeyMethod = null; for ( Method method : getRelevantGetters(clazz) ) { - if ( method.getParameterTypes().length == 0 && method.getAnnotation(DynamoDBRangeKey.class) != null ) { + if ( method.getParameterTypes().length == 0 && method.isAnnotationPresent(DynamoDBRangeKey.class)) { rangeKeyMethod = method; break; } @@ -121,7 +121,7 @@ Method getHashKeyGetter(Class clazz) { synchronized (hashKeyGetterCache) { if ( !hashKeyGetterCache.containsKey(clazz) ) { for ( Method method : getRelevantGetters(clazz) ) { - if ( method.getParameterTypes().length == 0 && method.getAnnotation(DynamoDBHashKey.class) != null ) { + if ( method.getParameterTypes().length == 0 && method.isAnnotationPresent(DynamoDBHashKey.class)) { hashKeyGetterCache.put(clazz, method); break; } @@ -152,7 +152,7 @@ DynamoDBTable getTable(Class clazz) { * Returns whether or not this getter has a custom marshaller */ private boolean isCustomMarshaller(Method getter) { - return getter.getAnnotation(DynamoDBMarshalling.class) != null; + return getter.isAnnotationPresent(DynamoDBMarshalling.class); } /** @@ -877,7 +877,7 @@ boolean isVersionAttributeGetter(Method getter) { versionAttributeGetterCache.put( getter, getter.getName().startsWith("get") && getter.getParameterTypes().length == 0 - && getter.getAnnotation(DynamoDBVersionAttribute.class) != null); + && getter.isAnnotationPresent(DynamoDBVersionAttribute.class)); } } @@ -892,9 +892,9 @@ boolean isAssignableKey(Method getter) { if ( !autoGeneratedKeyGetterCache.containsKey(getter) ) { autoGeneratedKeyGetterCache.put( getter, - getter.getAnnotation(DynamoDBAutoGeneratedKey.class) != null - && (getter.getAnnotation(DynamoDBHashKey.class) != null || getter - .getAnnotation(DynamoDBRangeKey.class) != null)); + getter.isAnnotationPresent(DynamoDBAutoGeneratedKey.class) + && (getter.isAnnotationPresent(DynamoDBHashKey.class) || getter + .isAnnotationPresent(DynamoDBRangeKey.class))); } } diff --git a/src/main/java/com/amazonaws/services/dynamodb/datamodeling/PaginatedList.java b/src/main/java/com/amazonaws/services/dynamodb/datamodeling/PaginatedList.java new file mode 100644 index 000000000000..1cd02203066b --- /dev/null +++ b/src/main/java/com/amazonaws/services/dynamodb/datamodeling/PaginatedList.java @@ -0,0 +1,367 @@ +/* + * Copyright 2011-2012 Amazon Technologies, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://aws.amazon.com/apache2.0 + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + * OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and + * limitations under the License. + */ +package com.amazonaws.services.dynamodb.datamodeling; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +import com.amazonaws.services.dynamodb.AmazonDynamoDB; + +/** + * Unmodifiable list supporting paginated result sets from Amazon DynamoDB. + *

+ * Pages of results are fetched lazily from DynamoDB as they are needed. Some + * methods, such as {@link PaginatedList#size()} and + * {@link PaginatedList#toArray()}, require fetching the entire result set + * eagerly. See the javadoc of individual methods for details on which are lazy. + * + * @param + * The domain object type stored in this list. + */ +public abstract class PaginatedList implements List { + + private static final String UNMODIFIABLE_MESSAGE = "This is an unmodifiable list"; + + /** + * Reference to the DynamoDB mapper for marshalling DynamoDB attributes back + * into objects + */ + protected final DynamoDBMapper mapper; + + /** + * The class annotated with DynamoDB tags declaring how to load/store + * objects into DynamoDB + */ + protected final Class clazz; + + /** The client for working with DynamoDB */ + protected final AmazonDynamoDB dynamo; + + /** Tracks if all results have been loaded yet or not */ + protected boolean allResultsLoaded = false; + + /** All currently loaded results for this list */ + protected final List allResults; + + /** Lazily loaded next results waiting to be added into allResults */ + protected final List nextResults = new LinkedList(); + + public PaginatedList(DynamoDBMapper mapper, Class clazz, AmazonDynamoDB dynamo) { + this.mapper = mapper; + this.clazz = clazz; + this.dynamo = dynamo; + + this.allResults = new ArrayList(); + } + + /** + * Eagerly loads all results for this list. + */ + public synchronized void loadAllResults() { + if ( allResultsLoaded ) + return; + + while ( nextResultsAvailable() ) { + moveNextResults(); + } + + allResultsLoaded = true; + } + + /** + * Returns whether there are more results available not yet included in the + * allResults member field. These could already have been fetched and are + * sitting in the nextResults buffer, or they could be fetched from the + * service opportunistically at the time this method is called. A return + * value of true guarantees that nextResults is non-empty. + */ + private boolean nextResultsAvailable() { + return !nextResults.isEmpty() || loadNextResults(); + } + + /** + * Attempts to load the next batch of results, if there are any, into the + * nextResults buffer. Returns whether there were any results to load. A + * return value of true guarantees that nextResults had items added to it. + */ + private synchronized boolean loadNextResults() { + if ( atEndOfResults() ) + return false; + + do { + nextResults.addAll(fetchNextPage()); + } while ( !atEndOfResults() && nextResults.isEmpty() ); + + return !nextResults.isEmpty(); + } + + /** + * Moves the contents of the nextResults buffer into allResults and resets + * the buffer. + */ + private void moveNextResults() { + allResults.addAll(nextResults); + nextResults.clear(); + } + + /** + * Fetches the next page of results (which may be empty) and returns any + * items found. + */ + protected abstract List fetchNextPage(); + + /** + * Returns whether we have reached the end of the result set. + */ + protected abstract boolean atEndOfResults(); + + /** + * Returns an iterator over this list that lazily initializes results as + * necessary. + */ + @Override + public Iterator iterator() { + + /* + * We make a copy of the allResults list to iterate over in order to + * avoid ConcurrentModificationExceptions caused by other methods + * loading more results into the list while someone iterates over it. + * This is a more severe problem than it might seem, because even + * innocuous-seeming operations such as contains() can modify the + * underlying result set. + */ + final List allResultsCopy = new ArrayList(); + allResultsCopy.addAll(allResults); + final Iterator iter = allResultsCopy.iterator(); + + return new Iterator() { + + Iterator iterator = iter; + int pos = 0; + + @Override + public boolean hasNext() { + return iterator.hasNext() || nextResultsAvailable(); + } + + @Override + public T next() { + if ( !iterator.hasNext() ) { + /* + * Our private copy of the result list may be out of date + * with the full one. If it is, we just need to update our + * private copy to get more results. If it's not, we need to + * fetch more results from the service. + */ + if ( allResults.size() == allResultsCopy.size() ) { + if ( !nextResultsAvailable() ) { + throw new NoSuchElementException(); + } + moveNextResults(); + } + + if ( allResults.size() > allResultsCopy.size() ) + allResultsCopy.addAll(allResults.subList(allResultsCopy.size(), allResults.size())); + + iterator = allResultsCopy.listIterator(pos); + } + + pos++; + return iterator.next(); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); + } + }; + } + + /** + * Returns whether the collection is empty. At most one (non-empty) page of + * results is loaded to make the check. + */ + @Override + public boolean isEmpty() { + return !iterator().hasNext(); + } + + /** + * Returns the Nth element of the list. Results are loaded until N elements + * are present, if necessary. + */ + @Override + public T get(int n) { + while ( allResults.size() <= n && nextResultsAvailable() ) { + moveNextResults(); + } + + return allResults.get(n); + } + + /** + * Returns whether the collection contains the given element. Results are + * loaded and checked incrementally until a match is found or the end of the + * result set is reached. + */ + @Override + public boolean contains(Object arg0) { + if ( allResults.contains(arg0) ) + return true; + + while ( nextResultsAvailable() ) { + boolean found = nextResults.contains(arg0); + moveNextResults(); + if ( found ) + return true; + } + + return false; + } + + /** + * Returns a sub-list in the range specified, loading more results as + * necessary. + */ + @Override + public List subList(int arg0, int arg1) { + while ( allResults.size() < arg1 && nextResultsAvailable() ) { + moveNextResults(); + } + + return Collections.unmodifiableList(allResults.subList(arg0, arg1)); + } + + /** + * Returns the first index of the object given in the list. Additional + * results are loaded incrementally as necessary. + */ + @Override + public int indexOf(Object arg0) { + int indexOf = allResults.indexOf(arg0); + if ( indexOf >= 0 ) + return indexOf; + + while ( nextResultsAvailable() ) { + indexOf = nextResults.indexOf(arg0); + int size = allResults.size(); + moveNextResults(); + if ( indexOf >= 0 ) + return indexOf + size; + } + + return -1; + } + + // Operations requiring the entire result set + + @Override + public int size() { + loadAllResults(); + return allResults.size(); + } + + @Override + public boolean containsAll(Collection arg0) { + loadAllResults(); + return allResults.containsAll(arg0); + } + + @Override + public int lastIndexOf(Object arg0) { + loadAllResults(); + return allResults.lastIndexOf(arg0); + } + + @Override + public Object[] toArray() { + loadAllResults(); + return allResults.toArray(); + } + + @Override + public X[] toArray(X[] a) { + loadAllResults(); + return allResults.toArray(a); + } + + // Unsupported Operations + + @Override + public ListIterator listIterator() { + throw new UnsupportedOperationException("ListIterators are not supported for this list"); + } + + @Override + public ListIterator listIterator(int arg0) { + throw new UnsupportedOperationException("ListIterators are not supported for this list"); + } + + @Override + public boolean remove(Object arg0) { + throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); + } + + @Override + public T remove(int arg0) { + throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); + } + + @Override + public boolean removeAll(Collection arg0) { + throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); + } + + @Override + public boolean retainAll(Collection arg0) { + throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); + } + + @Override + public T set(int arg0, T arg1) { + throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); + } + + @Override + public boolean add(T arg0) { + throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); + } + + @Override + public void add(int arg0, T arg1) { + throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); + } + + @Override + public boolean addAll(Collection arg0) { + throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); + } + + @Override + public boolean addAll(int arg0, Collection arg1) { + throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); + } + + @Override + public void clear() { + throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); + } +} diff --git a/src/main/java/com/amazonaws/services/dynamodb/datamodeling/internal/PaginatedQueryList.java b/src/main/java/com/amazonaws/services/dynamodb/datamodeling/PaginatedQueryList.java similarity index 65% rename from src/main/java/com/amazonaws/services/dynamodb/datamodeling/internal/PaginatedQueryList.java rename to src/main/java/com/amazonaws/services/dynamodb/datamodeling/PaginatedQueryList.java index 71e782bbfeb7..a2b96de48ed5 100644 --- a/src/main/java/com/amazonaws/services/dynamodb/datamodeling/internal/PaginatedQueryList.java +++ b/src/main/java/com/amazonaws/services/dynamodb/datamodeling/PaginatedQueryList.java @@ -12,20 +12,20 @@ * License for the specific language governing permissions and * limitations under the License. */ -package com.amazonaws.services.dynamodb.datamodeling.internal; +package com.amazonaws.services.dynamodb.datamodeling; + +import java.util.List; import com.amazonaws.services.dynamodb.AmazonDynamoDB; -import com.amazonaws.services.dynamodb.datamodeling.DynamoDBMapper; import com.amazonaws.services.dynamodb.model.QueryRequest; import com.amazonaws.services.dynamodb.model.QueryResult; /** * Implementation of the List interface that represents the results from a query * in AWS DynamoDB. Paginated results are loaded on demand when the user - * executes an operation that requires them. Only - * {@link PaginatedQueryList#iterator()} is lazy -- fetching the Nth element of - * the list, converting it to an array, etc. will cause all results to be loaded - * eagerly. + * executes an operation that requires them. Some operations, such as size(), + * must fetch the entire list, but results are lazily fetched page by page when + * possible. *

* This is an unmodifiable list, so callers should not invoke any operations * that modify this list, otherwise they will throw an @@ -33,6 +33,7 @@ * * @param * The type of objects held in this list. + * @see PaginatedList */ public class PaginatedQueryList extends PaginatedList { @@ -43,25 +44,24 @@ public class PaginatedQueryList extends PaginatedList { private QueryResult queryResult; - public PaginatedQueryList(DynamoDBMapper mapper, Class clazz, AmazonDynamoDB dynamo, int size, QueryRequest queryRequest, QueryResult queryResult) { - super(mapper, clazz, dynamo, size); + public PaginatedQueryList(DynamoDBMapper mapper, Class clazz, AmazonDynamoDB dynamo, QueryRequest queryRequest, QueryResult queryResult) { + super(mapper, clazz, dynamo); this.queryRequest = queryRequest; this.queryResult = queryResult; - unmarshallResults(queryResult.getItems()); + allResults.addAll(mapper.marshallIntoObjects(clazz, queryResult.getItems())); } - @Override - protected boolean hasMoreResults() { - return queryResult.getLastEvaluatedKey() != null; + @Override + protected boolean atEndOfResults() { + return queryResult.getLastEvaluatedKey() == null; } - @Override - protected void loadNextResult() { + @Override + protected synchronized List fetchNextPage() { queryRequest.setExclusiveStartKey(queryResult.getLastEvaluatedKey()); - queryResult = dynamo.query(applyUserAgent(queryRequest)); - unmarshallResults(queryResult.getItems()); + queryResult = dynamo.query(DynamoDBMapper.applyUserAgent(queryRequest)); + return mapper.marshallIntoObjects(clazz, queryResult.getItems()); } - } diff --git a/src/main/java/com/amazonaws/services/dynamodb/datamodeling/internal/PaginatedScanList.java b/src/main/java/com/amazonaws/services/dynamodb/datamodeling/PaginatedScanList.java similarity index 66% rename from src/main/java/com/amazonaws/services/dynamodb/datamodeling/internal/PaginatedScanList.java rename to src/main/java/com/amazonaws/services/dynamodb/datamodeling/PaginatedScanList.java index deae6811b5e8..175c511bf3c7 100644 --- a/src/main/java/com/amazonaws/services/dynamodb/datamodeling/internal/PaginatedScanList.java +++ b/src/main/java/com/amazonaws/services/dynamodb/datamodeling/PaginatedScanList.java @@ -12,20 +12,20 @@ * License for the specific language governing permissions and * limitations under the License. */ -package com.amazonaws.services.dynamodb.datamodeling.internal; +package com.amazonaws.services.dynamodb.datamodeling; + +import java.util.List; import com.amazonaws.services.dynamodb.AmazonDynamoDB; -import com.amazonaws.services.dynamodb.datamodeling.DynamoDBMapper; import com.amazonaws.services.dynamodb.model.ScanRequest; import com.amazonaws.services.dynamodb.model.ScanResult; /** * Implementation of the List interface that represents the results from a scan * in AWS DynamoDB. Paginated results are loaded on demand when the user - * executes an operation that requires them. Only - * {@link PaginatedScanList#iterator()} is lazy -- fetching the Nth element of - * the list, converting it to an array, etc. will cause all results to be loaded - * eagerly. + * executes an operation that requires them. Some operations, such as size(), + * must fetch the entire list, but results are lazily fetched page by page when + * possible. *

* This is an unmodifiable list, so callers should not invoke any operations * that modify this list, otherwise they will throw an @@ -33,6 +33,7 @@ * * @param * The type of objects held in this list. + * @see PaginatedList */ public class PaginatedScanList extends PaginatedList { @@ -43,25 +44,25 @@ public class PaginatedScanList extends PaginatedList { private ScanResult scanResult; - public PaginatedScanList(DynamoDBMapper mapper, Class clazz, AmazonDynamoDB dynamo, int size, ScanRequest scanRequest, ScanResult scanResult) { - super(mapper, clazz, dynamo, size); + public PaginatedScanList(DynamoDBMapper mapper, Class clazz, AmazonDynamoDB dynamo, ScanRequest scanRequest, ScanResult scanResult) { + super(mapper, clazz, dynamo); this.scanRequest = scanRequest; this.scanResult = scanResult; - unmarshallResults(scanResult.getItems()); + allResults.addAll(mapper.marshallIntoObjects(clazz, scanResult.getItems())); } @Override - protected synchronized boolean hasMoreResults() { - return scanResult.getLastEvaluatedKey() != null; + protected boolean atEndOfResults() { + return scanResult.getLastEvaluatedKey() == null; } - + @Override - protected synchronized void loadNextResult() { + protected synchronized List fetchNextPage() { scanRequest.setExclusiveStartKey(scanResult.getLastEvaluatedKey()); - scanResult = dynamo.scan(applyUserAgent(scanRequest)); - unmarshallResults(scanResult.getItems()); + scanResult = dynamo.scan(DynamoDBMapper.applyUserAgent(scanRequest)); + return mapper.marshallIntoObjects(clazz, scanResult.getItems()); } } diff --git a/src/main/java/com/amazonaws/services/dynamodb/datamodeling/internal/PaginatedList.java b/src/main/java/com/amazonaws/services/dynamodb/datamodeling/internal/PaginatedList.java deleted file mode 100644 index b3f2b5638f9d..000000000000 --- a/src/main/java/com/amazonaws/services/dynamodb/datamodeling/internal/PaginatedList.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright 2011-2012 Amazon Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://aws.amazon.com/apache2.0 - * - * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and - * limitations under the License. - */ -package com.amazonaws.services.dynamodb.datamodeling.internal; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; - -import com.amazonaws.AmazonWebServiceRequest; -import com.amazonaws.services.dynamodb.AmazonDynamoDB; -import com.amazonaws.services.dynamodb.datamodeling.DynamoDBMapper; -import com.amazonaws.services.dynamodb.model.AttributeValue; - -public abstract class PaginatedList implements List { - - private static final String UNMODIFIABLE_MESSAGE = "This is an unmodifiable list"; - - /** - * Reference to the DynamoDB mapper for marshalling DynamoDB attributes back - * into objects - */ - protected final DynamoDBMapper mapper; - - /** - * The class annotated with DynamoDB tags declaring how to load/store - * objects into DynamoDB - */ - protected final Class clazz; - - /** The client for working with DynamoDB */ - protected final AmazonDynamoDB dynamo; - - /** - * The total size of the results from the DynamoDB operation providing the data - * in this list - */ - private final int size; - - /** Tracks if all results have been loaded yet or not */ - protected boolean allResultsLoaded = false; - - /** All currently loaded results for this list */ - protected List allResults; - - - public PaginatedList(DynamoDBMapper mapper, Class clazz, AmazonDynamoDB dynamo, int size) { - this.mapper = mapper; - this.clazz = clazz; - this.dynamo = dynamo; - this.size = size; - - this.allResults = new ArrayList(); - } - - protected synchronized void loadAllResults() { - if (allResultsLoaded) return; - - while ( hasMoreResults() ) { - loadNextResult(); - } - - allResultsLoaded = true; - } - - protected abstract boolean hasMoreResults(); - - protected abstract void loadNextResult(); - - // List Interface - - @Override - public int size() { - return size; - } - - @Override - public boolean isEmpty() { - return allResults.isEmpty(); - } - - // Operations requiring the entire result set - - @Override - public boolean contains(Object arg0) { - loadAllResults(); - return allResults.contains(arg0); - } - - @Override - public boolean containsAll(Collection arg0) { - loadAllResults(); - return allResults.containsAll(arg0); - } - - @Override - public T get(int arg0) { - loadAllResults(); - return allResults.get(arg0); - } - - @Override - public int indexOf(Object arg0) { - loadAllResults(); - return allResults.indexOf(arg0); - } - - @Override - public int lastIndexOf(Object arg0) { - loadAllResults(); - return allResults.lastIndexOf(arg0); - } - - @Override - public List subList(int arg0, int arg1) { - loadAllResults(); - return allResults.subList(arg0, arg1); - } - - @Override - public Object[] toArray() { - loadAllResults(); - return allResults.toArray(); - } - - @Override - public X[] toArray(X[] a) { - loadAllResults(); - return allResults.toArray(a); - } - - // Iterator Operations - - /** - * Returns an iterator over this list that lazily initializes results as - * necessary. - */ - @Override - public Iterator iterator() { - final UnmodifiableIterator iter = new UnmodifiableIterator(allResults.iterator()); - return new Iterator() { - - Iterator iterator = iter; - int pos = 0; - - @Override - public boolean hasNext() { - return iterator.hasNext() || hasMoreResults(); - } - - @Override - public T next() { - if ( !iterator.hasNext() && hasMoreResults() ) { - loadNextResult(); - iterator = new UnmodifiableIterator(allResults.listIterator(pos)); - } - pos++; - return iterator.next(); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); - } - }; - } - - @Override - public ListIterator listIterator() { - throw new UnsupportedOperationException("ListIterators are not supported for this list"); - } - - @Override - public ListIterator listIterator(int arg0) { - throw new UnsupportedOperationException("ListIterators are not supported for this list"); - } - - // Unsupported Operations - - @Override - public boolean remove(Object arg0) { - throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); - } - - @Override - public T remove(int arg0) { - throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); - } - - @Override - public boolean removeAll(Collection arg0) { - throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); - } - - @Override - public boolean retainAll(Collection arg0) { - throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); - } - - @Override - public T set(int arg0, T arg1) { - throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); - } - - @Override - public boolean add(T arg0) { - throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); - } - - @Override - public void add(int arg0, T arg1) { - throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); - } - - @Override - public boolean addAll(Collection arg0) { - throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); - } - - @Override - public boolean addAll(int arg0, Collection arg1) { - throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); - } - - @Override - public void clear() { - throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE); - } - - - // Private Interface - - protected void unmarshallResults(List> items) { - for (Map attributeMap : items) { - try { - allResults.add(mapper.marshallIntoObject(clazz, attributeMap)); - } catch (Exception e) { - throw new RuntimeException("Unable to marshall attributes into object", e); - } - } - } - - static X applyUserAgent(X request) { - request.getRequestClientOptions().addClientMarker(DynamoDBMapper.USER_AGENT); - return request; - } -} diff --git a/src/main/java/com/amazonaws/services/dynamodb/datamodeling/internal/UnmodifiableIterator.java b/src/main/java/com/amazonaws/services/dynamodb/datamodeling/internal/UnmodifiableIterator.java deleted file mode 100644 index c20a1341da0d..000000000000 --- a/src/main/java/com/amazonaws/services/dynamodb/datamodeling/internal/UnmodifiableIterator.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2011-2012 Amazon Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://aws.amazon.com/apache2.0 - * - * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and - * limitations under the License. - */ -package com.amazonaws.services.dynamodb.datamodeling.internal; - -import java.util.Iterator; - -public class UnmodifiableIterator implements Iterator { - - private final Iterator iterator; - - public UnmodifiableIterator(Iterator iterator) { - this.iterator = iterator; - } - - @Override - public boolean hasNext() { - return iterator.hasNext(); - } - - @Override - public T next() { - return iterator.next(); - } - - @Override - public void remove() { - throw new UnsupportedOperationException("This is an unmodifiable iterator"); - } -} diff --git a/src/main/java/com/amazonaws/services/dynamodb/model/transform/AttributeValueJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/dynamodb/model/transform/AttributeValueJsonUnmarshaller.java index bb8b392942fe..78f5ee374f0a 100644 --- a/src/main/java/com/amazonaws/services/dynamodb/model/transform/AttributeValueJsonUnmarshaller.java +++ b/src/main/java/com/amazonaws/services/dynamodb/model/transform/AttributeValueJsonUnmarshaller.java @@ -35,7 +35,7 @@ public class AttributeValueJsonUnmarshaller implements Unmarshaller(StringJsonUnmarshaller.getInstance()).unmarshall(context)); } } else if (token == END_ARRAY || token == END_OBJECT) { - if (context.getCurrentDepth() < originalDepth) { + if (context.getCurrentDepth() <= originalDepth) { return attributeValue; } } diff --git a/src/main/java/com/amazonaws/services/dynamodb/model/transform/BatchGetItemResultJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/dynamodb/model/transform/BatchGetItemResultJsonUnmarshaller.java index bb2f6ac33da2..ceae0eebdcda 100644 --- a/src/main/java/com/amazonaws/services/dynamodb/model/transform/BatchGetItemResultJsonUnmarshaller.java +++ b/src/main/java/com/amazonaws/services/dynamodb/model/transform/BatchGetItemResultJsonUnmarshaller.java @@ -35,7 +35,7 @@ public class BatchGetItemResultJsonUnmarshaller implements Unmarshaller(StringJsonUnmarshaller.getInstance(), KeysAndAttributesJsonUnmarshaller.getInstance()).unmarshall(context)); } } else if (token == END_ARRAY || token == END_OBJECT) { - if (context.getCurrentDepth() < originalDepth) { + if (context.getCurrentDepth() <= originalDepth) { return batchGetItemResult; } } diff --git a/src/main/java/com/amazonaws/services/dynamodb/model/transform/BatchResponseJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/dynamodb/model/transform/BatchResponseJsonUnmarshaller.java index b7a1beb06bca..8f51c72cbf35 100644 --- a/src/main/java/com/amazonaws/services/dynamodb/model/transform/BatchResponseJsonUnmarshaller.java +++ b/src/main/java/com/amazonaws/services/dynamodb/model/transform/BatchResponseJsonUnmarshaller.java @@ -35,7 +35,7 @@ public class BatchResponseJsonUnmarshaller implements Unmarshaller(StringJsonUnmarshaller.getInstance()).unmarshall(context)); } } else if (token == END_ARRAY || token == END_OBJECT) { - if (context.getCurrentDepth() < originalDepth) { + if (context.getCurrentDepth() <= originalDepth) { return keysAndAttributes; } } diff --git a/src/main/java/com/amazonaws/services/dynamodb/model/transform/ListTablesResultJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/dynamodb/model/transform/ListTablesResultJsonUnmarshaller.java index 81125c0652bb..965d34938eb4 100644 --- a/src/main/java/com/amazonaws/services/dynamodb/model/transform/ListTablesResultJsonUnmarshaller.java +++ b/src/main/java/com/amazonaws/services/dynamodb/model/transform/ListTablesResultJsonUnmarshaller.java @@ -35,7 +35,7 @@ public class ListTablesResultJsonUnmarshaller implements Unmarshaller= NOTIFICATION_THRESHOLD) { diff --git a/src/main/java/com/amazonaws/services/s3/model/GetObjectRequest.java b/src/main/java/com/amazonaws/services/s3/model/GetObjectRequest.java index 61610c581113..50a3abf3ef71 100644 --- a/src/main/java/com/amazonaws/services/s3/model/GetObjectRequest.java +++ b/src/main/java/com/amazonaws/services/s3/model/GetObjectRequest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at - * + * * http://aws.amazon.com/apache2.0 - * + * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing @@ -27,7 +27,7 @@ * Provides options for downloading an Amazon S3 object. *

*

- * All GetObjectRequests must specify a bucket name and key. + * All GetObjectRequests must specify a bucket name and key. * Beyond that, requests can also specify: * *

*

- * + * * @see GetObjectRequest#GetObjectRequest(String, String) * @see GetObjectRequest#GetObjectRequest(String, String, String) * @see GetObjectMetadataRequest @@ -52,7 +52,7 @@ public class GetObjectRequest extends AmazonWebServiceRequest { * Optional version ID specifying which version of the object to download. * If not specified, the most recent version will be downloaded. *

- * For more information about enabling versioning for a bucket, see + * For more information about enabling versioning for a bucket, see * {@link AmazonS3#setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)}. */ private String versionId; @@ -84,12 +84,19 @@ public class GetObjectRequest extends AmazonWebServiceRequest { * object has been modified since the specified date. */ private Date modifiedSinceConstraint; - + /** * Optional field that overrides headers on the response. */ private ResponseHeaderOverrides responseHeaders; + /** + * The optional progress listener for receiving updates about object download + * status. + */ + private ProgressListener progressListener; + + /** * Constructs a new {@link GetObjectRequest} with all the required parameters. * @@ -98,8 +105,8 @@ public class GetObjectRequest extends AmazonWebServiceRequest { * @param key * The key in the specified bucket under which the object is * stored. - * - * @see GetObjectRequest#GetObjectRequest(String, String, String) + * + * @see GetObjectRequest#GetObjectRequest(String, String, String) */ public GetObjectRequest(String bucketName, String key) { this(bucketName, key, null); @@ -116,8 +123,8 @@ public GetObjectRequest(String bucketName, String key) { * @param versionId * The Amazon S3 version ID specifying a specific version of the * object to download. - * - * @see GetObjectRequest#GetObjectRequest(String, String) + * + * @see GetObjectRequest#GetObjectRequest(String, String) */ public GetObjectRequest(String bucketName, String key, String versionId) { setBucketName(bucketName); @@ -129,7 +136,7 @@ public GetObjectRequest(String bucketName, String key, String versionId) { * Gets the name of the bucket containing the object to be downloaded. * * @return The name of the bucket containing the object to be downloaded. - * + * * @see GetObjectRequest#setBucketName(String) * @see GetObjectRequest#withBucketName(String) */ @@ -142,9 +149,9 @@ public String getBucketName() { * * @param bucketName * The name of the bucket containing the object to be downloaded. - * + * * @see GetObjectRequest#getBucketName() - * @see GetObjectRequest#withBucketName(String) + * @see GetObjectRequest#withBucketName(String) */ public void setBucketName(String bucketName) { this.bucketName = bucketName; @@ -160,9 +167,9 @@ public void setBucketName(String bucketName) { * * @return This {@link GetObjectRequest}, enabling additional method * calls to be chained together. - * - * @see GetObjectRequest#getBucketName() - * @see GetObjectRequest#setBucketName(String) + * + * @see GetObjectRequest#getBucketName() + * @see GetObjectRequest#setBucketName(String) */ public GetObjectRequest withBucketName(String bucketName) { setBucketName(bucketName); @@ -173,7 +180,7 @@ public GetObjectRequest withBucketName(String bucketName) { * Gets the key under which the object to be downloaded is stored. * * @return The key under which the object to be downloaded is stored. - * + * * @see GetObjectRequest#setKey(String) * @see GetObjectRequest#withKey(String) */ @@ -186,8 +193,8 @@ public String getKey() { * * @param key * The key under which the object to be downloaded is stored. - * - * @see GetObjectRequest#getKey() + * + * @see GetObjectRequest#getKey() * @see GetObjectRequest#withKey(String) */ public void setKey(String key) { @@ -204,9 +211,9 @@ public void setKey(String key) { * * @return This {@link GetObjectRequest}, enabling additional method * calls to be chained together. - * + * * @see GetObjectRequest#getKey() - * @see GetObjectRequest#setKey(String) + * @see GetObjectRequest#setKey(String) */ public GetObjectRequest withKey(String key) { setKey(key); @@ -226,15 +233,15 @@ public GetObjectRequest withKey(String key) { * same as not having a version ID. *

*

- * For more information about enabling versioning for a bucket, see + * For more information about enabling versioning for a bucket, see * {@link AmazonS3#setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)}. *

* * @return The optional version ID specifying which version of the object to * download. If not specified, the most recent version will be * downloaded. - * - * @see GetObjectRequest#setVersionId(String) + * + * @see GetObjectRequest#setVersionId(String) * @see GetObjectRequest#withVersionId(String) */ public String getVersionId() { @@ -252,15 +259,15 @@ public String getVersionId() { * same as not having a version ID. *

*

- * For more information about enabling versioning for a bucket, see + * For more information about enabling versioning for a bucket, see * {@link AmazonS3#setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)}. *

* * @param versionId * The optional version ID specifying which version of the object * to download. - * - * @see GetObjectRequest#getVersionId() + * + * @see GetObjectRequest#getVersionId() * @see GetObjectRequest#withVersionId(String) */ public void setVersionId(String versionId) { @@ -282,19 +289,19 @@ public void setVersionId(String versionId) { * same as not having a version ID. *

*

- * For more information about enabling versioning for a bucket, see + * For more information about enabling versioning for a bucket, see * {@link AmazonS3#setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)}. *

* * @param versionId * The optional version ID specifying which version of the object * to download. - * + * * @return The updated request object, enabling additional method calls to be - * chained together. - * - * @see GetObjectRequest#getVersionId() - * @see GetObjectRequest#setVersionId(String) + * chained together. + * + * @see GetObjectRequest#getVersionId() + * @see GetObjectRequest#setVersionId(String) */ public GetObjectRequest withVersionId(String versionId) { setVersionId(versionId); @@ -309,12 +316,12 @@ public GetObjectRequest withVersionId(String versionId) { /** *

* Gets the optional inclusive byte range within the desired object - * that will be downloaded by this request. + * that will be downloaded by this request. *

*

* The range is returned as * a two element array, containing the start and end index of the byte range. - * If no byte range has been specified, the entire object is downloaded and + * If no byte range has been specified, the entire object is downloaded and * this method returns null. *

* @return A two element array indicating the inclusive start index and end index @@ -322,8 +329,8 @@ public GetObjectRequest withVersionId(String versionId) { * Returns null if no range has been specified, * and the whole object is * to be downloaded. - * - * @see GetObjectMetadataRequest#setRange(long, long) + * + * @see GetObjectMetadataRequest#setRange(long, long) * @see GetObjectRequest#withRange(long, long) */ public long[] getRange() { @@ -333,7 +340,7 @@ public long[] getRange() { /** *

* Sets the optional inclusive byte range within the desired object that - * will be downloaded by this request. + * will be downloaded by this request. *

*

* The first byte in an object has @@ -349,8 +356,8 @@ public long[] getRange() { * The start of the inclusive byte range to download. * @param end * The end of the inclusive byte range to download. - * - * @see GetObjectMetadataRequest#getRange() + * + * @see GetObjectMetadataRequest#getRange() * @see GetObjectRequest#withRange(long, long) */ public void setRange(long start, long end) { @@ -381,9 +388,9 @@ public void setRange(long start, long end) { * * @return This {@link GetObjectRequest}, enabling additional method * calls to be chained together. - * + * * @see GetObjectRequest#getRange() - * @see GetObjectRequest#setRange(long, long) + * @see GetObjectRequest#setRange(long, long) */ public GetObjectRequest withRange(long start, long end) { setRange(start, end); @@ -399,9 +406,9 @@ public GetObjectRequest withRange(long start, long end) { * @return The optional list of ETag constraints that when present must * include a match for the object's current ETag in order for this * request to be executed. - * + * * @see GetObjectRequest#setMatchingETagConstraints(List) - * @see GetObjectRequest#withMatchingETagConstraint(String) + * @see GetObjectRequest#withMatchingETagConstraint(String) */ public List getMatchingETagConstraints() { return matchingETagConstraints; @@ -418,9 +425,9 @@ public List getMatchingETagConstraints() { * The optional list of ETag constraints that must include a * match for the object's current ETag in order for this request * to be executed. - * + * * @see GetObjectRequest#getMatchingETagConstraints() - * @see GetObjectRequest#withMatchingETagConstraint(String) + * @see GetObjectRequest#withMatchingETagConstraint(String) */ public void setMatchingETagConstraints(List eTagList) { this.matchingETagConstraints = eTagList; @@ -442,9 +449,9 @@ public void setMatchingETagConstraints(List eTagList) { * * @return This {@link GetObjectRequest}, enabling additional method * calls to be chained together. - * + * * @see GetObjectRequest#getMatchingETagConstraints() - * @see GetObjectRequest#setMatchingETagConstraints(List) + * @see GetObjectRequest#setMatchingETagConstraints(List) */ public GetObjectRequest withMatchingETagConstraint(String eTag) { this.matchingETagConstraints.add(eTag); @@ -458,12 +465,12 @@ public GetObjectRequest withMatchingETagConstraint(String eTag) { * list matches the object's current ETag, this request will not be * executed by Amazon S3. * - * @return The optional list of ETag constraints that when present, must + * @return The optional list of ETag constraints that when present, must * not include a match for the object's current ETag in order * for this request to be executed. - * + * * @see GetObjectRequest#setNonmatchingETagConstraints(List) - * @see GetObjectRequest#withNonmatchingETagConstraint(String) + * @see GetObjectRequest#withNonmatchingETagConstraint(String) */ public List getNonmatchingETagConstraints() { return nonmatchingEtagConstraints; @@ -480,16 +487,16 @@ public List getNonmatchingETagConstraints() { * The list of ETag constraints that, when present, must not * include a match for the object's current ETag in order for * this request to be executed. - * + * * @see GetObjectRequest#getNonmatchingETagConstraints() - * @see GetObjectRequest#withNonmatchingETagConstraint(String) + * @see GetObjectRequest#withNonmatchingETagConstraint(String) */ public void setNonmatchingETagConstraints(List eTagList) { this.nonmatchingEtagConstraints = eTagList; } /** - * Sets a single ETag constraint to this request. + * Sets a single ETag constraint to this request. * Returns this {@link GetObjectRequest}, enabling additional method * calls to be chained together. *

@@ -506,9 +513,9 @@ public void setNonmatchingETagConstraints(List eTagList) { * * @return This {@link GetObjectRequest}, enabling additional method * calls to be chained together. - * - * @see GetObjectRequest#getNonmatchingETagConstraints() - * @see GetObjectRequest#setNonmatchingETagConstraints(List) + * + * @see GetObjectRequest#getNonmatchingETagConstraints() + * @see GetObjectRequest#setNonmatchingETagConstraints(List) */ public GetObjectRequest withNonmatchingETagConstraint(String eTag) { this.nonmatchingEtagConstraints.add(eTag); @@ -523,8 +530,8 @@ public GetObjectRequest withNonmatchingETagConstraint(String eTag) { * @return The optional unmodified constraint that restricts this * request to executing only if the object has not * been modified after the specified date. - * - * @see GetObjectRequest#setUnmodifiedSinceConstraint(Date) + * + * @see GetObjectRequest#setUnmodifiedSinceConstraint(Date) * @see GetObjectRequest#withUnmodifiedSinceConstraint(Date) */ public Date getUnmodifiedSinceConstraint() { @@ -542,9 +549,9 @@ public Date getUnmodifiedSinceConstraint() { * The unmodified constraint that restricts this request to * executing only if the object has not been * modified after this date. - * + * * @see GetObjectRequest#getUnmodifiedSinceConstraint() - * @see GetObjectRequest#withUnmodifiedSinceConstraint(Date) + * @see GetObjectRequest#withUnmodifiedSinceConstraint(Date) */ public void setUnmodifiedSinceConstraint(Date date) { this.unmodifiedSinceConstraint = date; @@ -566,9 +573,9 @@ public void setUnmodifiedSinceConstraint(Date date) { * * @return This {@link GetObjectRequest}, enabling additional method * calls to be chained together. - * + * * @see GetObjectRequest#getUnmodifiedSinceConstraint() - * @see GetObjectRequest#setUnmodifiedSinceConstraint(Date) + * @see GetObjectRequest#setUnmodifiedSinceConstraint(Date) */ public GetObjectRequest withUnmodifiedSinceConstraint(Date date) { setUnmodifiedSinceConstraint(date); @@ -583,9 +590,9 @@ public GetObjectRequest withUnmodifiedSinceConstraint(Date date) { * @return The optional modified constraint that restricts this * request to executing only if the object has * been modified after the specified date. - * - * @see GetObjectRequest#setModifiedSinceConstraint(Date) - * @see GetObjectRequest#withModifiedSinceConstraint(Date) + * + * @see GetObjectRequest#setModifiedSinceConstraint(Date) + * @see GetObjectRequest#withModifiedSinceConstraint(Date) */ public Date getModifiedSinceConstraint() { return modifiedSinceConstraint; @@ -603,9 +610,9 @@ public Date getModifiedSinceConstraint() { * The modified constraint that restricts this request to * executing only if the object has been modified * after the specified date. - * + * * @see GetObjectRequest#getModifiedSinceConstraint() - * @see GetObjectRequest#withModifiedSinceConstraint(Date) + * @see GetObjectRequest#withModifiedSinceConstraint(Date) */ public void setModifiedSinceConstraint(Date date) { this.modifiedSinceConstraint = date; @@ -627,9 +634,9 @@ public void setModifiedSinceConstraint(Date date) { * * @return This {@link GetObjectRequest}, enabling additional method * calls to be chained together. - * + * * @see GetObjectRequest#getModifiedSinceConstraint() - * @see GetObjectRequest#setModifiedSinceConstraint(Date) + * @see GetObjectRequest#setModifiedSinceConstraint(Date) */ public GetObjectRequest withModifiedSinceConstraint(Date date) { setModifiedSinceConstraint(date); @@ -638,7 +645,7 @@ public GetObjectRequest withModifiedSinceConstraint(Date date) { /** * Returns the headers to be overridden in the service response. - * + * * @return the headers to be overridden in the service response. */ public ResponseHeaderOverrides getResponseHeaders() { @@ -647,7 +654,7 @@ public ResponseHeaderOverrides getResponseHeaders() { /** * Sets the headers to be overridden in the service response. - * + * * @param responseHeaders * The headers to be overridden in the service response. */ @@ -658,15 +665,53 @@ public void setResponseHeaders(ResponseHeaderOverrides responseHeaders) { /** * Sets the headers to be overridden in the service response and returns * this object, for method chaining. - * + * * @param responseHeaders * The headers to be overridden in the service response. - * - * + * + * * @return This {@link GetObjectRequest} for method chaining. */ public GetObjectRequest withResponseHeaders(ResponseHeaderOverrides responseHeaders) { setResponseHeaders(responseHeaders); return this; } + + /** + * Sets the optional progress listener for receiving updates about object + * download status. + * + * @param progressListener + * The new progress listener. + */ + public void setProgressListener(ProgressListener progressListener) { + this.progressListener = progressListener; + } + + /** + * Returns the optional progress listener for receiving updates about object + * download status. + * + * @return the optional progress listener for receiving updates about object + * download status. + */ + public ProgressListener getProgressListener() { + return progressListener; + } + + /** + * Sets the optional progress listener for receiving updates about object + * download status, and returns this updated object so that additional method + * calls can be chained together. + * + * @param progressListener + * The new progress listener. + * + * @return This updated GetObjectRequest object. + */ + public GetObjectRequest withProgressListener(ProgressListener progressListener) { + setProgressListener(progressListener); + return this; + } + } diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/AmazonSimpleWorkflow.java b/src/main/java/com/amazonaws/services/simpleworkflow/AmazonSimpleWorkflow.java new file mode 100644 index 000000000000..6c7d6e00c55d --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/AmazonSimpleWorkflow.java @@ -0,0 +1,1424 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow; + +import com.amazonaws.*; +import com.amazonaws.services.simpleworkflow.model.*; + + +/** + * Interface for accessing AmazonSimpleWorkflow. + * Amazon Simple Workflow Service

+ * The Amazon Simple Workflow Service API Reference is intended for + * programmers who need detailed information about the Amazon SWF actions + * and data types. + *

+ *

+ * For an broader overview of the Amazon SWF programming model, please + * go to the + * Amazon SWF Developer Guide . + *

+ *

+ * This section provides an overview of Amazon SWF actions. + *

+ *

+ * Action Categories + *

+ *

+ * The Amazon SWF actions can be grouped into the following major + * categories. + *

+ * + * + *

+ * Actions related to Activities + *

+ *

+ * The following are actions that are performed by activity workers: + *

+ * + * + *

+ * Activity workers use the PollForActivityTask to get new activity + * tasks. After a worker receives an activity task from Amazon SWF, it + * performs the task and responds using RespondActivityTaskCompleted if + * successful or RespondActivityTaskFailed if unsuccessful. + *

+ *

+ * Actions related to Deciders + *

+ *

+ * The following are actions that are performed by deciders: + *

+ * + * + *

+ * Deciders use PollForDecisionTask to get decision tasks. After a + * decider receives a decision task from Amazon SWF, it examines its + * workflow execution history and decides what to do next. It calls + * RespondDecisionTaskCompletedto complete the decision task and provide + * zero or more next decisions. + *

+ *

+ * Actions related to Workflow Executions + *

+ *

+ * The following actions operate on a workflow execution: + *

+ * + * + *

+ * Actions related to Administration + *

+ *

+ * Although you can perform administrative tasks from the Amazon SWF + * console, you can use the actions in this section to automate functions + * or build your own administrative tools. + *

+ *

+ * Activity Management + *

+ * + * + *

+ * Workflow Management + *

+ * + * + *

+ * Domain Management + *

+ * + * + *

+ * Workflow Execution Management + *

+ * + * + *

+ * Visibility Actions + *

+ *

+ * Although you can perform visibility actions from the Amazon SWF + * console, you can use the actions in this section to build your own + * console or administrative tools. + *

+ * + * + *

+ * Activity Visibility + *

+ * + * + *

+ * Workflow Visibility + *

+ * + * + *

+ * Workflow Execution Visibility + *

+ * + * + *

+ * Domain Visibility + *

+ * + * + *

+ * Task List Visibility + *

+ * + * + */ +public interface AmazonSimpleWorkflow { + + /** + * Overrides the default endpoint for this client ("https://swf.amazonaws.com"). + * Callers can use this method to control which AWS region they want to work with. + *

+ * Callers can pass in just the endpoint (ex: "ec2.amazonaws.com") or a full + * URL, including the protocol (ex: "https://ec2.amazonaws.com"). If the + * protocol is not specified here, the default protocol from this client's + * {@link ClientConfiguration} will be used, which by default is HTTPS. + *

+ * For more information on using AWS regions with the AWS SDK for Java, and + * a complete list of all available endpoints for all AWS services, see: + * + * http://developer.amazonwebservices.com/connect/entry.jspa?externalID=3912 + * + * @param endpoint + * The endpoint (ex: "ec2.amazonaws.com") or a full URL, + * including the protocol (ex: "https://ec2.amazonaws.com") of + * the region specific AWS endpoint this client will communicate + * with. + * + * @throws IllegalArgumentException + * If any problems are detected with the specified endpoint. + */ + public void setEndpoint(String endpoint) throws java.lang.IllegalArgumentException; + + /** + *

+ * Deprecates the specified workflow type . After a workflow type + * has been deprecated, you cannot create new executions of that type. + * Executions that were started before the type was deprecated will + * continue to run. A deprecated workflow type may still be used when + * calling visibility actions. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param deprecateWorkflowTypeRequest Container for the necessary + * parameters to execute the DeprecateWorkflowType service method on + * AmazonSimpleWorkflow. + * + * @throws TypeDeprecatedException + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void deprecateWorkflowType(DeprecateWorkflowTypeRequest deprecateWorkflowTypeRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Deprecates the specified domain. After a domain has been deprecated + * it cannot be used to create new workflow executions or register new + * types. However, you can still use visibility actions on this domain. + * Deprecating a domain also deprecates all activity and workflow types + * registered in the domain. Executions that were started before the + * domain was deprecated will continue to run. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param deprecateDomainRequest Container for the necessary parameters + * to execute the DeprecateDomain service method on AmazonSimpleWorkflow. + * + * @throws DomainDeprecatedException + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void deprecateDomain(DeprecateDomainRequest deprecateDomainRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Registers a new workflow type and its configuration settings + * in the specified domain. + *

+ *

+ * IMPORTANT: If the type already exists, then a TypeAlreadyExists + * fault is returned. You cannot change the configuration settings of a + * workflow type once it is registered and it must be registered as a new + * version. + *

+ * + * @param registerWorkflowTypeRequest Container for the necessary + * parameters to execute the RegisterWorkflowType service method on + * AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * @throws TypeAlreadyExistsException + * @throws LimitExceededException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void registerWorkflowType(RegisterWorkflowTypeRequest registerWorkflowTypeRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns information about workflow types in the specified domain. The + * results may be split into multiple pages that can be retrieved by + * making the call repeatedly. + *

+ * + * @param listWorkflowTypesRequest Container for the necessary parameters + * to execute the ListWorkflowTypes service method on + * AmazonSimpleWorkflow. + * + * @return The response from the ListWorkflowTypes service method, as + * returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public WorkflowTypeInfos listWorkflowTypes(ListWorkflowTypesRequest listWorkflowTypesRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Starts an execution of the workflow type in the specified domain + * using the provided workflowId and input data. + *

+ *

+ * This action returns the newly started workflow execution. + *

+ * + * @param startWorkflowExecutionRequest Container for the necessary + * parameters to execute the StartWorkflowExecution service method on + * AmazonSimpleWorkflow. + * + * @return The response from the StartWorkflowExecution service method, + * as returned by AmazonSimpleWorkflow. + * + * @throws TypeDeprecatedException + * @throws OperationNotPermittedException + * @throws DefaultUndefinedException + * @throws UnknownResourceException + * @throws WorkflowExecutionAlreadyStartedException + * @throws LimitExceededException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Run startWorkflowExecution(StartWorkflowExecutionRequest startWorkflowExecutionRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Records a WorkflowExecutionSignaled event in the + * workflow execution history and creates a decision task for the + * workflow execution identified by the given domain, workflowId and + * runId. The event is recorded with the specified user defined + * signalName and input (if provided). + *

+ *

+ * NOTE: If a runId is not specified, then the + * WorkflowExecutionSignaled event is recorded in the history of the + * current open workflow with the matching workflowId in the domain. + *

+ *

+ * NOTE: If the specified workflow execution is not open, this + * method fails with UnknownResource. + *

+ * + * @param signalWorkflowExecutionRequest Container for the necessary + * parameters to execute the SignalWorkflowExecution service method on + * AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void signalWorkflowExecution(SignalWorkflowExecutionRequest signalWorkflowExecutionRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns the list of domains registered in the account. The results + * may be split into multiple pages. To retrieve subsequent pages, make + * the call again using the nextPageToken returned by the initial call. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param listDomainsRequest Container for the necessary parameters to + * execute the ListDomains service method on AmazonSimpleWorkflow. + * + * @return The response from the ListDomains service method, as returned + * by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public DomainInfos listDomains(ListDomainsRequest listDomainsRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Records a WorkflowExecutionCancelRequested event in the + * currently running workflow execution identified by the given domain, + * workflowId, and runId. This logically requests the cancellation of the + * workflow execution as a whole. It is up to the decider to take + * appropriate actions when it receives an execution history with this + * event. + *

+ *

+ * NOTE: If the runId is not specified, the + * WorkflowExecutionCancelRequested event is recorded in the history of + * the current open workflow execution with the specified workflowId in + * the domain. + *

+ *

+ * NOTE: Because this action allows the workflow to properly clean + * up and gracefully close, it should be used instead of + * TerminateWorkflowExecution when possible. + *

+ * + * @param requestCancelWorkflowExecutionRequest Container for the + * necessary parameters to execute the RequestCancelWorkflowExecution + * service method on AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void requestCancelWorkflowExecution(RequestCancelWorkflowExecutionRequest requestCancelWorkflowExecutionRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns information about the specified workflow type . This + * includes configuration settings specified when the type was registered + * and other information such as creation date, current status, etc. + *

+ * + * @param describeWorkflowTypeRequest Container for the necessary + * parameters to execute the DescribeWorkflowType service method on + * AmazonSimpleWorkflow. + * + * @return The response from the DescribeWorkflowType service method, as + * returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public WorkflowTypeDetail describeWorkflowType(DescribeWorkflowTypeRequest describeWorkflowTypeRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Deprecates the specified activity type . + * After an activity type has been deprecated, you cannot create new + * tasks of that activity type. Tasks of this type that were scheduled + * before the type was deprecated will continue to run. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param deprecateActivityTypeRequest Container for the necessary + * parameters to execute the DeprecateActivityType service method on + * AmazonSimpleWorkflow. + * + * @throws TypeDeprecatedException + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void deprecateActivityType(DeprecateActivityTypeRequest deprecateActivityTypeRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns the number of closed workflow executions within the given + * domain that meet the specified filtering criteria. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param countClosedWorkflowExecutionsRequest Container for the + * necessary parameters to execute the CountClosedWorkflowExecutions + * service method on AmazonSimpleWorkflow. + * + * @return The response from the CountClosedWorkflowExecutions service + * method, as returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public WorkflowExecutionCount countClosedWorkflowExecutions(CountClosedWorkflowExecutionsRequest countClosedWorkflowExecutionsRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns the estimated number of activity tasks in the specified task + * list. The count returned is an approximation and is not guaranteed to + * be exact. If you specify a task list that no activity task was ever + * scheduled in then 0 will be returned. + *

+ * + * @param countPendingActivityTasksRequest Container for the necessary + * parameters to execute the CountPendingActivityTasks service method on + * AmazonSimpleWorkflow. + * + * @return The response from the CountPendingActivityTasks service + * method, as returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public PendingTaskCount countPendingActivityTasks(CountPendingActivityTasksRequest countPendingActivityTasksRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Used by workers to tell the service that the ActivityTask identified + * by the taskToken was successfully canceled. Additional + * details can be optionally provided using the + * details argument. + *

+ *

+ * These details (if provided) appear in the + * ActivityTaskCanceled event added to the workflow history. + *

+ *

+ * IMPORTANT: Only use this operation if the canceled flag of a + * RecordActivityTaskHeartbeat request returns true and if the activity + * can be safely undone or abandoned. + *

+ * + * @param respondActivityTaskCanceledRequest Container for the necessary + * parameters to execute the RespondActivityTaskCanceled service method + * on AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void respondActivityTaskCanceled(RespondActivityTaskCanceledRequest respondActivityTaskCanceledRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Used by deciders to tell the service that the DecisionTask identified + * by the taskToken has successfully completed. The + * decisions argument specifies the list of decisions made + * while processing the task. + *

+ *

+ * A + * DecisionTaskCompleted event is added + * to the workflow history. The executionContext specified + * is attached to the event in the workflow execution history. + *

+ * + * @param respondDecisionTaskCompletedRequest Container for the necessary + * parameters to execute the RespondDecisionTaskCompleted service method + * on AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void respondDecisionTaskCompleted(RespondDecisionTaskCompletedRequest respondDecisionTaskCompletedRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Used by workers to tell the service that the ActivityTask identified + * by the taskToken completed successfully with a + * result (if provided). + *

+ *

+ * The result appears in the + * ActivityTaskCompleted event in the workflow history. + *

+ *

+ * IMPORTANT: If the requested task does not complete + * successfully, use RespondActivityTaskFailed instead. If the worker + * finds that the task is canceled through the canceled flag returned by + * RecordActivityTaskHeartbeat, it should cancel the task, clean up and + * then call RespondActivityTaskCanceled. + *

+ * + * @param respondActivityTaskCompletedRequest Container for the necessary + * parameters to execute the RespondActivityTaskCompleted service method + * on AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void respondActivityTaskCompleted(RespondActivityTaskCompletedRequest respondActivityTaskCompletedRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Used by workers to get an ActivityTask from the specified activity + * taskList . + * This initiates a long poll, where the service holds the HTTP + * connection open and responds as soon as a task becomes available. The + * maximum time the service holds on to the request before responding is + * 60 seconds. If no task is available within 60 seconds, the poll will + * return an empty result. An empty result, in this context, means that + * an ActivityTask is returned, but that the value of taskToken is an + * empty string. If a task is returned, the worker should use its type to + * identify and process it correctly. + *

+ *

+ * IMPORTANT: Workers should set their client side socket timeout + * to at least 70 seconds (10 seconds higher than the maximum time + * service may hold the poll request). + *

+ * + * @param pollForActivityTaskRequest Container for the necessary + * parameters to execute the PollForActivityTask service method on + * AmazonSimpleWorkflow. + * + * @return The response from the PollForActivityTask service method, as + * returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public ActivityTask pollForActivityTask(PollForActivityTaskRequest pollForActivityTaskRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns the number of open workflow executions within the given + * domain that meet the specified filtering criteria. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param countOpenWorkflowExecutionsRequest Container for the necessary + * parameters to execute the CountOpenWorkflowExecutions service method + * on AmazonSimpleWorkflow. + * + * @return The response from the CountOpenWorkflowExecutions service + * method, as returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public WorkflowExecutionCount countOpenWorkflowExecutions(CountOpenWorkflowExecutionsRequest countOpenWorkflowExecutionsRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns information about the specified activity type. This includes + * configuration settings provided at registration time as well as other + * general information about the type. + *

+ * + * @param describeActivityTypeRequest Container for the necessary + * parameters to execute the DescribeActivityType service method on + * AmazonSimpleWorkflow. + * + * @return The response from the DescribeActivityType service method, as + * returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public ActivityTypeDetail describeActivityType(DescribeActivityTypeRequest describeActivityTypeRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns a list of open workflow executions in the specified domain + * that meet the filtering criteria. The results may be split into + * multiple pages. To retrieve subsequent pages, make the call again + * using the nextPageToken returned by the initial call. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param listOpenWorkflowExecutionsRequest Container for the necessary + * parameters to execute the ListOpenWorkflowExecutions service method on + * AmazonSimpleWorkflow. + * + * @return The response from the ListOpenWorkflowExecutions service + * method, as returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public WorkflowExecutionInfos listOpenWorkflowExecutions(ListOpenWorkflowExecutionsRequest listOpenWorkflowExecutionsRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns the history of the specified workflow execution. The results + * may be split into multiple pages. To retrieve subsequent pages, make + * the call again using the nextPageToken returned by the + * initial call. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param getWorkflowExecutionHistoryRequest Container for the necessary + * parameters to execute the GetWorkflowExecutionHistory service method + * on AmazonSimpleWorkflow. + * + * @return The response from the GetWorkflowExecutionHistory service + * method, as returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public History getWorkflowExecutionHistory(GetWorkflowExecutionHistoryRequest getWorkflowExecutionHistoryRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Registers a new domain. + *

+ * + * @param registerDomainRequest Container for the necessary parameters to + * execute the RegisterDomain service method on AmazonSimpleWorkflow. + * + * @throws DomainAlreadyExistsException + * @throws OperationNotPermittedException + * @throws LimitExceededException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void registerDomain(RegisterDomainRequest registerDomainRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Registers a new activity type along with its configuration + * settings in the specified domain. + *

+ *

+ * IMPORTANT: A TypeAlreadyExists fault is returned if the type + * already exists in the domain. You cannot change any configuration + * settings of the type after its registration, and it must be registered + * as a new version. + *

+ * + * @param registerActivityTypeRequest Container for the necessary + * parameters to execute the RegisterActivityType service method on + * AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * @throws TypeAlreadyExistsException + * @throws LimitExceededException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void registerActivityType(RegisterActivityTypeRequest registerActivityTypeRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns a list of closed workflow executions in the specified domain + * that meet the filtering criteria. The results may be split into + * multiple pages. To retrieve subsequent pages, make the call again + * using the nextPageToken returned by the initial call. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param listClosedWorkflowExecutionsRequest Container for the necessary + * parameters to execute the ListClosedWorkflowExecutions service method + * on AmazonSimpleWorkflow. + * + * @return The response from the ListClosedWorkflowExecutions service + * method, as returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public WorkflowExecutionInfos listClosedWorkflowExecutions(ListClosedWorkflowExecutionsRequest listClosedWorkflowExecutionsRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Used by activity workers to report to the service that the + * ActivityTask represented by the specified taskToken is + * still making progress. The worker can also (optionally) specify + * details of the progress, for example percent complete, using the + * details parameter. This action can also be used by the + * worker as a mechanism to check if cancellation is being requested for + * the activity task. If a cancellation is being attempted for the + * specified task, then the boolean cancelRequested flag + * returned by the service is set to true . + * + *

+ *

+ * This action resets the taskHeartbeatTimeout clock. The + * taskHeartbeatTimeout is specified in + * RegisterActivityType. + *

+ *

+ * This action does not in itself create an event in the workflow + * execution history. However, if the task times out, the workflow + * execution history will contain a ActivityTaskTimedOut + * event that contains the information from the last heartbeat generated + * by the activity worker. + *

+ *

+ * NOTE: The taskStartToCloseTimeout of an activity type is the + * maximum duration of an activity task, regardless of the number of + * RecordActivityTaskHeartbeat requests received. The + * taskStartToCloseTimeout is also specified in RegisterActivityType. + *

+ *

+ * NOTE: This operation is only useful for long-lived activities + * to report liveliness of the task and to determine if a cancellation is + * being attempted. + *

+ *

+ * IMPORTANT: If the cancelRequested flag returns true, a + * cancellation is being attempted. If the worker can cancel the + * activity, it should respond with RespondActivityTaskCanceled. + * Otherwise, it should ignore the cancellation request. + *

+ * + * @param recordActivityTaskHeartbeatRequest Container for the necessary + * parameters to execute the RecordActivityTaskHeartbeat service method + * on AmazonSimpleWorkflow. + * + * @return The response from the RecordActivityTaskHeartbeat service + * method, as returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public ActivityTaskStatus recordActivityTaskHeartbeat(RecordActivityTaskHeartbeatRequest recordActivityTaskHeartbeatRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Used by deciders to get a DecisionTask from the specified decision + * taskList . + * A decision task may be returned for any open workflow + * execution that is using the specified task list. The task includes a + * paginated view of the history of the workflow execution. The decider + * should use the workflow type and the history to determine how to + * properly handle the task. + *

+ *

+ * This action initiates a long poll, where the service holds the HTTP + * connection open and responds as soon a task becomes available. If no + * decision task is available in the specified task list before the + * timeout of 60 seconds expires, an empty result is returned. An empty + * result, in this context, means that a DecisionTask is returned, but + * that the value of taskToken is an empty string. + *

+ *

+ * IMPORTANT: Deciders should set their client side socket timeout + * to at least 70 seconds (10 seconds higher than the timeout). + *

+ *

+ * IMPORTANT: Because the number of workflow history events for a + * single workflow execution might be very large, the result returned + * might be split up across a number of pages. To retrieve subsequent + * pages, make additional calls to PollForDecisionTask using the + * nextPageToken returned by the initial call. Note that you do not call + * GetWorkflowExecutionHistory with this nextPageToken. Instead, call + * PollForDecisionTask again. + *

+ * + * @param pollForDecisionTaskRequest Container for the necessary + * parameters to execute the PollForDecisionTask service method on + * AmazonSimpleWorkflow. + * + * @return The response from the PollForDecisionTask service method, as + * returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public DecisionTask pollForDecisionTask(PollForDecisionTaskRequest pollForDecisionTaskRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns information about all activities registered in the specified + * domain that match the specified name and registration status. The + * result includes information like creation date, current status of the + * activity, etc. The results may be split into multiple pages. To + * retrieve subsequent pages, make the call again using the + * nextPageToken returned by the initial call. + *

+ * + * @param listActivityTypesRequest Container for the necessary parameters + * to execute the ListActivityTypes service method on + * AmazonSimpleWorkflow. + * + * @return The response from the ListActivityTypes service method, as + * returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public ActivityTypeInfos listActivityTypes(ListActivityTypesRequest listActivityTypesRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns information about the specified domain including description + * and status. + *

+ * + * @param describeDomainRequest Container for the necessary parameters to + * execute the DescribeDomain service method on AmazonSimpleWorkflow. + * + * @return The response from the DescribeDomain service method, as + * returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public DomainDetail describeDomain(DescribeDomainRequest describeDomainRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Used by workers to tell the service that the ActivityTask identified + * by the taskToken has failed with reason (if + * specified). + *

+ *

+ * The reason and details appear in the + * ActivityTaskFailed event added to the workflow history. + *

+ * + * @param respondActivityTaskFailedRequest Container for the necessary + * parameters to execute the RespondActivityTaskFailed service method on + * AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void respondActivityTaskFailed(RespondActivityTaskFailedRequest respondActivityTaskFailedRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns the estimated number of decision tasks in the specified task + * list. The count returned is an approximation and is not guaranteed to + * be exact. If you specify a task list that no decision task was ever + * scheduled in then 0 will be returned. + *

+ * + * @param countPendingDecisionTasksRequest Container for the necessary + * parameters to execute the CountPendingDecisionTasks service method on + * AmazonSimpleWorkflow. + * + * @return The response from the CountPendingDecisionTasks service + * method, as returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public PendingTaskCount countPendingDecisionTasks(CountPendingDecisionTasksRequest countPendingDecisionTasksRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Records a WorkflowExecutionTerminated event and forces + * closure of the workflow execution identified by the given domain, + * runId, and workflowId. The child policy, registered with the workflow + * type or specified when starting this execution, is applied to any open + * child workflow executions of this workflow execution. + *

+ *

+ * IMPORTANT: If the identified workflow execution was in + * progress, it is terminated immediately. + *

+ *

+ * NOTE: If a runId is not specified, then the + * WorkflowExecutionTerminated event is recorded in the history of the + * current open workflow with the matching workflowId in the domain. + *

+ *

+ * NOTE: You should consider using RequestCancelWorkflowExecution + * action instead because it allows the workflow to gracefully close + * while TerminateWorkflowExecution does not. + *

+ * + * @param terminateWorkflowExecutionRequest Container for the necessary + * parameters to execute the TerminateWorkflowExecution service method on + * AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void terminateWorkflowExecution(TerminateWorkflowExecutionRequest terminateWorkflowExecutionRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns information about the specified workflow execution including + * its type and some statistics. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param describeWorkflowExecutionRequest Container for the necessary + * parameters to execute the DescribeWorkflowExecution service method on + * AmazonSimpleWorkflow. + * + * @return The response from the DescribeWorkflowExecution service + * method, as returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public WorkflowExecutionDetail describeWorkflowExecution(DescribeWorkflowExecutionRequest describeWorkflowExecutionRequest) + throws AmazonServiceException, AmazonClientException; + + /** + * Shuts down this client object, releasing any resources that might be held + * open. This is an optional method, and callers are not expected to call + * it, but can if they want to explicitly release any open resources. Once a + * client has been shutdown, it should not be used to make any more + * requests. + */ + public void shutdown(); + + /** + * Returns additional metadata for a previously executed successful request, typically used for + * debugging issues where a service isn't acting as expected. This data isn't considered part + * of the result data returned by an operation, so it's available through this separate, + * diagnostic interface. + *

+ * Response metadata is only cached for a limited period of time, so if you need to access + * this extra diagnostic information for an executed request, you should use this method + * to retrieve it as soon as possible after executing a request. + * + * @param request + * The originally executed request. + * + * @return The response metadata for the specified request, or null if none + * is available. + */ + public ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest request); + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/AmazonSimpleWorkflowAsync.java b/src/main/java/com/amazonaws/services/simpleworkflow/AmazonSimpleWorkflowAsync.java new file mode 100644 index 000000000000..30c31fe2fedf --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/AmazonSimpleWorkflowAsync.java @@ -0,0 +1,1332 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow; + +import java.util.concurrent.Future; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.AmazonServiceException; +import com.amazonaws.services.simpleworkflow.model.*; + +/** + * Interface for accessing AmazonSimpleWorkflow asynchronously, + * using Java Futures. + * Amazon Simple Workflow Service

+ * The Amazon Simple Workflow Service API Reference is intended for + * programmers who need detailed information about the Amazon SWF actions + * and data types. + *

+ *

+ * For an broader overview of the Amazon SWF programming model, please + * go to the + * Amazon SWF Developer Guide . + *

+ *

+ * This section provides an overview of Amazon SWF actions. + *

+ *

+ * Action Categories + *

+ *

+ * The Amazon SWF actions can be grouped into the following major + * categories. + *

+ * + * + *

+ * Actions related to Activities + *

+ *

+ * The following are actions that are performed by activity workers: + *

+ * + * + *

+ * Activity workers use the PollForActivityTask to get new activity + * tasks. After a worker receives an activity task from Amazon SWF, it + * performs the task and responds using RespondActivityTaskCompleted if + * successful or RespondActivityTaskFailed if unsuccessful. + *

+ *

+ * Actions related to Deciders + *

+ *

+ * The following are actions that are performed by deciders: + *

+ * + * + *

+ * Deciders use PollForDecisionTask to get decision tasks. After a + * decider receives a decision task from Amazon SWF, it examines its + * workflow execution history and decides what to do next. It calls + * RespondDecisionTaskCompletedto complete the decision task and provide + * zero or more next decisions. + *

+ *

+ * Actions related to Workflow Executions + *

+ *

+ * The following actions operate on a workflow execution: + *

+ * + * + *

+ * Actions related to Administration + *

+ *

+ * Although you can perform administrative tasks from the Amazon SWF + * console, you can use the actions in this section to automate functions + * or build your own administrative tools. + *

+ *

+ * Activity Management + *

+ * + * + *

+ * Workflow Management + *

+ * + * + *

+ * Domain Management + *

+ * + * + *

+ * Workflow Execution Management + *

+ * + * + *

+ * Visibility Actions + *

+ *

+ * Although you can perform visibility actions from the Amazon SWF + * console, you can use the actions in this section to build your own + * console or administrative tools. + *

+ * + * + *

+ * Activity Visibility + *

+ * + * + *

+ * Workflow Visibility + *

+ * + * + *

+ * Workflow Execution Visibility + *

+ * + * + *

+ * Domain Visibility + *

+ * + * + *

+ * Task List Visibility + *

+ * + * + */ +public interface AmazonSimpleWorkflowAsync extends AmazonSimpleWorkflow { + /** + *

+ * Deprecates the specified workflow type . After a workflow type + * has been deprecated, you cannot create new executions of that type. + * Executions that were started before the type was deprecated will + * continue to run. A deprecated workflow type may still be used when + * calling visibility actions. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param deprecateWorkflowTypeRequest Container for the necessary + * parameters to execute the DeprecateWorkflowType operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * DeprecateWorkflowType service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future deprecateWorkflowTypeAsync(DeprecateWorkflowTypeRequest deprecateWorkflowTypeRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Deprecates the specified domain. After a domain has been deprecated + * it cannot be used to create new workflow executions or register new + * types. However, you can still use visibility actions on this domain. + * Deprecating a domain also deprecates all activity and workflow types + * registered in the domain. Executions that were started before the + * domain was deprecated will continue to run. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param deprecateDomainRequest Container for the necessary parameters + * to execute the DeprecateDomain operation on AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * DeprecateDomain service method, as returned by AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future deprecateDomainAsync(DeprecateDomainRequest deprecateDomainRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Registers a new workflow type and its configuration settings + * in the specified domain. + *

+ *

+ * IMPORTANT: If the type already exists, then a TypeAlreadyExists + * fault is returned. You cannot change the configuration settings of a + * workflow type once it is registered and it must be registered as a new + * version. + *

+ * + * @param registerWorkflowTypeRequest Container for the necessary + * parameters to execute the RegisterWorkflowType operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * RegisterWorkflowType service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future registerWorkflowTypeAsync(RegisterWorkflowTypeRequest registerWorkflowTypeRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns information about workflow types in the specified domain. The + * results may be split into multiple pages that can be retrieved by + * making the call repeatedly. + *

+ * + * @param listWorkflowTypesRequest Container for the necessary parameters + * to execute the ListWorkflowTypes operation on AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * ListWorkflowTypes service method, as returned by AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future listWorkflowTypesAsync(ListWorkflowTypesRequest listWorkflowTypesRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Starts an execution of the workflow type in the specified domain + * using the provided workflowId and input data. + *

+ *

+ * This action returns the newly started workflow execution. + *

+ * + * @param startWorkflowExecutionRequest Container for the necessary + * parameters to execute the StartWorkflowExecution operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * StartWorkflowExecution service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future startWorkflowExecutionAsync(StartWorkflowExecutionRequest startWorkflowExecutionRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Records a WorkflowExecutionSignaled event in the + * workflow execution history and creates a decision task for the + * workflow execution identified by the given domain, workflowId and + * runId. The event is recorded with the specified user defined + * signalName and input (if provided). + *

+ *

+ * NOTE: If a runId is not specified, then the + * WorkflowExecutionSignaled event is recorded in the history of the + * current open workflow with the matching workflowId in the domain. + *

+ *

+ * NOTE: If the specified workflow execution is not open, this + * method fails with UnknownResource. + *

+ * + * @param signalWorkflowExecutionRequest Container for the necessary + * parameters to execute the SignalWorkflowExecution operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * SignalWorkflowExecution service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future signalWorkflowExecutionAsync(SignalWorkflowExecutionRequest signalWorkflowExecutionRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns the list of domains registered in the account. The results + * may be split into multiple pages. To retrieve subsequent pages, make + * the call again using the nextPageToken returned by the initial call. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param listDomainsRequest Container for the necessary parameters to + * execute the ListDomains operation on AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * ListDomains service method, as returned by AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future listDomainsAsync(ListDomainsRequest listDomainsRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Records a WorkflowExecutionCancelRequested event in the + * currently running workflow execution identified by the given domain, + * workflowId, and runId. This logically requests the cancellation of the + * workflow execution as a whole. It is up to the decider to take + * appropriate actions when it receives an execution history with this + * event. + *

+ *

+ * NOTE: If the runId is not specified, the + * WorkflowExecutionCancelRequested event is recorded in the history of + * the current open workflow execution with the specified workflowId in + * the domain. + *

+ *

+ * NOTE: Because this action allows the workflow to properly clean + * up and gracefully close, it should be used instead of + * TerminateWorkflowExecution when possible. + *

+ * + * @param requestCancelWorkflowExecutionRequest Container for the + * necessary parameters to execute the RequestCancelWorkflowExecution + * operation on AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * RequestCancelWorkflowExecution service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future requestCancelWorkflowExecutionAsync(RequestCancelWorkflowExecutionRequest requestCancelWorkflowExecutionRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns information about the specified workflow type . This + * includes configuration settings specified when the type was registered + * and other information such as creation date, current status, etc. + *

+ * + * @param describeWorkflowTypeRequest Container for the necessary + * parameters to execute the DescribeWorkflowType operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * DescribeWorkflowType service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future describeWorkflowTypeAsync(DescribeWorkflowTypeRequest describeWorkflowTypeRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Deprecates the specified activity type . + * After an activity type has been deprecated, you cannot create new + * tasks of that activity type. Tasks of this type that were scheduled + * before the type was deprecated will continue to run. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param deprecateActivityTypeRequest Container for the necessary + * parameters to execute the DeprecateActivityType operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * DeprecateActivityType service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future deprecateActivityTypeAsync(DeprecateActivityTypeRequest deprecateActivityTypeRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns the number of closed workflow executions within the given + * domain that meet the specified filtering criteria. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param countClosedWorkflowExecutionsRequest Container for the + * necessary parameters to execute the CountClosedWorkflowExecutions + * operation on AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * CountClosedWorkflowExecutions service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future countClosedWorkflowExecutionsAsync(CountClosedWorkflowExecutionsRequest countClosedWorkflowExecutionsRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns the estimated number of activity tasks in the specified task + * list. The count returned is an approximation and is not guaranteed to + * be exact. If you specify a task list that no activity task was ever + * scheduled in then 0 will be returned. + *

+ * + * @param countPendingActivityTasksRequest Container for the necessary + * parameters to execute the CountPendingActivityTasks operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * CountPendingActivityTasks service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future countPendingActivityTasksAsync(CountPendingActivityTasksRequest countPendingActivityTasksRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Used by workers to tell the service that the ActivityTask identified + * by the taskToken was successfully canceled. Additional + * details can be optionally provided using the + * details argument. + *

+ *

+ * These details (if provided) appear in the + * ActivityTaskCanceled event added to the workflow history. + *

+ *

+ * IMPORTANT: Only use this operation if the canceled flag of a + * RecordActivityTaskHeartbeat request returns true and if the activity + * can be safely undone or abandoned. + *

+ * + * @param respondActivityTaskCanceledRequest Container for the necessary + * parameters to execute the RespondActivityTaskCanceled operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * RespondActivityTaskCanceled service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future respondActivityTaskCanceledAsync(RespondActivityTaskCanceledRequest respondActivityTaskCanceledRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Used by deciders to tell the service that the DecisionTask identified + * by the taskToken has successfully completed. The + * decisions argument specifies the list of decisions made + * while processing the task. + *

+ *

+ * A + * DecisionTaskCompleted event is added + * to the workflow history. The executionContext specified + * is attached to the event in the workflow execution history. + *

+ * + * @param respondDecisionTaskCompletedRequest Container for the necessary + * parameters to execute the RespondDecisionTaskCompleted operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * RespondDecisionTaskCompleted service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future respondDecisionTaskCompletedAsync(RespondDecisionTaskCompletedRequest respondDecisionTaskCompletedRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Used by workers to tell the service that the ActivityTask identified + * by the taskToken completed successfully with a + * result (if provided). + *

+ *

+ * The result appears in the + * ActivityTaskCompleted event in the workflow history. + *

+ *

+ * IMPORTANT: If the requested task does not complete + * successfully, use RespondActivityTaskFailed instead. If the worker + * finds that the task is canceled through the canceled flag returned by + * RecordActivityTaskHeartbeat, it should cancel the task, clean up and + * then call RespondActivityTaskCanceled. + *

+ * + * @param respondActivityTaskCompletedRequest Container for the necessary + * parameters to execute the RespondActivityTaskCompleted operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * RespondActivityTaskCompleted service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future respondActivityTaskCompletedAsync(RespondActivityTaskCompletedRequest respondActivityTaskCompletedRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Used by workers to get an ActivityTask from the specified activity + * taskList . + * This initiates a long poll, where the service holds the HTTP + * connection open and responds as soon as a task becomes available. The + * maximum time the service holds on to the request before responding is + * 60 seconds. If no task is available within 60 seconds, the poll will + * return an empty result. An empty result, in this context, means that + * an ActivityTask is returned, but that the value of taskToken is an + * empty string. If a task is returned, the worker should use its type to + * identify and process it correctly. + *

+ *

+ * IMPORTANT: Workers should set their client side socket timeout + * to at least 70 seconds (10 seconds higher than the maximum time + * service may hold the poll request). + *

+ * + * @param pollForActivityTaskRequest Container for the necessary + * parameters to execute the PollForActivityTask operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * PollForActivityTask service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future pollForActivityTaskAsync(PollForActivityTaskRequest pollForActivityTaskRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns the number of open workflow executions within the given + * domain that meet the specified filtering criteria. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param countOpenWorkflowExecutionsRequest Container for the necessary + * parameters to execute the CountOpenWorkflowExecutions operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * CountOpenWorkflowExecutions service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future countOpenWorkflowExecutionsAsync(CountOpenWorkflowExecutionsRequest countOpenWorkflowExecutionsRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns information about the specified activity type. This includes + * configuration settings provided at registration time as well as other + * general information about the type. + *

+ * + * @param describeActivityTypeRequest Container for the necessary + * parameters to execute the DescribeActivityType operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * DescribeActivityType service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future describeActivityTypeAsync(DescribeActivityTypeRequest describeActivityTypeRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns a list of open workflow executions in the specified domain + * that meet the filtering criteria. The results may be split into + * multiple pages. To retrieve subsequent pages, make the call again + * using the nextPageToken returned by the initial call. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param listOpenWorkflowExecutionsRequest Container for the necessary + * parameters to execute the ListOpenWorkflowExecutions operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * ListOpenWorkflowExecutions service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future listOpenWorkflowExecutionsAsync(ListOpenWorkflowExecutionsRequest listOpenWorkflowExecutionsRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns the history of the specified workflow execution. The results + * may be split into multiple pages. To retrieve subsequent pages, make + * the call again using the nextPageToken returned by the + * initial call. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param getWorkflowExecutionHistoryRequest Container for the necessary + * parameters to execute the GetWorkflowExecutionHistory operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * GetWorkflowExecutionHistory service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future getWorkflowExecutionHistoryAsync(GetWorkflowExecutionHistoryRequest getWorkflowExecutionHistoryRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Registers a new domain. + *

+ * + * @param registerDomainRequest Container for the necessary parameters to + * execute the RegisterDomain operation on AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * RegisterDomain service method, as returned by AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future registerDomainAsync(RegisterDomainRequest registerDomainRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Registers a new activity type along with its configuration + * settings in the specified domain. + *

+ *

+ * IMPORTANT: A TypeAlreadyExists fault is returned if the type + * already exists in the domain. You cannot change any configuration + * settings of the type after its registration, and it must be registered + * as a new version. + *

+ * + * @param registerActivityTypeRequest Container for the necessary + * parameters to execute the RegisterActivityType operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * RegisterActivityType service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future registerActivityTypeAsync(RegisterActivityTypeRequest registerActivityTypeRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns a list of closed workflow executions in the specified domain + * that meet the filtering criteria. The results may be split into + * multiple pages. To retrieve subsequent pages, make the call again + * using the nextPageToken returned by the initial call. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param listClosedWorkflowExecutionsRequest Container for the necessary + * parameters to execute the ListClosedWorkflowExecutions operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * ListClosedWorkflowExecutions service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future listClosedWorkflowExecutionsAsync(ListClosedWorkflowExecutionsRequest listClosedWorkflowExecutionsRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Used by activity workers to report to the service that the + * ActivityTask represented by the specified taskToken is + * still making progress. The worker can also (optionally) specify + * details of the progress, for example percent complete, using the + * details parameter. This action can also be used by the + * worker as a mechanism to check if cancellation is being requested for + * the activity task. If a cancellation is being attempted for the + * specified task, then the boolean cancelRequested flag + * returned by the service is set to true . + * + *

+ *

+ * This action resets the taskHeartbeatTimeout clock. The + * taskHeartbeatTimeout is specified in + * RegisterActivityType. + *

+ *

+ * This action does not in itself create an event in the workflow + * execution history. However, if the task times out, the workflow + * execution history will contain a ActivityTaskTimedOut + * event that contains the information from the last heartbeat generated + * by the activity worker. + *

+ *

+ * NOTE: The taskStartToCloseTimeout of an activity type is the + * maximum duration of an activity task, regardless of the number of + * RecordActivityTaskHeartbeat requests received. The + * taskStartToCloseTimeout is also specified in RegisterActivityType. + *

+ *

+ * NOTE: This operation is only useful for long-lived activities + * to report liveliness of the task and to determine if a cancellation is + * being attempted. + *

+ *

+ * IMPORTANT: If the cancelRequested flag returns true, a + * cancellation is being attempted. If the worker can cancel the + * activity, it should respond with RespondActivityTaskCanceled. + * Otherwise, it should ignore the cancellation request. + *

+ * + * @param recordActivityTaskHeartbeatRequest Container for the necessary + * parameters to execute the RecordActivityTaskHeartbeat operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * RecordActivityTaskHeartbeat service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future recordActivityTaskHeartbeatAsync(RecordActivityTaskHeartbeatRequest recordActivityTaskHeartbeatRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Used by deciders to get a DecisionTask from the specified decision + * taskList . + * A decision task may be returned for any open workflow + * execution that is using the specified task list. The task includes a + * paginated view of the history of the workflow execution. The decider + * should use the workflow type and the history to determine how to + * properly handle the task. + *

+ *

+ * This action initiates a long poll, where the service holds the HTTP + * connection open and responds as soon a task becomes available. If no + * decision task is available in the specified task list before the + * timeout of 60 seconds expires, an empty result is returned. An empty + * result, in this context, means that a DecisionTask is returned, but + * that the value of taskToken is an empty string. + *

+ *

+ * IMPORTANT: Deciders should set their client side socket timeout + * to at least 70 seconds (10 seconds higher than the timeout). + *

+ *

+ * IMPORTANT: Because the number of workflow history events for a + * single workflow execution might be very large, the result returned + * might be split up across a number of pages. To retrieve subsequent + * pages, make additional calls to PollForDecisionTask using the + * nextPageToken returned by the initial call. Note that you do not call + * GetWorkflowExecutionHistory with this nextPageToken. Instead, call + * PollForDecisionTask again. + *

+ * + * @param pollForDecisionTaskRequest Container for the necessary + * parameters to execute the PollForDecisionTask operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * PollForDecisionTask service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future pollForDecisionTaskAsync(PollForDecisionTaskRequest pollForDecisionTaskRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns information about all activities registered in the specified + * domain that match the specified name and registration status. The + * result includes information like creation date, current status of the + * activity, etc. The results may be split into multiple pages. To + * retrieve subsequent pages, make the call again using the + * nextPageToken returned by the initial call. + *

+ * + * @param listActivityTypesRequest Container for the necessary parameters + * to execute the ListActivityTypes operation on AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * ListActivityTypes service method, as returned by AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future listActivityTypesAsync(ListActivityTypesRequest listActivityTypesRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns information about the specified domain including description + * and status. + *

+ * + * @param describeDomainRequest Container for the necessary parameters to + * execute the DescribeDomain operation on AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * DescribeDomain service method, as returned by AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future describeDomainAsync(DescribeDomainRequest describeDomainRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Used by workers to tell the service that the ActivityTask identified + * by the taskToken has failed with reason (if + * specified). + *

+ *

+ * The reason and details appear in the + * ActivityTaskFailed event added to the workflow history. + *

+ * + * @param respondActivityTaskFailedRequest Container for the necessary + * parameters to execute the RespondActivityTaskFailed operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * RespondActivityTaskFailed service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future respondActivityTaskFailedAsync(RespondActivityTaskFailedRequest respondActivityTaskFailedRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns the estimated number of decision tasks in the specified task + * list. The count returned is an approximation and is not guaranteed to + * be exact. If you specify a task list that no decision task was ever + * scheduled in then 0 will be returned. + *

+ * + * @param countPendingDecisionTasksRequest Container for the necessary + * parameters to execute the CountPendingDecisionTasks operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * CountPendingDecisionTasks service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future countPendingDecisionTasksAsync(CountPendingDecisionTasksRequest countPendingDecisionTasksRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Records a WorkflowExecutionTerminated event and forces + * closure of the workflow execution identified by the given domain, + * runId, and workflowId. The child policy, registered with the workflow + * type or specified when starting this execution, is applied to any open + * child workflow executions of this workflow execution. + *

+ *

+ * IMPORTANT: If the identified workflow execution was in + * progress, it is terminated immediately. + *

+ *

+ * NOTE: If a runId is not specified, then the + * WorkflowExecutionTerminated event is recorded in the history of the + * current open workflow with the matching workflowId in the domain. + *

+ *

+ * NOTE: You should consider using RequestCancelWorkflowExecution + * action instead because it allows the workflow to gracefully close + * while TerminateWorkflowExecution does not. + *

+ * + * @param terminateWorkflowExecutionRequest Container for the necessary + * parameters to execute the TerminateWorkflowExecution operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * TerminateWorkflowExecution service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future terminateWorkflowExecutionAsync(TerminateWorkflowExecutionRequest terminateWorkflowExecutionRequest) + throws AmazonServiceException, AmazonClientException; + + /** + *

+ * Returns information about the specified workflow execution including + * its type and some statistics. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param describeWorkflowExecutionRequest Container for the necessary + * parameters to execute the DescribeWorkflowExecution operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * DescribeWorkflowExecution service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future describeWorkflowExecutionAsync(DescribeWorkflowExecutionRequest describeWorkflowExecutionRequest) + throws AmazonServiceException, AmazonClientException; + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/AmazonSimpleWorkflowAsyncClient.java b/src/main/java/com/amazonaws/services/simpleworkflow/AmazonSimpleWorkflowAsyncClient.java new file mode 100644 index 000000000000..6be61a8886a8 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/AmazonSimpleWorkflowAsyncClient.java @@ -0,0 +1,1705 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow; + +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.AmazonServiceException; +import com.amazonaws.ClientConfiguration; +import com.amazonaws.auth.AWSCredentials; +import com.amazonaws.auth.AWSCredentialsProvider; + +import com.amazonaws.services.simpleworkflow.model.*; + + +/** + * Client for accessing AmazonSimpleWorkflow. All calls made + * using this client are non-blocking and will immediately return a Java Future. + * Callers must use the Future object to determine when the service call has actually + * completed. + * Amazon Simple Workflow Service

+ * The Amazon Simple Workflow Service API Reference is intended for + * programmers who need detailed information about the Amazon SWF actions + * and data types. + *

+ *

+ * For an broader overview of the Amazon SWF programming model, please + * go to the + * Amazon SWF Developer Guide . + *

+ *

+ * This section provides an overview of Amazon SWF actions. + *

+ *

+ * Action Categories + *

+ *

+ * The Amazon SWF actions can be grouped into the following major + * categories. + *

+ * + *
    + *
  • + * Actions related to Activities + *

    + *
  • + *
  • + * Actions related to Deciders + *

    + *
  • + *
  • + * Actions related to Workflow Executions + *

    + *
  • + *
  • + * Actions related to Administration + *

    + *
  • + *
  • + * Actions related to Visibility + *

    + *
  • + * + *
+ *

+ * Actions related to Activities + *

+ *

+ * The following are actions that are performed by activity workers: + *

+ * + *
    + *
  • + * PollForActivityTask + *

    + *
  • + *
  • + * RespondActivityTaskCompleted + *

    + *
  • + *
  • + * RespondActivityTaskFailed + *

    + *
  • + *
  • + * RespondActivityTaskCanceled + *

    + *
  • + *
  • + * RecordActivityTaskHeartbeat + *

    + *
  • + * + *
+ *

+ * Activity workers use the PollForActivityTask to get new activity + * tasks. After a worker receives an activity task from Amazon SWF, it + * performs the task and responds using RespondActivityTaskCompleted if + * successful or RespondActivityTaskFailed if unsuccessful. + *

+ *

+ * Actions related to Deciders + *

+ *

+ * The following are actions that are performed by deciders: + *

+ * + *
    + *
  • + * PollForDecisionTask + *

    + *
  • + *
  • + * RespondDecisionTaskCompleted + *

    + *
  • + * + *
+ *

+ * Deciders use PollForDecisionTask to get decision tasks. After a + * decider receives a decision task from Amazon SWF, it examines its + * workflow execution history and decides what to do next. It calls + * RespondDecisionTaskCompletedto complete the decision task and provide + * zero or more next decisions. + *

+ *

+ * Actions related to Workflow Executions + *

+ *

+ * The following actions operate on a workflow execution: + *

+ * + *
    + *
  • + * RequestCancelWorkflowExecution + *

    + *
  • + *
  • + * StartWorkflowExecution + *

    + *
  • + *
  • + * SignalWorkflowExecution + *

    + *
  • + *
  • + * TerminateWorkflowExecution + *

    + *
  • + * + *
+ *

+ * Actions related to Administration + *

+ *

+ * Although you can perform administrative tasks from the Amazon SWF + * console, you can use the actions in this section to automate functions + * or build your own administrative tools. + *

+ *

+ * Activity Management + *

+ * + *
    + *
  • + * RegisterActivityType + *

    + *
  • + *
  • + * DeprecateActivityType + *

    + *
  • + * + *
+ *

+ * Workflow Management + *

+ * + *
    + *
  • + * RegisterWorkflowType + *

    + *
  • + *
  • + * DeprecateWorkflowType + *

    + *
  • + * + *
+ *

+ * Domain Management + *

+ * + *
    + *
  • + * RegisterDomain + *

    + *
  • + *
  • + * DeprecateDomain + *

    + *
  • + * + *
+ *

+ * Workflow Execution Management + *

+ * + *
    + *
  • + * RequestCancelWorkflowExecution + *

    + *
  • + *
  • + * TerminateWorkflowExecution + *

    + *
  • + * + *
+ *

+ * Visibility Actions + *

+ *

+ * Although you can perform visibility actions from the Amazon SWF + * console, you can use the actions in this section to build your own + * console or administrative tools. + *

+ * + *
    + * + *
+ *

+ * Activity Visibility + *

+ * + *
    + *
  • + * ListActivityTypes + *

    + *
  • + *
  • + * DescribeActivity + *

    + *
  • + * + *
+ *

+ * Workflow Visibility + *

+ * + *
    + *
  • + * ListWorkflowTypes + *

    + *
  • + *
  • + * DescribeWorkflowType + *

    + *
  • + * + *
+ *

+ * Workflow Execution Visibility + *

+ * + *
    + *
  • + * DescribeWorkflowExecution + *

    + *
  • + *
  • + * ListOpenWorkflowExecutions + *

    + *
  • + *
  • + * ListClosedWorkflowExecutions + *

    + *
  • + *
  • + * CountOpenWorkflowExecutions + *

    + *
  • + *
  • + * CountClosedWorkflowExecutions + *

    + *
  • + *
  • + * GetWorkflowExecutionHistory + *

    + *
  • + * + *
+ *

+ * Domain Visibility + *

+ * + *
    + *
  • + * ListDomains + *

    + *
  • + *
  • + * DescribeDomain + *

    + *
  • + * + *
+ *

+ * Task List Visibility + *

+ * + *
    + *
  • + * CountPendingActivityTasks + *

    + *
  • + *
  • + * CountPendingDecisionTasks + *

    + *
  • + * + *
+ */ +public class AmazonSimpleWorkflowAsyncClient extends AmazonSimpleWorkflowClient + implements AmazonSimpleWorkflowAsync { + + /** + * Executor service for executing asynchronous requests. + */ + private ExecutorService executorService; + + + /** + * Constructs a new asynchronous client to invoke service methods on + * AmazonSimpleWorkflow using the specified AWS account credentials. + * Default client settings will be used, and a default cached thread pool will be + * created for executing the asynchronous tasks. + * + *

+ * All calls made using this new client object are non-blocking, and will immediately + * return a Java Future object that the caller can later check to see if the service + * call has actually completed. + * + * @param awsCredentials The AWS credentials (access key ID and secret key) to use + * when authenticating with AWS services. + */ + public AmazonSimpleWorkflowAsyncClient(AWSCredentials awsCredentials) { + this(awsCredentials, Executors.newCachedThreadPool()); + } + + /** + * Constructs a new asynchronous client to invoke service methods on + * AmazonSimpleWorkflow using the specified AWS account credentials + * and executor service. Default client settings will be used. + * + *

+ * All calls made using this new client object are non-blocking, and will immediately + * return a Java Future object that the caller can later check to see if the service + * call has actually completed. + * + * @param awsCredentials + * The AWS credentials (access key ID and secret key) to use + * when authenticating with AWS services. + * @param executorService + * The executor service by which all asynchronous requests will + * be executed. + */ + public AmazonSimpleWorkflowAsyncClient(AWSCredentials awsCredentials, ExecutorService executorService) { + super(awsCredentials); + this.executorService = executorService; + } + + /** + * Constructs a new asynchronous client to invoke service methods on + * AmazonSimpleWorkflow using the specified AWS account credentials, + * executor service, and client configuration options. + * + *

+ * All calls made using this new client object are non-blocking, and will immediately + * return a Java Future object that the caller can later check to see if the service + * call has actually completed. + * + * @param awsCredentials + * The AWS credentials (access key ID and secret key) to use + * when authenticating with AWS services. + * @param clientConfiguration + * Client configuration options (ex: max retry limit, proxy + * settings, etc). + * @param executorService + * The executor service by which all asynchronous requests will + * be executed. + */ + public AmazonSimpleWorkflowAsyncClient(AWSCredentials awsCredentials, + ClientConfiguration clientConfiguration, ExecutorService executorService) { + super(awsCredentials, clientConfiguration); + this.executorService = executorService; + } + + /** + * Constructs a new asynchronous client to invoke service methods on + * AmazonSimpleWorkflow using the specified AWS account credentials provider. + * Default client settings will be used, and a default cached thread pool will be + * created for executing the asynchronous tasks. + * + *

+ * All calls made using this new client object are non-blocking, and will immediately + * return a Java Future object that the caller can later check to see if the service + * call has actually completed. + * + * @param awsCredentialsProvider + * The AWS credentials provider which will provide credentials + * to authenticate requests with AWS services. + */ + public AmazonSimpleWorkflowAsyncClient(AWSCredentialsProvider awsCredentialsProvider) { + this(awsCredentialsProvider, Executors.newCachedThreadPool()); + } + + /** + * Constructs a new asynchronous client to invoke service methods on + * AmazonSimpleWorkflow using the specified AWS account credentials provider + * and executor service. Default client settings will be used. + * + *

+ * All calls made using this new client object are non-blocking, and will immediately + * return a Java Future object that the caller can later check to see if the service + * call has actually completed. + * + * @param awsCredentialsProvider + * The AWS credentials provider which will provide credentials + * to authenticate requests with AWS services. + * @param executorService + * The executor service by which all asynchronous requests will + * be executed. + */ + public AmazonSimpleWorkflowAsyncClient(AWSCredentialsProvider awsCredentialsProvider, ExecutorService executorService) { + this(awsCredentialsProvider, new ClientConfiguration(), executorService); + } + + /** + * Constructs a new asynchronous client to invoke service methods on + * AmazonSimpleWorkflow using the specified AWS account credentials + * provider, executor service, and client configuration options. + * + *

+ * All calls made using this new client object are non-blocking, and will immediately + * return a Java Future object that the caller can later check to see if the service + * call has actually completed. + * + * @param awsCredentialsProvider + * The AWS credentials provider which will provide credentials + * to authenticate requests with AWS services. + * @param clientConfiguration + * Client configuration options (ex: max retry limit, proxy + * settings, etc). + * @param executorService + * The executor service by which all asynchronous requests will + * be executed. + */ + public AmazonSimpleWorkflowAsyncClient(AWSCredentialsProvider awsCredentialsProvider, + ClientConfiguration clientConfiguration, ExecutorService executorService) { + super(awsCredentialsProvider, clientConfiguration); + this.executorService = executorService; + } + + + /** + * Returns the executor service used by this async client to execute + * requests. + * + * @return The executor service used by this async client to execute + * requests. + */ + public ExecutorService getExecutorService() { + return executorService; + } + + /** + * Shuts down the client, releasing all managed resources. This includes + * forcibly terminating all pending asynchronous service calls. Clients who + * wish to give pending asynchronous service calls time to complete should + * call getExecutorService().shutdown() prior to calling this method. + */ + @Override + public void shutdown() { + super.shutdown(); + executorService.shutdownNow(); + } + + /** + *

+ * Deprecates the specified workflow type . After a workflow type + * has been deprecated, you cannot create new executions of that type. + * Executions that were started before the type was deprecated will + * continue to run. A deprecated workflow type may still be used when + * calling visibility actions. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param deprecateWorkflowTypeRequest Container for the necessary + * parameters to execute the DeprecateWorkflowType operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * DeprecateWorkflowType service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future deprecateWorkflowTypeAsync(final DeprecateWorkflowTypeRequest deprecateWorkflowTypeRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public Void call() throws Exception { + deprecateWorkflowType(deprecateWorkflowTypeRequest); + return null; + } + }); + } + + /** + *

+ * Deprecates the specified domain. After a domain has been deprecated + * it cannot be used to create new workflow executions or register new + * types. However, you can still use visibility actions on this domain. + * Deprecating a domain also deprecates all activity and workflow types + * registered in the domain. Executions that were started before the + * domain was deprecated will continue to run. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param deprecateDomainRequest Container for the necessary parameters + * to execute the DeprecateDomain operation on AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * DeprecateDomain service method, as returned by AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future deprecateDomainAsync(final DeprecateDomainRequest deprecateDomainRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public Void call() throws Exception { + deprecateDomain(deprecateDomainRequest); + return null; + } + }); + } + + /** + *

+ * Registers a new workflow type and its configuration settings + * in the specified domain. + *

+ *

+ * IMPORTANT: If the type already exists, then a TypeAlreadyExists + * fault is returned. You cannot change the configuration settings of a + * workflow type once it is registered and it must be registered as a new + * version. + *

+ * + * @param registerWorkflowTypeRequest Container for the necessary + * parameters to execute the RegisterWorkflowType operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * RegisterWorkflowType service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future registerWorkflowTypeAsync(final RegisterWorkflowTypeRequest registerWorkflowTypeRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public Void call() throws Exception { + registerWorkflowType(registerWorkflowTypeRequest); + return null; + } + }); + } + + /** + *

+ * Returns information about workflow types in the specified domain. The + * results may be split into multiple pages that can be retrieved by + * making the call repeatedly. + *

+ * + * @param listWorkflowTypesRequest Container for the necessary parameters + * to execute the ListWorkflowTypes operation on AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * ListWorkflowTypes service method, as returned by AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future listWorkflowTypesAsync(final ListWorkflowTypesRequest listWorkflowTypesRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public WorkflowTypeInfos call() throws Exception { + return listWorkflowTypes(listWorkflowTypesRequest); + } + }); + } + + /** + *

+ * Starts an execution of the workflow type in the specified domain + * using the provided workflowId and input data. + *

+ *

+ * This action returns the newly started workflow execution. + *

+ * + * @param startWorkflowExecutionRequest Container for the necessary + * parameters to execute the StartWorkflowExecution operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * StartWorkflowExecution service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future startWorkflowExecutionAsync(final StartWorkflowExecutionRequest startWorkflowExecutionRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public Run call() throws Exception { + return startWorkflowExecution(startWorkflowExecutionRequest); + } + }); + } + + /** + *

+ * Records a WorkflowExecutionSignaled event in the + * workflow execution history and creates a decision task for the + * workflow execution identified by the given domain, workflowId and + * runId. The event is recorded with the specified user defined + * signalName and input (if provided). + *

+ *

+ * NOTE: If a runId is not specified, then the + * WorkflowExecutionSignaled event is recorded in the history of the + * current open workflow with the matching workflowId in the domain. + *

+ *

+ * NOTE: If the specified workflow execution is not open, this + * method fails with UnknownResource. + *

+ * + * @param signalWorkflowExecutionRequest Container for the necessary + * parameters to execute the SignalWorkflowExecution operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * SignalWorkflowExecution service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future signalWorkflowExecutionAsync(final SignalWorkflowExecutionRequest signalWorkflowExecutionRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public Void call() throws Exception { + signalWorkflowExecution(signalWorkflowExecutionRequest); + return null; + } + }); + } + + /** + *

+ * Returns the list of domains registered in the account. The results + * may be split into multiple pages. To retrieve subsequent pages, make + * the call again using the nextPageToken returned by the initial call. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param listDomainsRequest Container for the necessary parameters to + * execute the ListDomains operation on AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * ListDomains service method, as returned by AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future listDomainsAsync(final ListDomainsRequest listDomainsRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public DomainInfos call() throws Exception { + return listDomains(listDomainsRequest); + } + }); + } + + /** + *

+ * Records a WorkflowExecutionCancelRequested event in the + * currently running workflow execution identified by the given domain, + * workflowId, and runId. This logically requests the cancellation of the + * workflow execution as a whole. It is up to the decider to take + * appropriate actions when it receives an execution history with this + * event. + *

+ *

+ * NOTE: If the runId is not specified, the + * WorkflowExecutionCancelRequested event is recorded in the history of + * the current open workflow execution with the specified workflowId in + * the domain. + *

+ *

+ * NOTE: Because this action allows the workflow to properly clean + * up and gracefully close, it should be used instead of + * TerminateWorkflowExecution when possible. + *

+ * + * @param requestCancelWorkflowExecutionRequest Container for the + * necessary parameters to execute the RequestCancelWorkflowExecution + * operation on AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * RequestCancelWorkflowExecution service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future requestCancelWorkflowExecutionAsync(final RequestCancelWorkflowExecutionRequest requestCancelWorkflowExecutionRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public Void call() throws Exception { + requestCancelWorkflowExecution(requestCancelWorkflowExecutionRequest); + return null; + } + }); + } + + /** + *

+ * Returns information about the specified workflow type . This + * includes configuration settings specified when the type was registered + * and other information such as creation date, current status, etc. + *

+ * + * @param describeWorkflowTypeRequest Container for the necessary + * parameters to execute the DescribeWorkflowType operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * DescribeWorkflowType service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future describeWorkflowTypeAsync(final DescribeWorkflowTypeRequest describeWorkflowTypeRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public WorkflowTypeDetail call() throws Exception { + return describeWorkflowType(describeWorkflowTypeRequest); + } + }); + } + + /** + *

+ * Deprecates the specified activity type . + * After an activity type has been deprecated, you cannot create new + * tasks of that activity type. Tasks of this type that were scheduled + * before the type was deprecated will continue to run. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param deprecateActivityTypeRequest Container for the necessary + * parameters to execute the DeprecateActivityType operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * DeprecateActivityType service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future deprecateActivityTypeAsync(final DeprecateActivityTypeRequest deprecateActivityTypeRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public Void call() throws Exception { + deprecateActivityType(deprecateActivityTypeRequest); + return null; + } + }); + } + + /** + *

+ * Returns the number of closed workflow executions within the given + * domain that meet the specified filtering criteria. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param countClosedWorkflowExecutionsRequest Container for the + * necessary parameters to execute the CountClosedWorkflowExecutions + * operation on AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * CountClosedWorkflowExecutions service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future countClosedWorkflowExecutionsAsync(final CountClosedWorkflowExecutionsRequest countClosedWorkflowExecutionsRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public WorkflowExecutionCount call() throws Exception { + return countClosedWorkflowExecutions(countClosedWorkflowExecutionsRequest); + } + }); + } + + /** + *

+ * Returns the estimated number of activity tasks in the specified task + * list. The count returned is an approximation and is not guaranteed to + * be exact. If you specify a task list that no activity task was ever + * scheduled in then 0 will be returned. + *

+ * + * @param countPendingActivityTasksRequest Container for the necessary + * parameters to execute the CountPendingActivityTasks operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * CountPendingActivityTasks service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future countPendingActivityTasksAsync(final CountPendingActivityTasksRequest countPendingActivityTasksRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public PendingTaskCount call() throws Exception { + return countPendingActivityTasks(countPendingActivityTasksRequest); + } + }); + } + + /** + *

+ * Used by workers to tell the service that the ActivityTask identified + * by the taskToken was successfully canceled. Additional + * details can be optionally provided using the + * details argument. + *

+ *

+ * These details (if provided) appear in the + * ActivityTaskCanceled event added to the workflow history. + *

+ *

+ * IMPORTANT: Only use this operation if the canceled flag of a + * RecordActivityTaskHeartbeat request returns true and if the activity + * can be safely undone or abandoned. + *

+ * + * @param respondActivityTaskCanceledRequest Container for the necessary + * parameters to execute the RespondActivityTaskCanceled operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * RespondActivityTaskCanceled service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future respondActivityTaskCanceledAsync(final RespondActivityTaskCanceledRequest respondActivityTaskCanceledRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public Void call() throws Exception { + respondActivityTaskCanceled(respondActivityTaskCanceledRequest); + return null; + } + }); + } + + /** + *

+ * Used by deciders to tell the service that the DecisionTask identified + * by the taskToken has successfully completed. The + * decisions argument specifies the list of decisions made + * while processing the task. + *

+ *

+ * A + * DecisionTaskCompleted event is added + * to the workflow history. The executionContext specified + * is attached to the event in the workflow execution history. + *

+ * + * @param respondDecisionTaskCompletedRequest Container for the necessary + * parameters to execute the RespondDecisionTaskCompleted operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * RespondDecisionTaskCompleted service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future respondDecisionTaskCompletedAsync(final RespondDecisionTaskCompletedRequest respondDecisionTaskCompletedRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public Void call() throws Exception { + respondDecisionTaskCompleted(respondDecisionTaskCompletedRequest); + return null; + } + }); + } + + /** + *

+ * Used by workers to tell the service that the ActivityTask identified + * by the taskToken completed successfully with a + * result (if provided). + *

+ *

+ * The result appears in the + * ActivityTaskCompleted event in the workflow history. + *

+ *

+ * IMPORTANT: If the requested task does not complete + * successfully, use RespondActivityTaskFailed instead. If the worker + * finds that the task is canceled through the canceled flag returned by + * RecordActivityTaskHeartbeat, it should cancel the task, clean up and + * then call RespondActivityTaskCanceled. + *

+ * + * @param respondActivityTaskCompletedRequest Container for the necessary + * parameters to execute the RespondActivityTaskCompleted operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * RespondActivityTaskCompleted service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future respondActivityTaskCompletedAsync(final RespondActivityTaskCompletedRequest respondActivityTaskCompletedRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public Void call() throws Exception { + respondActivityTaskCompleted(respondActivityTaskCompletedRequest); + return null; + } + }); + } + + /** + *

+ * Used by workers to get an ActivityTask from the specified activity + * taskList . + * This initiates a long poll, where the service holds the HTTP + * connection open and responds as soon as a task becomes available. The + * maximum time the service holds on to the request before responding is + * 60 seconds. If no task is available within 60 seconds, the poll will + * return an empty result. An empty result, in this context, means that + * an ActivityTask is returned, but that the value of taskToken is an + * empty string. If a task is returned, the worker should use its type to + * identify and process it correctly. + *

+ *

+ * IMPORTANT: Workers should set their client side socket timeout + * to at least 70 seconds (10 seconds higher than the maximum time + * service may hold the poll request). + *

+ * + * @param pollForActivityTaskRequest Container for the necessary + * parameters to execute the PollForActivityTask operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * PollForActivityTask service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future pollForActivityTaskAsync(final PollForActivityTaskRequest pollForActivityTaskRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public ActivityTask call() throws Exception { + return pollForActivityTask(pollForActivityTaskRequest); + } + }); + } + + /** + *

+ * Returns the number of open workflow executions within the given + * domain that meet the specified filtering criteria. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param countOpenWorkflowExecutionsRequest Container for the necessary + * parameters to execute the CountOpenWorkflowExecutions operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * CountOpenWorkflowExecutions service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future countOpenWorkflowExecutionsAsync(final CountOpenWorkflowExecutionsRequest countOpenWorkflowExecutionsRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public WorkflowExecutionCount call() throws Exception { + return countOpenWorkflowExecutions(countOpenWorkflowExecutionsRequest); + } + }); + } + + /** + *

+ * Returns information about the specified activity type. This includes + * configuration settings provided at registration time as well as other + * general information about the type. + *

+ * + * @param describeActivityTypeRequest Container for the necessary + * parameters to execute the DescribeActivityType operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * DescribeActivityType service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future describeActivityTypeAsync(final DescribeActivityTypeRequest describeActivityTypeRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public ActivityTypeDetail call() throws Exception { + return describeActivityType(describeActivityTypeRequest); + } + }); + } + + /** + *

+ * Returns a list of open workflow executions in the specified domain + * that meet the filtering criteria. The results may be split into + * multiple pages. To retrieve subsequent pages, make the call again + * using the nextPageToken returned by the initial call. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param listOpenWorkflowExecutionsRequest Container for the necessary + * parameters to execute the ListOpenWorkflowExecutions operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * ListOpenWorkflowExecutions service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future listOpenWorkflowExecutionsAsync(final ListOpenWorkflowExecutionsRequest listOpenWorkflowExecutionsRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public WorkflowExecutionInfos call() throws Exception { + return listOpenWorkflowExecutions(listOpenWorkflowExecutionsRequest); + } + }); + } + + /** + *

+ * Returns the history of the specified workflow execution. The results + * may be split into multiple pages. To retrieve subsequent pages, make + * the call again using the nextPageToken returned by the + * initial call. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param getWorkflowExecutionHistoryRequest Container for the necessary + * parameters to execute the GetWorkflowExecutionHistory operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * GetWorkflowExecutionHistory service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future getWorkflowExecutionHistoryAsync(final GetWorkflowExecutionHistoryRequest getWorkflowExecutionHistoryRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public History call() throws Exception { + return getWorkflowExecutionHistory(getWorkflowExecutionHistoryRequest); + } + }); + } + + /** + *

+ * Registers a new domain. + *

+ * + * @param registerDomainRequest Container for the necessary parameters to + * execute the RegisterDomain operation on AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * RegisterDomain service method, as returned by AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future registerDomainAsync(final RegisterDomainRequest registerDomainRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public Void call() throws Exception { + registerDomain(registerDomainRequest); + return null; + } + }); + } + + /** + *

+ * Registers a new activity type along with its configuration + * settings in the specified domain. + *

+ *

+ * IMPORTANT: A TypeAlreadyExists fault is returned if the type + * already exists in the domain. You cannot change any configuration + * settings of the type after its registration, and it must be registered + * as a new version. + *

+ * + * @param registerActivityTypeRequest Container for the necessary + * parameters to execute the RegisterActivityType operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * RegisterActivityType service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future registerActivityTypeAsync(final RegisterActivityTypeRequest registerActivityTypeRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public Void call() throws Exception { + registerActivityType(registerActivityTypeRequest); + return null; + } + }); + } + + /** + *

+ * Returns a list of closed workflow executions in the specified domain + * that meet the filtering criteria. The results may be split into + * multiple pages. To retrieve subsequent pages, make the call again + * using the nextPageToken returned by the initial call. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param listClosedWorkflowExecutionsRequest Container for the necessary + * parameters to execute the ListClosedWorkflowExecutions operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * ListClosedWorkflowExecutions service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future listClosedWorkflowExecutionsAsync(final ListClosedWorkflowExecutionsRequest listClosedWorkflowExecutionsRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public WorkflowExecutionInfos call() throws Exception { + return listClosedWorkflowExecutions(listClosedWorkflowExecutionsRequest); + } + }); + } + + /** + *

+ * Used by activity workers to report to the service that the + * ActivityTask represented by the specified taskToken is + * still making progress. The worker can also (optionally) specify + * details of the progress, for example percent complete, using the + * details parameter. This action can also be used by the + * worker as a mechanism to check if cancellation is being requested for + * the activity task. If a cancellation is being attempted for the + * specified task, then the boolean cancelRequested flag + * returned by the service is set to true . + * + *

+ *

+ * This action resets the taskHeartbeatTimeout clock. The + * taskHeartbeatTimeout is specified in + * RegisterActivityType. + *

+ *

+ * This action does not in itself create an event in the workflow + * execution history. However, if the task times out, the workflow + * execution history will contain a ActivityTaskTimedOut + * event that contains the information from the last heartbeat generated + * by the activity worker. + *

+ *

+ * NOTE: The taskStartToCloseTimeout of an activity type is the + * maximum duration of an activity task, regardless of the number of + * RecordActivityTaskHeartbeat requests received. The + * taskStartToCloseTimeout is also specified in RegisterActivityType. + *

+ *

+ * NOTE: This operation is only useful for long-lived activities + * to report liveliness of the task and to determine if a cancellation is + * being attempted. + *

+ *

+ * IMPORTANT: If the cancelRequested flag returns true, a + * cancellation is being attempted. If the worker can cancel the + * activity, it should respond with RespondActivityTaskCanceled. + * Otherwise, it should ignore the cancellation request. + *

+ * + * @param recordActivityTaskHeartbeatRequest Container for the necessary + * parameters to execute the RecordActivityTaskHeartbeat operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * RecordActivityTaskHeartbeat service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future recordActivityTaskHeartbeatAsync(final RecordActivityTaskHeartbeatRequest recordActivityTaskHeartbeatRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public ActivityTaskStatus call() throws Exception { + return recordActivityTaskHeartbeat(recordActivityTaskHeartbeatRequest); + } + }); + } + + /** + *

+ * Used by deciders to get a DecisionTask from the specified decision + * taskList . + * A decision task may be returned for any open workflow + * execution that is using the specified task list. The task includes a + * paginated view of the history of the workflow execution. The decider + * should use the workflow type and the history to determine how to + * properly handle the task. + *

+ *

+ * This action initiates a long poll, where the service holds the HTTP + * connection open and responds as soon a task becomes available. If no + * decision task is available in the specified task list before the + * timeout of 60 seconds expires, an empty result is returned. An empty + * result, in this context, means that a DecisionTask is returned, but + * that the value of taskToken is an empty string. + *

+ *

+ * IMPORTANT: Deciders should set their client side socket timeout + * to at least 70 seconds (10 seconds higher than the timeout). + *

+ *

+ * IMPORTANT: Because the number of workflow history events for a + * single workflow execution might be very large, the result returned + * might be split up across a number of pages. To retrieve subsequent + * pages, make additional calls to PollForDecisionTask using the + * nextPageToken returned by the initial call. Note that you do not call + * GetWorkflowExecutionHistory with this nextPageToken. Instead, call + * PollForDecisionTask again. + *

+ * + * @param pollForDecisionTaskRequest Container for the necessary + * parameters to execute the PollForDecisionTask operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * PollForDecisionTask service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future pollForDecisionTaskAsync(final PollForDecisionTaskRequest pollForDecisionTaskRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public DecisionTask call() throws Exception { + return pollForDecisionTask(pollForDecisionTaskRequest); + } + }); + } + + /** + *

+ * Returns information about all activities registered in the specified + * domain that match the specified name and registration status. The + * result includes information like creation date, current status of the + * activity, etc. The results may be split into multiple pages. To + * retrieve subsequent pages, make the call again using the + * nextPageToken returned by the initial call. + *

+ * + * @param listActivityTypesRequest Container for the necessary parameters + * to execute the ListActivityTypes operation on AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * ListActivityTypes service method, as returned by AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future listActivityTypesAsync(final ListActivityTypesRequest listActivityTypesRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public ActivityTypeInfos call() throws Exception { + return listActivityTypes(listActivityTypesRequest); + } + }); + } + + /** + *

+ * Returns information about the specified domain including description + * and status. + *

+ * + * @param describeDomainRequest Container for the necessary parameters to + * execute the DescribeDomain operation on AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * DescribeDomain service method, as returned by AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future describeDomainAsync(final DescribeDomainRequest describeDomainRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public DomainDetail call() throws Exception { + return describeDomain(describeDomainRequest); + } + }); + } + + /** + *

+ * Used by workers to tell the service that the ActivityTask identified + * by the taskToken has failed with reason (if + * specified). + *

+ *

+ * The reason and details appear in the + * ActivityTaskFailed event added to the workflow history. + *

+ * + * @param respondActivityTaskFailedRequest Container for the necessary + * parameters to execute the RespondActivityTaskFailed operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * RespondActivityTaskFailed service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future respondActivityTaskFailedAsync(final RespondActivityTaskFailedRequest respondActivityTaskFailedRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public Void call() throws Exception { + respondActivityTaskFailed(respondActivityTaskFailedRequest); + return null; + } + }); + } + + /** + *

+ * Returns the estimated number of decision tasks in the specified task + * list. The count returned is an approximation and is not guaranteed to + * be exact. If you specify a task list that no decision task was ever + * scheduled in then 0 will be returned. + *

+ * + * @param countPendingDecisionTasksRequest Container for the necessary + * parameters to execute the CountPendingDecisionTasks operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * CountPendingDecisionTasks service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future countPendingDecisionTasksAsync(final CountPendingDecisionTasksRequest countPendingDecisionTasksRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public PendingTaskCount call() throws Exception { + return countPendingDecisionTasks(countPendingDecisionTasksRequest); + } + }); + } + + /** + *

+ * Records a WorkflowExecutionTerminated event and forces + * closure of the workflow execution identified by the given domain, + * runId, and workflowId. The child policy, registered with the workflow + * type or specified when starting this execution, is applied to any open + * child workflow executions of this workflow execution. + *

+ *

+ * IMPORTANT: If the identified workflow execution was in + * progress, it is terminated immediately. + *

+ *

+ * NOTE: If a runId is not specified, then the + * WorkflowExecutionTerminated event is recorded in the history of the + * current open workflow with the matching workflowId in the domain. + *

+ *

+ * NOTE: You should consider using RequestCancelWorkflowExecution + * action instead because it allows the workflow to gracefully close + * while TerminateWorkflowExecution does not. + *

+ * + * @param terminateWorkflowExecutionRequest Container for the necessary + * parameters to execute the TerminateWorkflowExecution operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * TerminateWorkflowExecution service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future terminateWorkflowExecutionAsync(final TerminateWorkflowExecutionRequest terminateWorkflowExecutionRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public Void call() throws Exception { + terminateWorkflowExecution(terminateWorkflowExecutionRequest); + return null; + } + }); + } + + /** + *

+ * Returns information about the specified workflow execution including + * its type and some statistics. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param describeWorkflowExecutionRequest Container for the necessary + * parameters to execute the DescribeWorkflowExecution operation on + * AmazonSimpleWorkflow. + * + * @return A Java Future object containing the response from the + * DescribeWorkflowExecution service method, as returned by + * AmazonSimpleWorkflow. + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Future describeWorkflowExecutionAsync(final DescribeWorkflowExecutionRequest describeWorkflowExecutionRequest) + throws AmazonServiceException, AmazonClientException { + return executorService.submit(new Callable() { + public WorkflowExecutionDetail call() throws Exception { + return describeWorkflowExecution(describeWorkflowExecutionRequest); + } + }); + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/AmazonSimpleWorkflowClient.java b/src/main/java/com/amazonaws/services/simpleworkflow/AmazonSimpleWorkflowClient.java new file mode 100644 index 000000000000..118efffe5265 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/AmazonSimpleWorkflowClient.java @@ -0,0 +1,1657 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map.Entry; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.amazonaws.*; +import com.amazonaws.auth.*; +import com.amazonaws.handlers.HandlerChainFactory; +import com.amazonaws.handlers.RequestHandler; +import com.amazonaws.http.JsonResponseHandler; +import com.amazonaws.http.JsonErrorResponseHandler; +import com.amazonaws.http.ExecutionContext; +import com.amazonaws.internal.StaticCredentialsProvider; +import com.amazonaws.transform.Unmarshaller; +import com.amazonaws.transform.JsonUnmarshallerContext; +import com.amazonaws.transform.JsonErrorUnmarshaller; +import com.amazonaws.util.json.JSONObject; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.services.simpleworkflow.model.transform.*; + + +/** + * Client for accessing AmazonSimpleWorkflow. All service calls made + * using this client are blocking, and will not return until the service call + * completes. + *

+ * Amazon Simple Workflow Service

+ * The Amazon Simple Workflow Service API Reference is intended for + * programmers who need detailed information about the Amazon SWF actions + * and data types. + *

+ *

+ * For an broader overview of the Amazon SWF programming model, please + * go to the + * Amazon SWF Developer Guide . + *

+ *

+ * This section provides an overview of Amazon SWF actions. + *

+ *

+ * Action Categories + *

+ *

+ * The Amazon SWF actions can be grouped into the following major + * categories. + *

+ * + *
    + *
  • + * Actions related to Activities + *

    + *
  • + *
  • + * Actions related to Deciders + *

    + *
  • + *
  • + * Actions related to Workflow Executions + *

    + *
  • + *
  • + * Actions related to Administration + *

    + *
  • + *
  • + * Actions related to Visibility + *

    + *
  • + * + *
+ *

+ * Actions related to Activities + *

+ *

+ * The following are actions that are performed by activity workers: + *

+ * + *
    + *
  • + * PollForActivityTask + *

    + *
  • + *
  • + * RespondActivityTaskCompleted + *

    + *
  • + *
  • + * RespondActivityTaskFailed + *

    + *
  • + *
  • + * RespondActivityTaskCanceled + *

    + *
  • + *
  • + * RecordActivityTaskHeartbeat + *

    + *
  • + * + *
+ *

+ * Activity workers use the PollForActivityTask to get new activity + * tasks. After a worker receives an activity task from Amazon SWF, it + * performs the task and responds using RespondActivityTaskCompleted if + * successful or RespondActivityTaskFailed if unsuccessful. + *

+ *

+ * Actions related to Deciders + *

+ *

+ * The following are actions that are performed by deciders: + *

+ * + *
    + *
  • + * PollForDecisionTask + *

    + *
  • + *
  • + * RespondDecisionTaskCompleted + *

    + *
  • + * + *
+ *

+ * Deciders use PollForDecisionTask to get decision tasks. After a + * decider receives a decision task from Amazon SWF, it examines its + * workflow execution history and decides what to do next. It calls + * RespondDecisionTaskCompletedto complete the decision task and provide + * zero or more next decisions. + *

+ *

+ * Actions related to Workflow Executions + *

+ *

+ * The following actions operate on a workflow execution: + *

+ * + *
    + *
  • + * RequestCancelWorkflowExecution + *

    + *
  • + *
  • + * StartWorkflowExecution + *

    + *
  • + *
  • + * SignalWorkflowExecution + *

    + *
  • + *
  • + * TerminateWorkflowExecution + *

    + *
  • + * + *
+ *

+ * Actions related to Administration + *

+ *

+ * Although you can perform administrative tasks from the Amazon SWF + * console, you can use the actions in this section to automate functions + * or build your own administrative tools. + *

+ *

+ * Activity Management + *

+ * + *
    + *
  • + * RegisterActivityType + *

    + *
  • + *
  • + * DeprecateActivityType + *

    + *
  • + * + *
+ *

+ * Workflow Management + *

+ * + *
    + *
  • + * RegisterWorkflowType + *

    + *
  • + *
  • + * DeprecateWorkflowType + *

    + *
  • + * + *
+ *

+ * Domain Management + *

+ * + *
    + *
  • + * RegisterDomain + *

    + *
  • + *
  • + * DeprecateDomain + *

    + *
  • + * + *
+ *

+ * Workflow Execution Management + *

+ * + *
    + *
  • + * RequestCancelWorkflowExecution + *

    + *
  • + *
  • + * TerminateWorkflowExecution + *

    + *
  • + * + *
+ *

+ * Visibility Actions + *

+ *

+ * Although you can perform visibility actions from the Amazon SWF + * console, you can use the actions in this section to build your own + * console or administrative tools. + *

+ * + *
    + * + *
+ *

+ * Activity Visibility + *

+ * + *
    + *
  • + * ListActivityTypes + *

    + *
  • + *
  • + * DescribeActivity + *

    + *
  • + * + *
+ *

+ * Workflow Visibility + *

+ * + *
    + *
  • + * ListWorkflowTypes + *

    + *
  • + *
  • + * DescribeWorkflowType + *

    + *
  • + * + *
+ *

+ * Workflow Execution Visibility + *

+ * + *
    + *
  • + * DescribeWorkflowExecution + *

    + *
  • + *
  • + * ListOpenWorkflowExecutions + *

    + *
  • + *
  • + * ListClosedWorkflowExecutions + *

    + *
  • + *
  • + * CountOpenWorkflowExecutions + *

    + *
  • + *
  • + * CountClosedWorkflowExecutions + *

    + *
  • + *
  • + * GetWorkflowExecutionHistory + *

    + *
  • + * + *
+ *

+ * Domain Visibility + *

+ * + *
    + *
  • + * ListDomains + *

    + *
  • + *
  • + * DescribeDomain + *

    + *
  • + * + *
+ *

+ * Task List Visibility + *

+ * + *
    + *
  • + * CountPendingActivityTasks + *

    + *
  • + *
  • + * CountPendingDecisionTasks + *

    + *
  • + * + *
+ */ +public class AmazonSimpleWorkflowClient extends AmazonWebServiceClient implements AmazonSimpleWorkflow { + + /** Provider for AWS credentials. */ + private AWSCredentialsProvider awsCredentialsProvider; + + private static final Log log = LogFactory.getLog(AmazonSimpleWorkflow.class); + + /** + * List of exception unmarshallers for all AmazonSimpleWorkflow exceptions. + */ + protected List> exceptionUnmarshallers; + + + /** AWS signer for authenticating requests. */ + private AWS3Signer signer; + + + /** + * Constructs a new client to invoke service methods on + * AmazonSimpleWorkflow using the specified AWS account credentials. + * + *

+ * All service calls made using this new client object are blocking, and will not + * return until the service call completes. + * + * @param awsCredentials The AWS credentials (access key ID and secret key) to use + * when authenticating with AWS services. + */ + public AmazonSimpleWorkflowClient(AWSCredentials awsCredentials) { + this(awsCredentials, new ClientConfiguration()); + } + + /** + * Constructs a new client to invoke service methods on + * AmazonSimpleWorkflow using the specified AWS account credentials + * and client configuration options. + * + *

+ * All service calls made using this new client object are blocking, and will not + * return until the service call completes. + * + * @param awsCredentials The AWS credentials (access key ID and secret key) to use + * when authenticating with AWS services. + * @param clientConfiguration The client configuration options controlling how this + * client connects to AmazonSimpleWorkflow + * (ex: proxy settings, retry counts, etc.). + */ + public AmazonSimpleWorkflowClient(AWSCredentials awsCredentials, ClientConfiguration clientConfiguration) { + super(clientConfiguration); + + this.awsCredentialsProvider = new StaticCredentialsProvider(awsCredentials); + + init(); + } + + /** + * Constructs a new client to invoke service methods on + * AmazonSimpleWorkflow using the specified AWS account credentials provider. + * + *

+ * All service calls made using this new client object are blocking, and will not + * return until the service call completes. + * + * @param awsCredentialsProvider + * The AWS credentials provider which will provide credentials + * to authenticate requests with AWS services. + */ + public AmazonSimpleWorkflowClient(AWSCredentialsProvider awsCredentialsProvider) { + this(awsCredentialsProvider, new ClientConfiguration()); + } + + /** + * Constructs a new client to invoke service methods on + * AmazonSimpleWorkflow using the specified AWS account credentials + * provider and client configuration options. + * + *

+ * All service calls made using this new client object are blocking, and will not + * return until the service call completes. + * + * @param awsCredentialsProvider + * The AWS credentials provider which will provide credentials + * to authenticate requests with AWS services. + * @param clientConfiguration The client configuration options controlling how this + * client connects to AmazonSimpleWorkflow + * (ex: proxy settings, retry counts, etc.). + */ + public AmazonSimpleWorkflowClient(AWSCredentialsProvider awsCredentialsProvider, ClientConfiguration clientConfiguration) { + super(clientConfiguration); + + this.awsCredentialsProvider = awsCredentialsProvider; + + init(); + } + + + private void init() { + exceptionUnmarshallers = new ArrayList>(); + exceptionUnmarshallers.add(new LimitExceededExceptionUnmarshaller()); + exceptionUnmarshallers.add(new DomainAlreadyExistsExceptionUnmarshaller()); + exceptionUnmarshallers.add(new DomainDeprecatedExceptionUnmarshaller()); + exceptionUnmarshallers.add(new DefaultUndefinedExceptionUnmarshaller()); + exceptionUnmarshallers.add(new OperationNotPermittedExceptionUnmarshaller()); + exceptionUnmarshallers.add(new UnknownResourceExceptionUnmarshaller()); + exceptionUnmarshallers.add(new WorkflowExecutionAlreadyStartedExceptionUnmarshaller()); + exceptionUnmarshallers.add(new TypeDeprecatedExceptionUnmarshaller()); + exceptionUnmarshallers.add(new TypeAlreadyExistsExceptionUnmarshaller()); + + exceptionUnmarshallers.add(new JsonErrorUnmarshaller()); + setEndpoint("swf.amazonaws.com"); + + signer = new AWS3Signer(); + + HandlerChainFactory chainFactory = new HandlerChainFactory(); + requestHandlers.addAll(chainFactory.newRequestHandlerChain( + "/com/amazonaws/services/simpleworkflow/request.handlers")); + + + clientConfiguration = new ClientConfiguration(clientConfiguration); + if (clientConfiguration.getMaxConnections() == ClientConfiguration.DEFAULT_MAX_CONNECTIONS) { + log.debug("Overriding default max connection value to: " + 1000); + clientConfiguration.setMaxConnections(1000); + } + if (clientConfiguration.getSocketTimeout() == ClientConfiguration.DEFAULT_SOCKET_TIMEOUT) { + log.debug("Overriding default socket timeout value to: " + 90000); + clientConfiguration.setSocketTimeout(90000); + } + setConfiguration(clientConfiguration); + } + + + /** + *

+ * Deprecates the specified workflow type . After a workflow type + * has been deprecated, you cannot create new executions of that type. + * Executions that were started before the type was deprecated will + * continue to run. A deprecated workflow type may still be used when + * calling visibility actions. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param deprecateWorkflowTypeRequest Container for the necessary + * parameters to execute the DeprecateWorkflowType service method on + * AmazonSimpleWorkflow. + * + * @throws TypeDeprecatedException + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void deprecateWorkflowType(DeprecateWorkflowTypeRequest deprecateWorkflowTypeRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new DeprecateWorkflowTypeRequestMarshaller().marshall(deprecateWorkflowTypeRequest); + invoke(request, null); + } + + /** + *

+ * Deprecates the specified domain. After a domain has been deprecated + * it cannot be used to create new workflow executions or register new + * types. However, you can still use visibility actions on this domain. + * Deprecating a domain also deprecates all activity and workflow types + * registered in the domain. Executions that were started before the + * domain was deprecated will continue to run. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param deprecateDomainRequest Container for the necessary parameters + * to execute the DeprecateDomain service method on AmazonSimpleWorkflow. + * + * @throws DomainDeprecatedException + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void deprecateDomain(DeprecateDomainRequest deprecateDomainRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new DeprecateDomainRequestMarshaller().marshall(deprecateDomainRequest); + invoke(request, null); + } + + /** + *

+ * Registers a new workflow type and its configuration settings + * in the specified domain. + *

+ *

+ * IMPORTANT: If the type already exists, then a TypeAlreadyExists + * fault is returned. You cannot change the configuration settings of a + * workflow type once it is registered and it must be registered as a new + * version. + *

+ * + * @param registerWorkflowTypeRequest Container for the necessary + * parameters to execute the RegisterWorkflowType service method on + * AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * @throws TypeAlreadyExistsException + * @throws LimitExceededException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void registerWorkflowType(RegisterWorkflowTypeRequest registerWorkflowTypeRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new RegisterWorkflowTypeRequestMarshaller().marshall(registerWorkflowTypeRequest); + invoke(request, null); + } + + /** + *

+ * Returns information about workflow types in the specified domain. The + * results may be split into multiple pages that can be retrieved by + * making the call repeatedly. + *

+ * + * @param listWorkflowTypesRequest Container for the necessary parameters + * to execute the ListWorkflowTypes service method on + * AmazonSimpleWorkflow. + * + * @return The response from the ListWorkflowTypes service method, as + * returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public WorkflowTypeInfos listWorkflowTypes(ListWorkflowTypesRequest listWorkflowTypesRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new ListWorkflowTypesRequestMarshaller().marshall(listWorkflowTypesRequest); + return invoke(request, new WorkflowTypeInfosJsonUnmarshaller()); + } + + /** + *

+ * Starts an execution of the workflow type in the specified domain + * using the provided workflowId and input data. + *

+ *

+ * This action returns the newly started workflow execution. + *

+ * + * @param startWorkflowExecutionRequest Container for the necessary + * parameters to execute the StartWorkflowExecution service method on + * AmazonSimpleWorkflow. + * + * @return The response from the StartWorkflowExecution service method, + * as returned by AmazonSimpleWorkflow. + * + * @throws TypeDeprecatedException + * @throws OperationNotPermittedException + * @throws DefaultUndefinedException + * @throws UnknownResourceException + * @throws WorkflowExecutionAlreadyStartedException + * @throws LimitExceededException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public Run startWorkflowExecution(StartWorkflowExecutionRequest startWorkflowExecutionRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new StartWorkflowExecutionRequestMarshaller().marshall(startWorkflowExecutionRequest); + return invoke(request, new RunJsonUnmarshaller()); + } + + /** + *

+ * Records a WorkflowExecutionSignaled event in the + * workflow execution history and creates a decision task for the + * workflow execution identified by the given domain, workflowId and + * runId. The event is recorded with the specified user defined + * signalName and input (if provided). + *

+ *

+ * NOTE: If a runId is not specified, then the + * WorkflowExecutionSignaled event is recorded in the history of the + * current open workflow with the matching workflowId in the domain. + *

+ *

+ * NOTE: If the specified workflow execution is not open, this + * method fails with UnknownResource. + *

+ * + * @param signalWorkflowExecutionRequest Container for the necessary + * parameters to execute the SignalWorkflowExecution service method on + * AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void signalWorkflowExecution(SignalWorkflowExecutionRequest signalWorkflowExecutionRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new SignalWorkflowExecutionRequestMarshaller().marshall(signalWorkflowExecutionRequest); + invoke(request, null); + } + + /** + *

+ * Returns the list of domains registered in the account. The results + * may be split into multiple pages. To retrieve subsequent pages, make + * the call again using the nextPageToken returned by the initial call. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param listDomainsRequest Container for the necessary parameters to + * execute the ListDomains service method on AmazonSimpleWorkflow. + * + * @return The response from the ListDomains service method, as returned + * by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public DomainInfos listDomains(ListDomainsRequest listDomainsRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new ListDomainsRequestMarshaller().marshall(listDomainsRequest); + return invoke(request, new DomainInfosJsonUnmarshaller()); + } + + /** + *

+ * Records a WorkflowExecutionCancelRequested event in the + * currently running workflow execution identified by the given domain, + * workflowId, and runId. This logically requests the cancellation of the + * workflow execution as a whole. It is up to the decider to take + * appropriate actions when it receives an execution history with this + * event. + *

+ *

+ * NOTE: If the runId is not specified, the + * WorkflowExecutionCancelRequested event is recorded in the history of + * the current open workflow execution with the specified workflowId in + * the domain. + *

+ *

+ * NOTE: Because this action allows the workflow to properly clean + * up and gracefully close, it should be used instead of + * TerminateWorkflowExecution when possible. + *

+ * + * @param requestCancelWorkflowExecutionRequest Container for the + * necessary parameters to execute the RequestCancelWorkflowExecution + * service method on AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void requestCancelWorkflowExecution(RequestCancelWorkflowExecutionRequest requestCancelWorkflowExecutionRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new RequestCancelWorkflowExecutionRequestMarshaller().marshall(requestCancelWorkflowExecutionRequest); + invoke(request, null); + } + + /** + *

+ * Returns information about the specified workflow type . This + * includes configuration settings specified when the type was registered + * and other information such as creation date, current status, etc. + *

+ * + * @param describeWorkflowTypeRequest Container for the necessary + * parameters to execute the DescribeWorkflowType service method on + * AmazonSimpleWorkflow. + * + * @return The response from the DescribeWorkflowType service method, as + * returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public WorkflowTypeDetail describeWorkflowType(DescribeWorkflowTypeRequest describeWorkflowTypeRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new DescribeWorkflowTypeRequestMarshaller().marshall(describeWorkflowTypeRequest); + return invoke(request, new WorkflowTypeDetailJsonUnmarshaller()); + } + + /** + *

+ * Deprecates the specified activity type . + * After an activity type has been deprecated, you cannot create new + * tasks of that activity type. Tasks of this type that were scheduled + * before the type was deprecated will continue to run. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param deprecateActivityTypeRequest Container for the necessary + * parameters to execute the DeprecateActivityType service method on + * AmazonSimpleWorkflow. + * + * @throws TypeDeprecatedException + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void deprecateActivityType(DeprecateActivityTypeRequest deprecateActivityTypeRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new DeprecateActivityTypeRequestMarshaller().marshall(deprecateActivityTypeRequest); + invoke(request, null); + } + + /** + *

+ * Returns the number of closed workflow executions within the given + * domain that meet the specified filtering criteria. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param countClosedWorkflowExecutionsRequest Container for the + * necessary parameters to execute the CountClosedWorkflowExecutions + * service method on AmazonSimpleWorkflow. + * + * @return The response from the CountClosedWorkflowExecutions service + * method, as returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public WorkflowExecutionCount countClosedWorkflowExecutions(CountClosedWorkflowExecutionsRequest countClosedWorkflowExecutionsRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new CountClosedWorkflowExecutionsRequestMarshaller().marshall(countClosedWorkflowExecutionsRequest); + return invoke(request, new WorkflowExecutionCountJsonUnmarshaller()); + } + + /** + *

+ * Returns the estimated number of activity tasks in the specified task + * list. The count returned is an approximation and is not guaranteed to + * be exact. If you specify a task list that no activity task was ever + * scheduled in then 0 will be returned. + *

+ * + * @param countPendingActivityTasksRequest Container for the necessary + * parameters to execute the CountPendingActivityTasks service method on + * AmazonSimpleWorkflow. + * + * @return The response from the CountPendingActivityTasks service + * method, as returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public PendingTaskCount countPendingActivityTasks(CountPendingActivityTasksRequest countPendingActivityTasksRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new CountPendingActivityTasksRequestMarshaller().marshall(countPendingActivityTasksRequest); + return invoke(request, new PendingTaskCountJsonUnmarshaller()); + } + + /** + *

+ * Used by workers to tell the service that the ActivityTask identified + * by the taskToken was successfully canceled. Additional + * details can be optionally provided using the + * details argument. + *

+ *

+ * These details (if provided) appear in the + * ActivityTaskCanceled event added to the workflow history. + *

+ *

+ * IMPORTANT: Only use this operation if the canceled flag of a + * RecordActivityTaskHeartbeat request returns true and if the activity + * can be safely undone or abandoned. + *

+ * + * @param respondActivityTaskCanceledRequest Container for the necessary + * parameters to execute the RespondActivityTaskCanceled service method + * on AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void respondActivityTaskCanceled(RespondActivityTaskCanceledRequest respondActivityTaskCanceledRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new RespondActivityTaskCanceledRequestMarshaller().marshall(respondActivityTaskCanceledRequest); + invoke(request, null); + } + + /** + *

+ * Used by deciders to tell the service that the DecisionTask identified + * by the taskToken has successfully completed. The + * decisions argument specifies the list of decisions made + * while processing the task. + *

+ *

+ * A + * DecisionTaskCompleted event is added + * to the workflow history. The executionContext specified + * is attached to the event in the workflow execution history. + *

+ * + * @param respondDecisionTaskCompletedRequest Container for the necessary + * parameters to execute the RespondDecisionTaskCompleted service method + * on AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void respondDecisionTaskCompleted(RespondDecisionTaskCompletedRequest respondDecisionTaskCompletedRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new RespondDecisionTaskCompletedRequestMarshaller().marshall(respondDecisionTaskCompletedRequest); + invoke(request, null); + } + + /** + *

+ * Used by workers to tell the service that the ActivityTask identified + * by the taskToken completed successfully with a + * result (if provided). + *

+ *

+ * The result appears in the + * ActivityTaskCompleted event in the workflow history. + *

+ *

+ * IMPORTANT: If the requested task does not complete + * successfully, use RespondActivityTaskFailed instead. If the worker + * finds that the task is canceled through the canceled flag returned by + * RecordActivityTaskHeartbeat, it should cancel the task, clean up and + * then call RespondActivityTaskCanceled. + *

+ * + * @param respondActivityTaskCompletedRequest Container for the necessary + * parameters to execute the RespondActivityTaskCompleted service method + * on AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void respondActivityTaskCompleted(RespondActivityTaskCompletedRequest respondActivityTaskCompletedRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new RespondActivityTaskCompletedRequestMarshaller().marshall(respondActivityTaskCompletedRequest); + invoke(request, null); + } + + /** + *

+ * Used by workers to get an ActivityTask from the specified activity + * taskList . + * This initiates a long poll, where the service holds the HTTP + * connection open and responds as soon as a task becomes available. The + * maximum time the service holds on to the request before responding is + * 60 seconds. If no task is available within 60 seconds, the poll will + * return an empty result. An empty result, in this context, means that + * an ActivityTask is returned, but that the value of taskToken is an + * empty string. If a task is returned, the worker should use its type to + * identify and process it correctly. + *

+ *

+ * IMPORTANT: Workers should set their client side socket timeout + * to at least 70 seconds (10 seconds higher than the maximum time + * service may hold the poll request). + *

+ * + * @param pollForActivityTaskRequest Container for the necessary + * parameters to execute the PollForActivityTask service method on + * AmazonSimpleWorkflow. + * + * @return The response from the PollForActivityTask service method, as + * returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public ActivityTask pollForActivityTask(PollForActivityTaskRequest pollForActivityTaskRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new PollForActivityTaskRequestMarshaller().marshall(pollForActivityTaskRequest); + return invoke(request, new ActivityTaskJsonUnmarshaller()); + } + + /** + *

+ * Returns the number of open workflow executions within the given + * domain that meet the specified filtering criteria. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param countOpenWorkflowExecutionsRequest Container for the necessary + * parameters to execute the CountOpenWorkflowExecutions service method + * on AmazonSimpleWorkflow. + * + * @return The response from the CountOpenWorkflowExecutions service + * method, as returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public WorkflowExecutionCount countOpenWorkflowExecutions(CountOpenWorkflowExecutionsRequest countOpenWorkflowExecutionsRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new CountOpenWorkflowExecutionsRequestMarshaller().marshall(countOpenWorkflowExecutionsRequest); + return invoke(request, new WorkflowExecutionCountJsonUnmarshaller()); + } + + /** + *

+ * Returns information about the specified activity type. This includes + * configuration settings provided at registration time as well as other + * general information about the type. + *

+ * + * @param describeActivityTypeRequest Container for the necessary + * parameters to execute the DescribeActivityType service method on + * AmazonSimpleWorkflow. + * + * @return The response from the DescribeActivityType service method, as + * returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public ActivityTypeDetail describeActivityType(DescribeActivityTypeRequest describeActivityTypeRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new DescribeActivityTypeRequestMarshaller().marshall(describeActivityTypeRequest); + return invoke(request, new ActivityTypeDetailJsonUnmarshaller()); + } + + /** + *

+ * Returns a list of open workflow executions in the specified domain + * that meet the filtering criteria. The results may be split into + * multiple pages. To retrieve subsequent pages, make the call again + * using the nextPageToken returned by the initial call. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param listOpenWorkflowExecutionsRequest Container for the necessary + * parameters to execute the ListOpenWorkflowExecutions service method on + * AmazonSimpleWorkflow. + * + * @return The response from the ListOpenWorkflowExecutions service + * method, as returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public WorkflowExecutionInfos listOpenWorkflowExecutions(ListOpenWorkflowExecutionsRequest listOpenWorkflowExecutionsRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new ListOpenWorkflowExecutionsRequestMarshaller().marshall(listOpenWorkflowExecutionsRequest); + return invoke(request, new WorkflowExecutionInfosJsonUnmarshaller()); + } + + /** + *

+ * Returns the history of the specified workflow execution. The results + * may be split into multiple pages. To retrieve subsequent pages, make + * the call again using the nextPageToken returned by the + * initial call. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param getWorkflowExecutionHistoryRequest Container for the necessary + * parameters to execute the GetWorkflowExecutionHistory service method + * on AmazonSimpleWorkflow. + * + * @return The response from the GetWorkflowExecutionHistory service + * method, as returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public History getWorkflowExecutionHistory(GetWorkflowExecutionHistoryRequest getWorkflowExecutionHistoryRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new GetWorkflowExecutionHistoryRequestMarshaller().marshall(getWorkflowExecutionHistoryRequest); + return invoke(request, new HistoryJsonUnmarshaller()); + } + + /** + *

+ * Registers a new domain. + *

+ * + * @param registerDomainRequest Container for the necessary parameters to + * execute the RegisterDomain service method on AmazonSimpleWorkflow. + * + * @throws DomainAlreadyExistsException + * @throws OperationNotPermittedException + * @throws LimitExceededException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void registerDomain(RegisterDomainRequest registerDomainRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new RegisterDomainRequestMarshaller().marshall(registerDomainRequest); + invoke(request, null); + } + + /** + *

+ * Registers a new activity type along with its configuration + * settings in the specified domain. + *

+ *

+ * IMPORTANT: A TypeAlreadyExists fault is returned if the type + * already exists in the domain. You cannot change any configuration + * settings of the type after its registration, and it must be registered + * as a new version. + *

+ * + * @param registerActivityTypeRequest Container for the necessary + * parameters to execute the RegisterActivityType service method on + * AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * @throws TypeAlreadyExistsException + * @throws LimitExceededException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void registerActivityType(RegisterActivityTypeRequest registerActivityTypeRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new RegisterActivityTypeRequestMarshaller().marshall(registerActivityTypeRequest); + invoke(request, null); + } + + /** + *

+ * Returns a list of closed workflow executions in the specified domain + * that meet the filtering criteria. The results may be split into + * multiple pages. To retrieve subsequent pages, make the call again + * using the nextPageToken returned by the initial call. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param listClosedWorkflowExecutionsRequest Container for the necessary + * parameters to execute the ListClosedWorkflowExecutions service method + * on AmazonSimpleWorkflow. + * + * @return The response from the ListClosedWorkflowExecutions service + * method, as returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public WorkflowExecutionInfos listClosedWorkflowExecutions(ListClosedWorkflowExecutionsRequest listClosedWorkflowExecutionsRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new ListClosedWorkflowExecutionsRequestMarshaller().marshall(listClosedWorkflowExecutionsRequest); + return invoke(request, new WorkflowExecutionInfosJsonUnmarshaller()); + } + + /** + *

+ * Used by activity workers to report to the service that the + * ActivityTask represented by the specified taskToken is + * still making progress. The worker can also (optionally) specify + * details of the progress, for example percent complete, using the + * details parameter. This action can also be used by the + * worker as a mechanism to check if cancellation is being requested for + * the activity task. If a cancellation is being attempted for the + * specified task, then the boolean cancelRequested flag + * returned by the service is set to true . + * + *

+ *

+ * This action resets the taskHeartbeatTimeout clock. The + * taskHeartbeatTimeout is specified in + * RegisterActivityType. + *

+ *

+ * This action does not in itself create an event in the workflow + * execution history. However, if the task times out, the workflow + * execution history will contain a ActivityTaskTimedOut + * event that contains the information from the last heartbeat generated + * by the activity worker. + *

+ *

+ * NOTE: The taskStartToCloseTimeout of an activity type is the + * maximum duration of an activity task, regardless of the number of + * RecordActivityTaskHeartbeat requests received. The + * taskStartToCloseTimeout is also specified in RegisterActivityType. + *

+ *

+ * NOTE: This operation is only useful for long-lived activities + * to report liveliness of the task and to determine if a cancellation is + * being attempted. + *

+ *

+ * IMPORTANT: If the cancelRequested flag returns true, a + * cancellation is being attempted. If the worker can cancel the + * activity, it should respond with RespondActivityTaskCanceled. + * Otherwise, it should ignore the cancellation request. + *

+ * + * @param recordActivityTaskHeartbeatRequest Container for the necessary + * parameters to execute the RecordActivityTaskHeartbeat service method + * on AmazonSimpleWorkflow. + * + * @return The response from the RecordActivityTaskHeartbeat service + * method, as returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public ActivityTaskStatus recordActivityTaskHeartbeat(RecordActivityTaskHeartbeatRequest recordActivityTaskHeartbeatRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new RecordActivityTaskHeartbeatRequestMarshaller().marshall(recordActivityTaskHeartbeatRequest); + return invoke(request, new ActivityTaskStatusJsonUnmarshaller()); + } + + /** + *

+ * Used by deciders to get a DecisionTask from the specified decision + * taskList . + * A decision task may be returned for any open workflow + * execution that is using the specified task list. The task includes a + * paginated view of the history of the workflow execution. The decider + * should use the workflow type and the history to determine how to + * properly handle the task. + *

+ *

+ * This action initiates a long poll, where the service holds the HTTP + * connection open and responds as soon a task becomes available. If no + * decision task is available in the specified task list before the + * timeout of 60 seconds expires, an empty result is returned. An empty + * result, in this context, means that a DecisionTask is returned, but + * that the value of taskToken is an empty string. + *

+ *

+ * IMPORTANT: Deciders should set their client side socket timeout + * to at least 70 seconds (10 seconds higher than the timeout). + *

+ *

+ * IMPORTANT: Because the number of workflow history events for a + * single workflow execution might be very large, the result returned + * might be split up across a number of pages. To retrieve subsequent + * pages, make additional calls to PollForDecisionTask using the + * nextPageToken returned by the initial call. Note that you do not call + * GetWorkflowExecutionHistory with this nextPageToken. Instead, call + * PollForDecisionTask again. + *

+ * + * @param pollForDecisionTaskRequest Container for the necessary + * parameters to execute the PollForDecisionTask service method on + * AmazonSimpleWorkflow. + * + * @return The response from the PollForDecisionTask service method, as + * returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public DecisionTask pollForDecisionTask(PollForDecisionTaskRequest pollForDecisionTaskRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new PollForDecisionTaskRequestMarshaller().marshall(pollForDecisionTaskRequest); + return invoke(request, new DecisionTaskJsonUnmarshaller()); + } + + /** + *

+ * Returns information about all activities registered in the specified + * domain that match the specified name and registration status. The + * result includes information like creation date, current status of the + * activity, etc. The results may be split into multiple pages. To + * retrieve subsequent pages, make the call again using the + * nextPageToken returned by the initial call. + *

+ * + * @param listActivityTypesRequest Container for the necessary parameters + * to execute the ListActivityTypes service method on + * AmazonSimpleWorkflow. + * + * @return The response from the ListActivityTypes service method, as + * returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public ActivityTypeInfos listActivityTypes(ListActivityTypesRequest listActivityTypesRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new ListActivityTypesRequestMarshaller().marshall(listActivityTypesRequest); + return invoke(request, new ActivityTypeInfosJsonUnmarshaller()); + } + + /** + *

+ * Returns information about the specified domain including description + * and status. + *

+ * + * @param describeDomainRequest Container for the necessary parameters to + * execute the DescribeDomain service method on AmazonSimpleWorkflow. + * + * @return The response from the DescribeDomain service method, as + * returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public DomainDetail describeDomain(DescribeDomainRequest describeDomainRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new DescribeDomainRequestMarshaller().marshall(describeDomainRequest); + return invoke(request, new DomainDetailJsonUnmarshaller()); + } + + /** + *

+ * Used by workers to tell the service that the ActivityTask identified + * by the taskToken has failed with reason (if + * specified). + *

+ *

+ * The reason and details appear in the + * ActivityTaskFailed event added to the workflow history. + *

+ * + * @param respondActivityTaskFailedRequest Container for the necessary + * parameters to execute the RespondActivityTaskFailed service method on + * AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void respondActivityTaskFailed(RespondActivityTaskFailedRequest respondActivityTaskFailedRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new RespondActivityTaskFailedRequestMarshaller().marshall(respondActivityTaskFailedRequest); + invoke(request, null); + } + + /** + *

+ * Returns the estimated number of decision tasks in the specified task + * list. The count returned is an approximation and is not guaranteed to + * be exact. If you specify a task list that no decision task was ever + * scheduled in then 0 will be returned. + *

+ * + * @param countPendingDecisionTasksRequest Container for the necessary + * parameters to execute the CountPendingDecisionTasks service method on + * AmazonSimpleWorkflow. + * + * @return The response from the CountPendingDecisionTasks service + * method, as returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public PendingTaskCount countPendingDecisionTasks(CountPendingDecisionTasksRequest countPendingDecisionTasksRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new CountPendingDecisionTasksRequestMarshaller().marshall(countPendingDecisionTasksRequest); + return invoke(request, new PendingTaskCountJsonUnmarshaller()); + } + + /** + *

+ * Records a WorkflowExecutionTerminated event and forces + * closure of the workflow execution identified by the given domain, + * runId, and workflowId. The child policy, registered with the workflow + * type or specified when starting this execution, is applied to any open + * child workflow executions of this workflow execution. + *

+ *

+ * IMPORTANT: If the identified workflow execution was in + * progress, it is terminated immediately. + *

+ *

+ * NOTE: If a runId is not specified, then the + * WorkflowExecutionTerminated event is recorded in the history of the + * current open workflow with the matching workflowId in the domain. + *

+ *

+ * NOTE: You should consider using RequestCancelWorkflowExecution + * action instead because it allows the workflow to gracefully close + * while TerminateWorkflowExecution does not. + *

+ * + * @param terminateWorkflowExecutionRequest Container for the necessary + * parameters to execute the TerminateWorkflowExecution service method on + * AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public void terminateWorkflowExecution(TerminateWorkflowExecutionRequest terminateWorkflowExecutionRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new TerminateWorkflowExecutionRequestMarshaller().marshall(terminateWorkflowExecutionRequest); + invoke(request, null); + } + + /** + *

+ * Returns information about the specified workflow execution including + * its type and some statistics. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @param describeWorkflowExecutionRequest Container for the necessary + * parameters to execute the DescribeWorkflowExecution service method on + * AmazonSimpleWorkflow. + * + * @return The response from the DescribeWorkflowExecution service + * method, as returned by AmazonSimpleWorkflow. + * + * @throws OperationNotPermittedException + * @throws UnknownResourceException + * + * @throws AmazonClientException + * If any internal errors are encountered inside the client while + * attempting to make the request or handle the response. For example + * if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow indicating + * either a problem with the data in the request, or a server side issue. + */ + public WorkflowExecutionDetail describeWorkflowExecution(DescribeWorkflowExecutionRequest describeWorkflowExecutionRequest) + throws AmazonServiceException, AmazonClientException { + Request request = new DescribeWorkflowExecutionRequestMarshaller().marshall(describeWorkflowExecutionRequest); + return invoke(request, new WorkflowExecutionDetailJsonUnmarshaller()); + } + + + /** + * Returns additional metadata for a previously executed successful, request, typically used for + * debugging issues where a service isn't acting as expected. This data isn't considered part + * of the result data returned by an operation, so it's available through this separate, + * diagnostic interface. + *

+ * Response metadata is only cached for a limited period of time, so if you need to access + * this extra diagnostic information for an executed request, you should use this method + * to retrieve it as soon as possible after executing the request. + * + * @param request + * The originally executed request + * + * @return The response metadata for the specified request, or null if none + * is available. + */ + public ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest request) { + return client.getResponseMetadataForRequest(request); + } + + private X invoke(Request request, Unmarshaller unmarshaller) { + request.setEndpoint(endpoint); + + AWSCredentials credentials = awsCredentialsProvider.getCredentials(); + AmazonWebServiceRequest originalRequest = request.getOriginalRequest(); + if (originalRequest != null && originalRequest.getRequestCredentials() != null) { + credentials = originalRequest.getRequestCredentials(); + } + + ExecutionContext executionContext = createExecutionContext(); + executionContext.setSigner(signer); + executionContext.setCredentials(credentials); + + JsonResponseHandler responseHandler = new JsonResponseHandler(unmarshaller); + JsonErrorResponseHandler errorResponseHandler = new JsonErrorResponseHandler(exceptionUnmarshallers); + + return (X)client.execute(request, responseHandler, errorResponseHandler, executionContext); + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivitiesClient.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivitiesClient.java new file mode 100644 index 000000000000..673df0899d11 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivitiesClient.java @@ -0,0 +1,27 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.generic.GenericActivityClient; + +public interface ActivitiesClient { + + public DataConverter getDataConverter(); + + public ActivitySchedulingOptions getSchedulingOptions(); + + public GenericActivityClient getGenericClient(); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivitiesClientBase.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivitiesClientBase.java new file mode 100644 index 000000000000..df72f811ab64 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivitiesClientBase.java @@ -0,0 +1,66 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.generic.GenericActivityClient; +import com.amazonaws.services.simpleworkflow.model.ActivityType; + +public abstract class ActivitiesClientBase implements ActivitiesClient { + + protected DynamicActivitiesClientImpl dynamicActivitiesClient; + + protected ActivitiesClientBase(GenericActivityClient genericClient, DataConverter dataConverter, + ActivitySchedulingOptions schedulingOptions) { + this.dynamicActivitiesClient = new DynamicActivitiesClientImpl(schedulingOptions, dataConverter, genericClient); + } + + protected Promise scheduleActivity(ActivityType activityType, Promise[] arguments, + ActivitySchedulingOptions optionsOverride, Class returnType, Promise... waitFor) { + return dynamicActivitiesClient.scheduleActivity(activityType, arguments, optionsOverride, returnType, waitFor); + } + + protected Promise scheduleActivity(ActivityType activityType, Object[] arguments, + ActivitySchedulingOptions optionsOverride, Class returnType, Promise... waitFor) { + return dynamicActivitiesClient.scheduleActivity(activityType, arguments, optionsOverride, returnType, waitFor); + } + + @Override + public DataConverter getDataConverter() { + return dynamicActivitiesClient.getDataConverter(); + } + + public void setDataConverter(DataConverter converter) { + dynamicActivitiesClient.setDataConverter(converter); + } + + @Override + public ActivitySchedulingOptions getSchedulingOptions() { + return dynamicActivitiesClient.getSchedulingOptions(); + } + + public void setSchedulingOptions(ActivitySchedulingOptions schedulingOptions) { + dynamicActivitiesClient.setSchedulingOptions(schedulingOptions); + } + + @Override + public GenericActivityClient getGenericClient() { + return dynamicActivitiesClient.getGenericClient(); + } + + public void setGenericClient(GenericActivityClient genericClient) { + dynamicActivitiesClient.setGenericClient(genericClient); + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityExecutionContext.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityExecutionContext.java new file mode 100644 index 000000000000..1d41787cb906 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityExecutionContext.java @@ -0,0 +1,81 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import java.util.concurrent.CancellationException; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.AmazonServiceException; +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.annotations.ManualActivityCompletion; +import com.amazonaws.services.simpleworkflow.flow.generic.ActivityImplementation; +import com.amazonaws.services.simpleworkflow.model.ActivityTask; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +/** + * Context object passed to an activity implementation. + * + * @see ActivityImplementation + * + * @author fateev + */ +public abstract class ActivityExecutionContext { + + /** + * @return task token that is required to report task completion when + * {@link ManualActivityCompletion} is used. + */ + public abstract String getTaskToken(); + + /** + * @return workfow execution that requested the activity execution + */ + public abstract WorkflowExecution getWorkflowExecution(); + + /** + * @return task that caused activity execution + */ + public abstract ActivityTask getTask(); + + /** + * Use to notify Simple Workflow that activity execution is alive. + * + * @param details + * In case of activity timeout details are returned as a field of + * the exception thrown. + * @throws AmazonClientException + * If any internal errors are encountered inside the client + * while attempting to make the request or handle the response. + * For example if a network connection is not available. + * @throws AmazonServiceException + * If an error response is returned by AmazonSimpleWorkflow + * indicating either a problem with the data in the request. + * Internal service errors are swallowed and not propagated to + * the caller. + * @throws CancellationException + * Indicates that activity cancellation was requested by the + * workflow.Should be rethrown from activity implementation to + * indicate successful cancellation. + */ + public abstract void recordActivityHeartbeat(String details) + throws AmazonServiceException, AmazonClientException, CancellationException; + + /** + * @return an instance of the Simple Workflow Java client that is the same + * used by the invoked activity worker. + */ + public abstract AmazonSimpleWorkflow getService(); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityExecutionContextProvider.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityExecutionContextProvider.java new file mode 100644 index 000000000000..3b18c50f8b42 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityExecutionContextProvider.java @@ -0,0 +1,30 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +/** + * Used to access execution context of the currently executed activity. An + * implementation might rely on thread local storage. So it is guaranteed to + * return current context only in the thread that invoked the activity + * implementation. If activity implementation needs to pass its execution + * context to other threads it has to do it explicitly. + * + * @author fateev + */ +public interface ActivityExecutionContextProvider { + + public ActivityExecutionContext getActivityExecutionContext(); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityExecutionContextProviderImpl.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityExecutionContextProviderImpl.java new file mode 100644 index 000000000000..027bc4350203 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityExecutionContextProviderImpl.java @@ -0,0 +1,32 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.worker.CurrentActivityExecutionContext; + +/** + * The default implementation of the ActivityExecutionContextProvider. Can be + * shared across any number of activity implementation instances. + * + * @author fateev + */ +public class ActivityExecutionContextProviderImpl implements ActivityExecutionContextProvider { + + @Override + public ActivityExecutionContext getActivityExecutionContext() { + return CurrentActivityExecutionContext.get(); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityFailureException.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityFailureException.java new file mode 100644 index 000000000000..2e8fa980dd35 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityFailureException.java @@ -0,0 +1,68 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.generic.ActivityImplementation; + +/** + * This exception is expected to be thrown from + * {@link ActivityImplementation#execute(ActivityExecutionContext)} + * as it contains details property in the format that the activity client code + * in the decider understands. + *

+ * It is not expected to be thrown by the application level code. + * + * @author fateev + */ +@SuppressWarnings("serial") +public class ActivityFailureException extends RuntimeException { + + private String details; + + public ActivityFailureException(String reason) { + super(reason); + } + + /** + * Construct exception with given arguments. + * + * @param statusCode + * value of status code field + * @param details + * application specific failure details + */ + public ActivityFailureException(String reason, String details) { + this(reason); + this.details = details; + } + + public String getDetails() { + return details; + } + + public void setDetails(String details) { + this.details = details; + } + + public String getReason() { + return getMessage(); + } + + @Override + public String toString() { + return super.toString() + " : " + getDetails(); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivitySchedulingOptions.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivitySchedulingOptions.java new file mode 100644 index 000000000000..ccb2e8d32d0c --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivitySchedulingOptions.java @@ -0,0 +1,94 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + + +public class ActivitySchedulingOptions { + + private Long heartbeatTimeoutSeconds; + + private Long scheduleToCloseTimeoutSeconds; + + private Long scheduleToStartTimeoutSeconds; + + private Long startToCloseTimeoutSeconds; + + private String taskList; + + public Long getHeartbeatTimeoutSeconds() { + return heartbeatTimeoutSeconds; + } + + public void setHeartbeatTimeoutSeconds(Long heartbeatTimeoutSeconds) { + this.heartbeatTimeoutSeconds = heartbeatTimeoutSeconds; + } + + public ActivitySchedulingOptions withHeartbeatTimeoutSeconds(Long heartbeatTimeoutSeconds) { + this.heartbeatTimeoutSeconds = heartbeatTimeoutSeconds; + return this; + } + + public Long getScheduleToCloseTimeoutSeconds() { + return scheduleToCloseTimeoutSeconds; + } + + public void setScheduleToCloseTimeoutSeconds(Long scheduleToCloseTimeoutSeconds) { + this.scheduleToCloseTimeoutSeconds = scheduleToCloseTimeoutSeconds; + } + + public ActivitySchedulingOptions withScheduleToCloseTimeoutSeconds(Long scheduleToCloseTimeoutSeconds) { + this.scheduleToCloseTimeoutSeconds = scheduleToCloseTimeoutSeconds; + return this; + } + + public Long getScheduleToStartTimeoutSeconds() { + return scheduleToStartTimeoutSeconds; + } + + public void setScheduleToStartTimeoutSeconds(Long scheduleToStartTimeoutSeconds) { + this.scheduleToStartTimeoutSeconds = scheduleToStartTimeoutSeconds; + } + + public ActivitySchedulingOptions withScheduleToStartTimeoutSeconds(Long scheduleToStartTimeoutSeconds) { + this.scheduleToStartTimeoutSeconds = scheduleToStartTimeoutSeconds; + return this; + } + + public Long getStartToCloseTimeoutSeconds() { + return startToCloseTimeoutSeconds; + } + + public void setStartToCloseTimeoutSeconds(Long startToCloseTimeoutSeconds) { + this.startToCloseTimeoutSeconds = startToCloseTimeoutSeconds; + } + + public ActivitySchedulingOptions withStartToCloseTimeoutSeconds(Long startToCloseTimeoutSeconds) { + this.startToCloseTimeoutSeconds = startToCloseTimeoutSeconds; + return this; + } + + public String getTaskList() { + return taskList; + } + + public void setTaskList(String taskList) { + this.taskList = taskList; + } + + public ActivitySchedulingOptions withTaskList(String taskList) { + this.taskList = taskList; + return this; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityTaskException.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityTaskException.java new file mode 100644 index 000000000000..54b3f42facac --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityTaskException.java @@ -0,0 +1,60 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.model.ActivityType; + + +/** + * Exception used to communicate failure of remote activity. + */ +@SuppressWarnings("serial") +public abstract class ActivityTaskException extends DecisionException { + + private ActivityType activityType; + + private String activityId; + + public ActivityTaskException(String message) { + super(message); + } + + public ActivityTaskException(String message, Throwable cause) { + super(message, cause); + } + + public ActivityTaskException(String message, long eventId, ActivityType activityType, String activityId) { + super(message + " for activityId=\"" + activityId + "\" of activityType=" + activityType, eventId); + this.activityType = activityType; + this.activityId = activityId; + } + + public ActivityType getActivityType() { + return activityType; + } + + public void setActivityType(ActivityType activityType) { + this.activityType = activityType; + } + + public String getActivityId() { + return activityId; + } + + public void setActivityId(String activityId) { + this.activityId = activityId; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityTaskFailedException.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityTaskFailedException.java new file mode 100644 index 000000000000..4cb52821ce65 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityTaskFailedException.java @@ -0,0 +1,48 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.model.ActivityType; + + +/** + * Exception used to communicate failure of remote activity. + */ +@SuppressWarnings("serial") +public class ActivityTaskFailedException extends ActivityTaskException { + + private String details; + + public ActivityTaskFailedException(String message, Throwable cause) { + super(message, cause); + } + + public ActivityTaskFailedException(String message) { + super(message); + } + + public ActivityTaskFailedException(long eventId, ActivityType activityType, String activityId, String reason, String details) { + super(reason, eventId, activityType, activityId); + this.details = details; + } + + public String getDetails() { + return details; + } + + public void setDetails(String details) { + this.details = details; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityTaskTimedOutException.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityTaskTimedOutException.java new file mode 100644 index 000000000000..ab4c76b5c7e6 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityTaskTimedOutException.java @@ -0,0 +1,64 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.model.ActivityTaskTimeoutType; +import com.amazonaws.services.simpleworkflow.model.ActivityType; + +/** + * Exception that indicates Activity time out. + */ +@SuppressWarnings("serial") +public class ActivityTaskTimedOutException extends ActivityTaskException { + + private ActivityTaskTimeoutType timeoutType; + + private String details; + + public ActivityTaskTimedOutException(String message, Throwable cause) { + super(message, cause); + } + + public ActivityTaskTimedOutException(String message) { + super(message); + } + + public ActivityTaskTimedOutException(long eventId, ActivityType activityType, String activityId, String timeoutType, + String details) { + super(timeoutType, eventId, activityType, activityId); + this.timeoutType = ActivityTaskTimeoutType.fromValue(timeoutType); + this.details = details; + } + + public ActivityTaskTimeoutType getTimeoutType() { + return timeoutType; + } + + public void setTimeoutType(ActivityTaskTimeoutType timeoutType) { + this.timeoutType = timeoutType; + } + + /** + * @return The value from the last activity heartbeat details field. + */ + public String getDetails() { + return details; + } + + public void setDetails(String details) { + this.details = details; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityWorker.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityWorker.java new file mode 100644 index 000000000000..cc07c6ef4e69 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ActivityWorker.java @@ -0,0 +1,266 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import java.lang.Thread.UncaughtExceptionHandler; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.generic.ActivityImplementation; +import com.amazonaws.services.simpleworkflow.flow.pojo.POJOActivityImplementationFactory; +import com.amazonaws.services.simpleworkflow.flow.worker.GenericActivityWorker; +import com.amazonaws.services.simpleworkflow.model.ActivityType; + +public class ActivityWorker implements WorkerBase { + + private final GenericActivityWorker genericWorker; + + private final POJOActivityImplementationFactory factory = new POJOActivityImplementationFactory(); + + public ActivityWorker(AmazonSimpleWorkflow service, String domain, String taskListToPoll) { + genericWorker = new GenericActivityWorker(service, domain, taskListToPoll); + genericWorker.setActivityImplementationFactory(factory); + } + + public void setActivitiesImplementations(Iterable activitiesImplementations) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + factory.setActivitiesImplementations(activitiesImplementations); + } + + public Iterable getActivitiesImplementations() { + return factory.getActivitiesImplementations(); + } + + public List addActivitiesImplementations(Iterable activitiesImplementations) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + return factory.addActivitiesImplementations(activitiesImplementations); + } + + public List addActivitiesImplementations(Iterable activitiesImplementations, DataConverter dataConverter) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + return factory.addActivitiesImplementations(activitiesImplementations, dataConverter); + } + + public List addActivitiesImplementation(Object activitiesImplementation) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + return factory.addActivitiesImplementation(activitiesImplementation); + } + + public List addActivitiesImplementation(Object activitiesImplementation, DataConverter converter) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + return factory.addActivitiesImplementation(activitiesImplementation, converter); + } + + public Iterable getActivityTypesToRegister() { + return factory.getActivityTypesToRegister(); + } + + public ActivityImplementation getActivityImplementation(ActivityType activityType) { + return factory.getActivityImplementation(activityType); + } + + public DataConverter getDataConverter() { + return factory.getDataConverter(); + } + + public void setDataConverter(DataConverter dataConverter) { + factory.setDataConverter(dataConverter); + } + + public int getTaskExecutorThreadPoolSize() { + return genericWorker.getTaskExecutorThreadPoolSize(); + } + + public void setTaskExecutorThreadPoolSize(int taskExecutorThreadPoolSize) { + genericWorker.setTaskExecutorThreadPoolSize(taskExecutorThreadPoolSize); + } + + @Override + public boolean shutdownAndAwaitTermination(long timeout, TimeUnit unit) throws InterruptedException { + return genericWorker.shutdownAndAwaitTermination(timeout, unit); + } + + @Override + public void shutdownNow() { + genericWorker.shutdownNow(); + } + + @Override + public AmazonSimpleWorkflow getService() { + return genericWorker.getService(); + } + + @Override + public String getDomain() { + return genericWorker.getDomain(); + } + + @Override + public boolean isRegisterDomain() { + return genericWorker.isRegisterDomain(); + } + + @Override + public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { + return genericWorker.awaitTermination(timeout, unit); + } + + @Override + public void setRegisterDomain(boolean registerDomain) { + genericWorker.setRegisterDomain(registerDomain); + } + + @Override + public long getDomainRetentionPeriodInDays() { + return genericWorker.getDomainRetentionPeriodInDays(); + } + + @Override + public void setDomainRetentionPeriodInDays(long days) { + genericWorker.setDomainRetentionPeriodInDays(days); + } + + @Override + public String getTaskListToPoll() { + return genericWorker.getTaskListToPoll(); + } + + @Override + public double getMaximumPollRatePerSecond() { + return genericWorker.getMaximumPollRatePerSecond(); + } + + @Override + public void setMaximumPollRatePerSecond(double maximumPollRatePerSecond) { + genericWorker.setMaximumPollRatePerSecond(maximumPollRatePerSecond); + } + + @Override + public int getMaximumPollRateIntervalMilliseconds() { + return genericWorker.getMaximumPollRateIntervalMilliseconds(); + } + + @Override + public void setMaximumPollRateIntervalMilliseconds(int maximumPollRateIntervalMilliseconds) { + genericWorker.setMaximumPollRateIntervalMilliseconds(maximumPollRateIntervalMilliseconds); + } + + @Override + public UncaughtExceptionHandler getUncaughtExceptionHandler() { + return genericWorker.getUncaughtExceptionHandler(); + } + + @Override + public void setUncaughtExceptionHandler(UncaughtExceptionHandler uncaughtExceptionHandler) { + genericWorker.setUncaughtExceptionHandler(uncaughtExceptionHandler); + } + + @Override + public String getIdentity() { + return genericWorker.getIdentity(); + } + + @Override + public void setIdentity(String identity) { + genericWorker.setIdentity(identity); + } + + @Override + public long getPollBackoffInitialInterval() { + return genericWorker.getPollBackoffInitialInterval(); + } + + @Override + public void setPollBackoffInitialInterval(long backoffInitialInterval) { + genericWorker.setPollBackoffInitialInterval(backoffInitialInterval); + } + + @Override + public long getPollBackoffMaximumInterval() { + return genericWorker.getPollBackoffMaximumInterval(); + } + + @Override + public void setPollBackoffMaximumInterval(long backoffMaximumInterval) { + genericWorker.setPollBackoffMaximumInterval(backoffMaximumInterval); + } + + @Override + public boolean isDisableServiceShutdownOnStop() { + return genericWorker.isDisableServiceShutdownOnStop(); + } + + @Override + public void setDisableServiceShutdownOnStop(boolean disableServiceShutdownOnStop) { + genericWorker.setDisableServiceShutdownOnStop(disableServiceShutdownOnStop); + } + + @Override + public double getPollBackoffCoefficient() { + return genericWorker.getPollBackoffCoefficient(); + } + + @Override + public void setPollBackoffCoefficient(double backoffCoefficient) { + genericWorker.setPollBackoffCoefficient(backoffCoefficient); + } + + @Override + public int getPollThreadCount() { + return genericWorker.getPollThreadCount(); + } + + @Override + public void setPollThreadCount(int threadCount) { + genericWorker.setPollThreadCount(threadCount); + } + + @Override + public void registerTypesToPoll() { + genericWorker.registerTypesToPoll(); + } + + @Override + public void start() { + genericWorker.start(); + } + + @Override + public void shutdown() { + genericWorker.shutdown(); + } + + @Override + public boolean isRunning() { + return genericWorker.isRunning(); + } + + @Override + public void suspendPolling() { + genericWorker.suspendPolling(); + } + + @Override + public void resumePolling() { + genericWorker.resumePolling(); + } + + @Override + public String toString() { + return this.getClass().getSimpleName() + "[genericWorker=" + genericWorker + ", factory=" + factory + "]"; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/ChildWorkflowException.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ChildWorkflowException.java new file mode 100644 index 000000000000..28c1582655ac --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ChildWorkflowException.java @@ -0,0 +1,60 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + + +/** + * Exception used to communicate failure of remote activity. + */ +@SuppressWarnings("serial") +public abstract class ChildWorkflowException extends DecisionException { + + private WorkflowExecution workflowExecution; + + private WorkflowType workflowType; + + public ChildWorkflowException(String message) { + super(message); + } + + public ChildWorkflowException(String message, Throwable cause) { + super(message, cause); + } + + public ChildWorkflowException(String message, long eventId, WorkflowExecution workflowExecution, WorkflowType workflowType) { + super(message + " for workflowExecution=\"" + workflowExecution + "\" of workflowType=" + workflowType, eventId); + this.workflowExecution = workflowExecution; + this.workflowType = workflowType; + } + + public WorkflowExecution getWorkflowExecution() { + return workflowExecution; + } + + public void setWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + } + + public WorkflowType getWorkflowType() { + return workflowType; + } + + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/ChildWorkflowFailedException.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ChildWorkflowFailedException.java new file mode 100644 index 000000000000..0aa56aceba37 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ChildWorkflowFailedException.java @@ -0,0 +1,51 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +@SuppressWarnings("serial") +public class ChildWorkflowFailedException extends ChildWorkflowException { + + private String details; + + public ChildWorkflowFailedException(String message) { + super(message); + } + + public ChildWorkflowFailedException(String message, Throwable cause) { + super(message, cause); + } + + public ChildWorkflowFailedException(long eventId, WorkflowExecution workflowExecution, WorkflowType workflowType, + String reason, String details) { + super(createMessage(workflowExecution, workflowType, reason), eventId, workflowExecution, workflowType); + this.details = details; + } + + public String getDetails() { + return details; + } + + public void setDetails(String details) { + this.details = details; + } + + private static String createMessage(WorkflowExecution workflowExecution, WorkflowType workflowType, String reason) { + return "name=" + workflowType.getName() + ", version=" + workflowType.getVersion() + ", workflowId=" + + workflowExecution.getWorkflowId() + ", runId=" + workflowExecution.getRunId() + ": " + reason; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/ChildWorkflowTerminatedException.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ChildWorkflowTerminatedException.java new file mode 100644 index 000000000000..71f645b7e86d --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ChildWorkflowTerminatedException.java @@ -0,0 +1,35 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +@SuppressWarnings("serial") +public class ChildWorkflowTerminatedException extends ChildWorkflowException { + + public ChildWorkflowTerminatedException(String message) { + super(message); + } + + public ChildWorkflowTerminatedException(String message, Throwable cause) { + super(message, cause); + } + + public ChildWorkflowTerminatedException(long eventId, WorkflowExecution workflowExecution, WorkflowType workflowType) { + super("Terminate", eventId, workflowExecution, workflowType); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/ChildWorkflowTimedOutException.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ChildWorkflowTimedOutException.java new file mode 100644 index 000000000000..1bcc7faaff99 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ChildWorkflowTimedOutException.java @@ -0,0 +1,35 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +@SuppressWarnings("serial") +public class ChildWorkflowTimedOutException extends ChildWorkflowException { + + public ChildWorkflowTimedOutException(String message) { + super(message); + } + + public ChildWorkflowTimedOutException(String message, Throwable cause) { + super(message, cause); + } + + public ChildWorkflowTimedOutException(long eventId, WorkflowExecution workflowExecution, WorkflowType workflowType) { + super("Time Out", eventId, workflowExecution, workflowType); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/DataConverter.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DataConverter.java new file mode 100644 index 000000000000..bbc452d6166c --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DataConverter.java @@ -0,0 +1,49 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +/** + * Used by the framework to serialize/deserialize method parameters that need to + * be sent over the wire. + * + * @author fateev + */ +public abstract class DataConverter { + + /** + * Implements conversion of the single value. + * + * @param value + * Java value to convert to String. + * @return converted value + * @throws DataConverterException + * if conversion of the value passed as parameter failed for any + * reason. + */ + public abstract String toData(Object value) throws DataConverterException; + + /** + * Implements conversion of the single value. + * + * @param data + * Simple Workflow Data value to convert to a Java object. + * @return converted Java object + * @throws DataConverterException + * if conversion of the data passed as parameter failed for any + * reason. + */ + public abstract T fromData(String content, Class valueType) throws DataConverterException; + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/DataConverterException.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DataConverterException.java new file mode 100644 index 000000000000..307f7aa91a63 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DataConverterException.java @@ -0,0 +1,51 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + + +/** + * @see DataConverter + * + * @author fateev + */ +@SuppressWarnings("serial") +public class DataConverterException extends RuntimeException { + + private String key; + + public DataConverterException() { + } + + public DataConverterException(String message, Throwable cause) { + super(message, cause); + } + + public DataConverterException(String message) { + super(message); + } + + public DataConverterException(Throwable cause) { + super(cause); + } + + public void setKey(String key) { + this.key = key; + } + + @Override + public String getMessage() { + return super.getMessage() + " when mapping key \"" + key + "\""; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/DecisionContext.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DecisionContext.java new file mode 100644 index 000000000000..3c1d0816ec97 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DecisionContext.java @@ -0,0 +1,35 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.generic.GenericActivityClient; +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClient; + +/** + * Represents the context for decider. Should only be used within the scope of + * workflow definition code, meaning any code which is not part of activity + * implementations. + */ +public abstract class DecisionContext { + + public abstract GenericActivityClient getActivityClient(); + + public abstract GenericWorkflowClient getWorkflowClient(); + + public abstract WorkflowClock getWorkflowClock(); + + public abstract WorkflowContext getWorkflowContext(); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/DecisionContextProvider.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DecisionContextProvider.java new file mode 100644 index 000000000000..9c5d6b035e76 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DecisionContextProvider.java @@ -0,0 +1,22 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + + +public interface DecisionContextProvider { + + public DecisionContext getDecisionContext(); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/DecisionContextProviderImpl.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DecisionContextProviderImpl.java new file mode 100644 index 000000000000..76b0472416bb --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DecisionContextProviderImpl.java @@ -0,0 +1,27 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.worker.CurrentDecisionContext; + + +public class DecisionContextProviderImpl implements DecisionContextProvider { + + @Override + public DecisionContext getDecisionContext() { + return CurrentDecisionContext.get(); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/DecisionException.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DecisionException.java new file mode 100644 index 000000000000..978bc9a60bfd --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DecisionException.java @@ -0,0 +1,48 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +/** + * Exception used to communicate failure during fulfillment of a decision sent + * to SWF. This exception and all its subclasses are expected to be thrown by + * the framework. The only reason its constructor is public is so allow unit + * tests that throw it. + */ +@SuppressWarnings("serial") +public abstract class DecisionException extends RuntimeException { + + private long eventId; + + public DecisionException(String message) { + super(message); + } + + public DecisionException(String message, Throwable cause) { + super(message, cause); + } + + public DecisionException(String message, long eventId) { + super(message); + this.eventId = eventId; + } + + public long getEventId() { + return eventId; + } + + public void setEventId(long eventId) { + this.eventId = eventId; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicActivitiesClient.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicActivitiesClient.java new file mode 100644 index 000000000000..d75bd18b1c6e --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicActivitiesClient.java @@ -0,0 +1,28 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.model.ActivityType; + +public interface DynamicActivitiesClient extends ActivitiesClient { + + Promise scheduleActivity(final ActivityType activityType, final Promise[] arguments, + final ActivitySchedulingOptions optionsOverride, final Class returnType, final Promise... waitFor); + + Promise scheduleActivity(final ActivityType activityType, final Object[] arguments, + final ActivitySchedulingOptions optionsOverride, final Class returnType, Promise... waitFor); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicActivitiesClientImpl.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicActivitiesClientImpl.java new file mode 100644 index 000000000000..560231fe54ad --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicActivitiesClientImpl.java @@ -0,0 +1,164 @@ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.core.Functor; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.core.Settable; +import com.amazonaws.services.simpleworkflow.flow.core.TryCatchFinally; +import com.amazonaws.services.simpleworkflow.flow.generic.ExecuteActivityParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.GenericActivityClient; +import com.amazonaws.services.simpleworkflow.model.ActivityType; + +public class DynamicActivitiesClientImpl implements DynamicActivitiesClient { + + protected DataConverter dataConverter; + + protected ActivitySchedulingOptions schedulingOptions; + + protected GenericActivityClient genericClient; + + protected DecisionContextProvider decisionContextProvider = new DecisionContextProviderImpl(); + + public DynamicActivitiesClientImpl() { + this(null, null, null); + } + + public DynamicActivitiesClientImpl(ActivitySchedulingOptions schedulingOptions) { + this(schedulingOptions, null, null); + } + + public DynamicActivitiesClientImpl(ActivitySchedulingOptions schedulingOptions, DataConverter dataConverter) { + this(schedulingOptions, dataConverter, null); + } + + public DynamicActivitiesClientImpl(ActivitySchedulingOptions schedulingOptions, DataConverter dataConverter, + GenericActivityClient genericClient) { + this.genericClient = genericClient; + + if (schedulingOptions == null) { + this.schedulingOptions = new ActivitySchedulingOptions(); + } + else { + this.schedulingOptions = schedulingOptions; + } + + if (dataConverter == null) { + this.dataConverter = new JsonDataConverter(); + } + else { + this.dataConverter = dataConverter; + } + + } + + @Override + public DataConverter getDataConverter() { + return dataConverter; + } + + public void setDataConverter(DataConverter dataConverter) { + this.dataConverter = dataConverter; + } + + @Override + public ActivitySchedulingOptions getSchedulingOptions() { + return schedulingOptions; + } + + public void setSchedulingOptions(ActivitySchedulingOptions schedulingOptions) { + this.schedulingOptions = schedulingOptions; + } + + @Override + public GenericActivityClient getGenericClient() { + return genericClient; + } + + public void setGenericClient(GenericActivityClient genericClient) { + this.genericClient = genericClient; + } + + public Promise scheduleActivity(final ActivityType activityType, final Promise[] arguments, + final ActivitySchedulingOptions optionsOverride, final Class returnType, final Promise... waitFor) { + return new Functor(arguments) { + + @Override + protected Promise doExecute() throws Throwable { + Object[] input = new Object[arguments.length]; + for (int i = 0; i < arguments.length; i++) { + Promise argument = arguments[i]; + input[i] = argument.get(); + } + return scheduleActivity(activityType, input, optionsOverride, returnType, waitFor); + } + + }; + + } + + public Promise scheduleActivity(final ActivityType activityType, final Object[] arguments, + final ActivitySchedulingOptions optionsOverride, final Class returnType, Promise... waitFor) { + final Settable result = new Settable(); + new TryCatchFinally(waitFor) { + + Promise stringOutput; + + @Override + protected void doTry() throws Throwable { + ExecuteActivityParameters parameters = new ExecuteActivityParameters(); + parameters.setActivityType(activityType); + String stringInput = dataConverter.toData(arguments); + parameters.setInput(stringInput); + final ExecuteActivityParameters _scheduleParameters_ = parameters.createExecuteActivityParametersFromOptions( + schedulingOptions, optionsOverride); + + GenericActivityClient client; + if (genericClient == null) { + client = decisionContextProvider.getDecisionContext().getActivityClient(); + } else { + client = genericClient; + } + stringOutput = client.scheduleActivityTask(_scheduleParameters_); + result.setDescription(stringOutput.getDescription()); + } + + @Override + protected void doCatch(Throwable e) throws Throwable { + if (e instanceof ActivityTaskFailedException) { + ActivityTaskFailedException taskFailedException = (ActivityTaskFailedException) e; + try { + String details = taskFailedException.getDetails(); + if (details != null) { + Throwable cause = dataConverter.fromData(details, Throwable.class); + if (cause != null && taskFailedException.getCause() == null) { + taskFailedException.initCause(cause); + } + } + } + catch (DataConverterException dataConverterException) { + if (dataConverterException.getCause() == null) { + dataConverterException.initCause(taskFailedException); + } + throw dataConverterException; + } + } + + throw e; + } + + @Override + protected void doFinally() throws Throwable { + if (stringOutput != null && stringOutput.isReady()) { + if (returnType.equals(Void.class)) { + result.set(null); + } + else { + T output = dataConverter.fromData(stringOutput.get(), returnType); + result.set(output); + } + } + } + }; + return result; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicClient.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicClient.java new file mode 100644 index 000000000000..dc2eab5d1a1c --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicClient.java @@ -0,0 +1,104 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import java.util.Map; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.generic.ContinueAsNewWorkflowExecutionParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.ExecuteActivityParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.SignalExternalWorkflowParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.StartChildWorkflowExecutionParameters; +/** + */ +public interface DynamicClient { + + + /** + * Used to dynamically schedule an activity using its name + * + * @param activity + * name of activity to schedule + * @param input + * a Value containing a map of all input parameters to that activity + * @return + * a Value which contains a Map of results returned by the activity + */ + public Promise> scheduleActivityTask(final String activity, final String version, + final Promise input); + + /** + * Used to dynamically schedule an activity for execution + * + * @param activity + * Name of activity + * @param input + * A map of all input parameters to that activity + * @return + * A Value which contains a Map of results returned by the activity + */ + public abstract Promise> scheduleActivityTask(String activity, String version, Object[] input); + + /** + * Used to dynamically schedule an activity for execution + * + * @param parameters + * An object which encapsulates all the information required to schedule an activity + * for execution + * @return + * An object which can be used to cancel the activity or retrieve the Value + * containing the result for the activity + */ + public abstract Promise scheduleActivityTask(ExecuteActivityParameters parameters); + + /** + * Used to dynamically schedule an activity for execution + * + * @param activity + * Name of activity + * @param input + * A map of all input parameters to that activity + * @param converter + * Data converter to use for serialization of input parameters and deserialization of + * output result + * @return + * A Value which contains a Map of results returned by the activity + */ + public abstract Promise> scheduleActivityTask(String activity, String version, + Object[] input, DataConverter converter); + + public abstract Promise startChildWorkflow(StartChildWorkflowExecutionParameters parameters); + + public abstract Promise> startChildWorkflow(String workflow, String version, Object[] input); + + public abstract Promise> startChildWorkflow(String workflow, String version, + Object[] input, DataConverter converter); + + public abstract Promise> startChildWorkflow(final String workflow, final String version, + final Promise input); + + public abstract Promise signalWorkflowExecution(SignalExternalWorkflowParameters parameters); + + /** + * Start a new generation of the workflow instance. + * + * @param input + * Map containing input parameters to the workflow + */ + public abstract void continueAsNewOnCompletion(Object[] input); + + public abstract void continueAsNewOnCompletion(ContinueAsNewWorkflowExecutionParameters parameters); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicWorkflowClient.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicWorkflowClient.java new file mode 100644 index 000000000000..8691fbc84e97 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicWorkflowClient.java @@ -0,0 +1,30 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + + +public interface DynamicWorkflowClient extends WorkflowClient { + + Promise startWorkflowExecution(final Promise[] arguments, + final StartWorkflowOptions startOptionsOverride, final Class returnType, final Promise... waitFor); + + Promise startWorkflowExecution(final Object[] arguments, final StartWorkflowOptions startOptionsOverride, + final Class returnType, Promise... waitFor); + + void signalWorkflowExecution(String signalName, Object[] arguments, Promise... waitFor); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicWorkflowClientExternal.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicWorkflowClientExternal.java new file mode 100644 index 000000000000..4362243718b0 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicWorkflowClientExternal.java @@ -0,0 +1,28 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + + +public interface DynamicWorkflowClientExternal extends WorkflowClientExternal { + + void startWorkflowExecution(Object[] arguments, StartWorkflowOptions startOptionsOverride); + + void startWorkflowExecution(Object[] arguments); + + void signalWorkflowExecution(String signalName, Object[] arguments); + + T getWorkflowExecutionState(Class returnType) throws Throwable; + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicWorkflowClientExternalImpl.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicWorkflowClientExternalImpl.java new file mode 100644 index 000000000000..532457a5b5dc --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicWorkflowClientExternalImpl.java @@ -0,0 +1,183 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClientExternal; +import com.amazonaws.services.simpleworkflow.flow.generic.SignalExternalWorkflowParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.StartWorkflowExecutionParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.TerminateWorkflowExecutionParameters; +import com.amazonaws.services.simpleworkflow.model.ChildPolicy; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +public class DynamicWorkflowClientExternalImpl implements DynamicWorkflowClientExternal { + + protected DataConverter dataConverter; + + protected StartWorkflowOptions schedulingOptions; + + protected GenericWorkflowClientExternal genericClient; + + protected WorkflowExecution workflowExecution; + + protected WorkflowType workflowType; + + public DynamicWorkflowClientExternalImpl(String workflowId, WorkflowType workflowType) { + this(new WorkflowExecution().withWorkflowId(workflowId), workflowType, null, null); + } + + public DynamicWorkflowClientExternalImpl(WorkflowExecution workflowExecution) { + this(workflowExecution, null, null, null); + } + + public DynamicWorkflowClientExternalImpl(String workflowId, WorkflowType workflowType, StartWorkflowOptions options) { + this(new WorkflowExecution().withWorkflowId(workflowId), workflowType, options, null, null); + } + + public DynamicWorkflowClientExternalImpl(WorkflowExecution workflowExecution, WorkflowType workflowType, + StartWorkflowOptions options) { + this(workflowExecution, workflowType, options, null, null); + } + + public DynamicWorkflowClientExternalImpl(WorkflowExecution workflowExecution, WorkflowType workflowType, + StartWorkflowOptions options, DataConverter dataConverter) { + this(workflowExecution, workflowType, options, dataConverter, null); + } + + public DynamicWorkflowClientExternalImpl(WorkflowExecution workflowExecution, WorkflowType workflowType, + StartWorkflowOptions options, DataConverter dataConverter, GenericWorkflowClientExternal genericClient) { + this.workflowExecution = workflowExecution; + this.workflowType = workflowType; + this.schedulingOptions = options; + if (dataConverter == null) { + this.dataConverter = new JsonDataConverter(); + } + else { + this.dataConverter = dataConverter; + } + this.genericClient = genericClient; + } + + public DataConverter getDataConverter() { + return dataConverter; + } + + public void setDataConverter(DataConverter dataConverter) { + this.dataConverter = dataConverter; + } + + public StartWorkflowOptions getSchedulingOptions() { + return schedulingOptions; + } + + public void setSchedulingOptions(StartWorkflowOptions schedulingOptions) { + this.schedulingOptions = schedulingOptions; + } + + public GenericWorkflowClientExternal getGenericClient() { + return genericClient; + } + + public void setGenericClient(GenericWorkflowClientExternal genericClient) { + this.genericClient = genericClient; + } + + public WorkflowExecution getWorkflowExecution() { + return workflowExecution; + } + + public void setWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + } + + public WorkflowType getWorkflowType() { + return workflowType; + } + + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + @Override + public void terminateWorkflowExecution(String reason, String details, ChildPolicy childPolicy) { + TerminateWorkflowExecutionParameters terminateParameters = new TerminateWorkflowExecutionParameters(); + terminateParameters.setReason(reason); + terminateParameters.setDetails(details); + terminateParameters.setChildPolicy(childPolicy); + terminateParameters.setWorkflowExecution(workflowExecution); + genericClient.terminateWorkflowExecution(terminateParameters); + } + + @Override + public void requestCancelWorkflowExecution() { + genericClient.requestCancelWorkflowExecution(workflowExecution); + } + + @Override + public void startWorkflowExecution(Object[] arguments) { + startWorkflowExecution(arguments, null); + } + + @Override + public void startWorkflowExecution(Object[] arguments, StartWorkflowOptions startOptionsOverride) { + if (workflowType == null) { + throw new IllegalStateException("Required property workflowType is null"); + } + if (workflowExecution == null) { + throw new IllegalStateException("wokflowExecution is null"); + } + else if (workflowExecution.getWorkflowId() == null) { + throw new IllegalStateException("wokflowId is null"); + } + StartWorkflowExecutionParameters parameters = new StartWorkflowExecutionParameters(); + parameters.setWorkflowType(workflowType); + parameters.setWorkflowId(workflowExecution.getWorkflowId()); + String input = dataConverter.toData(arguments); + parameters.setInput(input); + parameters = parameters.createStartWorkflowExecutionParametersFromOptions(schedulingOptions, startOptionsOverride); + WorkflowExecution newExecution = genericClient.startWorkflow(parameters); + String runId = newExecution.getRunId(); + workflowExecution.setRunId(runId); + } + + @Override + public void signalWorkflowExecution(String signalName, Object[] arguments) { + SignalExternalWorkflowParameters signalParameters = new SignalExternalWorkflowParameters(); + signalParameters.setRunId(workflowExecution.getRunId()); + signalParameters.setWorkflowId(workflowExecution.getWorkflowId()); + signalParameters.setSignalName(signalName); + String input = dataConverter.toData(arguments); + signalParameters.setInput(input); + genericClient.signalWorkflowExecution(signalParameters); + } + + @Override + public T getWorkflowExecutionState(Class returnType) throws Throwable { + String state = genericClient.getWorkflowState(workflowExecution); + if (state == null) return null; + + try { + Throwable failure = dataConverter.fromData(state, Throwable.class); + if (failure != null) { + throw failure; + } + } catch (DataConverterException e) { + } catch (RuntimeException e) { + } + + return dataConverter.fromData(state, returnType); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicWorkflowClientImpl.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicWorkflowClientImpl.java new file mode 100644 index 000000000000..5d5e90b839a5 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/DynamicWorkflowClientImpl.java @@ -0,0 +1,282 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.core.Functor; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.core.Settable; +import com.amazonaws.services.simpleworkflow.flow.core.Task; +import com.amazonaws.services.simpleworkflow.flow.core.TryFinally; +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClient; +import com.amazonaws.services.simpleworkflow.flow.generic.SignalExternalWorkflowParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.StartChildWorkflowExecutionParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.StartChildWorkflowReply; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +public class DynamicWorkflowClientImpl implements DynamicWorkflowClient { + + protected WorkflowType workflowType; + + protected GenericWorkflowClient genericClient; + + protected StartWorkflowOptions schedulingOptions; + + protected DataConverter dataConverter; + + protected WorkflowExecution workflowExecution; + + protected DecisionContextProvider decisionContextProvider = new DecisionContextProviderImpl(); + + protected Settable runId = new Settable(); + + public DynamicWorkflowClientImpl() { + this(null, null, null, null, null); + } + + public DynamicWorkflowClientImpl(WorkflowExecution workflowExecution) { + this(workflowExecution, null, null, null, null); + } + + public DynamicWorkflowClientImpl(WorkflowExecution workflowExecution, WorkflowType workflowType) { + this(workflowExecution, workflowType, null, null, null); + } + + public DynamicWorkflowClientImpl(WorkflowExecution workflowExecution, WorkflowType workflowType, StartWorkflowOptions options) { + this(workflowExecution, workflowType, options, null, null); + } + + public DynamicWorkflowClientImpl(WorkflowExecution workflowExecution, WorkflowType workflowType, + StartWorkflowOptions options, DataConverter dataConverter) { + this(workflowExecution, workflowType, options, dataConverter, null); + } + + public DynamicWorkflowClientImpl(WorkflowExecution workflowExecution, WorkflowType workflowType, + StartWorkflowOptions options, DataConverter dataConverter, GenericWorkflowClient genericClient) { + this.workflowType = workflowType; + this.workflowExecution = workflowExecution; + if (dataConverter == null) { + this.dataConverter = new JsonDataConverter(); + } + else { + this.dataConverter = dataConverter; + } + this.schedulingOptions = options; + this.genericClient = genericClient; + if (workflowExecution.getRunId() != null) { + this.runId.set(workflowExecution.getRunId()); + } + } + + @Override + public DataConverter getDataConverter() { + return dataConverter; + } + + @Override + public StartWorkflowOptions getSchedulingOptions() { + return schedulingOptions; + } + + @Override + public GenericWorkflowClient getGenericClient() { + return genericClient; + } + + @Override + public Promise getRunId() { + return runId; + } + + @Override + public WorkflowExecution getWorkflowExecution() { + return workflowExecution; + } + + @Override + public WorkflowType getWorkflowType() { + return workflowType; + } + + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + public void setGenericClient(GenericWorkflowClient genericClient) { + this.genericClient = genericClient; + } + + public void setSchedulingOptions(StartWorkflowOptions schedulingOptions) { + this.schedulingOptions = schedulingOptions; + } + + public void setDataConverter(DataConverter dataConverter) { + this.dataConverter = dataConverter; + } + + @Override + public void requestCancelWorkflowExecution(Promise... waitFor) { + checkWorkflowExecution(); + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + GenericWorkflowClient client = getGenericClientToUse(); + client.requestCancelWorkflowExecution(workflowExecution); + } + }; + } + + private void checkWorkflowExecution() { + if (workflowExecution == null) { + throw new IllegalStateException("required property workflowExecution is null"); + } + } + + public Promise startWorkflowExecution(final Promise[] arguments, + final StartWorkflowOptions startOptionsOverride, final Class returnType, final Promise... waitFor) { + checkState(); + if (runId.isReady()) { + runId = new Settable(); + } + return new Functor(arguments) { + + @Override + protected Promise doExecute() throws Throwable { + Object[] input = new Object[arguments.length]; + for (int i = 0; i < arguments.length; i++) { + Promise argument = arguments[i]; + input[i] = argument.get(); + } + return startWorkflowExecution(input, startOptionsOverride, returnType, waitFor); + } + + }; + } + + public Promise startWorkflowExecution(final Object[] arguments, final StartWorkflowOptions startOptionsOverride, + final Class returnType, Promise... waitFor) { + checkState(); + final Settable result = new Settable(); + if (runId.isReady()) { + runId = new Settable(); + } + new TryFinally(waitFor) { + + Promise reply; + + @Override + protected void doTry() throws Throwable { + StartChildWorkflowExecutionParameters parameters = new StartChildWorkflowExecutionParameters(); + parameters.setWorkflowType(workflowType); + String converterdArguments = dataConverter.toData(arguments); + parameters.setInput(converterdArguments); + parameters.setWorkflowId(workflowExecution.getWorkflowId()); + final StartChildWorkflowExecutionParameters startParameters = parameters.createStartChildWorkflowExecutionParametersFromOptions( + schedulingOptions, startOptionsOverride); + GenericWorkflowClient client = getGenericClientToUse(); + reply = client.startChildWorkflow(startParameters); + runId.setDescription("runId of " + reply.getDescription()); + result.setDescription(reply.getDescription()); + new Task(reply) { + + @Override + protected void doExecute() throws Throwable { + if (!runId.isReady()) { + runId.set(reply.get().getRunId()); + workflowExecution.setRunId(runId.get()); + } + } + + }; + } + + @Override + protected void doCatch(Throwable e) throws Throwable { + if (e instanceof ChildWorkflowFailedException) { + ChildWorkflowFailedException taskFailedException = (ChildWorkflowFailedException) e; + try { + String details = taskFailedException.getDetails(); + if (details != null) { + Throwable cause = dataConverter.fromData(details, Throwable.class); + if (cause != null && taskFailedException.getCause() == null) { + taskFailedException.initCause(cause); + } + } + } + catch (DataConverterException dataConverterException) { + if (dataConverterException.getCause() == null) { + dataConverterException.initCause(taskFailedException); + } + throw dataConverterException; + } + } + + throw e; + } + + @Override + protected void doFinally() throws Throwable { + if (reply != null && reply.isReady() && reply.get().getResult().isReady()) { + if (returnType.equals(Void.class)) { + result.set(null); + } + else { + T output = dataConverter.fromData(reply.get().getResult().get(), returnType); + result.set(output); + } + } + } + }; + return result; + } + + @Override + public void signalWorkflowExecution(final String signalName, final Object[] arguments, Promise... waitFor) { + checkWorkflowExecution(); + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + SignalExternalWorkflowParameters parameters = new SignalExternalWorkflowParameters(); + parameters.setSignalName(signalName); + String input = dataConverter.toData(arguments); + parameters.setInput(input); + parameters.setWorkflowId(workflowExecution.getWorkflowId()); + parameters.setRunId(workflowExecution.getRunId()); + GenericWorkflowClient client = getGenericClientToUse(); + client.signalWorkflowExecution(parameters); + } + }; + } + + private void checkState() { + if (workflowType == null) { + throw new IllegalStateException("required property workflowType is null"); + } + checkWorkflowExecution(); + } + + private GenericWorkflowClient getGenericClientToUse() { + GenericWorkflowClient client; + if (genericClient == null) { + client = decisionContextProvider.getDecisionContext().getWorkflowClient(); + } else { + client = genericClient; + } + return client; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/JsonDataConverter.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/JsonDataConverter.java new file mode 100644 index 000000000000..a6575c1b8ea1 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/JsonDataConverter.java @@ -0,0 +1,107 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import java.io.IOException; + +import org.codehaus.jackson.JsonGenerationException; +import org.codehaus.jackson.JsonParseException; +import org.codehaus.jackson.map.DeserializationConfig.Feature; +import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.ObjectMapper.DefaultTyping; + +/** + * Implements conversion through Jackson JSON processor. Consult its + * documentation on how to ensure that classes are serializable, configure their + * serialization through annotations and {@link ObjectMapper} parameters. + * + *

+ * Note that default configuration used by this class includes class name of the + * every serialized value into the produced JSON. It is done to support + * polymorphic types out of the box. But in some cases it might be beneficial to + * disable polymorphic support as it produces much more concise and portable + * output. + * + * @author fateev + */ +public class JsonDataConverter extends DataConverter { + + protected final ObjectMapper mapper; + + /** + * Create instance of the converter that uses ObjectMapper with + * {@link Feature#FAIL_ON_UNKNOWN_PROPERTIES} set to false and + * default typing set to {@link DefaultTyping#NON_FINAL}. + */ + public JsonDataConverter() { + this(new ObjectMapper()); + // ignoring unknown properties makes us more robust to changes + // in the schema + mapper.configure(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + // This will allow including type information all non-final types. This allows correct + // serialization/deserialization of generic collections, for example List. + mapper.enableDefaultTyping(DefaultTyping.NON_FINAL); + } + + /** + * Create instance of the converter that uses {@link ObjectMapper} + * configured externally. + */ + public JsonDataConverter(ObjectMapper mapper) { + this.mapper = mapper; + } + + @Override + public String toData(Object value) throws DataConverterException { + try { + return mapper.writeValueAsString(value); + } + catch (JsonGenerationException e) { + throwDataConverterException(e, value); + } + catch (JsonMappingException e) { + throwDataConverterException(e, value); + } + catch (IOException e) { + throwDataConverterException(e, value); + } + throw new IllegalStateException("not reachable"); + } + + private void throwDataConverterException(Throwable e, Object value) { + if (value instanceof Throwable && e.getCause() == null) { + e.initCause((Throwable) value); + } + throw new DataConverterException(e); + } + + @Override + public T fromData(String serialized, Class valueType) throws DataConverterException { + try { + return mapper.readValue(serialized, valueType); + } + catch (JsonParseException e) { + throw new DataConverterException(e); + } + catch (JsonMappingException e) { + throw new DataConverterException(e); + } + catch (IOException e) { + throw new DataConverterException(e); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/ManualActivityCompletionClient.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ManualActivityCompletionClient.java new file mode 100644 index 000000000000..1cd8d68cc29d --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ManualActivityCompletionClient.java @@ -0,0 +1,31 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import java.util.concurrent.CancellationException; + + + +public abstract class ManualActivityCompletionClient { + + public abstract void complete(Object result); + + public abstract void fail(Throwable failure); + + public abstract void recordHeartbeat(String details) throws CancellationException; + + public abstract void reportCancellation(String details); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/ManualActivityCompletionClientFactory.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ManualActivityCompletionClientFactory.java new file mode 100644 index 000000000000..faf707098655 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ManualActivityCompletionClientFactory.java @@ -0,0 +1,23 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + + + +public abstract class ManualActivityCompletionClientFactory { + + public abstract ManualActivityCompletionClient getClient(String taskToken); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/ManualActivityCompletionClientFactoryImpl.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ManualActivityCompletionClientFactoryImpl.java new file mode 100644 index 000000000000..5df454b17aaf --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ManualActivityCompletionClientFactoryImpl.java @@ -0,0 +1,57 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; + + +public class ManualActivityCompletionClientFactoryImpl extends ManualActivityCompletionClientFactory { + + private AmazonSimpleWorkflow service; + + private DataConverter dataConverter = new JsonDataConverter(); + + public ManualActivityCompletionClientFactoryImpl(AmazonSimpleWorkflow service) { + this.service = service; + } + + public AmazonSimpleWorkflow getService() { + return service; + } + + public void setService(AmazonSimpleWorkflow service) { + this.service = service; + } + + public DataConverter getDataConverter() { + return dataConverter; + } + + public void setDataConverter(DataConverter dataConverter) { + this.dataConverter = dataConverter; + } + + @Override + public ManualActivityCompletionClient getClient(String taskToken) { + if (service == null) { + throw new IllegalStateException("required property service is null"); + } + if (dataConverter == null) { + throw new IllegalStateException("required property dataConverter is null"); + } + return new ManualActivityCompletionClientImpl(service, taskToken, dataConverter); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/ManualActivityCompletionClientImpl.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ManualActivityCompletionClientImpl.java new file mode 100644 index 000000000000..0340060cd530 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ManualActivityCompletionClientImpl.java @@ -0,0 +1,79 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import java.util.concurrent.CancellationException; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.model.ActivityTaskStatus; +import com.amazonaws.services.simpleworkflow.model.RecordActivityTaskHeartbeatRequest; +import com.amazonaws.services.simpleworkflow.model.RespondActivityTaskCanceledRequest; +import com.amazonaws.services.simpleworkflow.model.RespondActivityTaskCompletedRequest; +import com.amazonaws.services.simpleworkflow.model.RespondActivityTaskFailedRequest; + +class ManualActivityCompletionClientImpl extends ManualActivityCompletionClient { + + private final AmazonSimpleWorkflow service; + + private final String taskToken; + + private final DataConverter dataConverter; + + public ManualActivityCompletionClientImpl(AmazonSimpleWorkflow service, String taskToken, DataConverter dataConverter) { + this.service = service; + this.taskToken = taskToken; + this.dataConverter = dataConverter; + } + + @Override + public void complete(Object result) { + RespondActivityTaskCompletedRequest request = new RespondActivityTaskCompletedRequest(); + String convertedResult = dataConverter.toData(result); + request.setResult(convertedResult); + request.setTaskToken(taskToken); + service.respondActivityTaskCompleted(request); + } + + @Override + public void fail(Throwable failure) { + RespondActivityTaskFailedRequest request = new RespondActivityTaskFailedRequest(); + String convertedFailure = dataConverter.toData(failure); + request.setReason(failure.getMessage()); + request.setDetails(convertedFailure); + request.setTaskToken(taskToken); + service.respondActivityTaskFailed(request); + } + + @Override + public void recordHeartbeat(String details) throws CancellationException { + RecordActivityTaskHeartbeatRequest request = new RecordActivityTaskHeartbeatRequest(); + request.setDetails(details); + request.setTaskToken(taskToken); + ActivityTaskStatus status = service.recordActivityTaskHeartbeat(request); + status = service.recordActivityTaskHeartbeat(request); + if (status.isCancelRequested()) { + throw new CancellationException(); + } + } + + @Override + public void reportCancellation(String details) { + RespondActivityTaskCanceledRequest request = new RespondActivityTaskCanceledRequest(); + request.setDetails(details); + request.setTaskToken(taskToken); + service.respondActivityTaskCanceled(request); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/ScheduleActivityTaskFailedException.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ScheduleActivityTaskFailedException.java new file mode 100644 index 000000000000..723ed988a73b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/ScheduleActivityTaskFailedException.java @@ -0,0 +1,52 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.model.ActivityType; +import com.amazonaws.services.simpleworkflow.model.ScheduleActivityTaskFailedCause; + +/** + * Exception used to communicate that activity wasn't scheduled due to some + * cause + */ +@SuppressWarnings("serial") +public class ScheduleActivityTaskFailedException extends ActivityTaskException { + + private ScheduleActivityTaskFailedCause failureCause; + + public ScheduleActivityTaskFailedException(String message) { + super(message); + } + + public ScheduleActivityTaskFailedException(String message, Throwable cause) { + super(message, cause); + } + + public ScheduleActivityTaskFailedException(long eventId, ActivityType activityType, String activityId, String cause) { + super(cause, eventId, activityType, activityId); + failureCause = ScheduleActivityTaskFailedCause.fromValue(cause); + } + + /** + * @return enumeration that contains the cause of the failure + */ + public ScheduleActivityTaskFailedCause getFailureCause() { + return failureCause; + } + + public void setFailureCause(ScheduleActivityTaskFailedCause failureCause) { + this.failureCause = failureCause; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/SignalExternalWorkflowException.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/SignalExternalWorkflowException.java new file mode 100644 index 000000000000..08a82c77e304 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/SignalExternalWorkflowException.java @@ -0,0 +1,59 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.model.SignalExternalWorkflowExecutionFailedCause; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +/** + * Exception used to communicate failure of a signal. + */ +@SuppressWarnings("serial") +public class SignalExternalWorkflowException extends DecisionException { + + private SignalExternalWorkflowExecutionFailedCause failureCause; + + private WorkflowExecution signaledExecution; + + public SignalExternalWorkflowException(String message) { + super(message); + } + + public SignalExternalWorkflowException(String message, Throwable cause) { + super(message, cause); + } + + public SignalExternalWorkflowException(long eventId, WorkflowExecution signaledExecution, String cause) { + super(cause + " for signaledExecution=\"" + signaledExecution, eventId); + this.signaledExecution = signaledExecution; + this.failureCause = SignalExternalWorkflowExecutionFailedCause.valueOf(cause); + } + + public WorkflowExecution getSignaledExecution() { + return signaledExecution; + } + + public void setFailureCause(SignalExternalWorkflowExecutionFailedCause failureCause) { + this.failureCause = failureCause; + } + + public SignalExternalWorkflowExecutionFailedCause getFailureCause() { + return failureCause; + } + + public void setSignaledExecution(WorkflowExecution signaledExecution) { + this.signaledExecution = signaledExecution; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/StartChildWorkflowFailedException.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/StartChildWorkflowFailedException.java new file mode 100644 index 000000000000..6a2765e6888f --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/StartChildWorkflowFailedException.java @@ -0,0 +1,51 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.model.StartChildWorkflowExecutionFailedCause; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +@SuppressWarnings("serial") +public class StartChildWorkflowFailedException extends ChildWorkflowException { + + private StartChildWorkflowExecutionFailedCause failureCause; + + public StartChildWorkflowFailedException(String message) { + super(message); + } + + public StartChildWorkflowFailedException(String message, Throwable cause) { + super(message, cause); + } + + public StartChildWorkflowFailedException(long eventId, WorkflowExecution workflowExecution, WorkflowType workflowType, + String cause) { + super(cause, eventId, workflowExecution, workflowType); + this.failureCause = StartChildWorkflowExecutionFailedCause.fromValue(cause); + } + + /** + * @return enumeration that contains the cause of the failure + */ + public StartChildWorkflowExecutionFailedCause getFailureCause() { + return failureCause; + } + + public void setFailureCause(StartChildWorkflowExecutionFailedCause failureCause) { + this.failureCause = failureCause; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/StartTimerFailedException.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/StartTimerFailedException.java new file mode 100644 index 000000000000..c51964903594 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/StartTimerFailedException.java @@ -0,0 +1,51 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.model.StartTimerFailedCause; + +/** + * Exception used to communicate that timer wasn't scheduled due to some cause + */ +@SuppressWarnings("serial") +public class StartTimerFailedException extends TimerException { + + private StartTimerFailedCause failureCause; + + public StartTimerFailedException(String message) { + super(message); + } + + public StartTimerFailedException(String message, Throwable cause) { + super(message, cause); + } + + public StartTimerFailedException(long eventId, String timerId, Object createTimerUserContext, String cause) { + super(cause + " for timerId=\"" + timerId, eventId, timerId, createTimerUserContext); + failureCause = StartTimerFailedCause.fromValue(cause); + } + + /** + * @return enumeration that contains the cause of the failure + */ + public StartTimerFailedCause getFailureCause() { + return failureCause; + } + + public void setFailureCause(StartTimerFailedCause failureCause) { + this.failureCause = failureCause; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/StartWorkflowOptions.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/StartWorkflowOptions.java new file mode 100644 index 000000000000..851a173cec1a --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/StartWorkflowOptions.java @@ -0,0 +1,76 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import java.util.List; + +public class StartWorkflowOptions { + Long executionStartToCloseTimeoutSeconds; + Long taskStartToCloseTimeoutSeconds; + private List tagList; + String taskList; + + public Long getExecutionStartToCloseTimeoutSeconds() { + return executionStartToCloseTimeoutSeconds; + } + + public void setExecutionStartToCloseTimeoutSeconds(Long executionStartToCloseTimeoutSeconds) { + this.executionStartToCloseTimeoutSeconds = executionStartToCloseTimeoutSeconds; + } + + public StartWorkflowOptions withExecutionStartToCloseTimeoutSeconds(Long executionStartToCloseTimeoutSeconds) { + this.executionStartToCloseTimeoutSeconds = executionStartToCloseTimeoutSeconds; + return this; + } + + public Long getTaskStartToCloseTimeoutSeconds() { + return taskStartToCloseTimeoutSeconds; + } + + public void setTaskStartToCloseTimeoutSeconds(Long taskStartToCloseTimeoutSeconds) { + this.taskStartToCloseTimeoutSeconds = taskStartToCloseTimeoutSeconds; + } + + public StartWorkflowOptions withTaskStartToCloseTimeoutSeconds(Long taskStartToCloseTimeoutSeconds) { + this.taskStartToCloseTimeoutSeconds = taskStartToCloseTimeoutSeconds; + return this; + } + + public List getTagList() { + return tagList; + } + + public void setTagList(List tagList) { + this.tagList = tagList; + } + + public StartWorkflowOptions withTagList(List tagList) { + this.tagList = tagList; + return this; + } + + public String getTaskList() { + return taskList; + } + + public void setTaskList(String taskList) { + this.taskList = taskList; + } + + public StartWorkflowOptions withTaskList(String taskList) { + this.taskList = taskList; + return this; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/Suspendable.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/Suspendable.java new file mode 100644 index 000000000000..4f2b7e1840b9 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/Suspendable.java @@ -0,0 +1,23 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +public interface Suspendable { + + void suspendPolling(); + + void resumePolling(); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/SuspendableWorker.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/SuspendableWorker.java new file mode 100644 index 000000000000..dd2ebb7709ed --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/SuspendableWorker.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + + +public interface SuspendableWorker extends Suspendable, WorkerLifecycle { + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/SynchronousActivityWorker.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/SynchronousActivityWorker.java new file mode 100644 index 000000000000..220e97a02d13 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/SynchronousActivityWorker.java @@ -0,0 +1,143 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import java.util.List; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.generic.ActivityImplementation; +import com.amazonaws.services.simpleworkflow.flow.pojo.POJOActivityImplementationFactory; +import com.amazonaws.services.simpleworkflow.flow.worker.ExponentialRetryParameters; +import com.amazonaws.services.simpleworkflow.flow.worker.GenericActivityWorker; +import com.amazonaws.services.simpleworkflow.flow.worker.SynchronousActivityTaskPoller; +import com.amazonaws.services.simpleworkflow.model.ActivityType; + +public class SynchronousActivityWorker { + + private final SynchronousActivityTaskPoller poller; + + private final POJOActivityImplementationFactory factory = new POJOActivityImplementationFactory(); + + public SynchronousActivityWorker() { + poller = new SynchronousActivityTaskPoller(); + poller.setActivityImplementationFactory(factory); + } + + public SynchronousActivityWorker(AmazonSimpleWorkflow service, String domain, String taskListToPoll) { + poller = new SynchronousActivityTaskPoller(service, domain, taskListToPoll, factory); + } + + public boolean pollAndProcessSingleActivityTask() throws Throwable { + return poller.pollAndProcessSingleTask(); + } + + public void setActivitiesImplementations(Iterable activitiesImplementations) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + factory.setActivitiesImplementations(activitiesImplementations); + } + + public Iterable getActivitiesImplementations() { + return factory.getActivitiesImplementations(); + } + + public List addActivitiesImplementations(Iterable activitiesImplementations) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + return factory.addActivitiesImplementations(activitiesImplementations); + } + + public List addActivitiesImplementations(Iterable activitiesImplementations, DataConverter dataConverter) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + return factory.addActivitiesImplementations(activitiesImplementations, dataConverter); + } + + public List addActivitiesImplementation(Object activitiesImplementation) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + return factory.addActivitiesImplementation(activitiesImplementation); + } + + public List addActivitiesImplementation(Object activitiesImplementation, DataConverter converter) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + return factory.addActivitiesImplementation(activitiesImplementation, converter); + } + + public Iterable getActivityTypesToRegister() { + return factory.getActivityTypesToRegister(); + } + + public ActivityImplementation getActivityImplementation(ActivityType activityType) { + return factory.getActivityImplementation(activityType); + } + + public AmazonSimpleWorkflow getService() { + return poller.getService(); + } + + public void setService(AmazonSimpleWorkflow service) { + poller.setService(service); + } + + public String getDomain() { + return poller.getDomain(); + } + + public void setDomain(String domain) { + poller.setDomain(domain); + } + + public String getPollTaskList() { + return poller.getPollTaskList(); + } + + public void setTaskListToPoll(String taskList) { + poller.setTaskListToPoll(taskList); + } + + public String getIdentity() { + return poller.getIdentity(); + } + + public void setIdentity(String identity) { + poller.setIdentity(identity); + } + + public ExponentialRetryParameters getReportCompletionRetryParameters() { + return poller.getReportCompletionRetryParameters(); + } + + public void setReportCompletionRetryParameters(ExponentialRetryParameters reportCompletionRetryParameters) { + poller.setReportCompletionRetryParameters(reportCompletionRetryParameters); + } + + public ExponentialRetryParameters getReportFailureRetryParameters() { + return poller.getReportFailureRetryParameters(); + } + + public void setReportFailureRetryParameters(ExponentialRetryParameters reportFailureRetryParameters) { + poller.setReportFailureRetryParameters(reportFailureRetryParameters); + } + + public String getTaskListToPoll() { + return poller.getTaskListToPoll(); + } + + @Override + public String toString() { + return this.getClass().getSimpleName() + "[poller=" + poller + ", factory=" + factory + "]"; + } + + public void registerTypesToPoll() throws Exception { + GenericActivityWorker.registerActivityTypes(getService(), getDomain(), getTaskListToPoll(), factory); + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/SynchronousWorkflowWorker.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/SynchronousWorkflowWorker.java new file mode 100644 index 000000000000..4427799b2e69 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/SynchronousWorkflowWorker.java @@ -0,0 +1,109 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import java.util.Collection; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.pojo.POJOWorkflowDefinitionFactoryFactory; +import com.amazonaws.services.simpleworkflow.flow.worker.AsyncDecisionTaskHandler; +import com.amazonaws.services.simpleworkflow.flow.worker.DecisionTaskPoller; +import com.amazonaws.services.simpleworkflow.flow.worker.GenericWorkflowWorker; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + + +public class SynchronousWorkflowWorker { + + private final DecisionTaskPoller poller; + + private final POJOWorkflowDefinitionFactoryFactory factoryFactory = new POJOWorkflowDefinitionFactoryFactory(); + + public SynchronousWorkflowWorker() { + poller = new DecisionTaskPoller(); + poller.setDecisionTaskHandler(new AsyncDecisionTaskHandler(factoryFactory)); + } + + public SynchronousWorkflowWorker(AmazonSimpleWorkflow service, String domain, String taskListToPoll) { + poller = new DecisionTaskPoller(service, domain, taskListToPoll, new AsyncDecisionTaskHandler(factoryFactory)); + } + + public String getIdentity() { + return poller.getIdentity(); + } + + public void setIdentity(String identity) { + poller.setIdentity(identity); + } + + public AmazonSimpleWorkflow getService() { + return poller.getService(); + } + + public String getDomain() { + return poller.getDomain(); + } + + public void setService(AmazonSimpleWorkflow service) { + poller.setService(service); + } + + public void setDomain(String domain) { + poller.setDomain(domain); + } + + public String getTaskListToPoll() { + return poller.getTaskListToPoll(); + } + + public void setTaskListToPoll(String pollTaskList) { + poller.setTaskListToPoll(pollTaskList); + } + + public boolean pollAndProcessSingleDecisionTask() throws Exception { + return poller.pollAndProcessSingleTask(); + } + + public void setConverter(DataConverter converter) { + factoryFactory.setDataConverter(converter); + } + + public Iterable getWorkflowTypesToRegister() { + return factoryFactory.getWorkflowTypesToRegister(); + } + + public void addWorkflowImplementationType(Class workflowImplementationType) + throws InstantiationException, IllegalAccessException { + factoryFactory.addWorkflowImplementationType(workflowImplementationType); + } + + public void addWorkflowImplementationType(Class workflowImplementationType, DataConverter converterOverride) + throws InstantiationException, IllegalAccessException { + factoryFactory.addWorkflowImplementationType(workflowImplementationType, converterOverride); + } + + public void setWorkflowImplementationTypes(Collection> workflowImplementationTypes) + throws InstantiationException, IllegalAccessException { + factoryFactory.setWorkflowImplementationTypes(workflowImplementationTypes); + } + + public Collection> getWorkflowImplementationTypes() { + return factoryFactory.getWorkflowImplementationTypes(); + } + + public void registerTypesToPoll() throws Exception { + GenericWorkflowWorker.registerWorkflowTypes(getService(), getDomain(), getTaskListToPoll(), factoryFactory); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/TimerException.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/TimerException.java new file mode 100644 index 000000000000..10b9f76617d9 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/TimerException.java @@ -0,0 +1,57 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +/** + * Exception used to communicate failure of a timer. + */ +@SuppressWarnings("serial") +public abstract class TimerException extends DecisionException { + + private String timerId; + + private Object createTimerUserContext; + + public TimerException(String message) { + super(message); + } + + public TimerException(String message, Throwable cause) { + super(message, cause); + } + + public TimerException(String message, long eventId, String timerId, Object createTimerUserContext) { + super(message, eventId); + this.timerId = timerId; + this.createTimerUserContext = createTimerUserContext; + } + + public String getTimerId() { + return timerId; + } + + public void setTimerId(String timerId) { + this.timerId = timerId; + } + + public Object getCreateTimerUserContext() { + return createTimerUserContext; + } + + public void setCreateTimerUserContext(Object createTimerUserContext) { + this.createTimerUserContext = createTimerUserContext; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkerBase.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkerBase.java new file mode 100644 index 000000000000..f4f6dbc18b68 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkerBase.java @@ -0,0 +1,77 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import java.lang.Thread.UncaughtExceptionHandler; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; + +public interface WorkerBase extends SuspendableWorker { + + AmazonSimpleWorkflow getService(); + + String getDomain(); + + boolean isRegisterDomain(); + + void setRegisterDomain(boolean registerDomain); + + long getDomainRetentionPeriodInDays(); + + void setDomainRetentionPeriodInDays(long domainRetentionPeriodInDays); + + String getTaskListToPoll(); + + double getMaximumPollRatePerSecond(); + + void setMaximumPollRatePerSecond(double maximumPollRatePerSecond); + + int getMaximumPollRateIntervalMilliseconds(); + + void setMaximumPollRateIntervalMilliseconds(int maximumPollRateIntervalMilliseconds); + + UncaughtExceptionHandler getUncaughtExceptionHandler(); + + void setUncaughtExceptionHandler(UncaughtExceptionHandler uncaughtExceptionHandler); + + String getIdentity(); + + void setIdentity(String identity); + + long getPollBackoffInitialInterval(); + + void setPollBackoffInitialInterval(long backoffInitialInterval); + + long getPollBackoffMaximumInterval(); + + void setPollBackoffMaximumInterval(long backoffMaximumInterval); + + boolean isDisableServiceShutdownOnStop(); + + void setDisableServiceShutdownOnStop(boolean disableServiceShutdownOnStop); + + double getPollBackoffCoefficient(); + + void setPollBackoffCoefficient(double backoffCoefficient); + + int getPollThreadCount(); + + void setPollThreadCount(int threadCount); + + void registerTypesToPoll(); + + boolean isRunning(); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkerLifecycle.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkerLifecycle.java new file mode 100644 index 000000000000..05147802da78 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkerLifecycle.java @@ -0,0 +1,31 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import java.util.concurrent.TimeUnit; + +public interface WorkerLifecycle { + + public abstract void start(); + + public abstract void shutdown(); + + public abstract void shutdownNow(); + + public abstract boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException; + + public abstract boolean shutdownAndAwaitTermination(long timeout, TimeUnit unit) throws InterruptedException; + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClient.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClient.java new file mode 100644 index 000000000000..243c221e2835 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClient.java @@ -0,0 +1,38 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClient; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +public interface WorkflowClient { + + WorkflowExecution getWorkflowExecution(); + + Promise getRunId(); + + GenericWorkflowClient getGenericClient(); + + StartWorkflowOptions getSchedulingOptions(); + + DataConverter getDataConverter(); + + void requestCancelWorkflowExecution(Promise... waitFor); + + WorkflowType getWorkflowType(); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientBase.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientBase.java new file mode 100644 index 000000000000..97c1590f798b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientBase.java @@ -0,0 +1,79 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClient; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +public abstract class WorkflowClientBase implements WorkflowClient { + + protected final DynamicWorkflowClientImpl dynamicWorkflowClient; + + protected WorkflowClientBase(WorkflowExecution workflowExecution, WorkflowType workflowType, StartWorkflowOptions options, + DataConverter dataConverter, GenericWorkflowClient genericClient) { + dynamicWorkflowClient = new DynamicWorkflowClientImpl(workflowExecution, workflowType, options, dataConverter, + genericClient); + } + + @Override + public DataConverter getDataConverter() { + return dynamicWorkflowClient.getDataConverter(); + } + + @Override + public StartWorkflowOptions getSchedulingOptions() { + return dynamicWorkflowClient.getSchedulingOptions(); + } + + @Override + public GenericWorkflowClient getGenericClient() { + return dynamicWorkflowClient.getGenericClient(); + } + + @Override + public Promise getRunId() { + return dynamicWorkflowClient.getRunId(); + } + + public WorkflowExecution getWorkflowExecution() { + return dynamicWorkflowClient.getWorkflowExecution(); + } + + @Override + public WorkflowType getWorkflowType() { + return dynamicWorkflowClient.getWorkflowType(); + } + + public void requestCancelWorkflowExecution(Promise... waitFor) { + dynamicWorkflowClient.requestCancelWorkflowExecution(waitFor); + } + + protected Promise startWorkflowExecution(Promise[] arguments, StartWorkflowOptions startOptionsOverride, + Class returnType, Promise... waitFor) { + return dynamicWorkflowClient.startWorkflowExecution(arguments, startOptionsOverride, returnType, waitFor); + } + + protected Promise startWorkflowExecution(Object[] arguments, StartWorkflowOptions startOptionsOverride, + Class returnType, Promise... waitFor) { + return dynamicWorkflowClient.startWorkflowExecution(arguments, startOptionsOverride, returnType, waitFor); + } + + protected void signalWorkflowExecution(String signalName, Object[] arguments, Promise... waitFor) { + dynamicWorkflowClient.signalWorkflowExecution(signalName, arguments, waitFor); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientExternal.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientExternal.java new file mode 100644 index 000000000000..7fb8d6f79d16 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientExternal.java @@ -0,0 +1,35 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClientExternal; +import com.amazonaws.services.simpleworkflow.model.ChildPolicy; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +public interface WorkflowClientExternal { + + public void requestCancelWorkflowExecution(); + + public void terminateWorkflowExecution(String reason, String details, ChildPolicy childPolicy); + + public DataConverter getDataConverter(); + + public StartWorkflowOptions getSchedulingOptions(); + + public GenericWorkflowClientExternal getGenericClient(); + + public WorkflowExecution getWorkflowExecution(); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientExternalBase.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientExternalBase.java new file mode 100644 index 000000000000..9fa6a99f7e1f --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientExternalBase.java @@ -0,0 +1,115 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClientExternal; +import com.amazonaws.services.simpleworkflow.model.ChildPolicy; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +public abstract class WorkflowClientExternalBase implements WorkflowClientExternal { + + private static boolean BOOLEAN_DEFAULT = false; + + private static byte BYTE_DEFAULT = 0; + + private static char CHARACTER_DEFAULT = '\u0000'; + + private static short SHORT_DEFAULT = 0; + + private static int INTEGER_DEFAULT = 0; + + private static long LONG_DEFAULT = 0L; + + private static float FLOAT_DEFAULT = 0.0f; + + private static double DOUBLE_DEFAULT = 0.0d; + + protected final DynamicWorkflowClientExternal dynamicWorkflowClient; + + public WorkflowClientExternalBase(WorkflowExecution workflowExecution, WorkflowType workflowType, + StartWorkflowOptions options, DataConverter dataConverter, GenericWorkflowClientExternal genericClient) { + this.dynamicWorkflowClient = new DynamicWorkflowClientExternalImpl(workflowExecution, workflowType, options, + dataConverter, genericClient); + } + + @Override + public void requestCancelWorkflowExecution() { + dynamicWorkflowClient.requestCancelWorkflowExecution(); + } + + @Override + public void terminateWorkflowExecution(String reason, String details, ChildPolicy childPolicy) { + dynamicWorkflowClient.terminateWorkflowExecution(reason, details, childPolicy); + } + + @Override + public DataConverter getDataConverter() { + return dynamicWorkflowClient.getDataConverter(); + } + + @Override + public StartWorkflowOptions getSchedulingOptions() { + return dynamicWorkflowClient.getSchedulingOptions(); + } + + @Override + public GenericWorkflowClientExternal getGenericClient() { + return dynamicWorkflowClient.getGenericClient(); + } + + @Override + public WorkflowExecution getWorkflowExecution() { + return dynamicWorkflowClient.getWorkflowExecution(); + } + + protected void startWorkflowExecution(Object[] arguments, StartWorkflowOptions startOptionsOverride) { + dynamicWorkflowClient.startWorkflowExecution(arguments, startOptionsOverride); + } + + protected void startWorkflowExecution(Object[] arguments) { + dynamicWorkflowClient.startWorkflowExecution(arguments); + } + + protected void signalWorkflowExecution(String signalName, Object[] arguments) { + dynamicWorkflowClient.signalWorkflowExecution(signalName, arguments); + } + + @SuppressWarnings({ "unchecked" }) + protected T defaultPrimitiveValue(Class clazz) { + Object returnValue = null; + if (clazz.equals(Boolean.TYPE)) { + returnValue = BOOLEAN_DEFAULT; + } else if (clazz.equals(Byte.TYPE)) { + returnValue = BYTE_DEFAULT; + } else if (clazz.equals(Character.TYPE)) { + returnValue = CHARACTER_DEFAULT; + } else if (clazz.equals(Short.TYPE)) { + returnValue = SHORT_DEFAULT; + } else if (clazz.equals(Integer.TYPE)) { + returnValue = INTEGER_DEFAULT; + } else if (clazz.equals(Long.TYPE)) { + returnValue = LONG_DEFAULT; + } else if (clazz.equals(Float.TYPE)) { + returnValue = FLOAT_DEFAULT; + } else if (clazz.equals(Double.TYPE)) { + returnValue = DOUBLE_DEFAULT; + } else { + throw new IllegalArgumentException("Type not supported: " + clazz); + } + + return (T)returnValue; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientFactory.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientFactory.java new file mode 100644 index 000000000000..46bae2eebea4 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientFactory.java @@ -0,0 +1,44 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClient; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +public interface WorkflowClientFactory { + + GenericWorkflowClient getGenericClient(); + + void setGenericClient(GenericWorkflowClient genericClient); + + DataConverter getDataConverter(); + + void setDataConverter(DataConverter dataConverter); + + StartWorkflowOptions getStartWorkflowOptions(); + + void setStartWorkflowOptions(StartWorkflowOptions startWorkflowOptions); + + T getClient(); + + T getClient(String workflowId); + + T getClient(WorkflowExecution execution); + + T getClient(WorkflowExecution execution, StartWorkflowOptions options); + + T getClient(WorkflowExecution execution, StartWorkflowOptions options, DataConverter dataConverter); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientFactoryBase.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientFactoryBase.java new file mode 100644 index 000000000000..989d34c56dbc --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientFactoryBase.java @@ -0,0 +1,124 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClient; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +public abstract class WorkflowClientFactoryBase implements WorkflowClientFactory { + + private GenericWorkflowClient genericClient; + + private DataConverter dataConverter; + + private StartWorkflowOptions startWorkflowOptions = new StartWorkflowOptions(); + + private final DecisionContextProvider decisionContextProvider = new DecisionContextProviderImpl(); + + public WorkflowClientFactoryBase() { + this(null, null, null); + } + + public WorkflowClientFactoryBase(StartWorkflowOptions startWorkflowOptions) { + this(startWorkflowOptions, null, null); + } + + public WorkflowClientFactoryBase(StartWorkflowOptions startWorkflowOptions, DataConverter dataConverter) { + this(startWorkflowOptions, dataConverter, null); + } + + public WorkflowClientFactoryBase(StartWorkflowOptions startWorkflowOptions, DataConverter dataConverter, + GenericWorkflowClient genericClient) { + this.startWorkflowOptions = startWorkflowOptions; + if (dataConverter == null) { + this.dataConverter = new JsonDataConverter(); + } + else { + this.dataConverter = dataConverter; + } + this.genericClient = genericClient; + } + + @Override + public GenericWorkflowClient getGenericClient() { + return genericClient; + } + + @Override + public void setGenericClient(GenericWorkflowClient genericClient) { + this.genericClient = genericClient; + } + + @Override + public DataConverter getDataConverter() { + return dataConverter; + } + + @Override + public void setDataConverter(DataConverter dataConverter) { + this.dataConverter = dataConverter; + } + + @Override + public StartWorkflowOptions getStartWorkflowOptions() { + return startWorkflowOptions; + } + + @Override + public void setStartWorkflowOptions(StartWorkflowOptions startWorkflowOptions) { + this.startWorkflowOptions = startWorkflowOptions; + } + + @Override + public T getClient() { + if (genericClient == null) { + genericClient = decisionContextProvider.getDecisionContext().getWorkflowClient(); + } + String workflowId = genericClient.generateUniqueId(); + WorkflowExecution execution = new WorkflowExecution().withWorkflowId(workflowId); + return getClient(execution, startWorkflowOptions, dataConverter); + } + + @Override + public T getClient(String workflowId) { + if (workflowId == null || workflowId.isEmpty()) { + throw new IllegalArgumentException("workflowId"); + } + WorkflowExecution execution = new WorkflowExecution().withWorkflowId(workflowId); + return getClient(execution, startWorkflowOptions, dataConverter); + } + + @Override + public T getClient(WorkflowExecution execution) { + return getClient(execution, startWorkflowOptions, dataConverter); + } + + @Override + public T getClient(WorkflowExecution execution, StartWorkflowOptions options) { + return getClient(execution, options, dataConverter); + } + + @Override + public T getClient(WorkflowExecution execution, StartWorkflowOptions options, DataConverter dataConverter) { + if (genericClient == null) { + genericClient = decisionContextProvider.getDecisionContext().getWorkflowClient(); + } + return createClientInstance(execution, options, dataConverter, genericClient); + } + + protected abstract T createClientInstance(WorkflowExecution execution, StartWorkflowOptions options, + DataConverter dataConverter, GenericWorkflowClient genericClient); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientFactoryExternal.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientFactoryExternal.java new file mode 100644 index 000000000000..73658c989d49 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientFactoryExternal.java @@ -0,0 +1,41 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClientExternal; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +public interface WorkflowClientFactoryExternal { + + GenericWorkflowClientExternal getGenericClient(); + + DataConverter getDataConverter(); + + StartWorkflowOptions getStartWorkflowOptions(); + + T getClient(); + + T getClient(String workflowId); + + T getClient(WorkflowExecution workflowExecution); + + T getClient(WorkflowExecution workflowExecution, StartWorkflowOptions options); + + T getClient(WorkflowExecution workflowExecution, StartWorkflowOptions options, DataConverter dataConverter); + + T getClient(WorkflowExecution workflowExecution, StartWorkflowOptions options, DataConverter dataConverter, + GenericWorkflowClientExternal genericClient); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientFactoryExternalBase.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientFactoryExternalBase.java new file mode 100644 index 000000000000..a3bff865c535 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClientFactoryExternalBase.java @@ -0,0 +1,112 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClientExternal; +import com.amazonaws.services.simpleworkflow.flow.worker.GenericWorkflowClientExternalImpl; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +public abstract class WorkflowClientFactoryExternalBase implements WorkflowClientFactoryExternal { + + private GenericWorkflowClientExternal genericClient; + + private DataConverter dataConverter = new com.amazonaws.services.simpleworkflow.flow.JsonDataConverter(); + + private StartWorkflowOptions startWorkflowOptions = new StartWorkflowOptions(); + + public WorkflowClientFactoryExternalBase(AmazonSimpleWorkflow service, String domain) { + this(new GenericWorkflowClientExternalImpl(service, domain)); + } + + public WorkflowClientFactoryExternalBase() { + this(null); + } + + public WorkflowClientFactoryExternalBase(GenericWorkflowClientExternal genericClient) { + this.genericClient = genericClient; + } + + @Override + public GenericWorkflowClientExternal getGenericClient() { + return genericClient; + } + + public void setGenericClient(GenericWorkflowClientExternal genericClient) { + this.genericClient = genericClient; + } + + @Override + public DataConverter getDataConverter() { + return dataConverter; + } + + public void setDataConverter(DataConverter dataConverter) { + this.dataConverter = dataConverter; + } + + @Override + public StartWorkflowOptions getStartWorkflowOptions() { + return startWorkflowOptions; + } + + public void setStartWorkflowOptions(StartWorkflowOptions startWorkflowOptions) { + this.startWorkflowOptions = startWorkflowOptions; + } + + @Override + public T getClient() { + String workflowId = genericClient.generateUniqueId(); + WorkflowExecution workflowExecution = new WorkflowExecution().withWorkflowId(workflowId); + return getClient(workflowExecution, startWorkflowOptions, dataConverter, genericClient); + } + + @Override + public T getClient(String workflowId) { + if (workflowId == null || workflowId.isEmpty()) { + throw new IllegalArgumentException("workflowId"); + } + WorkflowExecution workflowExecution = new WorkflowExecution().withWorkflowId(workflowId); + return getClient(workflowExecution, startWorkflowOptions, dataConverter, genericClient); + } + + @Override + public T getClient(WorkflowExecution workflowExecution) { + return getClient(workflowExecution, startWorkflowOptions, dataConverter, genericClient); + } + + @Override + public T getClient(WorkflowExecution workflowExecution, StartWorkflowOptions options) { + return getClient(workflowExecution, options, dataConverter, genericClient); + } + + @Override + public T getClient(WorkflowExecution workflowExecution, StartWorkflowOptions options, DataConverter dataConverter) { + return getClient(workflowExecution, options, dataConverter, genericClient); + } + + @Override + public T getClient(WorkflowExecution workflowExecution, StartWorkflowOptions options, DataConverter dataConverter, + GenericWorkflowClientExternal genericClient) { + if (genericClient == null) { + throw new IllegalStateException("required property genericClient is null"); + } + return createClientInstance(workflowExecution, options, dataConverter, genericClient); + } + + protected abstract T createClientInstance(WorkflowExecution workflowExecution, StartWorkflowOptions options, + DataConverter dataConverter, GenericWorkflowClientExternal genericClient); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClock.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClock.java new file mode 100644 index 000000000000..265d75924fa5 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowClock.java @@ -0,0 +1,60 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.model.DecisionTask; + +/** + * Clock that must be used inside workflow definition code to ensure replay + * determinism. + */ +public interface WorkflowClock { + + /** + * @return time of the {@link DecisionTask} start event of the decision + * being processed or replayed. + */ + public long currentTimeMillis(); + + /** + * true indicates if workflow is replaying already processed + * events to reconstruct it state. false indicates that code is + * making forward process for the first time. For example can be used to + * avoid duplicating log records due to replay. + */ + public boolean isReplaying(); + + /** + * Create a Value that becomes ready after the specified delay. + * + * @param delay + * time-interval after which the Value becomes ready in seconds. + * @return Promise that becomes ready after the specified delay. + */ + public abstract Promise createTimer(long delaySeconds); + + /** + * Create a Value that becomes ready after the specified delay. + * + * @param context + * context object that is returned inside the value when it + * becomes ready. + * @return Promise that becomes ready after the specified delay. When ready + * it contains value passed as context parameter. + */ + public abstract Promise createTimer(long delaySeconds, final T context); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowContext.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowContext.java new file mode 100644 index 000000000000..2d289c2cc9e0 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowContext.java @@ -0,0 +1,34 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.generic.ContinueAsNewWorkflowExecutionParameters; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + + +public interface WorkflowContext { + + public WorkflowExecution getWorkflowExecution(); + + public WorkflowType getWorkflowType(); + + public boolean isCancelRequested(); + + public ContinueAsNewWorkflowExecutionParameters getContinueAsNewOnCompletion(); + + public void setContinueAsNewOnCompletion(ContinueAsNewWorkflowExecutionParameters continueParameters); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowException.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowException.java new file mode 100644 index 000000000000..5359d42611d3 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowException.java @@ -0,0 +1,39 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +/** + * Exception that is thrown from generic workflow implementation to indicate + * that workflow execution should be failed with the given reason and details. + */ +@SuppressWarnings("serial") +public class WorkflowException extends Exception { + + private final String details; + + public WorkflowException(String reason, String details) { + super(reason); + this.details = details; + } + + public String getReason() { + return getMessage(); + } + + public String getDetails() { + return details; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowExecutionLocal.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowExecutionLocal.java new file mode 100644 index 000000000000..94b2432ff002 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowExecutionLocal.java @@ -0,0 +1,121 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import java.util.ArrayList; +import java.util.List; + +/** + * Contains value that is bound to a currently executing workflow. Has the same + * purpose as {@link ThreadLocal} which bounds value to a particular thread. It + * is subject to the same replay rules as the rest of the workflow definition. + */ +public class WorkflowExecutionLocal { + + private static class Wrapper { + + public T wrapped; + } + + /** + * It is not good idea to rely on the fact that implementation relies on + * ThreadLocal as it is subject to change. + */ + private final ThreadLocal> value = new ThreadLocal>(); + + private final static List> locals = new ArrayList>(); + + /** + * Must be called before each decision. It is not a good idea to call this + * method from non framework code for non testing scenarios. + */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + public static void before() { + List> currentLocals; + synchronized (locals) { + currentLocals = new ArrayList>(locals); + } + for (WorkflowExecutionLocal local : currentLocals) { + Wrapper w = new Wrapper(); + w.wrapped = local.initialValue(); + local.set(w); + } + } + + /** + * Must be called at the end of each decision. It is not a good idea to call + * this method from non framework code for non testing scenarios. + */ + public static void after() { + List> currentLocals; + synchronized (locals) { + currentLocals = new ArrayList>(locals); + } + for (WorkflowExecutionLocal local : currentLocals) { + local.removeAfter(); + } + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public WorkflowExecutionLocal() { + Wrapper w = new Wrapper(); + w.wrapped = initialValue(); + set(w); + synchronized (locals) { + locals.add(this); + } + } + + public T get() { + Wrapper w = getWrapped(); + return w.wrapped; + } + + private Wrapper getWrapped() { + Wrapper w = value.get(); + if (w == null) { + throw new IllegalStateException("Called outside of the workflow definition code."); + } + return w; + } + + public int hashCode() { + Wrapper w = getWrapped(); + return w.wrapped.hashCode(); + } + + public void remove() { + Wrapper w = getWrapped(); + w.wrapped = null; + } + + public void set(T v) { + Wrapper w = getWrapped(); + w.wrapped = v; + } + + private void set(Wrapper w) { + value.set(w); + } + + private void removeAfter() { + value.remove(); + } + + protected T initialValue() { + return null; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowReplayer.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowReplayer.java new file mode 100644 index 000000000000..db8f5d157d0b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowReplayer.java @@ -0,0 +1,333 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.common.WorkflowExecutionUtils; +import com.amazonaws.services.simpleworkflow.flow.core.AsyncTaskInfo; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinition; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinitionFactoryFactory; +import com.amazonaws.services.simpleworkflow.flow.pojo.POJOWorkflowDefinition; +import com.amazonaws.services.simpleworkflow.flow.pojo.POJOWorkflowDefinitionFactoryFactory; +import com.amazonaws.services.simpleworkflow.flow.pojo.POJOWorkflowImplementationFactory; +import com.amazonaws.services.simpleworkflow.flow.worker.AsyncDecisionTaskHandler; +import com.amazonaws.services.simpleworkflow.model.DecisionTask; +import com.amazonaws.services.simpleworkflow.model.EventType; +import com.amazonaws.services.simpleworkflow.model.History; +import com.amazonaws.services.simpleworkflow.model.HistoryEvent; +import com.amazonaws.services.simpleworkflow.model.RespondDecisionTaskCompletedRequest; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecutionInfo; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecutionStartedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +public class WorkflowReplayer { + + private final class WorkflowReplayerPOJOFactoryFactory extends POJOWorkflowDefinitionFactoryFactory { + + private final T workflowImplementation; + + private WorkflowReplayerPOJOFactoryFactory(T workflowImplementation) throws InstantiationException, IllegalAccessException { + this.workflowImplementation = workflowImplementation; + super.addWorkflowImplementationType(workflowImplementation.getClass()); + } + + @Override + protected POJOWorkflowImplementationFactory getImplementationFactory(Class workflowImplementationType, + Class workflowInteface, WorkflowType workflowType) { + return new POJOWorkflowImplementationFactory() { + + @Override + public Object newInstance(DecisionContext decisionContext) throws Exception { + return workflowImplementation; + } + + @Override + public void deleteInstance(Object instance) { + } + }; + } + } + + private abstract class DecisionTaskIterator implements Iterator { + + private DecisionTask next; + + protected void initNext() { + next = getNextHistoryTask(null); + } + + @Override + public boolean hasNext() { + if (next == null) { + return false; + } + List events = next.getEvents(); + if (events.size() == 0) { + return false; + } + if (replayUpToEventId == 0) { + return true; + } + HistoryEvent firstEvent = next.getEvents().get(0); + return firstEvent.getEventId() <= replayUpToEventId; + } + + @Override + public DecisionTask next() { + if (!hasNext()) { + throw new IllegalStateException("hasNext() == false"); + } + DecisionTask result = next; + if (next.getNextPageToken() == null) { + next = null; + } + else { + next = getNextHistoryTask(next.getNextPageToken()); + } + return result; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + protected List truncateHistory(List events) { + if (events.size() == 0) { + return null; + } + if (replayUpToEventId == 0) { + return events; + } + HistoryEvent lastEvent = events.get(events.size() - 1); + if (lastEvent.getEventId() <= replayUpToEventId) { + return events; + } + List truncated = new ArrayList(); + for (HistoryEvent event : events) { + if (event.getEventId() > replayUpToEventId) { + break; + } + truncated.add(event); + } + if (truncated.size() == 0) { + return null; + } + return truncated; + } + + protected abstract DecisionTask getNextHistoryTask(String nextPageToken); + + } + + private class ServiceDecisionTaskIterator extends DecisionTaskIterator { + + private final AmazonSimpleWorkflow service; + + private final String domain; + + private final WorkflowExecution workflowExecution; + + public ServiceDecisionTaskIterator(AmazonSimpleWorkflow service, String domain, WorkflowExecution workflowExecution) { + this.service = service; + this.domain = domain; + this.workflowExecution = workflowExecution; + initNext(); + } + + protected DecisionTask getNextHistoryTask(String nextPageToken) { + WorkflowExecutionInfo executionInfo = WorkflowExecutionUtils.describeWorkflowInstance(service, domain, + workflowExecution); + History history = WorkflowExecutionUtils.getHistoryPage(nextPageToken, service, domain, workflowExecution); + DecisionTask task = new DecisionTask(); + List events = history.getEvents(); + events = truncateHistory(events); + if (events == null) { + return null; + } + task.setEvents(events); + task.setWorkflowExecution(workflowExecution); + task.setWorkflowType(executionInfo.getWorkflowType()); + task.setNextPageToken(history.getNextPageToken()); + return task; + } + + } + + private class HistoryIterableDecisionTaskIterator extends DecisionTaskIterator { + + private final WorkflowExecution workflowExecution; + + private final Iterable history; + + public HistoryIterableDecisionTaskIterator(WorkflowExecution workflowExecution, Iterable history) { + this.workflowExecution = workflowExecution; + this.history = history; + initNext(); + } + + @Override + protected DecisionTask getNextHistoryTask(String nextPageToken) { + DecisionTask result = new DecisionTask(); + Iterator iterator = history.iterator(); + if (!iterator.hasNext()) { + throw new IllegalStateException("empty history"); + } + HistoryEvent startEvent = iterator.next(); + WorkflowExecutionStartedEventAttributes startedAttributes = startEvent.getWorkflowExecutionStartedEventAttributes(); + if (startedAttributes == null) { + throw new IllegalStateException("first event is not WorkflowExecutionStarted: " + startEvent); + } + List events = new ArrayList(); + events.add(startEvent); + EventType eventType = null; + int lastStartedIndex = 0; + int index = 1; + long previousStartedEventId = 0; + long startedEventId = 0; + while (iterator.hasNext()) { + HistoryEvent event = iterator.next(); + eventType = EventType.fromValue(event.getEventType()); + events.add(event); + if (eventType == EventType.DecisionTaskStarted) { + previousStartedEventId = startedEventId; + startedEventId = event.getEventId(); + lastStartedIndex = index; + } + index++; + } + if (events.size() > lastStartedIndex + 1) { + events = events.subList(0, lastStartedIndex + 1); + } + result.setEvents(events); + result.setPreviousStartedEventId(previousStartedEventId); + result.setStartedEventId(startedEventId); + result.setWorkflowExecution(workflowExecution); + WorkflowType workflowType = startedAttributes.getWorkflowType(); + result.setWorkflowType(workflowType); + return result; + } + } + + private final Iterator taskIterator; + + private final AsyncDecisionTaskHandler taskHandler; + + private int replayUpToEventId; + + public WorkflowReplayer(AmazonSimpleWorkflow service, String domain, WorkflowExecution workflowExecution, + Class workflowImplementationType) throws InstantiationException, IllegalAccessException { + POJOWorkflowDefinitionFactoryFactory ff = new POJOWorkflowDefinitionFactoryFactory(); + ff.addWorkflowImplementationType(workflowImplementationType); + taskIterator = new ServiceDecisionTaskIterator(service, domain, workflowExecution); + taskHandler = new AsyncDecisionTaskHandler(ff); + } + + public WorkflowReplayer(AmazonSimpleWorkflow service, String domain, WorkflowExecution workflowExecution, + final T workflowImplementation) throws InstantiationException, IllegalAccessException { + WorkflowDefinitionFactoryFactory ff = new WorkflowReplayerPOJOFactoryFactory(workflowImplementation); + taskIterator = new ServiceDecisionTaskIterator(service, domain, workflowExecution); + taskHandler = new AsyncDecisionTaskHandler(ff); + } + + public WorkflowReplayer(AmazonSimpleWorkflow service, String domain, WorkflowExecution workflowExecution, + WorkflowDefinitionFactoryFactory workflowDefinitionFactoryFactory) + throws InstantiationException, IllegalAccessException { + taskIterator = new ServiceDecisionTaskIterator(service, domain, workflowExecution); + taskHandler = new AsyncDecisionTaskHandler(workflowDefinitionFactoryFactory); + } + + public WorkflowReplayer(Iterable history, WorkflowExecution workflowExecution, + Class workflowImplementationType) throws InstantiationException, IllegalAccessException { + POJOWorkflowDefinitionFactoryFactory ff = new POJOWorkflowDefinitionFactoryFactory(); + ff.addWorkflowImplementationType(workflowImplementationType); + taskIterator = new HistoryIterableDecisionTaskIterator(workflowExecution, history); + taskHandler = new AsyncDecisionTaskHandler(ff); + } + + public WorkflowReplayer(Iterable history, WorkflowExecution workflowExecution, final T workflowImplementation) + throws InstantiationException, IllegalAccessException { + WorkflowDefinitionFactoryFactory ff = new WorkflowReplayerPOJOFactoryFactory(workflowImplementation); + taskIterator = new HistoryIterableDecisionTaskIterator(workflowExecution, history); + taskHandler = new AsyncDecisionTaskHandler(ff); + } + + public WorkflowReplayer(Iterable history, WorkflowExecution workflowExecution, + WorkflowDefinitionFactoryFactory workflowDefinitionFactoryFactory) + throws InstantiationException, IllegalAccessException { + taskIterator = new HistoryIterableDecisionTaskIterator(workflowExecution, history); + taskHandler = new AsyncDecisionTaskHandler(workflowDefinitionFactoryFactory); + } + + public WorkflowReplayer(Iterator decisionTasks, Class workflowImplementationType) + throws InstantiationException, IllegalAccessException { + POJOWorkflowDefinitionFactoryFactory ff = new POJOWorkflowDefinitionFactoryFactory(); + ff.addWorkflowImplementationType(workflowImplementationType); + taskIterator = decisionTasks; + taskHandler = new AsyncDecisionTaskHandler(ff); + } + + public WorkflowReplayer(Iterator decisionTasks, final T workflowImplementation) + throws InstantiationException, IllegalAccessException { + WorkflowDefinitionFactoryFactory ff = new WorkflowReplayerPOJOFactoryFactory(workflowImplementation); + taskIterator = decisionTasks; + taskHandler = new AsyncDecisionTaskHandler(ff); + } + + public WorkflowReplayer(Iterator decisionTasks, + WorkflowDefinitionFactoryFactory workflowDefinitionFactoryFactory) + throws InstantiationException, IllegalAccessException { + taskIterator = decisionTasks; + taskHandler = new AsyncDecisionTaskHandler(workflowDefinitionFactoryFactory); + } + + public int getReplayUpToEventId() { + return replayUpToEventId; + } + + /** + * The replay stops at the event with the given eventId. Default is 0. + * + * @param replayUpToEventId + * 0 means the whole history. + */ + public void setReplayUpToEventId(int replayUpToEventId) { + this.replayUpToEventId = replayUpToEventId; + } + + public RespondDecisionTaskCompletedRequest replay() throws Exception { + return taskHandler.handleDecisionTask(taskIterator); + } + + @SuppressWarnings("unchecked") + public T loadWorkflow() throws Exception { + WorkflowDefinition definition = taskHandler.loadWorkflowThroughReplay(taskIterator); + POJOWorkflowDefinition pojoDefinition = (POJOWorkflowDefinition) definition; + return (T) pojoDefinition.getImplementationInstance(); + } + + public List getAsynchronousThreadDump() throws Exception { + return taskHandler.getAsynchronousThreadDump(taskIterator); + } + + public String getAsynchronousThreadDumpAsString() throws Exception { + return taskHandler.getAsynchronousThreadDumpAsString(taskIterator); + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowSelfClient.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowSelfClient.java new file mode 100644 index 000000000000..06359412d832 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowSelfClient.java @@ -0,0 +1,33 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClient; + +public interface WorkflowSelfClient { + + public DataConverter getDataConverter(); + + public void setDataConverter(DataConverter converter); + + public StartWorkflowOptions getSchedulingOptions(); + + public void setSchedulingOptions(StartWorkflowOptions schedulingOptions); + + public GenericWorkflowClient getGenericClient(); + + public void setGenericClient(GenericWorkflowClient genericClient); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowSelfClientBase.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowSelfClientBase.java new file mode 100644 index 000000000000..aebd03a181b6 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowSelfClientBase.java @@ -0,0 +1,78 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClient; + + +public abstract class WorkflowSelfClientBase implements WorkflowSelfClient { + + protected DataConverter dataConverter; + + protected StartWorkflowOptions schedulingOptions; + + protected GenericWorkflowClient genericClient; + + protected final DecisionContextProvider decisionContextProvider = new DecisionContextProviderImpl(); + + public WorkflowSelfClientBase(GenericWorkflowClient genericClient, + DataConverter dataConverter, StartWorkflowOptions schedulingOptions) { + this.genericClient = genericClient; + + if (dataConverter == null) { + this.dataConverter = new JsonDataConverter(); + } + else { + this.dataConverter = dataConverter; + } + + if (schedulingOptions == null) { + this.schedulingOptions = new StartWorkflowOptions(); + } + else { + this.schedulingOptions = schedulingOptions; + } + } + + @Override + public DataConverter getDataConverter() { + return dataConverter; + } + + @Override + public void setDataConverter(DataConverter converter) { + this.dataConverter = converter; + } + + @Override + public StartWorkflowOptions getSchedulingOptions() { + return schedulingOptions; + } + + @Override + public void setSchedulingOptions(StartWorkflowOptions schedulingOptions) { + this.schedulingOptions = schedulingOptions; + } + + @Override + public GenericWorkflowClient getGenericClient() { + return genericClient; + } + + @Override + public void setGenericClient(GenericWorkflowClient genericClient) { + this.genericClient = genericClient; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowTypeRegistrationOptions.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowTypeRegistrationOptions.java new file mode 100644 index 000000000000..0d7382469ea0 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowTypeRegistrationOptions.java @@ -0,0 +1,86 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import com.amazonaws.services.simpleworkflow.model.ChildPolicy; + +public class WorkflowTypeRegistrationOptions { + + private ChildPolicy defaultChildPolicy = ChildPolicy.TERMINATE; + + private long defaultExecutionStartToCloseTimeoutSeconds; + + private long defaultTaskStartToCloseTimeoutSeconds; + + private String defaultTaskList; + + private String description; + + public ChildPolicy getDefaultChildPolicy() { + return defaultChildPolicy; + } + + public void setDefaultChildPolicy(ChildPolicy defaultChildPolicy) { + this.defaultChildPolicy = defaultChildPolicy; + } + + public long getDefaultExecutionStartToCloseTimeoutSeconds() { + return defaultExecutionStartToCloseTimeoutSeconds; + } + + public void setDefaultExecutionStartToCloseTimeoutSeconds(long defaultExecutionStartToCloseTimeoutSeconds) { + this.defaultExecutionStartToCloseTimeoutSeconds = defaultExecutionStartToCloseTimeoutSeconds; + } + + /** + * Default Workflow TaskList. null means to use {@link WorkflowWorker} task list. + * TaskList with "NO_DEFAULT_TASK_LIST" name means that no default task list is registered. + * @return + */ + public String getDefaultTaskList() { + return defaultTaskList; + } + + public void setDefaultTaskList(String defaultTaskList) { + this.defaultTaskList = defaultTaskList; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public long getDefaultTaskStartToCloseTimeoutSeconds() { + return defaultTaskStartToCloseTimeoutSeconds; + } + + public void setDefaultTaskStartToCloseTimeoutSeconds(long defaultTaskStartToCloseTimeoutSeconds) { + this.defaultTaskStartToCloseTimeoutSeconds = defaultTaskStartToCloseTimeoutSeconds; + } + + @Override + public String toString() { + return "WorkflowVersionRegistrationOptions [defaultTaskList=" + defaultTaskList + + ", defaultExecutionStartToCloseTimeoutSeconds=" + defaultExecutionStartToCloseTimeoutSeconds + + ", defaultTaskList=" + defaultTaskList + + ", description=" + description + + ", defaultTaskStartToCloseTimeoutSeconds=" + defaultTaskStartToCloseTimeoutSeconds + + "]"; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowWorker.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowWorker.java new file mode 100644 index 000000000000..a3862ed3b7b6 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/WorkflowWorker.java @@ -0,0 +1,242 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow; + +import java.lang.Thread.UncaughtExceptionHandler; +import java.util.ArrayList; +import java.util.Collection; +import java.util.concurrent.TimeUnit; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.pojo.POJOWorkflowDefinitionFactoryFactory; +import com.amazonaws.services.simpleworkflow.flow.worker.GenericWorkflowWorker; + +public class WorkflowWorker implements WorkerBase { + + private final GenericWorkflowWorker genericWorker; + + private final POJOWorkflowDefinitionFactoryFactory factoryFactory = new POJOWorkflowDefinitionFactoryFactory(); + + private final Collection> workflowImplementationTypes = new ArrayList>(); + + public WorkflowWorker(AmazonSimpleWorkflow service, String domain, String taskListToPoll) { + genericWorker = new GenericWorkflowWorker(service, domain, taskListToPoll); + genericWorker.setWorkflowDefinitionFactoryFactory(factoryFactory); + } + + @Override + public AmazonSimpleWorkflow getService() { + return genericWorker.getService(); + } + + @Override + public String getDomain() { + return genericWorker.getDomain(); + } + + @Override + public boolean isRegisterDomain() { + return genericWorker.isRegisterDomain(); + } + + @Override + public void setRegisterDomain(boolean registerDomain) { + genericWorker.setRegisterDomain(registerDomain); + } + + @Override + public long getDomainRetentionPeriodInDays() { + return genericWorker.getDomainRetentionPeriodInDays(); + } + + @Override + public void setDomainRetentionPeriodInDays(long domainRetentionPeriodInDays) { + genericWorker.setDomainRetentionPeriodInDays(domainRetentionPeriodInDays); + } + + @Override + public String getTaskListToPoll() { + return genericWorker.getTaskListToPoll(); + } + + @Override + public double getMaximumPollRatePerSecond() { + return genericWorker.getMaximumPollRatePerSecond(); + } + + @Override + public void setMaximumPollRatePerSecond(double maximumPollRatePerSecond) { + genericWorker.setMaximumPollRatePerSecond(maximumPollRatePerSecond); + } + + @Override + public int getMaximumPollRateIntervalMilliseconds() { + return genericWorker.getMaximumPollRateIntervalMilliseconds(); + } + + @Override + public void setMaximumPollRateIntervalMilliseconds(int maximumPollRateIntervalMilliseconds) { + genericWorker.setMaximumPollRateIntervalMilliseconds(maximumPollRateIntervalMilliseconds); + } + + @Override + public UncaughtExceptionHandler getUncaughtExceptionHandler() { + return genericWorker.getUncaughtExceptionHandler(); + } + + @Override + public void setUncaughtExceptionHandler(UncaughtExceptionHandler uncaughtExceptionHandler) { + genericWorker.setUncaughtExceptionHandler(uncaughtExceptionHandler); + } + + @Override + public String getIdentity() { + return genericWorker.getIdentity(); + } + + @Override + public void setIdentity(String identity) { + genericWorker.setIdentity(identity); + } + + @Override + public long getPollBackoffInitialInterval() { + return genericWorker.getPollBackoffInitialInterval(); + } + + @Override + public void setPollBackoffInitialInterval(long backoffInitialInterval) { + genericWorker.setPollBackoffInitialInterval(backoffInitialInterval); + } + + @Override + public long getPollBackoffMaximumInterval() { + return genericWorker.getPollBackoffMaximumInterval(); + } + + @Override + public void setPollBackoffMaximumInterval(long backoffMaximumInterval) { + genericWorker.setPollBackoffMaximumInterval(backoffMaximumInterval); + } + + @Override + public boolean isDisableServiceShutdownOnStop() { + return genericWorker.isDisableServiceShutdownOnStop(); + } + + @Override + public void setDisableServiceShutdownOnStop(boolean disableServiceShutdownOnStop) { + genericWorker.setDisableServiceShutdownOnStop(disableServiceShutdownOnStop); + } + + @Override + public double getPollBackoffCoefficient() { + return genericWorker.getPollBackoffCoefficient(); + } + + @Override + public void setPollBackoffCoefficient(double backoffCoefficient) { + genericWorker.setPollBackoffCoefficient(backoffCoefficient); + } + + @Override + public int getPollThreadCount() { + return genericWorker.getPollThreadCount(); + } + + @Override + public void setPollThreadCount(int threadCount) { + genericWorker.setPollThreadCount(threadCount); + } + + @Override + public void registerTypesToPoll() { + genericWorker.registerTypesToPoll(); + } + + @Override + public void start() { + genericWorker.start(); + } + + @Override + public void shutdown() { + genericWorker.shutdown(); + } + + @Override + public void shutdownNow() { + genericWorker.shutdownNow(); + } + + @Override + public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { + return genericWorker.awaitTermination(timeout, unit); + } + + @Override + public boolean isRunning() { + return genericWorker.isRunning(); + } + + @Override + public void suspendPolling() { + genericWorker.suspendPolling(); + } + + @Override + public void resumePolling() { + genericWorker.resumePolling(); + } + + public void setWorkflowImplementationTypes(Collection> workflowImplementationTypes) + throws InstantiationException, IllegalAccessException { + for (Class workflowImplementationType : workflowImplementationTypes) { + addWorkflowImplementationType(workflowImplementationType); + } + } + + public Collection> getWorkflowImplementationTypes() { + return workflowImplementationTypes; + } + + public void addWorkflowImplementationType(Class workflowImplementationType) throws InstantiationException, IllegalAccessException { + factoryFactory.addWorkflowImplementationType(workflowImplementationType); + } + + public void addWorkflowImplementationType(Class workflowImplementationType, DataConverter converter) throws InstantiationException, IllegalAccessException { + factoryFactory.addWorkflowImplementationType(workflowImplementationType, converter); + } + + @Override + public String toString() { + return this.getClass().getSimpleName() + "[genericWorker=" + genericWorker + ", wokflowImplementationTypes=" + + workflowImplementationTypes + "]"; + } + + @Override + public boolean shutdownAndAwaitTermination(long timeout, TimeUnit unit) throws InterruptedException { + return genericWorker.shutdownAndAwaitTermination(timeout, unit); + } + + public DataConverter getDataConverter() { + return factoryFactory.getDataConverter(); + } + + public void setDefaultConverter(DataConverter converter) { + factoryFactory.setDataConverter(converter); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Activities.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Activities.java new file mode 100644 index 000000000000..c3f6385a43aa --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Activities.java @@ -0,0 +1,72 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.amazonaws.services.simpleworkflow.flow.DataConverter; +import com.amazonaws.services.simpleworkflow.flow.JsonDataConverter; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +/** + * @Activities annotation is allowed on interfaces to define a set of activities. + * This interface forms the contract between the implementation of the activities and + * the clients used to invoke them. The client-side is auto-generated by AWS Flow Framework + * annotation processor from the interfaces marked with @Activities annotation. + * + * Each method on the interface annotated with @Activities annotation corresponds to + * an activity. Activity methods are not allowed to have {@link Promise} parameters + * or return types. + * + * @author fateev, samar + * + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface Activities { + + /** + * Prefix to use for each activity defined within the interface annotated + * with @Activities annotation. Default is empty string which means that + * name of interface should be used as the prefix for each activity name. + */ + String activityNamePrefix() default ""; + + /** + * Version to use to each activity defined within the interface annotated + * with @Activities annotation. Default is empty string which means that + * version should be specified using {@link Activity#version()} on every + * method individually. Alternatively you can specify the version for + * all activities defined within the interface using this attribute. + * + * AWS Flow Framework annotation processor will report an error if version + * for an activity is not specified through {@link Activities#version()} or + * {@link Activity#version()}. + */ + String version() default ""; + + /** + * This is used to specify {@link DataConverter} type to use for + * serialization/de-serialization of activity method parameters and return types. + * + * Default is {@link NullDataConverter} which means to use the default + * DataConverter used by framework. Default DataConverter used by framework is + * {@link JsonDataConverter}. + */ + Class dataConverter() default NullDataConverter.class; +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Activity.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Activity.java new file mode 100644 index 000000000000..0ca2b5a0eebd --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Activity.java @@ -0,0 +1,49 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Optional annotation used on activity methods to override the name + * and version. + * + * @see Activities + * @author fateev, samar + * + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Activity { + + /** + * This is used to override the name of ActivityType. + * Default is empty string which means to use the method name. + */ + String name() default ""; + + /** + * This is used to override the version of ActivityType. + * Default is empty string which means to use the version specified on + * {@link Activities} annotation for the interface. If + * {@link Activities#version()} is also empty string then AWS Flow Framework + * annotation processor reports an error. + */ + String version() default ""; + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/ActivityRegistrationOptions.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/ActivityRegistrationOptions.java new file mode 100644 index 000000000000..5c6511a4c396 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/ActivityRegistrationOptions.java @@ -0,0 +1,75 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.amazonaws.services.simpleworkflow.flow.ActivitySchedulingOptions; +import com.amazonaws.services.simpleworkflow.flow.ActivityWorker; +import com.amazonaws.services.simpleworkflow.flow.common.FlowConstants; + +/** + * @ActivityRegistrationOptions is a required annotation, unless + * {@link SkipTypeRegistration} is provided, on either interface annotated with + * {@link Activities} or activity method. + * + * It contains all the registration options for ActivityType which will be used + * for registration with Amazon SWF Service. Registration of activity types happen + * on {@link ActivityWorker#start()}. + * + * @see ActivityWorker + * @author fateev, samar + * + */ +@Target({ ElementType.METHOD, ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +public @interface ActivityRegistrationOptions { + + String description() default ""; + + long defaultTaskScheduleToStartTimeoutSeconds(); + + /** + * Default is {@link FlowConstants#NONE} which disables separate heartbeat + * timeout. + */ + long defaultTaskHeartbeatTimeoutSeconds() default FlowConstants.NONE; + + /** + * Default is {@link FlowConstants#NONE}. + */ + long defaultTaskScheduleToCloseTimeoutSeconds() default FlowConstants.NONE; + + long defaultTaskStartToCloseTimeoutSeconds(); + + /** + * Task list that activity task is delivered through when no task list is + * specified on activity invocation. + * + *

+ * Default is {@link FlowConstants#USE_WORKER_TASK_LIST}, which means to use task + * list from the {@link ActivityWorker} that the activity implementation is + * registered with. Specify {@link FlowConstants#NO_DEFAULT_TASK_LIST} to + * not register any default task list. If no default task list registered it + * becomes required scheduling option (specified through + * {@link ActivitySchedulingOptions#setTaskList(String)}) when an activity + * is called. + */ + String defaultTaskList() default FlowConstants.USE_WORKER_TASK_LIST; + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Asynchronous.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Asynchronous.java new file mode 100644 index 000000000000..57f27ec5365a --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Asynchronous.java @@ -0,0 +1,46 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.core.TryCatchFinally; + +/** + * Call to @Asynchronous method always returns immediately without executing it + * code. Method body is scheduled for execution after all parameters that extend + * {@link Promise} and not marked with {@link NoWait} are ready. The only valid + * return types for @Asynchronous method are void and + * {@link Promise}. + * + * @author fateev + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Asynchronous { + + /** + * if set to true treats asynchronous task as a daemon task, allowing the + * parent asynchronous scope to close if all non-daemon child tasks + * completes. Default is false which means use the value of the + * parent task. See {@link TryCatchFinally} for more info on daemon + * semantic. + */ + boolean daemon() default false; +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Execute.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Execute.java new file mode 100644 index 000000000000..a6fbe2940202 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Execute.java @@ -0,0 +1,50 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +/** + * @Execute annotation is used on methods of interface annotated with {@link Workflow} + * to specify the entry-point for WorkflowType. + * + * @Execute method can only have void or {@link Promise} return types. + * Parameters of type {@link Promise} are not allowed. + * + * @see Workflow, WorkflowWorker + * @author fateev, samar + * + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Execute { + + /** + * Optional name of the workflow type. When missing defaults to the + * annotated method name. Maximum length is 256 characters. + */ + String name() default ""; + + /** + * Required version of the workflow type. Maximum length is 64 characters. + */ + String version(); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/ExponentialRetry.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/ExponentialRetry.java new file mode 100644 index 000000000000..910873c90073 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/ExponentialRetry.java @@ -0,0 +1,81 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.amazonaws.services.simpleworkflow.flow.common.FlowDefaults; +import com.amazonaws.services.simpleworkflow.flow.interceptors.RetryDecorator; + +/** + * This annotation can be used for retrying failures on any asynchronous executions. + * For retrying based on dynamic retry policy use {@link RetryDecorator}. + * Both @ExponentialRetry annotation and {@link RetryDecorator} should not be + * used simultaneously on the same asynchronous method call. + * + * @author fateev, samar + * + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface ExponentialRetry { + + /** + * Retry period to use for the first retry by ExponentialRetryPolicy. This + * value should not be greater than values specified for maximumRetryPeriod + * or retryExpirationPeriod. + */ + long initialRetryIntervalSeconds(); + + /** + * Maximum retry period between attempts used by ExponentialRetryPolicy. + * This value should not be less than value specified for + * initialRetryPeriod. Default value is unlimited. + */ + long maximumRetryIntervalSeconds() default FlowDefaults.EXPONENTIAL_RETRY_MAXIMUM_RETRY_INTERVAL_SECONDS; + + /** + * Expiration period of retries used by ExponentialRetryPolicy. This value + * should not be less than value specified for initialRetryPeriod. Default + * value is unlimited. + */ + long retryExpirationSeconds() default FlowDefaults.EXPONENTIAL_RETRY_RETRY_EXPIRATION_SECONDS; + + /** + * Coefficient to use for exponential retry policy. Default is 2.0. + */ + double backoffCoefficient() default FlowDefaults.EXPONENTIAL_RETRY_BACKOFF_COEFFICIENT; + + /** + * Number of maximum retry attempts used by ExponentialRetryPolicy. Default + * value is no limit. + */ + int maximumAttempts() default FlowDefaults.EXPONENTIAL_RETRY_MAXIMUM_ATTEMPTS; + + /** + * Default is {@link Throwable} which means that all exceptions are retried. + */ + Class[] exceptionsToRetry() default { Throwable.class }; + + /** + * What exceptions that match exceptionsToRetry list should be not retried. + * Default is empty list. + */ + Class[] excludeExceptions() default {}; + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/GetState.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/GetState.java new file mode 100644 index 000000000000..afb0c12e377b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/GetState.java @@ -0,0 +1,43 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +/** + * Indicates that method is used to retrieve current workflow state. The method + * is expected to perform read only access of the workflow implementation object + * and is invoked synchronously which disallows use of any asynchronous + * operations (like calling methods annotated with {@link Asynchronous}). + * + * Method is expected to have empty list of parameters. + * {@link Promise} or void return types are not allowed for the annotated method. + * + * The generated external client implementation uses {@link AmazonSimpleWorkflow#describeWorkflowExecution(com.amazonaws.services.simpleworkflow.model.DescribeWorkflowExecutionRequest) + * visibility API to retrieve the state. It allows access to the sate using external client if decider + * workers are down and even after workflow execution completion. + * + * @author fateev, samar + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface GetState { +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/ManualActivityCompletion.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/ManualActivityCompletion.java new file mode 100644 index 000000000000..7f6818fcefb2 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/ManualActivityCompletion.java @@ -0,0 +1,38 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @ManualActivityCompletion is an optional annotation meant to be used on + * implementations of activity methods to mark them to be completed + * asynchronously. + * + * If this annotation is specified on an activity implementation method, then + * Flow Framework will not try to automatically complete this activity when + * method returns. If this method have a return type then return value + * from the method is ignored. + * + * @author fateev, samar + * + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface ManualActivityCompletion { +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/NoWait.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/NoWait.java new file mode 100644 index 000000000000..be84cf46a2a3 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/NoWait.java @@ -0,0 +1,48 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +/** + * Used to mark {@link Promise} arguments of @Asynchronous methods that should + * not be waited for. + *

+ * Example usage: + * + *

+ * 
+ * @Asynchronous
+ * private void calculate(Promise arg1, @NoWait Settable result) {
+ *    ...
+ *    result.set(r);
+ * }
+ * 
+ * 
+ * + * @see Asynchronous + * + * @author fateev + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.PARAMETER) +public @interface NoWait { + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/NullDataConverter.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/NullDataConverter.java new file mode 100644 index 000000000000..c882db43fb8d --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/NullDataConverter.java @@ -0,0 +1,41 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.annotations; + +import com.amazonaws.services.simpleworkflow.flow.DataConverter; +import com.amazonaws.services.simpleworkflow.flow.DataConverterException; + +/** + * To be used only by annotations as they do not support null parameters. + * + * @see Activities, Workflow + * @author fateev, samar + */ +public final class NullDataConverter extends DataConverter { + + private NullDataConverter() { + } + + @Override + public T fromData(String content, Class valueType) throws DataConverterException { + throw new UnsupportedOperationException("not implemented"); + } + + @Override + public String toData(Object value) throws DataConverterException { + throw new UnsupportedOperationException("not implemented"); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Signal.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Signal.java new file mode 100644 index 000000000000..07f68f18cc81 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Signal.java @@ -0,0 +1,46 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +/** + * @Signal annotation is used on methods of interface annotated with {@link Workflow} + * to specify the method to invoke when a particular signal is received by workflow + * execution with a matching name. + * + * @Signal methods are not allowed to have {@link Promise} parameters types and can + * only have void as return types. + * + * @see Workflow, WorkflowWorker + * @author fateev, samar + * + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Signal { + /** + * Optional name of the signal. + * Default is empty-string which means to use the name of annotated method + * as signal name. + * Maximum length is 256 characters. + */ + String name() default ""; +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/SkipTypeRegistration.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/SkipTypeRegistration.java new file mode 100644 index 000000000000..e0868621a065 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/SkipTypeRegistration.java @@ -0,0 +1,41 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.amazonaws.services.simpleworkflow.flow.ActivityWorker; +import com.amazonaws.services.simpleworkflow.flow.WorkflowWorker; + +/** + * This can be used on interfaces annotated with {@link Activities} or {@link Workflow} + * to specify no registration options are needed for ActivityType or WorkflowType + * defined by such interfaces. + * + * Registration of types is skipped by {@link ActivityWorker} or {@link WorkflowWorker} + * when interface is annotated with @SkipTypeRegistration. + * + * @see Activities, Workflow, ActivityWorker, WorkflowWorker + * @author fateev, samar + * + */ +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface SkipTypeRegistration { + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Wait.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Wait.java new file mode 100644 index 000000000000..e9dd58a8451e --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Wait.java @@ -0,0 +1,36 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.util.Collection; +import java.util.Map; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +/** + * Used to mark parameters of @{@link Asynchronous} method that should be waited + * to be ready. Not necessary for parameters that subclass {@link Promise}. + * Required for {@link Collection} of Promises and {@link Map} of values of + * Promise type. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.PARAMETER) +public @interface Wait { + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Workflow.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Workflow.java new file mode 100644 index 000000000000..52a478a3a74c --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/Workflow.java @@ -0,0 +1,68 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.amazonaws.services.simpleworkflow.flow.DataConverter; +import com.amazonaws.services.simpleworkflow.flow.DecisionContext; +import com.amazonaws.services.simpleworkflow.flow.JsonDataConverter; + +/** + * @Workflow annotation is allowed on interfaces to define a workflow. This + * interface forms the contract between the implementation of WorkflowType + * and clients interested in starting executions, sending signals, and getting + * current state of execution. + * + * Use {@link Execute} annotation on the method to mark it as the entry-point + * for WorkflowType. @Workflow interface cannot have more than one method marked + * with {@link Execute} annotation. + * + * Use {@link Signal} annotation on the methods to mark them as signals + * supported by WorkflowType. @Workflow interface can have zero or more methods + * marked with {@link Signal} annotation. + * + * Use {@link GetState} annotation on the method which framework will use to + * update the current workflow state for WorkflowType. @Workflow interface + * cannot have more than one method marked with {@link GetState} annotation. + * + * {@link Execute}, {@link Signal} and {@link GetState} annotations are mutually + * exclusive and cannot be used simultaneously on a method. AWS Flow Framework + * annotation processor will auto-generate three different clients which can + * be used to start new executions, sending signals and retrieving workflow states + * for different situations. + * + * @see DecisionContext + * @author fateev, samar + * + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface Workflow { + + /** + * This is used to specify {@link DataConverter} type to use for + * serialization/de-serialization of workflow method parameters and return types. + * + * Default is {@link NullDataConverter} which means to use the default + * DataConverter used by framework. Default DataConverter used by framework is + * {@link JsonDataConverter}. + */ + Class dataConverter() default NullDataConverter.class; + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/WorkflowRegistrationOptions.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/WorkflowRegistrationOptions.java new file mode 100644 index 000000000000..dd3295bf3bbe --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/annotations/WorkflowRegistrationOptions.java @@ -0,0 +1,76 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.amazonaws.services.simpleworkflow.flow.WorkflowWorker; +import com.amazonaws.services.simpleworkflow.flow.common.FlowConstants; +import com.amazonaws.services.simpleworkflow.model.ChildPolicy; + +/** + * @WorkflowRegistrationOptions is a required annotation, unless + * {@link SkipTypeRegistration} is provided, on interfaces annotated with + * {@link Workflow}. + * + * It contains all the registration options for WorkflowType which will be used for + * registration with Amazon SWF Service. Registration of types happen on + * {@link WorkflowWorker#start()}. + * + * @see WorkflowWorker + * @author fateev, samar + * + */ +@Target(ElementType.TYPE) +@Retention(value = RetentionPolicy.RUNTIME) +public @interface WorkflowRegistrationOptions { + + /** + * Optional textual description of the workflow type. Maximum length is 1024 + * characters. + */ + String description() default ""; + + /** + * Maximum time that workflow run is allowed to execute. Workflow is + * forcefully closed by the SWF service if this timeout is exceeded. + */ + long defaultExecutionStartToCloseTimeoutSeconds(); + + /** + * Single decision timeout. This timeout defines how long it takes to + * reexecute a decision after {@link WorkflowWorker} catastrophic failure in + * the middle of one. Do not confuse with the whole worklfow timeout ( + * {@link #defaultExecutionStartToCloseTimeoutSeconds()} which can be really + * big. Default is 30 seconds. + */ + long defaultTaskStartToCloseTimeoutSeconds() default 30; + + /** + * Task list that decision task is delivered through for the given workflow + * type. + * + *

+ * Default is {@link FlowConstants#USE_WORKER_TASK_LIST}, which means to use task + * list from the {@link WorkflowWorker} that the workflow implementation is + * registered with. + */ + String defaultTaskList() default FlowConstants.USE_WORKER_TASK_LIST; + + ChildPolicy defaultChildPolicy() default ChildPolicy.TERMINATE; +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/AsynchronousAspect.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/AsynchronousAspect.java new file mode 100644 index 000000000000..a096536fc51f --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/AsynchronousAspect.java @@ -0,0 +1,110 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.aspectj; + +import java.lang.annotation.Annotation; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.Signature; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.reflect.MethodSignature; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Asynchronous; +import com.amazonaws.services.simpleworkflow.flow.annotations.NoWait; +import com.amazonaws.services.simpleworkflow.flow.annotations.Wait; +import com.amazonaws.services.simpleworkflow.flow.core.AndPromise; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +@Aspect +public class AsynchronousAspect { + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Around("call(@com.amazonaws.services.simpleworkflow.flow.annotations.Asynchronous * *(..)) && @annotation(asynchronousAnnotation)") + public Object makeAsynchronous(ProceedingJoinPoint pjp, Asynchronous asynchronousAnnotation) throws Throwable { + final Signature signature = pjp.getStaticPart().getSignature(); + if (signature instanceof MethodSignature) { + final MethodSignature methodSignature = (MethodSignature) signature; + int i = 0; + Object[] methodArguments = pjp.getArgs(); + Annotation[][] parameterAnnotations = methodSignature.getMethod().getParameterAnnotations(); + List valueParams = new ArrayList(); + for (final Class parameterType : methodSignature.getParameterTypes()) { + if ((isPromise(parameterType) || isPromiseArray(parameterType) || (isCollection(parameterType) && hasWaitAnnotation(parameterAnnotations[i]))) + && !hasNoWaitAnnotation(parameterAnnotations[i])) { + Object param = methodArguments[i]; + if (isPromise(parameterType)) { + valueParams.add((Promise) param); + } + else if (isCollection(parameterType)) { + valueParams.add(new AndPromise((Collection) param)); + } + else { + valueParams.add(new AndPromise((Promise[]) param)); + } + } else { + valueParams.add(null); + } + i++; + } + + Promise[] values = valueParams.toArray(new Promise[0]); + Boolean daemon = asynchronousAnnotation.daemon() ? true : null; + AsynchronousAspectTask task = new AsynchronousAspectTask(daemon, pjp, values); + return task.getReturnValue(); + } + + return pjp.proceed(); + } + + private static boolean isPromise(Class clazz) { + return Promise.class.isAssignableFrom(clazz); + } + + private static boolean isCollection(Class clazz) { + return Collection.class.isAssignableFrom(clazz); + } + + private static boolean isPromiseArray(Class clazz) { + if (!clazz.isArray()) { + return false; + } + Class elementType = clazz.getComponentType(); + return isPromise(elementType); + } + + private static boolean hasWaitAnnotation(Annotation[] annotations) { + for (Annotation annotation : annotations) { + if (annotation.annotationType().equals(Wait.class)) { + return true; + } + } + + return false; + } + + private static boolean hasNoWaitAnnotation(Annotation[] annotations) { + for (Annotation annotation : annotations) { + if (annotation.annotationType().equals(NoWait.class)) { + return true; + } + } + + return false; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/AsynchronousAspectTask.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/AsynchronousAspectTask.java new file mode 100644 index 000000000000..aeeb4105c67c --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/AsynchronousAspectTask.java @@ -0,0 +1,55 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.aspectj; + +import org.aspectj.lang.ProceedingJoinPoint; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.core.Settable; +import com.amazonaws.services.simpleworkflow.flow.core.Task; + +class AsynchronousAspectTask extends Task { + + ProceedingJoinPoint pjp; + @SuppressWarnings("rawtypes") + Settable returnValue = new Settable(); + + @SuppressWarnings("rawtypes") + public AsynchronousAspectTask(Boolean daemon, ProceedingJoinPoint pjp, Promise[] waitFor) { + super(daemon, "_aroundBody", true, 7, waitFor); + this.pjp = pjp; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + protected void doExecute() throws Throwable { + Object result = pjp.proceed(); + if (result != null && !(result instanceof Promise)) { + throw new RuntimeException("@Asynchronous annotation is allowed only for methods with void or Promise return types: " + + pjp.getStaticPart().getSignature().getName()); + } + + if (result != null) { + returnValue.chain((Promise)result); + } else { + returnValue.set(null); + } + } + + @SuppressWarnings("rawtypes") + public Promise getReturnValue() { + return returnValue; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/ExponentialRetryAspect.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/ExponentialRetryAspect.java new file mode 100644 index 000000000000..8b85cd33b707 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/aspectj/ExponentialRetryAspect.java @@ -0,0 +1,79 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.aspectj; + +import java.util.Arrays; + +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.Signature; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.reflect.MethodSignature; + +import com.amazonaws.services.simpleworkflow.flow.annotations.ExponentialRetry; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.interceptors.ExponentialRetryPolicy; +import com.amazonaws.services.simpleworkflow.flow.interceptors.RetryCallable; +import com.amazonaws.services.simpleworkflow.flow.interceptors.RetryInterceptor; +import com.amazonaws.services.simpleworkflow.flow.interceptors.RetryInterceptorWithResult; +import com.amazonaws.services.simpleworkflow.flow.interceptors.RetryInterceptorVoid; + +@Aspect +public class ExponentialRetryAspect { + + @Around("execution(@com.amazonaws.services.simpleworkflow.flow.annotations.ExponentialRetry * *(..)) && @annotation(retryAnnotation)") + public Object retry(final ProceedingJoinPoint pjp, ExponentialRetry retryAnnotation) throws Throwable { + ExponentialRetryPolicy retryPolicy = createExponentialRetryPolicy(retryAnnotation); + + @SuppressWarnings("rawtypes") + RetryCallable retryCallable = new RetryCallable() { + + @Override + public Promise call() throws Throwable { + return (Promise) pjp.proceed(); + } + }; + + boolean isVoidReturnType = false; + final Signature signature = pjp.getStaticPart().getSignature(); + if (signature instanceof MethodSignature) { + final MethodSignature methodSignature = (MethodSignature) signature; + isVoidReturnType = (methodSignature != null) ? Void.TYPE.equals(methodSignature.getReturnType()) : false; + } + + RetryInterceptor interceptor = null; + if (isVoidReturnType) { + interceptor = new RetryInterceptorVoid(retryCallable, retryPolicy); + } else { + interceptor = new RetryInterceptorWithResult(retryCallable, retryPolicy); + } + + return interceptor.execute(); + } + + private ExponentialRetryPolicy createExponentialRetryPolicy(ExponentialRetry retryAnnotation) { + + ExponentialRetryPolicy retryPolicy = new ExponentialRetryPolicy(retryAnnotation.initialRetryIntervalSeconds()) + .withExceptionsToRetry(Arrays.asList(retryAnnotation.exceptionsToRetry())) + .withExceptionsToExclude(Arrays.asList(retryAnnotation.excludeExceptions())) + .withBackoffCoefficient(retryAnnotation.backoffCoefficient()) + .withMaximumRetryIntervalSeconds(retryAnnotation.maximumRetryIntervalSeconds()) + .withRetryExpirationIntervalSeconds(retryAnnotation.retryExpirationSeconds()) + .withMaximumAttempts(retryAnnotation.maximumAttempts()); + + retryPolicy.validate(); + return retryPolicy; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowConstants.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowConstants.java new file mode 100644 index 000000000000..55d6ede24789 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowConstants.java @@ -0,0 +1,36 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.common; + +public final class FlowConstants { + + public static final int NONE = -1; + + public static final int USE_REGISTERED_DEFAULTS = -2; + + /** + * Do not specify task list on registration. Which means that task list is + * required when scheduling activity. + */ + public static final String NO_DEFAULT_TASK_LIST = "NO_DEFAULT_TASK_LIST"; + + /** + * Use task list of the {@link ActivityWorker} or {@link WorkflowWorker} + * that is used to register activity or workflow as the defalt task list for + * the activity or workflow type. + */ + public static final String USE_WORKER_TASK_LIST = "USE_WORKER_TASK_LIST"; + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowDefaults.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowDefaults.java new file mode 100644 index 000000000000..e85277e4d119 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowDefaults.java @@ -0,0 +1,22 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.common; + +public class FlowDefaults { + public static final long EXPONENTIAL_RETRY_MAXIMUM_RETRY_INTERVAL_SECONDS = FlowConstants.NONE; + public static final long EXPONENTIAL_RETRY_RETRY_EXPIRATION_SECONDS = FlowConstants.NONE; + public static final double EXPONENTIAL_RETRY_BACKOFF_COEFFICIENT = 2; + public static final int EXPONENTIAL_RETRY_MAXIMUM_ATTEMPTS = FlowConstants.NONE; +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowHelpers.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowHelpers.java new file mode 100644 index 000000000000..81d11215cf90 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowHelpers.java @@ -0,0 +1,55 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.common; + +import java.lang.reflect.Method; + +import com.amazonaws.services.simpleworkflow.model.PredefinedDuration; + + +public final class FlowHelpers { + + public static String secondsToDuration(Long seconds) { + if (seconds == null || seconds == FlowConstants.NONE) { + return PredefinedDuration.NONE.toString(); + } else if (seconds == FlowConstants.USE_REGISTERED_DEFAULTS) { + return null; + } + + return Long.toString(seconds); + } + + public static Object[] validateInput(Method method, Object[] args) { + Class[] paramterTypes = method.getParameterTypes(); + int numberOfParameters = paramterTypes.length; + if (args == null || args.length != numberOfParameters) { + throw new IllegalStateException("Number of parameters does not match args size."); + } + + int index = 0; + for (Class paramType: paramterTypes) { + Object argument = args[index]; + if (argument != null && !paramType.isAssignableFrom(argument.getClass())) { + throw new IllegalStateException("Param type '" + paramType.getName() + "' is not assigable from '" + + argument.getClass().getName() + "'."); + } + + index++; + } + + return args; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowValueConstraint.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowValueConstraint.java new file mode 100644 index 000000000000..73c13358950f --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/FlowValueConstraint.java @@ -0,0 +1,64 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.common; + + +public enum FlowValueConstraint { + + FAILURE_REASON("FAILURE_REASON", 0, 256), + + FAILURE_DETAILS("FAILURE_DETAILS", 0, 32768); + + private final String value; + + private final int min; + + private final int max; + + private FlowValueConstraint(String value, int min, int max) { + this.value = value; + this.min = min; + this.max = max; + } + + @Override + public String toString() { + return value; + } + + public int getMinSize() { + return min; + } + + public int getMaxSize() { + return max; + } + + public static FlowValueConstraint fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + } + else if ("FAILURE_REASON".equals(value)) { + return FlowValueConstraint.FAILURE_REASON; + } + else if ("FAILURE_DETAILS".equals(value)) { + return FlowValueConstraint.FAILURE_DETAILS; + } + else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/WorkflowExecutionUtils.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/WorkflowExecutionUtils.java new file mode 100644 index 000000000000..7c4445a176fd --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/common/WorkflowExecutionUtils.java @@ -0,0 +1,635 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.common; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeoutException; + +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.DeserializationConfig.Feature; +import org.codehaus.jackson.map.ObjectMapper.DefaultTyping; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.model.CloseStatus; +import com.amazonaws.services.simpleworkflow.model.Decision; +import com.amazonaws.services.simpleworkflow.model.DescribeWorkflowExecutionRequest; +import com.amazonaws.services.simpleworkflow.model.EventType; +import com.amazonaws.services.simpleworkflow.model.ExecutionStatus; +import com.amazonaws.services.simpleworkflow.model.GetWorkflowExecutionHistoryRequest; +import com.amazonaws.services.simpleworkflow.model.History; +import com.amazonaws.services.simpleworkflow.model.HistoryEvent; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecutionCompletedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecutionContinuedAsNewEventAttributes; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecutionDetail; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecutionInfo; + +/** + * Convenience methods to be used by unit tests and during development. + * + * @author fateev + */ +public class WorkflowExecutionUtils { + + /** + * Blocks until workflow instance completes and returns its result. Useful + * for unit tests and during development. Never use in + * production setting as polling for worklow instance status is an expensive + * operation. + * + * @param workflowExecution + * result of + * {@link AmazonSimpleWorkflow#startWorkflowInstance(com.amazonaws.services.simpleworkflow.model.StartWorkflowInstanceRequest)} + * @return workflow instance result. + * @throws InterruptedException + * if thread is interrupted + * @throws RuntimeException + * if workflow instance ended up in any state but completed + */ + public static WorkflowExecutionCompletedEventAttributes waitForWorkflowExecutionResult(AmazonSimpleWorkflow service, + String domain, WorkflowExecution workflowExecution) throws InterruptedException { + try { + return waitForWorkflowExecutionResult(service, domain, workflowExecution, 0); + } + catch (TimeoutException e) { + throw new Error("should never happen", e); + } + } + + /** + * Waits up to specified timeout until workflow instance completes and + * returns its result. Useful for unit tests and during development. + * Never use in production setting as polling for worklow + * instance status is an expensive operation. + * + * @param workflowExecution + * result of + * {@link AmazonSimpleWorkflow#startWorkflowInstance(com.amazonaws.services.simpleworkflow.model.StartWorkflowInstanceRequest)} + * @return workflow instance result. + * @throws InterruptedException + * if thread is interrupted + * @throws TimeoutException + * if instance is not complete after specified timeout + * @throws RuntimeException + * if workflow instance ended up in any state but completed + */ + public static WorkflowExecutionCompletedEventAttributes waitForWorkflowExecutionResult(AmazonSimpleWorkflow service, + String domain, WorkflowExecution workflowExecution, long timeoutSeconds) + throws InterruptedException, TimeoutException { + if (!waitForWorkflowInstanceCompletion(service, domain, workflowExecution, timeoutSeconds).equals( + CloseStatus.COMPLETED.toString())) { + String historyDump = WorkflowExecutionUtils.prettyPrintHistory(service, domain, workflowExecution); + throw new RuntimeException("Workflow instance is not in completed state:\n" + historyDump); + } + return getWorkflowExecutionResult(service, domain, workflowExecution); + } + + /** + * Returns result of workflow instance execution. result of + * {@link AmazonSimpleWorkflow#startWorkflowInstance(com.amazonaws.services.simpleworkflow.model.StartWorkflowInstanceRequest)} + * + * @throws IllegalStateException + * if workflow is still running + * @throws RuntimeException + * if workflow instance ended up in any state but completed + */ + public static WorkflowExecutionCompletedEventAttributes getWorkflowExecutionResult(AmazonSimpleWorkflow service, + String domain, WorkflowExecution workflowExecution) { + HistoryEvent closeEvent = getInstanceCloseEvent(service, domain, workflowExecution); + if (closeEvent == null) { + throw new IllegalStateException("Workflow is still running"); + } + if (closeEvent.getEventType().equals(EventType.WorkflowExecutionCompleted.toString())) { + return closeEvent.getWorkflowExecutionCompletedEventAttributes(); + } + throw new RuntimeException("Workflow end state is not completed: " + prettyPrintHistoryEvent(closeEvent)); + } + + public static HistoryEvent getInstanceCloseEvent(AmazonSimpleWorkflow service, String domain, + WorkflowExecution workflowExecution) { + + WorkflowExecutionInfo executionInfo = describeWorkflowInstance(service, domain, workflowExecution); + if (executionInfo == null || executionInfo.getExecutionStatus().equals(ExecutionStatus.OPEN.toString())) { + return null; + } + + List events = getHistory(service, domain, workflowExecution); + HistoryEvent result = null; + for (HistoryEvent event : events) { + if (isWorkflowExecutionCompletedEvent(event)) { + result = event; + break; + } + } + return result; + } + + public static boolean isWorkflowExecutionCompletedEvent(HistoryEvent event) { + return ((event != null) && (event.getEventType().equals(EventType.WorkflowExecutionCompleted.toString()) + || event.getEventType().equals(EventType.WorkflowExecutionCanceled.toString()) + || event.getEventType().equals(EventType.WorkflowExecutionFailed.toString()) + || event.getEventType().equals(EventType.WorkflowExecutionTimedOut.toString()) + || event.getEventType().equals(EventType.WorkflowExecutionContinuedAsNew.toString()) || event.getEventType().equals( + EventType.WorkflowExecutionTerminated.toString()))); + } + + public static boolean isActivityTaskClosedEvent(HistoryEvent event) { + return ((event != null) && (event.getEventType().equals(EventType.ActivityTaskCompleted.toString()) + || event.getEventType().equals(EventType.ActivityTaskCanceled.toString()) + || event.getEventType().equals(EventType.ActivityTaskFailed.toString()) || event.getEventType().equals( + EventType.ActivityTaskTimedOut.toString()))); + } + + public static boolean isExternalWorkflowClosedEvent(HistoryEvent event) { + return ((event != null) && (event.getEventType().equals(EventType.ChildWorkflowExecutionCompleted.toString()) + || event.getEventType().equals(EventType.ChildWorkflowExecutionCanceled.toString()) + || event.getEventType().equals(EventType.ChildWorkflowExecutionFailed.toString()) + || event.getEventType().equals(EventType.ChildWorkflowExecutionTerminated.toString()) || event.getEventType().equals( + EventType.ChildWorkflowExecutionTimedOut.toString()))); + } + + public static WorkflowExecution getWorkflowIdFromExternalWorkflowCompletedEvent(HistoryEvent event) { + if (event != null) { + if (event.getEventType().equals(EventType.ChildWorkflowExecutionCompleted.toString())) { + return event.getChildWorkflowExecutionCompletedEventAttributes().getWorkflowExecution(); + } + else if (event.getEventType().equals(EventType.ChildWorkflowExecutionCanceled.toString())) { + return event.getChildWorkflowExecutionCanceledEventAttributes().getWorkflowExecution(); + } + else if (event.getEventType().equals(EventType.ChildWorkflowExecutionFailed.toString())) { + return event.getChildWorkflowExecutionFailedEventAttributes().getWorkflowExecution(); + } + else if (event.getEventType().equals(EventType.ChildWorkflowExecutionTerminated.toString())) { + return event.getChildWorkflowExecutionTerminatedEventAttributes().getWorkflowExecution(); + } + else if (event.getEventType().equals(EventType.ChildWorkflowExecutionTimedOut.toString())) { + return event.getChildWorkflowExecutionTimedOutEventAttributes().getWorkflowExecution(); + } + } + + return null; + } + + public static String getId(HistoryEvent historyEvent) { + String id = null; + if (historyEvent != null) { + if (historyEvent.getEventType().equals(EventType.StartChildWorkflowExecutionFailed.toString())) { + id = historyEvent.getStartChildWorkflowExecutionFailedEventAttributes().getWorkflowId(); + } else if (historyEvent.getEventType().equals(EventType.ScheduleActivityTaskFailed.toString())) { + id = historyEvent.getScheduleActivityTaskFailedEventAttributes().getActivityId(); + } else if (historyEvent.getEventType().equals(EventType.StartTimerFailed.toString())) { + id = historyEvent.getStartTimerFailedEventAttributes().getTimerId(); + } + } + + return id; + } + + public static String getFailureCause(HistoryEvent historyEvent) { + String failureCause = null; + if (historyEvent != null) { + if (historyEvent.getEventType().equals(EventType.StartChildWorkflowExecutionFailed.toString())) { + failureCause = historyEvent.getStartChildWorkflowExecutionFailedEventAttributes().getCause(); + } else if (historyEvent.getEventType().equals(EventType.SignalExternalWorkflowExecutionFailed.toString())) { + failureCause = historyEvent.getSignalExternalWorkflowExecutionFailedEventAttributes().getCause(); + } else if (historyEvent.getEventType().equals(EventType.ScheduleActivityTaskFailed.toString())) { + failureCause = historyEvent.getScheduleActivityTaskFailedEventAttributes().getCause(); + } else if (historyEvent.getEventType().equals(EventType.StartTimerFailed.toString())) { + failureCause = historyEvent.getStartTimerFailedEventAttributes().getCause(); + } else if (historyEvent.getEventType().equals(EventType.ContinueAsNewWorkflowExecutionFailed.toString())) { + failureCause = historyEvent.getContinueAsNewWorkflowExecutionFailedEventAttributes().getCause(); + } + } + + return failureCause; + } + + /** + * Blocks until workflow instance completes. Never use in + * production setting as polling for worklow instance status is an expensive + * operation. + * + * @param workflowExecution + * result of + * {@link AmazonSimpleWorkflow#startWorkflowInstance(com.amazonaws.services.simpleworkflow.model.StartWorkflowInstanceRequest)} + * @return instance close status + */ + public static String waitForWorkflowInstanceCompletion(AmazonSimpleWorkflow service, String domain, + WorkflowExecution workflowExecution) throws InterruptedException { + try { + return waitForWorkflowInstanceCompletion(service, domain, workflowExecution, 0); + } + catch (TimeoutException e) { + throw new Error("should never happen", e); + } + } + + /** + * Waits up to specified timeout for workflow instance completion. + * Never use in production setting as polling for worklow + * instance status is an expensive operation. + * + * @param workflowExecution + * result of + * {@link AmazonSimpleWorkflow#startWorkflowInstance(com.amazonaws.services.simpleworkflow.model.StartWorkflowInstanceRequest)} + * @param timeoutSeconds + * maximum time to wait for completion. 0 means wait forever. + * @return instance close status + * @throws TimeoutException + */ + public static String waitForWorkflowInstanceCompletion(AmazonSimpleWorkflow service, String domain, + WorkflowExecution workflowExecution, long timeoutSeconds) + throws InterruptedException, TimeoutException { + long start = System.currentTimeMillis(); + WorkflowExecutionInfo executionInfo = null; + do { + if (timeoutSeconds > 0 && System.currentTimeMillis() - start >= timeoutSeconds * 1000) { + String historyDump = WorkflowExecutionUtils.prettyPrintHistory(service, domain, workflowExecution); + throw new TimeoutException("Workflow instance is not complete after " + timeoutSeconds + " seconds: \n" + + historyDump); + } + if (executionInfo != null) { + Thread.sleep(1000); + } + executionInfo = describeWorkflowInstance(service, domain, workflowExecution); + } + while (executionInfo.getExecutionStatus().equals(ExecutionStatus.OPEN.toString())); + return executionInfo.getCloseStatus(); + } + + /** + * Like + * {@link #waitForWorkflowInstanceCompletion(AmazonSimpleWorkflow, String, WorkflowExecution, long)} + * , except will wait for continued generations of the original workflow + * execution too. + * + * @param service + * @param domain + * @param workflowExecution + * @param timeoutSeconds + * @return + * @throws InterruptedException + * @throws TimeoutException + * + * @see #waitForWorkflowInstanceCompletion(AmazonSimpleWorkflow, String, + * WorkflowExecution, long) + */ + public static String waitForWorkflowInstanceCompletionAcrossGenerations(AmazonSimpleWorkflow service, String domain, + WorkflowExecution workflowExecution, long timeoutSeconds) throws InterruptedException, TimeoutException { + + WorkflowExecution lastExecutionToRun = workflowExecution; + long millisecondsAtFirstWait = System.currentTimeMillis(); + String lastExecutionToRunCloseStatus = waitForWorkflowInstanceCompletion(service, domain, lastExecutionToRun, + timeoutSeconds); + + // keep waiting if the instance continued as new + while (lastExecutionToRunCloseStatus.equals(CloseStatus.CONTINUED_AS_NEW.toString())) { + // get the new execution's information + HistoryEvent closeEvent = getInstanceCloseEvent(service, domain, lastExecutionToRun); + WorkflowExecutionContinuedAsNewEventAttributes continuedAsNewAttributes = closeEvent.getWorkflowExecutionContinuedAsNewEventAttributes(); + + WorkflowExecution newGenerationExecution = new WorkflowExecution().withWorkflowId(lastExecutionToRun.getWorkflowId()).withRunId( + continuedAsNewAttributes.getNewExecutionRunId()); + + // and wait for it + long currentTime = System.currentTimeMillis(); + long millisecondsSinceFirstWait = currentTime - millisecondsAtFirstWait; + long timeoutInSecondsForNextWait = timeoutSeconds - (millisecondsSinceFirstWait / 1000L); + + lastExecutionToRunCloseStatus = waitForWorkflowInstanceCompletion(service, domain, newGenerationExecution, timeoutInSecondsForNextWait); + lastExecutionToRun = newGenerationExecution; + } + + return lastExecutionToRunCloseStatus; + } + + /** + * Like + * {@link #waitForWorkflowInstanceCompletionAcrossGenerations(AmazonSimpleWorkflow, String, WorkflowExecution, long)} + * , but with no timeout. + * + * @param service + * @param domain + * @param workflowExecution + * @return + * @throws InterruptedException + */ + public static String waitForWorkflowInstanceCompletionAcrossGenerations(AmazonSimpleWorkflow service, String domain, + WorkflowExecution workflowExecution) throws InterruptedException { + try { + return waitForWorkflowInstanceCompletionAcrossGenerations(service, domain, workflowExecution, 0L); + } + catch (TimeoutException e) { + throw new Error("should never happen", e); + } + } + + public static WorkflowExecutionInfo describeWorkflowInstance(AmazonSimpleWorkflow service, String domain, + WorkflowExecution workflowExecution) { + DescribeWorkflowExecutionRequest describeRequest = new DescribeWorkflowExecutionRequest(); + describeRequest.setDomain(domain); + describeRequest.setExecution(workflowExecution); + WorkflowExecutionDetail executionDetail = service.describeWorkflowExecution(describeRequest); + WorkflowExecutionInfo instanceMetadata = executionDetail.getExecutionInfo(); + return instanceMetadata; + } + + /** + * Returns workflow instance history in a human readable format. + * + * @param workflowExecution + * result of + * {@link AmazonSimpleWorkflow#startWorkflowInstance(com.amazonaws.services.simpleworkflow.model.StartWorkflowInstanceRequest)} + */ + public static String prettyPrintHistory(AmazonSimpleWorkflow service, String domain, WorkflowExecution workflowExecution) { + return prettyPrintHistory(service, domain, workflowExecution, true); + } + + /** + * Returns workflow instance history in a human readable format. + * + * @param workflowExecution + * result of + * {@link AmazonSimpleWorkflow#startWorkflowInstance(com.amazonaws.services.simpleworkflow.model.StartWorkflowInstanceRequest)} + * @param showWorkflowTasks + * when set to false workflow task events (decider events) are + * not included + */ + public static String prettyPrintHistory(AmazonSimpleWorkflow service, String domain, WorkflowExecution workflowExecution, + boolean showWorkflowTasks) { + List events = getHistory(service, domain, workflowExecution); + return prettyPrintHistory(events, showWorkflowTasks); + } + + public static List getHistory(AmazonSimpleWorkflow service, String domain, + WorkflowExecution workflowExecution) { + List events = new ArrayList(); + String nextPageToken = null; + do { + History history = getHistoryPage(nextPageToken, service, domain, workflowExecution); + events.addAll(history.getEvents()); + nextPageToken = history.getNextPageToken(); + } + while (nextPageToken != null); + return events; + } + + public static History getHistoryPage(String nextPageToken, AmazonSimpleWorkflow service, String domain, + WorkflowExecution workflowExecution) { + + GetWorkflowExecutionHistoryRequest getHistoryRequest = new GetWorkflowExecutionHistoryRequest(); + getHistoryRequest.setDomain(domain); + getHistoryRequest.setExecution(workflowExecution); + getHistoryRequest.setNextPageToken(nextPageToken); + + History history = service.getWorkflowExecutionHistory(getHistoryRequest); + if (history == null) { + throw new IllegalArgumentException("unknown workflow execution: " + workflowExecution); + } + return history; + } + + /** + * Returns workflow instance history in a human readable format. + * + * @history Workflow instance history + * @param showWorkflowTasks + * when set to false workflow task events (decider events) are + * not included + */ + public static String prettyPrintHistory(History history, boolean showWorkflowTasks) { + return prettyPrintHistory(history.getEvents(), showWorkflowTasks); + } + + public static String prettyPrintHistory(Iterable events, boolean showWorkflowTasks) { + StringBuffer result = new StringBuffer(); + result.append("{"); + boolean first = true; + for (HistoryEvent event : events) { + if (!showWorkflowTasks && event.getEventType().startsWith("WorkflowTask")) { + continue; + } + if (first) { + first = false; + } + else { + result.append(","); + } + result.append("\n "); + result.append(prettyPrintHistoryEvent(event)); + } + result.append("\n}"); + return result.toString(); + } + + public static String prettyPrintDecisions(Iterable decisions) { + StringBuffer result = new StringBuffer(); + result.append("{"); + boolean first = true; + for (Decision decision : decisions) { + if (first) { + first = false; + } + else { + result.append(","); + } + result.append("\n "); + result.append(prettyPrintDecision(decision)); + } + result.append("\n}"); + return result.toString(); + } + + /** + * Returns single event in a human readable format + * + * @param event + * event to pretty print + */ + public static String prettyPrintHistoryEvent(HistoryEvent event) { + String eventType = event.getEventType(); + StringBuffer result = new StringBuffer(); + result.append(eventType); + result.append(prettyPrintObject(event, "getType", true, " ", false)); + return result.toString(); + } + + /** + * Returns single decision in a human readable format + * + * @param event + * event to pretty print + */ + public static String prettyPrintDecision(Decision decision) { + return prettyPrintObject(decision, "getType", true, " ", true); + } + + /** + * Not really a generic method for printing random object graphs. But it + * works for events and decisions. + */ + private static String prettyPrintObject(Object object, String methodToSkip, boolean skipNullsAndEmptyCollections, + String indentation, boolean skipLevel) { + StringBuffer result = new StringBuffer(); + if (object == null) { + return "null"; + } + Class clz = object.getClass(); + if (Number.class.isAssignableFrom(clz)) { + return String.valueOf(object); + } + if (Boolean.class.isAssignableFrom(clz)) { + return String.valueOf(object); + } + if (clz.equals(String.class)) { + return (String) object; + } + if (clz.equals(Date.class)) { + return String.valueOf(object); + } + if (Map.class.isAssignableFrom(clz)) { + return String.valueOf(object); + } + if (Collection.class.isAssignableFrom(clz)) { + return String.valueOf(object); + } + if (!skipLevel) { + result.append(" {"); + } + Method[] eventMethods = object.getClass().getMethods(); + boolean first = true; + for (Method method : eventMethods) { + String name = method.getName(); + if (!name.startsWith("get")) { + continue; + } + if (name.equals(methodToSkip) || name.equals("getClass")) { + continue; + } + if (Modifier.isStatic(method.getModifiers())) { + continue; + } + Object value; + try { + value = method.invoke(object, (Object[]) null); + if (value != null && value.getClass().equals(String.class) && name.equals("getDetails")) { + value = printDetails((String) value); + } + } + catch (InvocationTargetException e) { + throw new RuntimeException(e.getTargetException()); + } + catch (RuntimeException e) { + throw (RuntimeException) e; + } + catch (Exception e) { + throw new RuntimeException(e); + } + if (skipNullsAndEmptyCollections) { + if (value == null) { + continue; + } + if (value instanceof Map && ((Map) value).isEmpty()) { + continue; + } + if (value instanceof Collection && ((Collection) value).isEmpty()) { + continue; + } + } + if (!skipLevel) { + if (first) { + first = false; + } + else { + result.append(";"); + } + result.append("\n"); + result.append(indentation); + result.append(" "); + result.append(name.substring(3)); + result.append(" = "); + result.append(prettyPrintObject(value, methodToSkip, skipNullsAndEmptyCollections, indentation + " ", false)); + } + else { + result.append(prettyPrintObject(value, methodToSkip, skipNullsAndEmptyCollections, indentation, false)); + } + } + if (!skipLevel) { + result.append("\n"); + result.append(indentation); + result.append("}"); + } + return result.toString(); + } + + public static String printDetails(String details) { + Throwable failure = null; + try { + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.enableDefaultTyping(DefaultTyping.NON_FINAL); + + failure = mapper.readValue(details, Throwable.class); + } catch (Exception e) { + // eat up any data converter exceptions + } + + if (failure != null) { + StringBuilder builder = new StringBuilder(); + + // Also print callstack + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + failure.printStackTrace(pw); + + builder.append(sw.toString()); + + details = builder.toString(); + } + + return details; + } + + /** + * Simple Workflow limits length of the reason field. This method truncates + * the passed argument to the maximum length. + * + * @param reason + * string value to truncate + * @return truncated value + */ + public static String truncateReason(String reason) { + if (reason != null && reason.length() > FlowValueConstraint.FAILURE_REASON.getMaxSize()) { + reason = reason.substring(0, FlowValueConstraint.FAILURE_REASON.getMaxSize()); + } + return reason; + } + + public static String truncateDetails(String details) { + if (details != null && details.length() > FlowValueConstraint.FAILURE_DETAILS.getMaxSize()) { + details = details.substring(0, FlowValueConstraint.FAILURE_DETAILS.getMaxSize()); + } + return details; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AndPromise.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AndPromise.java new file mode 100644 index 000000000000..18094156e07b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AndPromise.java @@ -0,0 +1,94 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +import java.util.Collection; + +/** + * Promise that becomes ready when all its values are ready. null + * value is considered ready. + */ +public class AndPromise extends Promise { + + private final class AndPromiseCallback implements Runnable { + + private int count; + + AndPromiseCallback(int count) { + this.count = count; + } + + @Override + public void run() { + if (--count == 0) { + impl.set(null); + } + } + } + + private static final Promise[] EMPTY_VALUE_ARRAY = new Promise[0]; + + private final Settable impl = new Settable(); + + @SuppressWarnings("rawtypes") + private final Promise[] values; + + public AndPromise(Promise... values) { + this.values = values; + if (values.length == 0) { + impl.set(null); + } + Runnable callback = new AndPromiseCallback(values.length); + for (Promise value : values) { + if (value != null) { + value.addCallback(callback); + } + else { + callback.run(); + } + } + } + + @SuppressWarnings({ "rawtypes" }) + public AndPromise(Collection collection) { + this(collection.toArray(EMPTY_VALUE_ARRAY)); + } + + @SuppressWarnings("rawtypes") + public Promise[] getValues() { + return values; + } + + @Override + protected void addCallback(Runnable callback) { + impl.addCallback(callback); + } + + @Override + public Void get() { + return impl.get(); + } + + @Override + public boolean isReady() { + return impl.isReady(); + } + + @Override + protected void removeCallback(Runnable callback) { + impl.removeCallback(callback); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncContextAware.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncContextAware.java new file mode 100644 index 000000000000..35d8857beafd --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncContextAware.java @@ -0,0 +1,22 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + + +abstract class AsyncContextAware { + + abstract AsyncParentContext getContext(); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncContextBase.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncContextBase.java new file mode 100644 index 000000000000..a567c5b09f1e --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncContextBase.java @@ -0,0 +1,113 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +import java.util.ArrayList; +import java.util.List; + +abstract class AsyncContextBase implements Runnable, AsyncParentContext { + + private final static ThreadLocal currentContext = new ThreadLocal(); + + static AsyncParentContext current() { + AsyncParentContext result = currentContext.get(); + if (result == null) { + throw new IllegalStateException("Attempt to execute asynchronous code outside of AsyncScope.doAsync() method"); + } + return result; + } + + static void setCurrent(AsyncParentContext newCurrent) { + currentContext.set(newCurrent); + } + + private final boolean daemon; + + protected final AsyncParentContext parent; + + protected AsyncStackTrace stackTrace; + + private final Promise[] waitFor; + + private String name; + + public AsyncContextBase(Boolean daemon, Promise[] waitFor, int skipStackLines) { + this(current(), daemon, waitFor, skipStackLines); + } + + public AsyncContextBase(AsyncParentContext parent, Boolean daemon, Promise[] waitFor, int skipStackLines) { + this.parent = parent; + this.daemon = daemon == null ? parent.getDaemonFlagForHeir() : daemon; + this.waitFor = waitFor; + this.name = parent == null ? null : parent.getName(); + AsyncStackTrace parentStack = parent.getStackTrace(); + if (parentStack != null) { + stackTrace = new AsyncStackTrace(parentStack, Thread.currentThread().getStackTrace(), skipStackLines); + stackTrace.setStartFrom(parent.getParentTaskMethodName()); + stackTrace.setHideStartFromMethod(parent.getHideStartFromMethod()); + } + this.parent.add(this, waitFor == null || waitFor.length == 0 ? null : new AndPromise(waitFor)); + } + + public boolean isDaemon() { + return daemon; + } + + public AsyncStackTrace getStackTrace() { + return stackTrace; + } + + public AsyncTaskInfo getTaskInfo() { + return new AsyncTaskInfo(name, stackTrace == null ? null : stackTrace.getStackTrace(), daemon, waitFor); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * @param cause + * the cancellation cause. Can be null + */ + public abstract void cancel(Throwable cause); + + public String getAsynchronousStackTraceDumpAsString() { + List infos = new ArrayList(); + getAsynchronousStackTraceDump(infos); + StringBuffer sb = new StringBuffer(); + for (int j = 0; j < infos.size(); j++) { + AsyncTaskInfo info = infos.get(j); + if (j > 0) { + sb.append("-----------------------------------------------------\n"); + } + sb.append(info); + } + return sb.toString(); + } + + @Override + public boolean getHideStartFromMethod() { + return false; + } + + protected void getAsynchronousStackTraceDump(List result) { + result.add(getTaskInfo()); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncEventLoop.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncEventLoop.java new file mode 100644 index 000000000000..ac7aeb4cfa28 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncEventLoop.java @@ -0,0 +1,50 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +import java.util.LinkedList; +import java.util.Queue; +import java.util.concurrent.Executor; + +class AsyncEventLoop implements Executor { + + private final Queue tasks = new LinkedList(); + + @Override + public void execute(Runnable task) { + synchronized (tasks) { + tasks.add(task); + } + } + + public void executeAllQueued() { + while (executeQueuedTask()) { + + } + } + + public boolean executeQueuedTask() { + synchronized (tasks) { + Runnable task = tasks.peek(); + if (task == null) { + return false; + } + task.run(); + tasks.remove(); + return true; + } + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncParentContext.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncParentContext.java new file mode 100644 index 000000000000..f47f898d410b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncParentContext.java @@ -0,0 +1,48 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +import java.util.concurrent.Executor; + +interface AsyncParentContext { + + void add(AsyncContextBase async, Promise waitFor); + + void remove(AsyncContextBase async); + + void fail(AsyncContextBase async, Throwable e); + + /** + * Only Task passes daemon flag to its heirs. Daemon TryCatchFinally doesn't + * pass it to heirs as cancellation of the daemon TryCatchFinally causes + * heirs cancellation independently of their daemon status. + */ + boolean getDaemonFlagForHeir(); + + Executor getExecutor(); + + AsyncStackTrace getStackTrace(); + + String getParentTaskMethodName(); + + boolean isRethrown(Throwable e); + + AsyncParentContext getCurrentTryCatchFinallyContext(); + + boolean getHideStartFromMethod(); + + String getName(); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncScope.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncScope.java new file mode 100644 index 000000000000..c55506aa0c9e --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncScope.java @@ -0,0 +1,92 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +import java.util.List; + +/** + * Interface between synchronous and asynchronous code. Serves as a root scope + * for asynchronous computation and as event loop for the owning synchronous + * code. + * + * @author fateev + */ +public abstract class AsyncScope extends AsyncContextAware implements Cancelable { + + private final AsyncScopeContext context; + + public AsyncScope() { + // The reason this(...) is not called is to keep the same stack depth for both constructors. + // It simplifies creation of async stack traces + this.context = new AsyncScopeContext(this, false, false); + } + + public AsyncScope(boolean disableAsyncStackTrace, boolean excludeAsyncScopeStack) { + this.context = new AsyncScopeContext(this, disableAsyncStackTrace, excludeAsyncScopeStack); + } + + public void cancel(Throwable cause) { + context.cancel(cause); + } + + @Override + public boolean isCancelRequested() { + return context.isCancelRequested(); + } + + + + public List getAsynchronousThreadDump() { + return context.getAsynchronousStackTraceDump(); + } + + public String getAsynchronousThreadDumpAsString() { + return context.getAsynchronousStackTraceDumpAsString(); + } + + /** + * Execute all queued tasks. If execution of those tasks result in addition + * of new tasks to the queue execute them as well. + *

+ * Unless there are external dependencies or bugs single call to this method + * performs the complete asynchronous execution. + *

+ * In presence of external dependencies it is expected that + * eventLoop() is called every time after change in their state + * can unblock the asynchronous execution. + * + * @return true means there are no tasks originated from this scope that are + * not done yet. + */ + public boolean eventLoop() throws Throwable { + return context.eventLoop(); + } + + public boolean isComplete() { + return context.isComplete(); + } + + public Throwable getFailure() { + return context.getFailure(); + } + + @Override + AsyncParentContext getContext() { + return context.getRootContext(); + } + + protected abstract void doAsync() throws Throwable; + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncScopeContext.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncScopeContext.java new file mode 100644 index 000000000000..a0cbf69b51e6 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncScopeContext.java @@ -0,0 +1,195 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +import java.util.List; +import java.util.concurrent.Executor; + +class AsyncScopeContext { + + private final class RootTryCatchFinally extends TryCatchFinally { + + private RootTryCatchFinally(boolean daemon, int skipStackLines) { + super(daemon, "doAsync", skipStackLines, new Promise[0]); + } + + @Override + protected void doTry() throws Throwable { + asyncScope.doAsync(); + } + + @Override + protected void doCatch(Throwable e) throws Throwable { + throw e; + } + + @Override + protected void doFinally() { + } + + @Override + AsyncParentContext getContext() { + if (super.getState() != TryCatchFinally.State.CREATED && super.getState() != TryCatchFinally.State.TRYING) { + throw new IllegalStateException("Already executed"); + } + return super.getContext(); + } + + } + + private final class RootAsyncContext implements AsyncParentContext { + + @Override + public void remove(AsyncContextBase async) { + assert !complete; + complete = true; + } + + @Override + public Executor getExecutor() { + return executor; + } + + @Override + public void fail(AsyncContextBase async, Throwable e) { + assert !complete; + failure = e; + complete = true; + } + + @Override + public void add(AsyncContextBase async, Promise waitFor) { + if (waitFor != null) { + throw new IllegalArgumentException(); + } + executor.execute(async); + } + + @Override + public AsyncStackTrace getStackTrace() { + return stackTrace; + } + + @Override + public boolean isRethrown(Throwable e) { + throw new IllegalStateException("should not be called"); + } + + @Override + public AsyncParentContext getCurrentTryCatchFinallyContext() { + throw new IllegalStateException("should not be called"); + } + + @Override + public boolean getDaemonFlagForHeir() { + return false; + } + + @Override + public String getParentTaskMethodName() { + return null; + } + + @Override + public boolean getHideStartFromMethod() { + return false; + } + + @Override + public String getName() { + return name; + } + } + + private final AsyncScope asyncScope; + + private boolean complete; + + private Throwable failure; + + private AsyncEventLoop executor; + + private TryCatchFinally root; + + private AsyncStackTrace stackTrace; + + private String name; + + public AsyncScopeContext(AsyncScope asyncScope, boolean disableAsyncStackTrace, boolean excludeAsyncScopeStack) { + this.asyncScope = asyncScope; + if (!disableAsyncStackTrace) { + stackTrace = new AsyncStackTrace(null, new StackTraceElement[0], 0); + } + executor = new AsyncEventLoop(); + AsyncParentContext rootContext = new RootAsyncContext(); + AsyncContextBase.setCurrent(rootContext); + try { + int skipStackLines = excludeAsyncScopeStack ? Integer.MAX_VALUE : 10; + root = new RootTryCatchFinally(false, skipStackLines); + } + finally { + AsyncContextBase.setCurrent(null); + } + } + + public boolean eventLoop() throws Throwable { + if (complete) { + throw new IllegalStateException("already complete"); + } + executor.executeAllQueued(); + if (complete && failure != null) { + throw failure; + } + return complete; + } + + + public boolean isComplete() { + return complete; + } + + public Throwable getFailure() { + return failure; + } + + public void cancel(Throwable cause) { + root.cancel(cause); + } + + public boolean isCancelRequested() { + return root.isCancelRequested(); + } + + public List getAsynchronousStackTraceDump() { + return root.getAsynchronousStackTraceDump(); + } + + public String getAsynchronousStackTraceDumpAsString() { + return root.getAsynchronousStackTraceDumpAsString(); + } + + public AsyncParentContext getRootContext() { + return root.getContext(); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncStackTrace.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncStackTrace.java new file mode 100644 index 000000000000..bb8b5a0cea62 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncStackTrace.java @@ -0,0 +1,144 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +import java.util.ArrayList; +import java.util.List; + +/** + *

+ * TODO: Deal with repeating async stack frames due to recursion. 
+ * So
+ * at a
+ * at -- continuation -- (repeated:1)
+ * at b
+ * at -- continuation -- (repeated:1)
+ * at c
+ * at -- continuation -- (repeated:1)
+ * at d
+ * at -- continuation -- (repeated:1)
+ * at c
+ * at -- continuation -- (repeated:1)
+ * at d
+ * 
+ * Should become something like + *
+ * at a
+ * at -- continuation -- (repeated:1)
+ * at b
+ * at -- continuation -- (repeated:2)
+ *   at c
+ *   at -- continuation -- (repeated:1)
+ *   at d
+ *  
+ */ +class AsyncStackTrace { + + private final StackTraceElement[] stackTrace; + + private final AsyncStackTrace parentTrace; + + private String startFrom; + + private boolean hideStartFromMethod; + + private final int skip; + + /** + * When set to true disables the removal of any stack elements. + * Useful for troubleshooting the broken traces. + */ + private static final boolean printRawTrace = false; + + public AsyncStackTrace(AsyncStackTrace parentTrace, StackTraceElement[] stackTrace, int skip) { + super(); + this.parentTrace = parentTrace; + this.stackTrace = stackTrace; + this.skip = skip; + } + + public StackTraceElement[] getStackTrace() { + if (printRawTrace) { + return printRawTrace(); + } + List result = new ArrayList(); + getStackTrace(result); + return result.toArray(new StackTraceElement[0]); + } + + private void getStackTrace(List result) { + for (int i = skip; i < stackTrace.length; i++) { + StackTraceElement element = stackTrace[i]; + if (i == skip && result.size() > 0) { + StackTraceElement separator = new StackTraceElement("--- continuation ---", "", "", 0); + result.add(separator); + } + if (startFrom != null && element.getMethodName().contains(startFrom)) { + if (!hideStartFromMethod) { + result.add(element); + } + break; + } + result.add(element); + } + if (parentTrace != null) { + parentTrace.getStackTrace(result); + } + } + + private StackTraceElement[] printRawTrace() { + if (parentTrace != null) { + StackTraceElement[] parentStack = parentTrace.getStackTrace(); + int parentLength = parentStack.length; + if (parentLength > 0) { + StackTraceElement separator = new StackTraceElement("---continuation---", "", "", 0); + StackTraceElement[] result = new StackTraceElement[stackTrace.length + parentLength + 1]; + System.arraycopy(stackTrace, 0, result, 0, stackTrace.length); + result[stackTrace.length] = separator; + System.arraycopy(parentStack, 0, result, stackTrace.length + 1, parentLength); + return result; + } + } + return stackTrace; + } + + public void setStartFrom(String startFrom) { + this.startFrom = startFrom; + } + + public void setHideStartFromMethod(boolean hideStartFromMethod) { + this.hideStartFromMethod = hideStartFromMethod; + } + + public String toString() { + return stackTraceToString(getStackTrace()); + } + + private String stackTraceToString(StackTraceElement[] trace) { + StringBuffer result = new StringBuffer(); + for (int i = 0; i < trace.length; i++) { + if (i > 0) { + result.append("\n\tat "); + } + else { + result.append("\tat "); + } + result.append(trace[i]); + } + return result.toString(); + } + + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncTaskInfo.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncTaskInfo.java new file mode 100644 index 000000000000..c51585c60568 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/AsyncTaskInfo.java @@ -0,0 +1,118 @@ +package com.amazonaws.services.simpleworkflow.flow.core; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +public final class AsyncTaskInfo { + + private final StackTraceElement[] asyncStackTrace; + + private final boolean daemon; + + private final Promise[] waitingFor; + + private final String name; + + public AsyncTaskInfo(String name, StackTraceElement[] asyncStackTrace, boolean daemon, Promise[] waitFor) { + this.name = name; + this.asyncStackTrace = asyncStackTrace; + this.daemon = daemon; + this.waitingFor = waitFor; + } + + public String getName() { + return name; + } + + public StackTraceElement[] getAsyncStackTrace() { + return asyncStackTrace; + } + + public boolean isDaemon() { + return daemon; + } + + public Promise[] getWaitingFor() { + return waitingFor; + } + + @Override + public String toString() { + StringBuilder result = new StringBuilder(); + if (name != null) { + result.append("\""); + result.append(name); + result.append("\""); + } + if (daemon) { + if (result.length() > 0) { + result.append(" "); + } + result.append("daemon"); + } + if (waitingFor != null) { + Map waitingOnArguments = new HashMap(); + for (int i = 0; i < waitingFor.length; i++) { + Promise promise = waitingFor[i]; + if (promise != null && !promise.isReady()) { + if (promise instanceof AndPromise) { + AndPromise andPromise = (AndPromise) promise; + Promise[] elements = andPromise.getValues(); + StringBuilder description = new StringBuilder(); + description.append("PromiseCollection["); + for (int j = 0; j < elements.length; j++) { + Promise e = elements[j]; + String d = e.getDescription(); + if (d != null) { + description.append(j); + description.append(":\""); + description.append(d); + description.append("\""); + } + } + description.append("]"); + waitingOnArguments.put(i + 1, description.toString()); + } + else { + waitingOnArguments.put(i + 1, promise.getDescription()); + } + } + } + if (waitingOnArguments.size() > 0) { + if (result.length() > 0) { + result.append(" "); + } + result.append("waiting on argument"); + if (waitingOnArguments.size() > 1) { + result.append("s"); + } + result.append(" (starting from 1)"); + for (Entry pair : waitingOnArguments.entrySet()) { + result.append(" "); + result.append(pair.getKey()); + String description = pair.getValue(); + if (description != null) { + result.append(":\""); + result.append(description); + result.append("\""); + } + } + } + } + if (result.length() > 0) { + result.append("\n"); + } + if (asyncStackTrace != null) { + for (int i = 0; i < asyncStackTrace.length; i++) { + result.append("\tat "); + result.append(asyncStackTrace[i]); + result.append("\n"); + } + } + else { + result.append("Async Trace is Disabled."); + } + return result.toString(); + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Cancelable.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Cancelable.java new file mode 100644 index 000000000000..260390f22cee --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Cancelable.java @@ -0,0 +1,24 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + + +public interface Cancelable { + + public void cancel(Throwable cause); + + public boolean isCancelRequested(); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/ExternalTask.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/ExternalTask.java new file mode 100644 index 000000000000..7d691747ff64 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/ExternalTask.java @@ -0,0 +1,64 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +/** + * Used to bridge asynchronous execution to external asynchronous APIs or + * events. {@link ExternalTask#doExecute(handle)} method is expected to initiate + * call to an external API and return without blocking. Then completion or + * failure of the external task is reported through + * {@link ExternalTaskCompletionHandle}. A cancellation handler returned by the + * doExecute is used to report cancellation of the external task. + */ +public abstract class ExternalTask extends AsyncContextAware { + + private final ExternalTaskContext context; + + public ExternalTask(Promise... waitFor) { + context = new ExternalTaskContext(this, null, waitFor); + } + + public ExternalTask(boolean daemon, Promise... waitFor) { + context = new ExternalTaskContext(this, daemon, waitFor); + } + + public ExternalTask(AsyncContextAware parent, Promise... waitFor) { + context = new ExternalTaskContext(parent.getContext(), this, null, waitFor); + } + + public ExternalTask(AsyncContextAware parent, boolean daemon, Promise... waitFor) { + context = new ExternalTaskContext(parent.getContext(), this, daemon, waitFor); + } + + public String getName() { + return context.getName(); + } + + public void setName(String name) { + context.setName(name); + } + + public StackTraceElement[] getStackTrace() { + return context.getStackTrace().getStackTrace(); + } + + @Override + AsyncParentContext getContext() { + return context; + } + + protected abstract ExternalTaskCancellationHandler doExecute(ExternalTaskCompletionHandle handle) throws Throwable; + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/ExternalTaskCancellationHandler.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/ExternalTaskCancellationHandler.java new file mode 100644 index 000000000000..875cb8a1de08 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/ExternalTaskCancellationHandler.java @@ -0,0 +1,29 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +public interface ExternalTaskCancellationHandler { + + /** + * Called when cancellation of the external task is requested. Use + * {@link ExternalTaskCompletionHandle#complete()} to report task successful + * completion or cancellation. Use + * {@link ExternalTaskCompletionHandle#fail(Throwable)} to report task + * completion or cancellation failure. + * @param cause the reason for the cancellation. May be null. + */ + public void handleCancellation(Throwable cause); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/ExternalTaskCompletionHandle.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/ExternalTaskCompletionHandle.java new file mode 100644 index 000000000000..f1685c7e74c7 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/ExternalTaskCompletionHandle.java @@ -0,0 +1,34 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +/** + * Used to complete or fail an external task initiated through + * {@link ExternalTask#doExecute(ExternalTaskCompletionHandle)}. + *

+ * Flow framework is not thread safe and expects that all asynchronous code is + * executed in a single thread. Currently ExternalTaskCompletionHandle is the + * only exception as it allows {@link #complete()} and {@link #fail(Throwable)} + * be called from other threads. + * + * @author fateev + */ +public interface ExternalTaskCompletionHandle { + + public void complete(); + + public void fail(Throwable e); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/ExternalTaskContext.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/ExternalTaskContext.java new file mode 100644 index 000000000000..fef855b35e62 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/ExternalTaskContext.java @@ -0,0 +1,238 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +import java.util.concurrent.Executor; + +class ExternalTaskContext extends AsyncContextBase { + + private final class ExternalTaskCompletionHandleImpl implements ExternalTaskCompletionHandle { + + private String methodName; + + private boolean completed; + + private Throwable failure; + + private void setDoExecuteFailed(String methodName, Throwable e) { + this.failure = e; + this.methodName = methodName; + } + + @Override + public void complete() { + if (failure != null) { + throw new IllegalStateException("Invalid ExternalTaskCompletionHandle as " + methodName + + " failed with an exception.", failure); + } + if (completed) { + throw new IllegalStateException("Already completed"); + } + completed = true; + if (!inCancellationHandler) { + removeFromParent(); + } + } + + @Override + public void fail(final Throwable e) { + if (failure != null) { + throw new IllegalStateException("Invalid ExternalTaskCompletionHandle as " + methodName + + " failed with exception.", failure); + } + if (completed) { + throw new IllegalStateException("Already completed"); + } + if (stackTrace != null && !parent.isRethrown(e)) { + AsyncStackTrace merged = new AsyncStackTrace(stackTrace, e.getStackTrace(), 0); + merged.setStartFrom(getParentTaskMethodName()); + e.setStackTrace(merged.getStackTrace()); + } + failure = e; + if (!inCancellationHandler) { + failToParent(e); + } + } + + public boolean isCompleted() { + return completed; + } + + public Throwable getFailure() { + return failure; + } + + } + + private final ExternalTask task; + + private ExternalTaskCancellationHandler cancellationHandler; + + private boolean canceled; + + /** + * Used to deal with situation when task is completed while in cancellation + * handler and then exception is thrown from it. + */ + private boolean inCancellationHandler; + + private ExternalTaskCompletionHandleImpl completionHandle = new ExternalTaskCompletionHandleImpl(); + + private String description; + + public ExternalTaskContext(ExternalTask task, Boolean daemon, Promise[] waitFor) { + super(daemon, waitFor, 6); + this.task = task; + } + + public ExternalTaskContext(AsyncParentContext parent, ExternalTask task, Boolean daemon, Promise[] waitFor) { + super(parent, daemon, waitFor, 6); + this.task = task; + } + + public void cancel(final Throwable cause) { + if (completionHandle.failure != null || completionHandle.completed) { + return; + } + if (canceled) { + return; + } + canceled = true; + if (cancellationHandler != null) { + parent.getExecutor().execute(new Runnable() { + + @Override + public void run() { + try { + inCancellationHandler = true; + cancellationHandler.handleCancellation(cause); + } + catch (Throwable e) { + if (stackTrace != null && !parent.isRethrown(e)) { + AsyncStackTrace merged = new AsyncStackTrace(stackTrace, e.getStackTrace(), 0); + merged.setStartFrom(getParentTaskMethodName()); + e.setStackTrace(merged.getStackTrace()); + } + completionHandle.setDoExecuteFailed("ExternalTaskCancellationHandler.handleCancellation", e); + } + finally { + inCancellationHandler = false; + if (completionHandle.getFailure() != null) { + failToParent(completionHandle.getFailure()); + } + else if (completionHandle.isCompleted()) { + removeFromParent(); + } + } + } + }); + } + } + + @Override + public void run() { + if (canceled) { + return; + } + setCurrent(parent); + try { + cancellationHandler = task.doExecute(completionHandle); + } + catch (Throwable e) { + completionHandle.setDoExecuteFailed("ExternalTask.doExecute", e); + if (stackTrace != null && !parent.isRethrown(e)) { + AsyncStackTrace merged = new AsyncStackTrace(stackTrace, e.getStackTrace(), 0); + merged.setStartFrom(getParentTaskMethodName()); + e.setStackTrace(merged.getStackTrace()); + } + parent.fail(this, e); + } + finally { + setCurrent(null); + } + } + + @Override + public void add(AsyncContextBase async, Promise waitFor) { + parent.add(async, waitFor); + } + + @Override + public void remove(AsyncContextBase async) { + parent.remove(async); + } + + @Override + public void fail(AsyncContextBase async, Throwable e) { + parent.fail(async, e); + } + + @Override + public Executor getExecutor() { + return parent.getExecutor(); + } + + @Override + public boolean isRethrown(Throwable e) { + return parent.isRethrown(e); + } + + @Override + public AsyncParentContext getCurrentTryCatchFinallyContext() { + return parent; + } + + @Override + public boolean getDaemonFlagForHeir() { + return isDaemon(); + } + + @Override + public String getParentTaskMethodName() { + if (canceled) { + return "handleCancellation"; + } + return "doExecute"; + } + + private void removeFromParent() { + parent.getExecutor().execute(new Runnable() { + + @Override + public void run() { + parent.remove(ExternalTaskContext.this); + } + }); + } + + private void failToParent(final Throwable e) { + parent.getExecutor().execute(new Runnable() { + + @Override + public void run() { + parent.fail(ExternalTaskContext.this, e); + } + }); + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return description; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Functor.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Functor.java new file mode 100644 index 000000000000..ed0e7b3895c4 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Functor.java @@ -0,0 +1,52 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +public abstract class Functor extends Promise { + + private final Settable result = new Settable(); + + public Functor(Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + result.chain(Functor.this.doExecute()); + } + }; + } + + protected abstract Promise doExecute() throws Throwable; + + @Override + public T get() { + return result.get(); + } + + @Override + public boolean isReady() { + return result.isReady(); + } + + @Override + protected void addCallback(Runnable callback) { + result.addCallback(callback); + } + + @Override + protected void removeCallback(Runnable callback) { + result.removeCallback(callback); + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/OrPromise.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/OrPromise.java new file mode 100644 index 000000000000..9fef2fe2651d --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/OrPromise.java @@ -0,0 +1,74 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +/** + * Promise that becomes ready when any of its values becomes ready. + * null value is considered ready. + */ +public class OrPromise extends Promise { + + private final class OrPromiseCallback implements Runnable { + + @Override + public void run() { + if (!impl.isReady()) { + impl.set(null); + } + } + } + + private final Settable impl = new Settable(); + + private final Promise[] values; + + public OrPromise(Promise... values) { + this.values = values; + Runnable callback = new OrPromiseCallback(); + for (Promise value : values) { + if (value != null) { + value.addCallback(callback); + } + else { + callback.run(); + } + } + } + + public Promise[] getValues() { + return values; + } + + @Override + protected void addCallback(Runnable callback) { + impl.addCallback(callback); + } + + @Override + public Void get() { + return impl.get(); + } + + @Override + public boolean isReady() { + return impl.isReady(); + } + + @Override + protected void removeCallback(Runnable callback) { + impl.removeCallback(callback); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Promise.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Promise.java new file mode 100644 index 000000000000..33dbb889834c --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Promise.java @@ -0,0 +1,106 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +/** + * Promise is a future like object that is used as a placeholder for a result of + * an asynchronous API. Java Future is a synchronization construct that is used + * to block a thread that called get() method if result is not available yet. + * Promise differs from it as it cannot be used for blocking. A call to its + * get() method throws IllegalStateException if result is not available yet. The + * correct way to ensure that Promise is ready is to access it from a method + * that is annotated as @Asynchronous and have the given Promise as one its + * arguments or from {@link Task#doExecute()} method assuming that promise was + * passed to the Task as a constructor parameter. + * + *

+ * Promise is not linked to error handling like Future is. In case of exceptions + * they are propagated to the {@link TryCatchFinally#doCatch(Throwable)} method + * of the {@link TryCatchFinally} that owns the asynchronous task that failed. + * See {@link TryCatchFinally} for more info on the error handling. + * + *

+ * For promises that don't need a value and just used to ensure correct ordering + * of asynchronous operations the common pattern to use {@link Void} as a + * generic type. + *

+ * + * @param + * The result type returned by this Promise's get method. Use + * {@link Void} to represent Promise that indicates completion of + * operation that doesn't return a value. + */ +public abstract class Promise { + + /** + * @return result of your asynchronous computation + * @throws IllegalStateException + * if result of your asynchronous computation is not available + * yet + */ + public abstract V get(); + + /** + * @return true if the result of your asynchronous computation + * is available + */ + public abstract boolean isReady(); + + /** + * @return human friendly description on what this promise represents. + * Emitted for example as part of + * {@link AsyncScope#getAsynchronousThreadDumpAsString()} + */ + public String getDescription() { + return null; + } + + /** + * Compliant implementation should notify callbacks after promise is set to + * ready state. + * + * @param callback + * callback to notify + */ + protected abstract void addCallback(Runnable callback); + + protected abstract void removeCallback(Runnable callback); + + /** + * Convenience method for creating a Promise object which is in ready state + * and returns the passed in value when get() is called. + *

+ * The same as new {@link Settable}(value) + * + * @param + * Type of value + * @param value + * Object to return when get() is called + * @return An instance of Promise wrapper object + */ + public static Promise asPromise(T value) { + return new Settable(value); + } + + /** + * This is a factory method to create a Promise object in ready state. + * + * @return An instance of Promise object with no value. + */ + public static Promise Void() { + return new Settable(null); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Promises.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Promises.java new file mode 100644 index 000000000000..7dcd483046c5 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Promises.java @@ -0,0 +1,86 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + + +public class Promises { + + private Promises() {} + + public static Promise> listOfPromisesToPromise(final List> list) { + final Settable> result = new Settable>(); + @SuppressWarnings({ "rawtypes", "unchecked" }) + AndPromise andPromise = new AndPromise((Collection)list); + new Task(andPromise) { + + @Override + protected void doExecute() throws Throwable { + List extracted = new ArrayList(list.size()); + for (Promise promise : list) { + extracted.add(promise.get()); + } + result.set(extracted); + } + + }; + return result; + } + + public static Promise> mapOfPromisesToPromise(final Map> map) { + final Settable> result = new Settable>(); + @SuppressWarnings({ "rawtypes", "unchecked" }) + AndPromise andPromise = new AndPromise((Collection) map.values()); + new Task(andPromise) { + + @Override + protected void doExecute() throws Throwable { + Map extracted = new HashMap(map.size()); + for (Entry> pair : map.entrySet()) { + extracted.put(pair.getKey(), pair.getValue().get()); + } + result.set(extracted); + } + }; + return result; + } + + public static Promise> setOfPromisesToPromise(final Set> set) { + final Settable> result = new Settable>(); + @SuppressWarnings({ "rawtypes", "unchecked" }) + AndPromise andPromise = new AndPromise((Collection) set); + new Task(andPromise) { + + @Override + protected void doExecute() throws Throwable { + Set extracted = new HashSet(set.size()); + for (Promise promise : set) { + extracted.add(promise.get()); + } + result.set(extracted); + } + + }; + return result; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Settable.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Settable.java new file mode 100644 index 000000000000..a33e0d476b6a --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Settable.java @@ -0,0 +1,223 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +import java.util.ArrayList; +import java.util.List; + +/** + * It is an implementation of Promise, which exposes an additional + * {@link #set(Object)} and {@link #chain(Promise)} methods. Calling + * {@link #set(Object)} puts it in ready state, with value retrievable through + * {@link #get()} method. {@link #chain(Promise)} links state of this Settable + * to another Promise. When another promise changes its state to ready the + * chained one is also becomes ready. + * + *

+ * Use settable.set(null) to set Settable<Void> + * to the ready state. + * + *

+ * Settable is frequently used to return data from code contained in anonymous + * classes. For example: + * + *

+ * 
+ * Promise<Integer> foo() {
+ *     final Settable<Integer> result = new Settable<Integer>();
+ *     new TryCatch() {
+ *                            
+ *         protected void doTry() throws Throwable {
+ *             Promise<Integer> activity1Result = activities.callActivity1();
+ *             result.chain(activity1Result);
+ *         }
+ *                            
+ *         protected void doCatch(Throwable e) throws Throwable {
+ *             Promise<Void> handled = handleFailure(e);
+ *             rethrow(e, handled);
+ *         }
+ *      };
+ *      return result;
+ * }
+ * 
+ * 
+ * + * @param + * The type of value accepted and returned by this Settable.Use + * {@link Void} to represent Promise that indicates completion of + * operation that doesn't return a value. + */ +public class Settable extends Promise { + + private final List callbacks = new ArrayList(); + + private Runnable chainCallback; + + private Promise chainedTo; + + private V value; + + private boolean ready; + + private String description; + + public Settable(V value) { + set(value); + } + + public Settable() { + } + + /** + * @return The value passed in when set() is called + * @throws IllegalStateException + * If set() is never called for this instance of Settable + */ + @Override + public V get() { + if (!ready) { + throw new IllegalStateException("not ready"); + } + return value; + } + + /** + * @return true if set() is called for this Settable + */ + @Override + public boolean isReady() { + return ready; + } + + /** + * + * @param value + * Object to return when get() is called for this Settable. Use + * null to set Settable<Void> to + * the ready state. + * @throws IllegalStateException + * if the Promise is already in ready state + */ + public void set(V value) { + if (ready) { + throw new IllegalStateException("already set to " + this.value); + } + this.value = value; + this.ready = true; + for (Runnable callback : callbacks) { + callback.run(); + } + } + + /** + * Used to chain this Settable with the passed in Promise. This allows the + * Settable to be ready whenever the passed in Promise is ready and the + * value for the chained Promise can be retrieved by calling get() method on + * this Settable. + * + * @see #unchain() + * @param chainTo + * Promise object to chain this Settable to. Chaining to + * null equates calling {@link #set(Object)} with + * null argument. + * @throws IllegalStateException + * if Settable is already in ready state or it is already + * chained to some other Promise + */ + public void chain(final Promise chainTo) { + if (ready) { + throw new IllegalStateException("already ready"); + } + if (chainCallback != null) { + throw new IllegalStateException("Already chained. Call unchain() to get rid of the previous chaining."); + } + if (chainTo == null) { + set(null); + return; + } + chainCallback = new Runnable() { + + @Override + public void run() { + set(chainTo.get()); + } + }; + + chainTo.addCallback(chainCallback); + chainedTo = chainTo; + } + + /** + * Used to unchain this Settable from the Promise object passed in last + * invocation of chain. There is no requirement to unchain unless there is a + * need to chain the Settable to another Promise. Such need usually appears + * when implementing recursive functions or in + * {@link TryCatchFinally#doCatch(Throwable)} blocks. It is safe to call + * unchain if chain is never called for this Settable. + * + * @throws IllegalStateException + * If the Promise it is chained to is already in the ready state + */ + public void unchain() { + if (chainedTo == null) { + return; + } + if (chainedTo.isReady()) { + throw new IllegalStateException("Cannot unchain from a value which is ready"); + } + if (chainCallback != null) { + chainedTo.removeCallback(chainCallback); + chainCallback = null; + chainedTo = null; + } + } + + protected void addCallback(Runnable callback) { + if (ready) { + callback.run(); + } + else { + callbacks.add(callback); + } + } + + @Override + protected void removeCallback(Runnable callback) { + callbacks.remove(callback); + } + + @Override + public String getDescription() { + if (description == null && chainedTo != null) { + return chainedTo.getDescription(); + } + return description; + } + + /** + * @param description + * human readable description of what this Promise represents. + * @see Promise#getDescription() + */ + public void setDescription(String description) { + this.description = description; + } + + @Override + public String toString() { + return "Settable [value=" + value + ", ready=" + ready + "]"; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Task.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Task.java new file mode 100644 index 000000000000..0d7093dcbba4 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/Task.java @@ -0,0 +1,110 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +/** + * Asynchronous task that is executed when all {@link Promise}s passed to its + * constructor are ready (null parameter is considered ready). + * + *

+ * Should be created in the context of {@link AsyncScope#doAsync()} method, from + * {@link Task#doExecute()} or from {@link TryCatchFinally} do... methods. + * Exceptions thrown from {@link #doExecute()} are delivered asynchronously to + * the wrapping {@link TryCatchFinally#doCatch(Throwable)} method or rethrown + * from {@link AsyncScope#eventLoop()} if no wrapping {@link TryCatchFinally} is + * found. + * + *

+ * Example of using {@link Task} to implement asynchronous function that sums + * parameters when both of them are ready: + * + *

+ * 
+ * public Promise<Integer> sum(Promise<Integer> a, Promise<Integer> b) {
+ *     Settable<Integer> result = new Settable<Integer>();
+ *     new Task(a, b) {
+ *         public void doExecute() {
+ *             result.set(a.get() + b.get());
+ *         }
+ *     };
+ *     return result;
+ * }
+ * 
+ * 
+ * + * @see AsyncScope + * @see TryCatchFinally + * @see Promise + */ +public abstract class Task extends AsyncContextAware { + + private TaskContext context; + + public Task(Promise... waitFor) { + this((Boolean) null, waitFor); + } + + public Task(boolean daemon, Promise... waitFor) { + context = new TaskContext(this, daemon, waitFor); + } + + private Task(Boolean daemon, Promise... waitFor) { + context = new TaskContext(this, daemon, waitFor); + } + + public Task(AsyncContextAware parent, boolean daemon, Promise... waitFor) { + context = new TaskContext(parent.getContext(), this, daemon, waitFor); + } + + public Task(AsyncContextAware parent, Promise... waitFor) { + context = new TaskContext(parent.getContext(), this, null, waitFor); + } + + protected Task(AsyncContextAware parent, Boolean daemon, String parentTaskMethodName, boolean hideParentTaskMethodName, + int skipStackLines, Promise... waitFor) { + context = new TaskContext(parent.getContext(), this, daemon, parentTaskMethodName, hideParentTaskMethodName, + skipStackLines, waitFor); + } + + protected Task(Boolean daemon, String parentTaskMethodName, boolean hideParentTaskMethodName, int skipStackLines, + Promise... waitFor) { + context = new TaskContext(this, daemon, parentTaskMethodName, hideParentTaskMethodName, skipStackLines, waitFor); + } + + + public String getName() { + return context.getName(); + } + + public void setName(String name) { + context.setName(name); + } + + public StackTraceElement[] getStackTrace() { + return context.getStackTrace().getStackTrace(); + } + + @Override + AsyncParentContext getContext() { + return context; + } + + public String toString() { + return context.toString(); + } + + protected abstract void doExecute() throws Throwable; + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/TaskContext.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/TaskContext.java new file mode 100644 index 000000000000..1e0684d8eeee --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/TaskContext.java @@ -0,0 +1,138 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +import java.util.concurrent.Executor; + +class TaskContext extends AsyncContextBase implements AsyncParentContext { + + private final Task task; + + private boolean canceled; + + private final String parentTaskMethodName; + + private final boolean hideStartFromMethod; + + public TaskContext(Task task, Boolean daemon, Promise[] waitFor) { + super(daemon, waitFor, 7); + this.task = task; + this.parentTaskMethodName = null; + this.hideStartFromMethod = false; + } + + public TaskContext(AsyncParentContext parent, Task task, Boolean daemon, Promise[] waitFor) { + super(parent, daemon, waitFor, 5); + this.task = task; + this.parentTaskMethodName = null; + this.hideStartFromMethod = false; + } + + public TaskContext(AsyncParentContext parent, Task task, Boolean daemon, String parentTaskMethodName, boolean hideParentTaskMethodName, int skipStackLines, + Promise[] waitFor) { + super(parent, daemon, waitFor, skipStackLines); + this.task = task; + this.parentTaskMethodName = parentTaskMethodName; + this.hideStartFromMethod = hideParentTaskMethodName; + } + + public TaskContext(Task task, Boolean daemon, String parentTaskMethodName, boolean hideParentTaskMethodName, int skipStackLines, Promise[] waitFor) { + super(daemon, waitFor, skipStackLines); + this.task = task; + this.parentTaskMethodName = parentTaskMethodName; + this.hideStartFromMethod = hideParentTaskMethodName; + } + + public void cancel(Throwable cause) { + canceled = true; + parent.remove(this); + } + + @Override + public void run() { + if (canceled) { + return; + } + setCurrent(this); + try { + task.doExecute(); + parent.remove(this); + } + catch (Throwable e) { + if (stackTrace != null && !parent.isRethrown(e)) { + AsyncStackTrace merged = new AsyncStackTrace(stackTrace, e.getStackTrace(), 0); + merged.setStartFrom(getParentTaskMethodName()); + merged.setHideStartFromMethod(hideStartFromMethod); + e.setStackTrace(merged.getStackTrace()); + } + parent.fail(this, e); + } + finally { + setCurrent(null); + } + } + + @Override + public void add(AsyncContextBase async, Promise waitFor) { + parent.add(async, waitFor); + } + + @Override + public void remove(AsyncContextBase async) { + parent.remove(async); + } + + @Override + public void fail(AsyncContextBase async, Throwable e) { + parent.fail(async, e); + } + + @Override + public Executor getExecutor() { + return parent.getExecutor(); + } + + @Override + public boolean isRethrown(Throwable e) { + return parent.isRethrown(e); + } + + @Override + public AsyncParentContext getCurrentTryCatchFinallyContext() { + return parent; + } + + @Override + public boolean getDaemonFlagForHeir() { + return isDaemon(); + } + + @Override + public String getParentTaskMethodName() { + return parentTaskMethodName == null ? "doExecute" : parentTaskMethodName; + } + + @Override + public boolean getHideStartFromMethod() { + return hideStartFromMethod; + } + + public String toString() { + if (stackTrace != null) { + return stackTrace.toString(); + } + return super.toString(); + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/TryCatch.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/TryCatch.java new file mode 100644 index 000000000000..388c46c1ff1a --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/TryCatch.java @@ -0,0 +1,41 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +public abstract class TryCatch extends TryCatchFinally { + + public TryCatch(Promise... waitFor) { + // The reason this() is not called here is to pass correct value of the skipStackLines. + // While this() passes the same value it also adds its own line into the stack trace. + super(null, null, 7, waitFor); + } + + public TryCatch(boolean daemon, Promise... waitFor) { + super(daemon, null, 7, waitFor); + } + + public TryCatch(AsyncContextAware parent, boolean daemon, Promise... waitFor) { + super(parent, daemon, null, 7, waitFor); + } + + public TryCatch(AsyncContextAware parent, Promise... waitFor) { + super(parent, null, null, 7, waitFor); + } + + @Override + protected void doFinally() throws Throwable { + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/TryCatchFinally.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/TryCatchFinally.java new file mode 100644 index 000000000000..73dd635debde --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/TryCatchFinally.java @@ -0,0 +1,301 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CancellationException; +import java.util.concurrent.Future; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Asynchronous; + +/** + * Asynchronous equivalent of synchronous try-catch-finally.

Overview

+ *

+ * SWF Flow error handling relies on the idea that any asynchronous task (which + * includes methods annotated as {@link Asynchronous}) is executed in a parent + * context. In the case of an exception being thrown from a task, all sibling + * tasks that share the same parent context are canceled. After successful + * cancellation the exception is propagated to the parent context for handling. + *

+ *

+ * TryCatchFinally {@link #doTry()}, {@link #doFinally()} and + * {@link #doCatch(Throwable)} methods serve as parent scopes for tasks created + * during their execution. + *

+ *

+ * For example if any {@link Task} (or method annotated with + * {@link Asynchronous}) that originates (possibly indirectly through parent + * task) in {@link #doTry()} throws an exception all other tasks that originated + * in {@link #doTry()} are canceled and only then {@link #doCatch(Throwable)} is + * called. Through this cancellation mechanism it is guaranteed that + * {@link #doCatch(Throwable)} is called at most once even if there are multiple + * parallel tasks executing in the {@link #doTry()} scope. + *

+ *

+ * If failure happens in a task originated in {@link #doCatch(Throwable)} then + * all its siblings are canceled first and then {@link #doFinally()} is called. + *

+ *

+ * The same happens if task originated in {@link #doFinally()} fails. All it + * siblings are canceled and then parent scope of the + * TryCatchFinally is given chance to handle the exception. + *

+ *

Cancellation

+ *

+ * The cancellation semantic depends on the task implementation. {@link Task} + * (or method annotated with {@link Asynchronous}) that has not started + * execution is never given chance to execute after cancellation. Task which is + * already executing is not interrupted and completes (or fails). + * {@link ExternalTask} cancellation depends on the external resource. For + * example SWF activities and child workflows that are modeled as + * {@link ExternalTask}s are canceled through SWF API. + *

+ *

+ * When TryCatchFinally itself is canceled because of sibling task + * failure it handles its own cancellation in the following order: + *

+ *
    + *
  1. If doTry hasn't started yet then TryCatchFinally is + * considered canceled immediately.
  2. + *
  3. If are any outstanding task that originated in {@link #doTry()} then + * cancellation of all of them is requested.
  4. + *
  5. After all tasks originated in doTry are canceled call + * {@link #doCatch(Throwable)} with {@link CancellationException}.
  6. + *
  7. After all tasks originated in doCatch are completed call + * {@link #doFinally()}.
  8. + *
  9. After all tasks originated in {@link #doFinally()} are completed consider + * TryCathFinally canceled
  10. + *
+ *

+ * {@link #doCatch(Throwable)} and {@link #doFinally()} + * are not cancelable. It means that cancellation request always waits + * for completion of all tasks that originate in these methods. Special care + * should be taken when writing code in {@link #doCatch(Throwable)} and in + * {@link #doFinally()} to ensure that in all possible failure scenarios they + * don't end up in a stuck state. + *

+ *

+ * TryCatchFinally can be canceled explicitly through + * {@link #cancel(Throwable)} method. In case of explicit cancellation any + * exception including {@link CancellationException} that is rethrown from + * {@link #doCatch(Throwable)} or {@link #doFinally()} is propagated to the + * parent context. + *

+ *

Daemon Tasks

+ *

+ * It is pretty common to have tasks that have their lifecycle linked to some + * other tasks. For example notification activity that is sent out if some other + * activity is not completed in a specified period of time. The timer and the + * notification activity should be canceled as soon as the monitored activity is + * completed. Such use case can be supported by wrapping timer and notification + * activity in TryCatchFinally which is explicitly canceled upon + * monitored activity completion. The more convenient way to perform such + * cleanup is by marking a Task (or method annotated with {@link Asynchronous}) + * as daemon. The asynchronous scope in absence of failures is executed in the + * following sequence: + *

    + *
  1. The scope method (for example {@link #doTry()}) is executed.
  2. + *
  3. All tasks that are created during its execution are executed (when + * Promises they are waiting on become ready) possibly creating more tasks.
  4. + *
  5. When all non daemon tasks originated in the scope method are + * completed cancellation requests are sent to all daemon siblings.
  6. + *
  7. The scope is completed after all daemon tasks are canceled. + *
+ *

+ * Pass true to the first argument of + * {@link Task#Task(boolean, Promise...)} constructor to mark a Task as daemon. + * Use {@link Asynchronous#daemon()} annotation parameter to mark an + * asynchronous method as daemon. Any task that is created during execution of a + * daemon task is marked as daemon. TryCatchFinally also can be + * marked as daemon through {@link #TryCatchFinally(boolean, Promise...)} + * constructor or by by being created by a daemon task. Note that + * TryCatchFinally doesn't pass its daemon flag to tasks created in + * {@link #doTry()}, {@link #doCatch(Throwable)} and {@link #doFinally()}. It is + * because each of these methods acts as a separate asynchronous scope and the + * rules of execution described above apply to them. + *

+ *

Miscellaneous

+ *

+ * In case of multiple simultaneous exceptions (which is possible for external + * tasks) or if cancellation of a child results in any exception that is not + * {@link CancellationException} the last exception "wins". I.e. it becomes the + * exception delivered to {@link #doCatch(Throwable)} method. + *

+ *

+ * Note that instances of {@link Promise} do not participate in error handling + * the way {@link Future} does. If method that returns Promise throws an + * exception the Promise state and return value are not changed. It is similar + * to behavior of variables in case of synchronous code. + *

+ *

Usage Examples

+ *

+ * Basic error handling: + *

+ * + *
+ * new TryCatchFinally() {
+ * 
+ *     final List<Promise<String>> instances = new ArrayList<Promise<String>>();
+ * 
+ *     protected void doTry() throws Throwable {
+ *         for (int i = 0; i < count; i++) {
+ *             Promise<String> instanceId = ec2.startInstance();
+ *             instances.add(instanceId);
+ *         }
+ *         performSimulation(instances);
+ *     }
+ * 
+ *     protected void doCatch(Throwable e) throws Throwable {
+ *         mail.notifySimulationFailure(e);
+ *     }
+ * 
+ *     protected void doFinally() throws Throwable {
+ *         for (int i = 0; i < count; i++) {
+ *             Promise<String> instanceId = instances.get(i);
+ *             if (instanceId.isReady()) {
+ *                 ec2.stopInstance(instanceId.get());
+ *             }
+ *         }
+ *     }
+ * };
+ * 
+ *

+ * Daemon example: + *

+ * + *
+ * 
+ * 
+ * protected void doTry() throws Throwable {
+ *     for (int i = 0; i < count; i++) {
+ *         Promise<String> instanceId = ec2.startInstance();
+ *         instances.add(instanceId);
+ *     }
+ *     performSimulation(instances);
+ *     notifyOnDelay();
+ * }
+ * 
+ * @Asynchronous(daemon = true)
+ * public void notifyOnDelay() {
+ *     Promise<Void> timer = clock.scheduleTimer(3600);
+ *     mail.notifyDelay(timer);
+ * }
+ * 
+ * + * @author fateev + */ +public abstract class TryCatchFinally extends AsyncContextAware implements Cancelable { + + public enum State { + CREATED, + TRYING, + CATCHING, + FINALIZING, + CLOSED + } + + private final TryCatchFinallyContext context; + + public TryCatchFinally() { + this(null, null, 7, null); + } + + public TryCatchFinally(Promise... waitFor) { + this(null, null, 7, waitFor); + } + + public TryCatchFinally(boolean daemon, Promise... waitFor) { + this(daemon, null, 7, waitFor); + } + + public TryCatchFinally(AsyncContextAware parent, boolean daemon, Promise... waitFor) { + context = new TryCatchFinallyContext(parent.getContext(), this, daemon, null, 5, waitFor); + } + + public TryCatchFinally(AsyncContextAware parent, Promise... waitFor) { + context = new TryCatchFinallyContext(parent.getContext(), this, null, null, 5, waitFor); + } + + protected TryCatchFinally(Boolean daemon, String parentTaskMethodName, int skipStackLines, Promise[] waitFor) { + context = new TryCatchFinallyContext(this, daemon, parentTaskMethodName, skipStackLines, waitFor); + } + + protected TryCatchFinally(AsyncContextAware parent, Boolean daemon, String parentTaskMethodName, int skipStackLines, + Promise[] waitFor) { + context = new TryCatchFinallyContext(parent.getContext(), this, daemon, parentTaskMethodName, skipStackLines, waitFor); + } + + public String getName() { + return context.getName(); + } + + public void setName(String name) { + context.setName(name); + } + + @Override + AsyncParentContext getContext() { + return context; + } + + public void cancel(Throwable cause) { + context.cancel(cause); + } + + public boolean isCancelRequested() { + return context.isCancelRequested(); + } + + public StackTraceElement[] getStackTrace() { + return context.getStackTrace().getStackTrace(); + } + + public List getAsynchronousStackTraceDump() { + List result = new ArrayList(); + context.getAsynchronousStackTraceDump(result); + return result; + } + + public String getAsynchronousStackTraceDumpAsString() { + return context.getAsynchronousStackTraceDumpAsString(); + } + + public State getState() { + return context.getState(); + } + + @Override + public String toString() { + return context.toString(); + } + + protected void rethrow(final Throwable e, Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + throw e; + } + }; + } + + protected abstract void doTry() throws Throwable; + + protected abstract void doCatch(Throwable e) throws Throwable; + + protected abstract void doFinally() throws Throwable; + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/TryCatchFinallyContext.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/TryCatchFinallyContext.java new file mode 100644 index 000000000000..164040ec6588 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/TryCatchFinallyContext.java @@ -0,0 +1,302 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CancellationException; +import java.util.concurrent.Executor; + +import com.amazonaws.services.simpleworkflow.flow.core.TryCatchFinally.State; + +class TryCatchFinallyContext extends AsyncContextBase { + + private List heirs = new ArrayList(); + + private int nonDaemonHeirsCount; + + private Executor executor; + + private State state = State.CREATED; + + private Throwable failure; + + private boolean canceled; + + private boolean executed; + + private boolean daemondCausedCancellation; + + private final TryCatchFinally tryCatchFinally; + + private final String parentTaskMethodName; + + TryCatchFinallyContext(TryCatchFinally tryCatchFinally, Boolean daemon, String parentTaskMethodName, int skipStackLines, + Promise[] waitFor) { + super(daemon, waitFor, skipStackLines); + this.tryCatchFinally = tryCatchFinally; + this.executor = parent.getExecutor(); + this.parentTaskMethodName = parentTaskMethodName; + } + + TryCatchFinallyContext(AsyncParentContext parent, TryCatchFinally tryCatchFinally, Boolean daemon, + String parentTaskMethodName, int skipStackLines, Promise[] waitFor) { + super(parent, daemon, waitFor, skipStackLines); + this.tryCatchFinally = tryCatchFinally; + this.executor = parent.getExecutor(); + this.parentTaskMethodName = parentTaskMethodName; + } + + public Executor getExecutor() { + return executor; + } + + @Override + public void add(final AsyncContextBase async, Promise waitFor) { + checkClosed(); + heirs.add(async); + if (!async.isDaemon()) { + nonDaemonHeirsCount++; + } + if (waitFor == null) { + executor.execute(async); + } + else { + waitFor.addCallback(new Runnable() { + + @Override + public void run() { + executor.execute(async); + } + + }); + } + } + + private void checkClosed() { + if (state == State.CLOSED) { + throw new IllegalStateException(state.toString()); + } + } + + public void cancel(Throwable cause) { + if (state == State.CREATED) { + assert heirs.size() == 0; + state = State.CLOSED; + parent.remove(this); + return; + } + if (failure == null) { + canceled = true; + failure = new CancellationException(); + if (stackTrace != null) { + failure.setStackTrace(stackTrace.getStackTrace()); + } + failure.initCause(cause); + if (state == State.TRYING) { + cancelHeirs(); + } + } + } + + public boolean isCancelRequested() { + return canceled; + } + + public void remove(AsyncContextBase async) { + checkClosed(); + heirs.remove(async); + if (!async.isDaemon()) { + nonDaemonHeirsCount--; + assert nonDaemonHeirsCount >= 0; + } + updateState(); + } + + public void fail(AsyncContextBase async, Throwable e) { + checkClosed(); + boolean cancellationException = e instanceof CancellationException; + // Explicit cancellation through cancel() call leads to CancellationException being + // thrown from the cancelled component. At the same time cancellation caused by the + // daemon flag is ignored. + if (!cancellationException || (failure == null && !daemondCausedCancellation)) { + failure = e; + } + boolean removed = heirs.remove(async); + assert removed; + if (!async.isDaemon()) { + nonDaemonHeirsCount--; + assert nonDaemonHeirsCount >= 0; + } + cancelHeirs(); + updateState(); + } + + @Override + public void run() { + if (state == State.CLOSED) { + return; + } + if (state == State.CREATED) { + state = State.TRYING; + } + setCurrent(this); + Throwable f = failure; + try { + switch (state) { + case TRYING: + if (canceled) { + return; + } + tryCatchFinally.doTry(); + break; + case CATCHING: + failure = null; + tryCatchFinally.doCatch(f); + break; + case FINALIZING: + tryCatchFinally.doFinally(); + } + } + catch (Throwable e) { + if (stackTrace != null && e != f) { + AsyncStackTrace merged = new AsyncStackTrace(stackTrace, e.getStackTrace(), 0); + merged.setStartFrom(getParentTaskMethodName()); + e.setStackTrace(merged.getStackTrace()); + } + failure = e; + cancelHeirs(); + } + finally { + setCurrent(null); + executed = true; + updateState(); + } + } + + private void cancelHeirs() { + List toCancel = new ArrayList(heirs); + for (AsyncContextBase heir : toCancel) { + heir.cancel(failure); + } + } + + private void updateState() { + if (state == State.CLOSED || !executed) { + return; + } + if (nonDaemonHeirsCount == 0) { + if (heirs.isEmpty()) { + if (state == State.TRYING) { + if (failure == null) { + state = State.FINALIZING; + execute(); + } + else { + state = State.CATCHING; + execute(); + } + } + else if (state == State.CATCHING) { + state = State.FINALIZING; + execute(); + } + else if (state == State.FINALIZING) { + assert state != State.CLOSED; + state = State.CLOSED; + if (failure == null) { + parent.remove(this); + } + else { + parent.fail(this, failure); + } + } + else { + throw new IllegalStateException("Unknown state " + state); + } + } + else { + if (failure == null) { + daemondCausedCancellation = true; + } + cancelHeirs(); + } + } + } + + private void execute() { + executed = false; + executor.execute(this); + } + + @Override + protected void getAsynchronousStackTraceDump(List result) { + if (heirs.size() == 0) { + result.add(getTaskInfo()); + } + else { + for (AsyncContextBase heir : heirs) { + heir.getAsynchronousStackTraceDump(result); + } + } + } + + public boolean isRethrown(Throwable e) { + return e == failure; + } + + @Override + public AsyncParentContext getCurrentTryCatchFinallyContext() { + return this; + } + + /** + * Heirs of the TryCatchFinally do not inherit daemon flag. + */ + @Override + public boolean getDaemonFlagForHeir() { + return false; + } + + @Override + public String getParentTaskMethodName() { + if (parentTaskMethodName != null) { + return parentTaskMethodName; + } + if (state == State.TRYING) { + return "doTry"; + } + if (state == State.CATCHING) { + return "doCatch"; + } + if (state == State.FINALIZING) { + return "doFinally"; + } + return null; + } + + public State getState() { + return state; + } + + @Override + public String toString() { + if (stackTrace != null) { + return stackTrace.toString(); + } + return super.toString(); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/TryFinally.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/TryFinally.java new file mode 100644 index 000000000000..7aca107a7ece --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/core/TryFinally.java @@ -0,0 +1,42 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.core; + +public abstract class TryFinally extends TryCatchFinally { + + public TryFinally(Promise... waitFor) { + // The reason this() is not called here is to pass correct value of the skipStackLines. + // While this() passes the same value it also adds its own line into the stack trace. + super(null, null, 7, null); + } + + public TryFinally(boolean daemon, Promise... waitFor) { + super(daemon, null, 7, waitFor); + } + + public TryFinally(AsyncContextAware parent, boolean daemon, Promise... waitFor) { + super(parent, daemon, null, 7, waitFor); + } + + public TryFinally(AsyncContextAware parent, Promise... waitFor) { + super(parent, null, null, 7, waitFor); + } + + @Override + protected void doCatch(Throwable e) throws Throwable { + throw e; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/ActivityImplementation.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/ActivityImplementation.java new file mode 100644 index 000000000000..2c5f679d79f7 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/ActivityImplementation.java @@ -0,0 +1,67 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.generic; + +import java.util.Map; +import java.util.concurrent.CancellationException; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; +import com.amazonaws.services.simpleworkflow.flow.ActivityFailureException; +import com.amazonaws.services.simpleworkflow.flow.ActivityWorker; +import com.amazonaws.services.simpleworkflow.flow.worker.ActivityTypeExecutionOptions; +import com.amazonaws.services.simpleworkflow.flow.worker.ActivityTypeRegistrationOptions; +import com.amazonaws.services.simpleworkflow.model.ActivityTask; + +/** + * Base class for activity implementation. Extending + * {@link ActivityImplementationBase} instead of {@link ActivityImplementation} + * is recommended. + * + * @see ActivityWorker + * @see ActivityImplementationBase + * + * @author fateev, suskin + */ +public abstract class ActivityImplementation { + + /** + * Options passed to the + * {@link AmazonSimpleWorkflow#registerActivityType(com.amazonaws.services.simpleworkflow.model.RegisterActivityTypeRequest)} + * call. + * + * @return null if activity registration is not required on the worker + * startup + */ + public abstract ActivityTypeRegistrationOptions getRegistrationOptions(); + + public abstract ActivityTypeExecutionOptions getExecutionOptions(); + + /** + * Execute external activity or initiate its execution if + * {@link #isManualActivityCompletion()} is true. + * + * @param task + * information about activity to be executed. Use + * {@link ActivityTask#getInput()} to get activity input + * arguments. + * @return result of activity execution if {@link #isManualActivityCompletion()} is set + * to false. Use + * {@link ActivityWorker#respondActivityTaskCompleted(String, Map)} + * to return result in asynchronous case. + */ + public abstract String execute(ActivityExecutionContext context) throws ActivityFailureException, CancellationException; + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/ActivityImplementationBase.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/ActivityImplementationBase.java new file mode 100644 index 000000000000..de3ee47e8380 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/ActivityImplementationBase.java @@ -0,0 +1,79 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.generic; + +import java.util.Map; +import java.util.concurrent.CancellationException; + +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; +import com.amazonaws.services.simpleworkflow.flow.ActivityFailureException; +import com.amazonaws.services.simpleworkflow.flow.ActivityWorker; +import com.amazonaws.services.simpleworkflow.flow.DataConverter; +import com.amazonaws.services.simpleworkflow.flow.worker.ActivityTypeExecutionOptions; +import com.amazonaws.services.simpleworkflow.flow.worker.ActivityTypeRegistrationOptions; +import com.amazonaws.services.simpleworkflow.model.ActivityTask; + +/** + * Extend this class to implement an activity. There are two types of activity + * implementation: synchronous and asynchronous. Synchronous ties thread that + * calls {@link #execute(Map, ActivityExecutionContext)} method. + * + * @see ActivityWorker + * + * @author fateev + */ +public abstract class ActivityImplementationBase extends ActivityImplementation { + + /** + * @see ActivityImplementation#execute(ActivityExecutionContext) + */ + @Override + public String execute(ActivityExecutionContext context) + throws ActivityFailureException, CancellationException { + ActivityTask task = context.getTask(); + return execute(task.getInput(), context); + } + + @Override + public ActivityTypeExecutionOptions getExecutionOptions() { + return new ActivityTypeExecutionOptions(); + } + + /** + * By default do not register + */ + @Override + public ActivityTypeRegistrationOptions getRegistrationOptions() { + return null; + } + + /** + * Execute activity. + * + * @see #isManualActivityCompletion() + * + * @param input + * activity input. + * @return result of activity execution + * @throws Exception + * any other exception is converted to status, reason and + * details using + * {@link DataConverter#failureToTaskFailed(Throwable)}. + */ + + protected abstract String execute(String input, ActivityExecutionContext context) + throws ActivityFailureException, CancellationException; + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/ActivityImplementationFactory.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/ActivityImplementationFactory.java new file mode 100644 index 000000000000..ded1a2630048 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/ActivityImplementationFactory.java @@ -0,0 +1,25 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.generic; + +import com.amazonaws.services.simpleworkflow.model.ActivityType; + +public abstract class ActivityImplementationFactory { + + public abstract Iterable getActivityTypesToRegister(); + + public abstract ActivityImplementation getActivityImplementation(ActivityType activityType); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/ContinueAsNewWorkflowExecutionParameters.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/ContinueAsNewWorkflowExecutionParameters.java new file mode 100644 index 000000000000..6ca7be87733e --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/ContinueAsNewWorkflowExecutionParameters.java @@ -0,0 +1,172 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.generic; + +import java.util.List; + +import com.amazonaws.services.simpleworkflow.flow.StartWorkflowOptions; +import com.amazonaws.services.simpleworkflow.flow.common.FlowConstants; + + +public class ContinueAsNewWorkflowExecutionParameters { + private long executionStartToCloseTimeoutSeconds = FlowConstants.USE_REGISTERED_DEFAULTS; + private String input; + private List tagList; + private String taskList; + private long taskStartToCloseTimeoutSeconds = FlowConstants.USE_REGISTERED_DEFAULTS; + + public ContinueAsNewWorkflowExecutionParameters() { + } + + public long getExecutionStartToCloseTimeoutSeconds() { + return executionStartToCloseTimeoutSeconds; + } + + public void setExecutionStartToCloseTimeoutSeconds(long executionStartToCloseTimeoutSeconds) { + this.executionStartToCloseTimeoutSeconds = executionStartToCloseTimeoutSeconds; + } + + public ContinueAsNewWorkflowExecutionParameters withExecutionStartToCloseTimeoutSeconds(long executionStartToCloseTimeoutSeconds) { + this.executionStartToCloseTimeoutSeconds = executionStartToCloseTimeoutSeconds; + return this; + } + + public String getInput() { + return input; + } + + public void setInput(String input) { + this.input = input; + } + + public ContinueAsNewWorkflowExecutionParameters withInput(String input) { + this.input = input; + return this; + } + + public List getTagList() { + return tagList; + } + + public void setTagList(List tagList) { + this.tagList = tagList; + } + + public ContinueAsNewWorkflowExecutionParameters withTagList(List tagList) { + this.tagList = tagList; + return this; + } + + public String getTaskList() { + return taskList; + } + + public void setTaskList(String taskList) { + this.taskList = taskList; + } + + public ContinueAsNewWorkflowExecutionParameters withTaskList(String taskList) { + this.taskList = taskList; + return this; + } + + public long getTaskStartToCloseTimeoutSeconds() { + return taskStartToCloseTimeoutSeconds; + } + + public void setTaskStartToCloseTimeoutSeconds(long taskStartToCloseTimeoutSeconds) { + this.taskStartToCloseTimeoutSeconds = taskStartToCloseTimeoutSeconds; + } + + public ContinueAsNewWorkflowExecutionParameters withTaskStartToCloseTimeoutSeconds(long taskStartToCloseTimeoutSeconds) { + this.taskStartToCloseTimeoutSeconds = taskStartToCloseTimeoutSeconds; + return this; + } + + public ContinueAsNewWorkflowExecutionParameters createContinueAsNewParametersFromOptions(StartWorkflowOptions options, + StartWorkflowOptions optionsOverride) { + ContinueAsNewWorkflowExecutionParameters continueAsNewWorkflowExecutionParameters = this.clone(); + + if (options != null) { + Long executionStartToCloseTimeoutSeconds = options.getExecutionStartToCloseTimeoutSeconds(); + if (executionStartToCloseTimeoutSeconds != null) { + continueAsNewWorkflowExecutionParameters.setExecutionStartToCloseTimeoutSeconds(executionStartToCloseTimeoutSeconds); + } + + Long taskStartToCloseTimeoutSeconds = options.getTaskStartToCloseTimeoutSeconds(); + if (taskStartToCloseTimeoutSeconds != null) { + continueAsNewWorkflowExecutionParameters.setTaskStartToCloseTimeoutSeconds(taskStartToCloseTimeoutSeconds); + } + + List tagList = options.getTagList(); + if (tagList != null) { + continueAsNewWorkflowExecutionParameters.setTagList(tagList); + } + + String taskList = options.getTaskList(); + if (taskList != null && !taskList.isEmpty()) { + continueAsNewWorkflowExecutionParameters.setTaskList(taskList); + } + } + + if (optionsOverride != null) { + Long executionStartToCloseTimeoutSeconds = optionsOverride.getExecutionStartToCloseTimeoutSeconds(); + if (executionStartToCloseTimeoutSeconds != null) { + continueAsNewWorkflowExecutionParameters.setExecutionStartToCloseTimeoutSeconds(executionStartToCloseTimeoutSeconds); + } + + Long taskStartToCloseTimeoutSeconds = optionsOverride.getTaskStartToCloseTimeoutSeconds(); + if (taskStartToCloseTimeoutSeconds != null) { + continueAsNewWorkflowExecutionParameters.setTaskStartToCloseTimeoutSeconds(taskStartToCloseTimeoutSeconds); + } + + List tagList = optionsOverride.getTagList(); + if (tagList != null) { + continueAsNewWorkflowExecutionParameters.setTagList(tagList); + } + + String taskList = optionsOverride.getTaskList(); + if (taskList != null && !taskList.isEmpty()) { + continueAsNewWorkflowExecutionParameters.setTaskList(taskList); + } + } + + return continueAsNewWorkflowExecutionParameters; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + sb.append("Input: " + input + ", "); + sb.append("ExecutionStartToCloseTimeout: " + executionStartToCloseTimeoutSeconds + ", "); + sb.append("TaskStartToCloseTimeout: " + taskStartToCloseTimeoutSeconds + ", "); + sb.append("TagList: " + tagList + ", "); + sb.append("TaskList: " + taskList); + sb.append("}"); + return sb.toString(); + } + + public ContinueAsNewWorkflowExecutionParameters clone() { + ContinueAsNewWorkflowExecutionParameters result = new ContinueAsNewWorkflowExecutionParameters(); + result.setExecutionStartToCloseTimeoutSeconds(executionStartToCloseTimeoutSeconds); + result.setInput(input); + result.setTagList(tagList); + result.setTaskList(taskList); + result.setTaskStartToCloseTimeoutSeconds(taskStartToCloseTimeoutSeconds); + return result; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/ExecuteActivityParameters.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/ExecuteActivityParameters.java new file mode 100644 index 000000000000..9eefcdbefdcc --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/ExecuteActivityParameters.java @@ -0,0 +1,444 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.generic; + +import com.amazonaws.services.simpleworkflow.flow.ActivitySchedulingOptions; +import com.amazonaws.services.simpleworkflow.flow.common.FlowConstants; +import com.amazonaws.services.simpleworkflow.model.ActivityType; + +public class ExecuteActivityParameters implements Cloneable { + private String activityId; + private ActivityType activityType; + private String control; + private long heartbeatTimeoutSeconds = FlowConstants.USE_REGISTERED_DEFAULTS; + private String input; + private long scheduleToCloseTimeoutSeconds = FlowConstants.USE_REGISTERED_DEFAULTS; + private long scheduleToStartTimeoutSeconds = FlowConstants.USE_REGISTERED_DEFAULTS; + private long startToCloseTimeoutSeconds = FlowConstants.USE_REGISTERED_DEFAULTS; + private String taskList; + + public ExecuteActivityParameters() { + } + + /** + * Returns the value of the Control property for this object. + *

+ * Constraints:
+ * Length: 0 - 100000
+ * + * @return The value of the Control property for this object. + */ + public String getControl() { + return control; + } + + /** + * Sets the value of the Control property for this object. + *

+ * Constraints:
+ * Length: 0 - 100000
+ * + * @param control The new value for the Control property for this object. + */ + public void setControl(String control) { + this.control = control; + } + + /** + * Sets the value of the Control property for this object. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 100000
+ * + * @param control The new value for the Control property for this object. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ExecuteActivityParameters withControl(String control) { + this.control = control; + return this; + } + + /** + * Returns the value of the ActivityType property for this object. + * + * @return The value of the ActivityType property for this object. + */ + public ActivityType getActivityType() { + return activityType; + } + + /** + * Sets the value of the ActivityType property for this object. + * + * @param activityType The new value for the ActivityType property for this object. + */ + public void setActivityType(ActivityType activityType) { + this.activityType = activityType; + } + + /** + * Sets the value of the ActivityType property for this object. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param activityType The new value for the ActivityType property for this object. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ExecuteActivityParameters withActivityType(ActivityType activityType) { + this.activityType = activityType; + return this; + } + + + /** + * Returns the value of the ActivityId property for this object. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @return The value of the ActivityId property for this object. + */ + public String getActivityId() { + return activityId; + } + + /** + * Sets the value of the ActivityId property for this object. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param activityId The new value for the ActivityId property for this object. + */ + public void setActivityId(String activityId) { + this.activityId = activityId; + } + + /** + * Sets the value of the ActivityId property for this object. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param activityId The new value for the ActivityId property for this object. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ExecuteActivityParameters withActivityId(String activityId) { + this.activityId = activityId; + return this; + } + + + /** + * Returns the value of the Input property for this object. + *

+ * Constraints:
+ * Length: 0 - 100000
+ * + * @return The value of the Input property for this object. + */ + public String getInput() { + return input; + } + + /** + * Sets the value of the Input property for this object. + *

+ * Constraints:
+ * Length: 0 - 100000
+ * + * @param input The new value for the Input property for this object. + */ + public void setInput(String input) { + this.input = input; + } + + /** + * Sets the value of the Input property for this object. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 100000
+ * + * @param input The new value for the Input property for this object. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ExecuteActivityParameters withInput(String input) { + this.input = input; + return this; + } + + public long getHeartbeatTimeoutSeconds() { + return heartbeatTimeoutSeconds; + } + + + public void setHeartbeatTimeoutSeconds(long heartbeatTimeoutSeconds) { + this.heartbeatTimeoutSeconds = heartbeatTimeoutSeconds; + } + + public ExecuteActivityParameters withHeartbeatTimeoutSeconds(long heartbeatTimeoutSeconds) { + this.heartbeatTimeoutSeconds = heartbeatTimeoutSeconds; + return this; + } + + + /** + * Returns the value of the ScheduleToStartTimeout property for this + * object. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @return The value of the ScheduleToStartTimeout property for this object. + */ + public long getScheduleToStartTimeoutSeconds() { + return scheduleToStartTimeoutSeconds; + } + + /** + * Sets the value of the ScheduleToStartTimeout property for this object. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param scheduleToStartTimeoutSeconds The new value for the ScheduleToStartTimeout property for this object. + */ + public void setScheduleToStartTimeoutSeconds(long scheduleToStartTimeoutSeconds) { + this.scheduleToStartTimeoutSeconds = scheduleToStartTimeoutSeconds; + } + + /** + * Sets the value of the ScheduleToStartTimeout property for this object. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param scheduleToStartTimeoutSeconds The new value for the ScheduleToStartTimeout property for this object. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ExecuteActivityParameters withScheduleToStartTimeoutSeconds(long scheduleToStartTimeoutSeconds) { + this.scheduleToStartTimeoutSeconds = scheduleToStartTimeoutSeconds; + return this; + } + + + /** + * Returns the value of the ScheduleToCloseTimeout property for this + * object. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @return The value of the ScheduleToCloseTimeout property for this object. + */ + public long getScheduleToCloseTimeoutSeconds() { + return scheduleToCloseTimeoutSeconds; + } + + /** + * Sets the value of the ScheduleToCloseTimeout property for this object. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param scheduleToCloseTimeoutSeconds The new value for the ScheduleToCloseTimeout property for this object. + */ + public void setScheduleToCloseTimeoutSeconds(long scheduleToCloseTimeoutSeconds) { + this.scheduleToCloseTimeoutSeconds = scheduleToCloseTimeoutSeconds; + } + + /** + * Sets the value of the ScheduleToCloseTimeout property for this object. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param scheduleToCloseTimeoutSeconds The new value for the ScheduleToCloseTimeout property for this object. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ExecuteActivityParameters withScheduleToCloseTimeoutSeconds(long scheduleToCloseTimeoutSeconds) { + this.scheduleToCloseTimeoutSeconds = scheduleToCloseTimeoutSeconds; + return this; + } + + public long getStartToCloseTimeoutSeconds() { + return startToCloseTimeoutSeconds; + } + + + public void setStartToCloseTimeoutSeconds(long startToCloseTimeoutSeconds) { + this.startToCloseTimeoutSeconds = startToCloseTimeoutSeconds; + } + + public ExecuteActivityParameters withStartToCloseTimeoutSeconds(long startToCloseTimeoutSeconds) { + this.startToCloseTimeoutSeconds = startToCloseTimeoutSeconds; + return this; + } + + /** + * Returns the value of the TaskList property for this object. + * + * @return The value of the TaskList property for this object. + */ + public String getTaskList() { + return taskList; + } + + /** + * Sets the value of the TaskList property for this object. + * + * @param taskList The new value for the TaskList property for this object. + */ + public void setTaskList(String taskList) { + this.taskList = taskList; + } + + /** + * Sets the value of the TaskList property for this object. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param taskList The new value for the TaskList property for this object. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ExecuteActivityParameters withTaskList(String taskList) { + this.taskList = taskList; + return this; + } + + public ExecuteActivityParameters createExecuteActivityParametersFromOptions(ActivitySchedulingOptions options, + ActivitySchedulingOptions optionsOverride) { + ExecuteActivityParameters scheduleActivityParameters = this.clone(); + + if (options != null) { + Long heartbeatTimeoutSeconds = options.getHeartbeatTimeoutSeconds(); + if (heartbeatTimeoutSeconds != null) { + scheduleActivityParameters.setHeartbeatTimeoutSeconds(heartbeatTimeoutSeconds); + } + + Long scheduleToCloseTimeout = options.getScheduleToCloseTimeoutSeconds(); + if (scheduleToCloseTimeout != null) { + scheduleActivityParameters.setScheduleToCloseTimeoutSeconds(scheduleToCloseTimeout); + } + + Long scheduleToStartTimeout = options.getScheduleToStartTimeoutSeconds(); + if (scheduleToStartTimeout != null) { + scheduleActivityParameters.setScheduleToStartTimeoutSeconds(scheduleToStartTimeout); + } + + Long startToCloseTimeoutSeconds = options.getStartToCloseTimeoutSeconds(); + if (startToCloseTimeoutSeconds != null) { + scheduleActivityParameters.setStartToCloseTimeoutSeconds(startToCloseTimeoutSeconds); + } + + String taskList = options.getTaskList(); + if (taskList != null && !taskList.isEmpty()) { + scheduleActivityParameters.setTaskList(taskList); + } + } + + if (optionsOverride != null) { + Long heartbeatTimeoutSeconds = optionsOverride.getHeartbeatTimeoutSeconds(); + if (heartbeatTimeoutSeconds != null) { + scheduleActivityParameters.setHeartbeatTimeoutSeconds(heartbeatTimeoutSeconds); + } + + Long scheduleToCloseTimeout = optionsOverride.getScheduleToCloseTimeoutSeconds(); + if (scheduleToCloseTimeout != null) { + scheduleActivityParameters.setScheduleToCloseTimeoutSeconds(scheduleToCloseTimeout); + } + + Long scheduleToStartTimeout = optionsOverride.getScheduleToStartTimeoutSeconds(); + if (scheduleToStartTimeout != null) { + scheduleActivityParameters.setScheduleToStartTimeoutSeconds(scheduleToStartTimeout); + } + + Long startToCloseTimeoutSeconds = optionsOverride.getStartToCloseTimeoutSeconds(); + if (startToCloseTimeoutSeconds != null) { + scheduleActivityParameters.setStartToCloseTimeoutSeconds(startToCloseTimeoutSeconds); + } + + String taskList = optionsOverride.getTaskList(); + if (taskList != null && !taskList.isEmpty()) { + scheduleActivityParameters.setTaskList(taskList); + } + } + + return scheduleActivityParameters; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + sb.append("ActivityType: " + activityType + ", "); + sb.append("ActivityId: " + activityId + ", "); + sb.append("Input: " + input + ", "); + sb.append("Control: " + control + ", "); + sb.append("HeartbeatTimeout: " + heartbeatTimeoutSeconds + ", "); + sb.append("ScheduleToStartTimeout: " + scheduleToStartTimeoutSeconds + ", "); + sb.append("ScheduleToCloseTimeout: " + scheduleToCloseTimeoutSeconds + ", "); + sb.append("StartToCloseTimeout: " + startToCloseTimeoutSeconds + ", "); + sb.append("TaskList: " + taskList); + sb.append("}"); + return sb.toString(); + } + + public ExecuteActivityParameters clone() { + ExecuteActivityParameters result = new ExecuteActivityParameters(); + result.setActivityType(activityType); + result.setActivityId(activityId); + result.setInput(input); + result.setControl(control); + result.setHeartbeatTimeoutSeconds(heartbeatTimeoutSeconds); + result.setScheduleToStartTimeoutSeconds(scheduleToStartTimeoutSeconds); + result.setScheduleToCloseTimeoutSeconds(scheduleToCloseTimeoutSeconds); + result.setStartToCloseTimeoutSeconds(startToCloseTimeoutSeconds); + result.setTaskList(taskList); + return result; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/GenericActivityClient.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/GenericActivityClient.java new file mode 100644 index 000000000000..a500d0c409dc --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/GenericActivityClient.java @@ -0,0 +1,54 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.generic; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +public interface GenericActivityClient { + + /** + * Used to dynamically schedule an activity for execution + * + * @param parameters + * An object which encapsulates all the information required to + * schedule an activity for execution + * @return Promise to the result returned by the activity + */ + public abstract Promise scheduleActivityTask(ExecuteActivityParameters parameters); + + /** + * Used to dynamically schedule an activity for execution + * + * @param activity + * Name of activity + * @param input + * A map of all input parameters to that activity + * @return Promise to a result returned by the activity + */ + public abstract Promise scheduleActivityTask(String activity, String version, String input); + + /** + * Used to dynamically schedule an activity using its name + * + * @param activity + * name of activity to schedule + * @param input + * a Value containing a map of all input parameters to that + * activity + * @return a Value which contains a Map of results returned by the activity + */ + public abstract Promise scheduleActivityTask(final String activity, final String version, final Promise input); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/GenericWorkflowClient.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/GenericWorkflowClient.java new file mode 100644 index 000000000000..db07dd625f88 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/GenericWorkflowClient.java @@ -0,0 +1,46 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.generic; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +public interface GenericWorkflowClient { + + /** + * Start child workflow. + * + * @return becomes ready when child successfully started. + * {@link StartChildWorkflowReply#getResult()} becomes ready upon + * child completion. + */ + public Promise startChildWorkflow(StartChildWorkflowExecutionParameters parameters); + + public Promise startChildWorkflow(String workflow, String version, String input); + + public Promise startChildWorkflow(String workflow, String version, Promise input); + + public Promise signalWorkflowExecution(SignalExternalWorkflowParameters signalParameters); + + public void requestCancelWorkflowExecution(WorkflowExecution execution); + + public void continueAsNewOnCompletion(ContinueAsNewWorkflowExecutionParameters parameters); + + /** + * Deterministic unique Id generator + */ + public String generateUniqueId(); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/GenericWorkflowClientExternal.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/GenericWorkflowClientExternal.java new file mode 100644 index 000000000000..7500f3853a66 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/GenericWorkflowClientExternal.java @@ -0,0 +1,34 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.generic; + +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + + +public interface GenericWorkflowClientExternal { + + public WorkflowExecution startWorkflow(StartWorkflowExecutionParameters startParameters); + + public void signalWorkflowExecution(SignalExternalWorkflowParameters signalParameters); + + public void requestCancelWorkflowExecution(WorkflowExecution execution); + + public String getWorkflowState(WorkflowExecution execution); + + public void terminateWorkflowExecution(TerminateWorkflowExecutionParameters terminateParameters); + + public String generateUniqueId(); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/SignalExternalWorkflowParameters.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/SignalExternalWorkflowParameters.java new file mode 100644 index 000000000000..3cfff2d7e254 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/SignalExternalWorkflowParameters.java @@ -0,0 +1,104 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.generic; + +public class SignalExternalWorkflowParameters implements Cloneable { + + private String input; + + private String runId; + + private String signalName; + + private String workflowId; + + public SignalExternalWorkflowParameters() { + } + + public String getInput() { + return input; + } + + public void setInput(String input) { + this.input = input; + } + + public SignalExternalWorkflowParameters withInput(String input) { + this.input = input; + return this; + } + + public String getRunId() { + return runId; + } + + public void setRunId(String runId) { + this.runId = runId; + } + + public SignalExternalWorkflowParameters withRunId(String runId) { + this.runId = runId; + return this; + } + + public String getSignalName() { + return signalName; + } + + public void setSignalName(String signalName) { + this.signalName = signalName; + } + + public SignalExternalWorkflowParameters withSignalName(String signalName) { + this.signalName = signalName; + return this; + } + + public String getWorkflowId() { + return workflowId; + } + + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + public SignalExternalWorkflowParameters withWorkflowId(String workflowId) { + this.workflowId = workflowId; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + sb.append("SignalName: " + signalName + ", "); + sb.append("Input: " + input + ", "); + sb.append("WorkflowId: " + workflowId + ", "); + sb.append("RunId: " + runId + ", "); + sb.append("}"); + return sb.toString(); + } + + public SignalExternalWorkflowParameters clone() { + SignalExternalWorkflowParameters result = new SignalExternalWorkflowParameters(); + result.setInput(input); + result.setRunId(runId); + result.setSignalName(signalName); + result.setWorkflowId(workflowId); + return result; + } + + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/StartChildWorkflowExecutionParameters.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/StartChildWorkflowExecutionParameters.java new file mode 100644 index 000000000000..45fbf68b9edf --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/StartChildWorkflowExecutionParameters.java @@ -0,0 +1,221 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.generic; + +import java.util.List; + +import com.amazonaws.services.simpleworkflow.flow.StartWorkflowOptions; +import com.amazonaws.services.simpleworkflow.flow.common.FlowConstants; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + + +public class StartChildWorkflowExecutionParameters implements Cloneable { + private String control; + private long executionStartToCloseTimeoutSeconds = FlowConstants.USE_REGISTERED_DEFAULTS; + private String input; + private List tagList; + private String taskList; + private long taskStartToCloseTimeoutSeconds = FlowConstants.USE_REGISTERED_DEFAULTS; + private String workflowId; + private WorkflowType workflowType; + + public StartChildWorkflowExecutionParameters() { + } + + public String getControl() { + return control; + } + + public void setControl(String control) { + this.control = control; + } + + public StartChildWorkflowExecutionParameters withControl(String control) { + this.control = control; + return this; + } + + public long getExecutionStartToCloseTimeoutSeconds() { + return executionStartToCloseTimeoutSeconds; + } + + public void setExecutionStartToCloseTimeoutSeconds(long executionStartToCloseTimeoutSeconds) { + this.executionStartToCloseTimeoutSeconds = executionStartToCloseTimeoutSeconds; + } + + public StartChildWorkflowExecutionParameters withExecutionStartToCloseTimeoutSeconds(long executionStartToCloseTimeoutSeconds) { + this.executionStartToCloseTimeoutSeconds = executionStartToCloseTimeoutSeconds; + return this; + } + + public String getInput() { + return input; + } + + public void setInput(String input) { + this.input = input; + } + + public StartChildWorkflowExecutionParameters withInput(String input) { + this.input = input; + return this; + } + + public List getTagList() { + return tagList; + } + + public void setTagList(List tagList) { + this.tagList = tagList; + } + + public StartChildWorkflowExecutionParameters withTagList(List tagList) { + this.tagList = tagList; + return this; + } + + public String getTaskList() { + return taskList; + } + + public void setTaskList(String taskList) { + this.taskList = taskList; + } + + public StartChildWorkflowExecutionParameters withTaskList(String taskList) { + this.taskList = taskList; + return this; + } + + public long getTaskStartToCloseTimeoutSeconds() { + return taskStartToCloseTimeoutSeconds; + } + + public void setTaskStartToCloseTimeoutSeconds(long taskStartToCloseTimeoutSeconds) { + this.taskStartToCloseTimeoutSeconds = taskStartToCloseTimeoutSeconds; + } + + public StartChildWorkflowExecutionParameters withTaskStartToCloseTimeoutSeconds(long taskStartToCloseTimeoutSeconds) { + this.taskStartToCloseTimeoutSeconds = taskStartToCloseTimeoutSeconds; + return this; + } + + public String getWorkflowId() { + return workflowId; + } + + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + public StartChildWorkflowExecutionParameters withWorkflowId(String workflowId) { + this.workflowId = workflowId; + return this; + } + + public WorkflowType getWorkflowType() { + return workflowType; + } + + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + public StartChildWorkflowExecutionParameters withWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + return this; + } + + public StartChildWorkflowExecutionParameters createStartChildWorkflowExecutionParametersFromOptions(StartWorkflowOptions options, + StartWorkflowOptions optionsOverride) { + StartChildWorkflowExecutionParameters startChildWorkflowExecutionParameters = this.clone(); + + if (options != null) { + Long executionStartToCloseTimeoutSeconds = options.getExecutionStartToCloseTimeoutSeconds(); + if (executionStartToCloseTimeoutSeconds != null) { + startChildWorkflowExecutionParameters.setExecutionStartToCloseTimeoutSeconds(executionStartToCloseTimeoutSeconds); + } + + Long taskStartToCloseTimeoutSeconds = options.getTaskStartToCloseTimeoutSeconds(); + if (taskStartToCloseTimeoutSeconds != null) { + startChildWorkflowExecutionParameters.setTaskStartToCloseTimeoutSeconds(taskStartToCloseTimeoutSeconds); + } + + List tagList = options.getTagList(); + if (tagList != null) { + startChildWorkflowExecutionParameters.setTagList(tagList); + } + + String taskList = options.getTaskList(); + if (taskList != null && !taskList.isEmpty()) { + startChildWorkflowExecutionParameters.setTaskList(taskList); + } + } + + if (optionsOverride != null) { + Long executionStartToCloseTimeoutSeconds = optionsOverride.getExecutionStartToCloseTimeoutSeconds(); + if (executionStartToCloseTimeoutSeconds != null) { + startChildWorkflowExecutionParameters.setExecutionStartToCloseTimeoutSeconds(executionStartToCloseTimeoutSeconds); + } + + Long taskStartToCloseTimeoutSeconds = optionsOverride.getTaskStartToCloseTimeoutSeconds(); + if (taskStartToCloseTimeoutSeconds != null) { + startChildWorkflowExecutionParameters.setTaskStartToCloseTimeoutSeconds(taskStartToCloseTimeoutSeconds); + } + + List tagList = optionsOverride.getTagList(); + if (tagList != null) { + startChildWorkflowExecutionParameters.setTagList(tagList); + } + + String taskList = optionsOverride.getTaskList(); + if (taskList != null && !taskList.isEmpty()) { + startChildWorkflowExecutionParameters.setTaskList(taskList); + } + } + + return startChildWorkflowExecutionParameters; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + sb.append("WorkflowType: " + workflowType + ", "); + sb.append("WorkflowId: " + workflowId + ", "); + sb.append("Input: " + input + ", "); + sb.append("Control: " + control + ", "); + sb.append("ExecutionStartToCloseTimeout: " + executionStartToCloseTimeoutSeconds + ", "); + sb.append("TaskStartToCloseTimeout: " + taskStartToCloseTimeoutSeconds + ", "); + sb.append("TagList: " + tagList + ", "); + sb.append("TaskList: " + taskList); + sb.append("}"); + return sb.toString(); + } + + public StartChildWorkflowExecutionParameters clone() { + StartChildWorkflowExecutionParameters result = new StartChildWorkflowExecutionParameters(); + result.setControl(control); + result.setExecutionStartToCloseTimeoutSeconds(executionStartToCloseTimeoutSeconds); + result.setInput(input); + result.setTagList(tagList); + result.setTaskList(taskList); + result.setTaskStartToCloseTimeoutSeconds(taskStartToCloseTimeoutSeconds); + result.setWorkflowId(workflowId); + result.setWorkflowType(workflowType); + return result; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/StartChildWorkflowReply.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/StartChildWorkflowReply.java new file mode 100644 index 000000000000..356f43613f7b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/StartChildWorkflowReply.java @@ -0,0 +1,26 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.generic; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + + +public interface StartChildWorkflowReply { + + public String getRunId(); + + public Promise getResult(); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/StartWorkflowExecutionParameters.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/StartWorkflowExecutionParameters.java new file mode 100644 index 000000000000..ba4c1835fde7 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/StartWorkflowExecutionParameters.java @@ -0,0 +1,406 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.generic; + +import com.amazonaws.services.simpleworkflow.flow.StartWorkflowOptions; +import com.amazonaws.services.simpleworkflow.flow.common.FlowConstants; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +public class StartWorkflowExecutionParameters { + + private String workflowId; + + private WorkflowType workflowType; + + private String taskList; + + private String input; + + private long executionStartToCloseTimeoutSeconds = FlowConstants.USE_REGISTERED_DEFAULTS; + + private long taskStartToCloseTimeoutSeconds = FlowConstants.USE_REGISTERED_DEFAULTS; + + private java.util.List tagList; + + /** + * Returns the value of the WorkflowId property for this object. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @return The value of the WorkflowId property for this object. + */ + public String getWorkflowId() { + return workflowId; + } + + /** + * Sets the value of the WorkflowId property for this object. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param workflowId The new value for the WorkflowId property for this object. + */ + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + /** + * Sets the value of the WorkflowId property for this object. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param workflowId The new value for the WorkflowId property for this object. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartWorkflowExecutionParameters withWorkflowId(String workflowId) { + this.workflowId = workflowId; + return this; + } + + + /** + * Returns the value of the WorkflowType property for this object. + * + * @return The value of the WorkflowType property for this object. + */ + public WorkflowType getWorkflowType() { + return workflowType; + } + + /** + * Sets the value of the WorkflowType property for this object. + * + * @param workflowType The new value for the WorkflowType property for this object. + */ + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + /** + * Sets the value of the WorkflowType property for this object. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowType The new value for the WorkflowType property for this object. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartWorkflowExecutionParameters withWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + return this; + } + + + /** + * Returns the value of the TaskList property for this object. + * + * @return The value of the TaskList property for this object. + */ + public String getTaskList() { + return taskList; + } + + /** + * Sets the value of the TaskList property for this object. + * + * @param taskList The new value for the TaskList property for this object. + */ + public void setTaskList(String taskList) { + this.taskList = taskList; + } + + /** + * Sets the value of the TaskList property for this object. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param taskList The new value for the TaskList property for this object. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartWorkflowExecutionParameters withTaskList(String taskList) { + this.taskList = taskList; + return this; + } + + + /** + * Returns the value of the Input property for this object. + *

+ * Constraints:
+ * Length: 0 - 100000
+ * + * @return The value of the Input property for this object. + */ + public String getInput() { + return input; + } + + /** + * Sets the value of the Input property for this object. + *

+ * Constraints:
+ * Length: 0 - 100000
+ * + * @param input The new value for the Input property for this object. + */ + public void setInput(String input) { + this.input = input; + } + + /** + * Sets the value of the Input property for this object. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 100000
+ * + * @param input The new value for the Input property for this object. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartWorkflowExecutionParameters withInput(String input) { + this.input = input; + return this; + } + + + /** + * Returns the value of the StartToCloseTimeout property for this object. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @return The value of the StartToCloseTimeout property for this object. + */ + public long getExecutionStartToCloseTimeout() { + return executionStartToCloseTimeoutSeconds; + } + + /** + * Sets the value of the StartToCloseTimeout property for this object. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param startToCloseTimeout The new value for the StartToCloseTimeout property for this object. + */ + public void setExecutionStartToCloseTimeoutSeconds(long executionStartToCloseTimeoutSeconds) { + this.executionStartToCloseTimeoutSeconds = executionStartToCloseTimeoutSeconds; + } + + /** + * Sets the value of the StartToCloseTimeout property for this object. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param startToCloseTimeout The new value for the StartToCloseTimeout property for this object. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartWorkflowExecutionParameters withExecutionStartToCloseTimeoutSeconds(long executionStartToCloseTimeoutSeconds) { + this.executionStartToCloseTimeoutSeconds = executionStartToCloseTimeoutSeconds; + return this; + } + + public long getTaskStartToCloseTimeoutSeconds() { + return taskStartToCloseTimeoutSeconds; + } + + public void setTaskStartToCloseTimeoutSeconds(long taskStartToCloseTimeoutSeconds) { + this.taskStartToCloseTimeoutSeconds = taskStartToCloseTimeoutSeconds; + } + + public StartWorkflowExecutionParameters withTaskStartToCloseTimeoutSeconds(long taskStartToCloseTimeoutSeconds) { + this.taskStartToCloseTimeoutSeconds = taskStartToCloseTimeoutSeconds; + return this; + } + + /** + * Returns the value of the TagList property for this object. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @return The value of the TagList property for this object. + */ + public java.util.List getTagList() { + if (tagList == null) { + tagList = new java.util.ArrayList(); + } + return tagList; + } + + /** + * Sets the value of the TagList property for this object. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The new value for the TagList property for this object. + */ + public void setTagList(java.util.Collection tagList) { + java.util.List tagListCopy = new java.util.ArrayList(); + if (tagList != null) { + tagListCopy.addAll(tagList); + } + this.tagList = tagListCopy; + } + + /** + * Sets the value of the TagList property for this object. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The new value for the TagList property for this object. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartWorkflowExecutionParameters withTagList(String... tagList) { + for (String value : tagList) { + getTagList().add(value); + } + return this; + } + + /** + * Sets the value of the TagList property for this object. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The new value for the TagList property for this object. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartWorkflowExecutionParameters withTagList(java.util.Collection tagList) { + java.util.List tagListCopy = new java.util.ArrayList(); + if (tagList != null) { + tagListCopy.addAll(tagList); + } + this.tagList = tagListCopy; + + return this; + } + + public StartWorkflowExecutionParameters createStartWorkflowExecutionParametersFromOptions(StartWorkflowOptions options, + StartWorkflowOptions optionsOverride) { + StartWorkflowExecutionParameters parameters = this.clone(); + + if (options != null) { + Long executionStartToCloseTimeout = options.getExecutionStartToCloseTimeoutSeconds(); + if (executionStartToCloseTimeout != null) { + parameters.setExecutionStartToCloseTimeoutSeconds(executionStartToCloseTimeout); + } + + Long taskStartToCloseTimeout = options.getTaskStartToCloseTimeoutSeconds(); + if (taskStartToCloseTimeout != null) { + parameters.setTaskStartToCloseTimeoutSeconds(taskStartToCloseTimeout); + } + + java.util.Collection tagList = options.getTagList(); + if (tagList != null) { + parameters.setTagList(tagList); + } + + String taskList = options.getTaskList(); + if (taskList != null && !taskList.isEmpty()) { + parameters.setTaskList(taskList); + } + } + + if (optionsOverride != null) { + Long executionStartToCloseTimeout = optionsOverride.getExecutionStartToCloseTimeoutSeconds(); + if (executionStartToCloseTimeout != null) { + parameters.setExecutionStartToCloseTimeoutSeconds(executionStartToCloseTimeout); + } + + Long taskStartToCloseTimeout = optionsOverride.getTaskStartToCloseTimeoutSeconds(); + if (taskStartToCloseTimeout != null) { + parameters.setTaskStartToCloseTimeoutSeconds(taskStartToCloseTimeout); + } + + java.util.Collection tagList = optionsOverride.getTagList(); + if (tagList != null) { + parameters.setTagList(tagList); + } + + String taskList = optionsOverride.getTaskList(); + if (taskList != null && !taskList.isEmpty()) { + parameters.setTaskList(taskList); + } + } + + return parameters; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + sb.append("WorkflowId: " + workflowId + ", "); + sb.append("WorkflowType: " + workflowType + ", "); + sb.append("TaskList: " + taskList + ", "); + sb.append("Input: " + input + ", "); + sb.append("StartToCloseTimeout: " + executionStartToCloseTimeoutSeconds + ", "); + sb.append("TagList: " + tagList + ", "); + sb.append("}"); + return sb.toString(); + } + + public StartWorkflowExecutionParameters clone() { + StartWorkflowExecutionParameters result = new StartWorkflowExecutionParameters(); + result.setInput(input); + result.setExecutionStartToCloseTimeoutSeconds(executionStartToCloseTimeoutSeconds); + result.setTaskStartToCloseTimeoutSeconds(taskStartToCloseTimeoutSeconds); + result.setTagList(tagList); + result.setTaskList(taskList); + result.setWorkflowId(workflowId); + result.setWorkflowType(workflowType); + return result; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/TerminateWorkflowExecutionParameters.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/TerminateWorkflowExecutionParameters.java new file mode 100644 index 000000000000..b0653430c75f --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/TerminateWorkflowExecutionParameters.java @@ -0,0 +1,79 @@ +package com.amazonaws.services.simpleworkflow.flow.generic; + +import com.amazonaws.services.simpleworkflow.model.ChildPolicy; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +public class TerminateWorkflowExecutionParameters { + + private WorkflowExecution workflowExecution; + + private ChildPolicy childPolicy; + + private String reason; + + private String details; + + public TerminateWorkflowExecutionParameters() { + } + + public TerminateWorkflowExecutionParameters(WorkflowExecution workflowExecution, ChildPolicy childPolicy, String reason, + String details) { + this.workflowExecution = workflowExecution; + this.childPolicy = childPolicy; + this.reason = reason; + this.details = details; + } + + public WorkflowExecution getWorkflowExecution() { + return workflowExecution; + } + + public void setWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + } + + public TerminateWorkflowExecutionParameters withWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + return this; + } + + public ChildPolicy getChildPolicy() { + return childPolicy; + } + + public void setChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy; + } + + public TerminateWorkflowExecutionParameters withChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy; + return this; + } + + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } + + public TerminateWorkflowExecutionParameters withReason(String reason) { + this.reason = reason; + return this; + } + + public String getDetails() { + return details; + } + + public void setDetails(String details) { + this.details = details; + } + + public TerminateWorkflowExecutionParameters withDetails(String details) { + this.details = details; + return this; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/WorkflowDefinition.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/WorkflowDefinition.java new file mode 100644 index 000000000000..a566ae79a797 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/WorkflowDefinition.java @@ -0,0 +1,84 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.generic; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.WorkflowException; +import com.amazonaws.services.simpleworkflow.flow.annotations.Asynchronous; +import com.amazonaws.services.simpleworkflow.flow.annotations.Execute; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.core.Task; +import com.amazonaws.services.simpleworkflow.flow.core.TryCatchFinally; +import com.amazonaws.services.simpleworkflow.model.RespondDecisionTaskCompletedRequest; + +/** + * Base class for all workflow definitions. Implementation should use + * {@link Execute} to specify workflow name different from implementation class + * name, different workflow version and other workflow instance registration and + * execution parameters. + * + * @see Execute + * @author fateev + */ +public abstract class WorkflowDefinition { + + /** + * Asynchronous method that implements workflow business logic. This method + * invocation is surrounded by {@link TryCatchFinally}. Workflow is + * completed when {@link TryCatchFinally#doFinally()} is executed. So even + * if return {@link Promise} of the method is ready but there is some + * asynchronous task or activity still not completed workflow is not going + * to complete. + * + * @param input + * Data passed to the worklfow instance during start instance + * call. + * @return + * @throws WorkflowException + * Prefer throwing {@link WorkflowException}. + */ + public abstract Promise execute(String input) throws WorkflowException; + + /** + * Asynchronous method that implements signals handling logic. This method + * invocation is surrounded by the same doTry of {@link TryCatchFinally} + * that is used to execute workflow. It means that non handled failure + * inside this method causes workflow execution failure. + * + * @throws Exception + * Prefer throwing {@link WorkflowException}. + * @throws Exception + */ + public abstract void signalRecieved(String signalName, String input) throws WorkflowException; + + /** + * Return state that is inserted decision completion through + * {@link RespondDecisionTaskCompletedRequest#setExecutionContext(String)} + * and later can be retrieved through + * {@link AmazonSimpleWorkflow#describeWorkflowExecution(com.amazonaws.services.simpleworkflow.model.DescribeWorkflowExecutionRequest)} + * visibility call. + * + * Implementation of this call is expected to be synchronous and is not + * allowed to invoke any asynchronous operations like creation of new + * {@link Task} or calling methods marked with {@link Asynchronous} + * annotation. It is also expected to be read only operation which is not + * allowed to modify state of workflow in any way. + * + * @return current state of the workflow execution. + * @throws WorkflowException + */ + public abstract String getWorkflowState() throws WorkflowException; + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/WorkflowDefinitionFactory.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/WorkflowDefinitionFactory.java new file mode 100644 index 000000000000..564e4bd69d2b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/WorkflowDefinitionFactory.java @@ -0,0 +1,37 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.generic; + +import com.amazonaws.services.simpleworkflow.flow.DecisionContext; +import com.amazonaws.services.simpleworkflow.flow.WorkflowTypeRegistrationOptions; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +public abstract class WorkflowDefinitionFactory { + + /** + * + * @return options to use when registering workflow type with the service. + * null if registration is not necessary on executor + * startup. + */ + public abstract WorkflowTypeRegistrationOptions getWorkflowRegistrationOptions(); + + public abstract WorkflowDefinition getWorkflowDefinition(DecisionContext context) throws Exception; + + public abstract void deleteWorkflowDefinition(WorkflowDefinition instance); + + public abstract WorkflowType getWorkflowType(); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/WorkflowDefinitionFactoryFactory.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/WorkflowDefinitionFactoryFactory.java new file mode 100644 index 000000000000..ac03c4fdae68 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/generic/WorkflowDefinitionFactoryFactory.java @@ -0,0 +1,32 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.generic; + +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +public abstract class WorkflowDefinitionFactoryFactory { + + public abstract WorkflowDefinitionFactory getWorkflowDefinitionFactory(WorkflowType workflowType); + + /** + * There is no requirement to return any types. If type is returned + * {@link #getWorkflowDefinitionFactory(WorkflowType)} should support it. + * + * @return types that should be registered before polling and executing + * decision tasks. + */ + public abstract Iterable getWorkflowTypesToRegister(); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/Decorator.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/Decorator.java new file mode 100644 index 000000000000..dc741dedee5c --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/Decorator.java @@ -0,0 +1,22 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.interceptors; + + +public interface Decorator { + public V decorate(Class interfaces, V object); + + public V decorate(Class[] interfaces, V object); +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/ExponentialRetryPolicy.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/ExponentialRetryPolicy.java new file mode 100644 index 000000000000..8070d1c146bd --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/ExponentialRetryPolicy.java @@ -0,0 +1,138 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.interceptors; + +import java.util.Collection; +import java.util.Date; + +import com.amazonaws.services.simpleworkflow.flow.common.FlowConstants; +import com.amazonaws.services.simpleworkflow.flow.common.FlowDefaults; + +public class ExponentialRetryPolicy extends RetryPolicyBase { + + private final long initialRetryIntervalSeconds; + private long maximumRetryIntervalSeconds = FlowDefaults.EXPONENTIAL_RETRY_MAXIMUM_RETRY_INTERVAL_SECONDS; + private long retryExpirationIntervalSeconds = FlowDefaults.EXPONENTIAL_RETRY_RETRY_EXPIRATION_SECONDS; + private double backoffCoefficient = FlowDefaults.EXPONENTIAL_RETRY_BACKOFF_COEFFICIENT; + private int maximumAttempts = FlowDefaults.EXPONENTIAL_RETRY_MAXIMUM_ATTEMPTS; + + public ExponentialRetryPolicy(long initialRetryIntervalSeconds) { + this.initialRetryIntervalSeconds = initialRetryIntervalSeconds; + } + + public long getInitialRetryIntervalSeconds() { + return initialRetryIntervalSeconds; + } + + public long getMaximumRetryIntervalSeconds() { + return maximumRetryIntervalSeconds; + } + + public void setMaximumRetryIntervalSeconds(long maximumRetryIntervalSeconds) { + this.maximumRetryIntervalSeconds = maximumRetryIntervalSeconds; + } + + public ExponentialRetryPolicy withMaximumRetryIntervalSeconds(long maximumRetryIntervalSeconds) { + this.maximumRetryIntervalSeconds = maximumRetryIntervalSeconds; + return this; + } + + public long getRetryExpirationIntervalSeconds() { + return retryExpirationIntervalSeconds; + } + + public void setRetryExpirationIntervalSeconds(long retryExpirationIntervalSeconds) { + this.retryExpirationIntervalSeconds = retryExpirationIntervalSeconds; + } + + public ExponentialRetryPolicy withRetryExpirationIntervalSeconds(long retryExpirationIntervalSeconds) { + this.retryExpirationIntervalSeconds = retryExpirationIntervalSeconds; + return this; + } + + public double getBackoffCoefficient() { + return backoffCoefficient; + } + + public void setBackoffCoefficient(double backoffCoefficient) { + this.backoffCoefficient = backoffCoefficient; + } + + public ExponentialRetryPolicy withBackoffCoefficient(double backoffCoefficient) { + this.backoffCoefficient = backoffCoefficient; + return this; + } + + public int getMaximumAttempts() { + return maximumAttempts; + } + + public void setMaximumAttempts(int maximumAttempts) { + this.maximumAttempts = maximumAttempts; + } + + public ExponentialRetryPolicy withMaximumAttempts(int maximumAttempts) { + this.maximumAttempts = maximumAttempts; + return this; + } + + @Override + public ExponentialRetryPolicy withExceptionsToRetry(Collection> exceptionsToRetry) { + super.withExceptionsToRetry(exceptionsToRetry); + return this; + } + + @Override + public ExponentialRetryPolicy withExceptionsToExclude(Collection> exceptionsToRetry) { + super.withExceptionsToExclude(exceptionsToRetry); + return this; + } + + @Override + public long nextRetryDelaySeconds(Date firstAttempt, Date recordedFailure, int numberOfTries) { + + if (numberOfTries < 2) { + throw new IllegalArgumentException("attempt is less then 2: " + numberOfTries); + } + + if (maximumAttempts > FlowConstants.NONE && numberOfTries > maximumAttempts) { + return -1; + } + + long result = (long) (initialRetryIntervalSeconds * Math.pow(backoffCoefficient, numberOfTries - 2)); + result = maximumRetryIntervalSeconds > FlowConstants.NONE ? Math.min(result, maximumRetryIntervalSeconds) : result; + int secondsSinceFirstAttempt = (int) ((recordedFailure.getTime() - firstAttempt.getTime()) / 1000); + if (retryExpirationIntervalSeconds > FlowConstants.NONE && secondsSinceFirstAttempt + result >= retryExpirationIntervalSeconds) { + return -1; + } + + return result; + } + + /** + * Performs the following three validation checks for ExponentialRetry Policy: + * 1) initialRetryIntervalSeconds is not greater than maximumRetryIntervalSeconds + * 2) initialRetryIntervalSeconds is not greater than retryExpirationIntervalSeconds + */ + public void validate() throws IllegalStateException { + if (maximumRetryIntervalSeconds > FlowConstants.NONE && initialRetryIntervalSeconds > maximumRetryIntervalSeconds) { + throw new IllegalStateException("ExponentialRetryPolicy requires maximumRetryIntervalSeconds to have a value larger than initialRetryIntervalSeconds."); + } + + if (retryExpirationIntervalSeconds > FlowConstants.NONE && initialRetryIntervalSeconds > retryExpirationIntervalSeconds) { + throw new IllegalStateException("ExponentialRetryPolicy requires retryExpirationIntervalSeconds to have a value larger than initialRetryIntervalSeconds."); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryCallable.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryCallable.java new file mode 100644 index 000000000000..bc8c8244c2b8 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryCallable.java @@ -0,0 +1,21 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.interceptors; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +public interface RetryCallable { + Promise call() throws Throwable; +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryDecorator.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryDecorator.java new file mode 100644 index 000000000000..51f6c851cbf6 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryDecorator.java @@ -0,0 +1,100 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.interceptors; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +public class RetryDecorator implements Decorator { + + private final RetryPolicy retryPolicy; + + public RetryDecorator(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + } + + @SuppressWarnings("unchecked") + @Override + public final V decorate(Class interfaces, V object) { + + Class[] interfazes = {interfaces}; + + return (V)Proxy.newProxyInstance( + object.getClass().getClassLoader(), + interfazes, + new DecoratorInvocationHandler(object, retryPolicy)); + + } + + @SuppressWarnings("unchecked") + @Override + public final V decorate(Class[] interfaces, V object) { + + return (V)Proxy.newProxyInstance( + object.getClass().getClassLoader(), + interfaces, + new DecoratorInvocationHandler(object, retryPolicy)); + } + + private final class DecoratorInvocationHandler implements InvocationHandler { + + private final Object object; + private final RetryPolicy retryPolicy; + + + public DecoratorInvocationHandler(Object object, RetryPolicy retryPolicy) { + this.object = object; + this.retryPolicy = retryPolicy; + } + + @Override + public Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable { + try { + if (!isDecorated(method, args)) { + return method.invoke(object, args); + } + } catch (InvocationTargetException ite) { + throw ite.getTargetException(); + } + + @SuppressWarnings("rawtypes") + RetryCallable retryCallable = new RetryCallable() { + + @Override + public Promise call() throws Throwable { + return (Promise) method.invoke(object, args); + } + }; + + boolean isVoidReturnType = Void.TYPE.equals(method.getReturnType()); + RetryInterceptor interceptor = null; + if (isVoidReturnType) { + interceptor = new RetryInterceptorVoid(retryCallable, retryPolicy); + } else { + interceptor = new RetryInterceptorWithResult(retryCallable, retryPolicy); + } + + return interceptor.execute(); + } + } + + protected boolean isDecorated(Method method, Object[] args) { + return !method.getDeclaringClass().equals(Object.class); + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryInterceptor.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryInterceptor.java new file mode 100644 index 000000000000..dd30a03b14d5 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryInterceptor.java @@ -0,0 +1,6 @@ +package com.amazonaws.services.simpleworkflow.flow.interceptors; + + +public interface RetryInterceptor { + public Object execute() throws Throwable; +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryInterceptorBase.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryInterceptorBase.java new file mode 100644 index 000000000000..b7573bc80700 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryInterceptorBase.java @@ -0,0 +1,19 @@ +package com.amazonaws.services.simpleworkflow.flow.interceptors; + +import com.amazonaws.services.simpleworkflow.flow.DecisionContextProvider; +import com.amazonaws.services.simpleworkflow.flow.DecisionContextProviderImpl; + + +@SuppressWarnings("rawtypes") +public abstract class RetryInterceptorBase implements RetryInterceptor { + protected final DecisionContextProvider contextProvider = new DecisionContextProviderImpl(); + protected final RetryCallable retryCallable; + protected final RetryPolicy retryPolicy; + + public RetryInterceptorBase(RetryCallable retryCallable, RetryPolicy retryPolicy) { + this.retryCallable = retryCallable; + this.retryPolicy = retryPolicy; + } + + public abstract Object execute() throws Throwable; +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryInterceptorVoid.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryInterceptorVoid.java new file mode 100644 index 000000000000..4f2e9a7765b2 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryInterceptorVoid.java @@ -0,0 +1,96 @@ +package com.amazonaws.services.simpleworkflow.flow.interceptors; + +import java.util.Date; +import java.util.concurrent.CancellationException; + +import com.amazonaws.services.simpleworkflow.flow.WorkflowClock; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.core.Settable; +import com.amazonaws.services.simpleworkflow.flow.core.Task; +import com.amazonaws.services.simpleworkflow.flow.core.TryCatchFinally; + +@SuppressWarnings("rawtypes") +public class RetryInterceptorVoid extends RetryInterceptorBase { + + public RetryInterceptorVoid(RetryCallable retryCallable, RetryPolicy retryPolicy) { + super(retryCallable, retryPolicy); + } + + @Override + public Object execute() throws Throwable { + WorkflowClock clock = contextProvider.getDecisionContext().getWorkflowClock(); + scheduleWithRetry(null, 1, clock.currentTimeMillis(), 0, clock); + return null; + } + + private void scheduleWithRetry(final Throwable failure, final int attempt, + final long firstAttemptTime, final long timeOfRecordedFailure, final WorkflowClock clock) throws Throwable { + + long delay = -1; + if (attempt > 1) { + if (!retryPolicy.isRetryable(failure)) { + throw failure; + } + + delay = retryPolicy.nextRetryDelaySeconds(new Date(firstAttemptTime), new Date(timeOfRecordedFailure), attempt); + + if (delay < 0) { + throw failure; + } + } + + if (delay > 0) { + Promise timer = clock.createTimer(delay); + new Task(timer) { + @Override + protected void doExecute() throws Throwable { + invoke(attempt, firstAttemptTime, clock); + } + }; + } else { + invoke(attempt, firstAttemptTime, clock); + } + + } + + private void invoke(final int attempt, final long firstAttemptTime, final WorkflowClock clock) { + final Settable shouldRetry = new Settable(); + + new TryCatchFinally() { + Throwable failureToRetry = null; + + @Override + protected void doTry() throws Throwable { + retryCallable.call(); + } + + @Override + protected void doCatch(Throwable failure) throws Throwable { + if (failure instanceof Error || failure instanceof CancellationException) { + throw failure; + } + + failureToRetry = failure; + } + + @Override + protected void doFinally() throws Throwable { + shouldRetry.set(failureToRetry); + + } + }; + + new Task(shouldRetry) { + + @Override + protected void doExecute() throws Throwable { + Throwable failure = shouldRetry.get(); + if (failure != null) { + scheduleWithRetry((Exception) failure, attempt + 1, firstAttemptTime, + clock.currentTimeMillis(), clock); + } + } + }; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryInterceptorWithResult.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryInterceptorWithResult.java new file mode 100644 index 000000000000..ef0b6055fc51 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryInterceptorWithResult.java @@ -0,0 +1,115 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.interceptors; + +import java.util.Date; +import java.util.concurrent.CancellationException; + +import com.amazonaws.services.simpleworkflow.flow.WorkflowClock; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.core.Settable; +import com.amazonaws.services.simpleworkflow.flow.core.Task; +import com.amazonaws.services.simpleworkflow.flow.core.TryCatchFinally; + +@SuppressWarnings("rawtypes") +public class RetryInterceptorWithResult extends RetryInterceptorBase { + + public RetryInterceptorWithResult(RetryCallable retryCallable, RetryPolicy retryPolicy) { + super(retryCallable, retryPolicy); + } + + @Override + public Object execute() throws Throwable { + Settable result = new Settable(); + WorkflowClock clock = contextProvider.getDecisionContext().getWorkflowClock(); + scheduleWithRetry(result, null, 1, clock.currentTimeMillis(), + 0, clock); + return result; + } + + private void scheduleWithRetry(final Settable result, final Throwable failure, final int attempt, + final long firstAttemptTime, final long timeOfRecordedFailure, final WorkflowClock clock) throws Throwable { + + long delay = -1; + if (attempt > 1) { + if (!retryPolicy.isRetryable(failure)) { + throw failure; + } + + delay = retryPolicy.nextRetryDelaySeconds(new Date(firstAttemptTime), new Date(timeOfRecordedFailure), attempt); + + if (delay < 0) { + throw failure; + } + } + + if (delay > 0) { + Promise timer = clock.createTimer(delay); + new Task(timer) { + @Override + protected void doExecute() throws Throwable { + invoke(result, attempt, firstAttemptTime, clock); + } + }; + } else { + invoke(result, attempt, firstAttemptTime, clock); + } + + } + + @SuppressWarnings("unchecked") + private void invoke(final Settable result, final int attempt, final long firstAttemptTime, final WorkflowClock clock) { + final Settable shouldRetry = new Settable(); + + new TryCatchFinally() { + Throwable failureToRetry = null; + + @Override + protected void doTry() throws Throwable { + result.chain(retryCallable.call()); + } + + @Override + protected void doCatch(Throwable failure) throws Throwable { + if (failure instanceof Error || failure instanceof CancellationException) { + throw failure; + } + if (result.isReady()) { + throw new IllegalStateException("Cannot retry as result is in ready state", failure); + } + result.unchain(); + failureToRetry = failure; + } + + @Override + protected void doFinally() throws Throwable { + shouldRetry.set(failureToRetry); + } + }; + + new Task(shouldRetry) { + + @Override + protected void doExecute() throws Throwable { + Throwable failure = shouldRetry.get(); + if (failure != null) { + scheduleWithRetry(result, (Exception) failure, attempt + 1, firstAttemptTime, + clock.currentTimeMillis(), clock); + } + } + }; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryPolicy.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryPolicy.java new file mode 100644 index 000000000000..073fdc86a5f2 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryPolicy.java @@ -0,0 +1,25 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.interceptors; + +import java.util.Date; + + +public interface RetryPolicy { + + boolean isRetryable(Throwable failure); + + long nextRetryDelaySeconds(Date firstAttempt, Date recordedFailure, int numberOfTries); +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryPolicyBase.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryPolicyBase.java new file mode 100644 index 000000000000..7d2abb6f3bb9 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/RetryPolicyBase.java @@ -0,0 +1,109 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.interceptors; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import com.amazonaws.services.simpleworkflow.flow.DecisionException; + + +public abstract class RetryPolicyBase implements RetryPolicy { + + private List> exceptionsToRetry; + + private List> exceptionsToExclude; + + public List> getExceptionsToRetry() { + if (exceptionsToRetry == null) { + exceptionsToRetry = new ArrayList>(); + exceptionsToRetry.add(Throwable.class); + } + return exceptionsToRetry; + } + + public void setExceptionsToRetry(List> exceptionsToRetry) { + List> exceptionsToRetryCopy = new ArrayList>(); + if (exceptionsToRetry != null) { + exceptionsToRetryCopy.addAll(exceptionsToRetry); + } + + this.exceptionsToRetry = exceptionsToRetryCopy; + } + + public RetryPolicyBase withExceptionsToRetry(Collection> exceptionsToRetry) { + List> exceptionsToRetryCopy = new ArrayList>(); + if (exceptionsToRetry != null) { + exceptionsToRetryCopy.addAll(exceptionsToRetry); + } + + this.exceptionsToRetry = exceptionsToRetryCopy; + return this; + } + + public List> getExceptionsToExclude() { + if (exceptionsToExclude == null) { + exceptionsToExclude = new ArrayList>(); + } + return exceptionsToExclude; + } + + public void setExceptionsToExclude(List> exceptionsToExclude) { + List> exceptionsToExcludeCopy = new ArrayList>(); + if (exceptionsToExclude != null) { + exceptionsToExcludeCopy.addAll(exceptionsToRetry); + } + + this.exceptionsToExclude = exceptionsToExcludeCopy; + } + + public RetryPolicyBase withExceptionsToExclude(Collection> exceptionsToRetry) { + List> exceptionsToExcludeCopy = new ArrayList>(); + if (exceptionsToExclude != null) { + exceptionsToExcludeCopy.addAll(exceptionsToRetry); + } + + this.exceptionsToExclude = exceptionsToExcludeCopy; + return this; + } + + @Override + public boolean isRetryable(Throwable failure) { + boolean isRetryable = false; + + if (failure instanceof DecisionException && failure.getCause() != null) { + failure = failure.getCause(); + } + + for (Class exceptionToRetry: getExceptionsToRetry()) { + if (exceptionToRetry.isAssignableFrom(failure.getClass())) { + isRetryable = true; + break; + } + } + + if (isRetryable) { + for (Class exceptionNotToRetry: getExceptionsToExclude()) { + if (exceptionNotToRetry.isAssignableFrom(failure.getClass())) { + isRetryable = false; + break; + } + } + } + + return isRetryable; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/AsyncAssert.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/AsyncAssert.java new file mode 100644 index 000000000000..1818b28ce4e8 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/AsyncAssert.java @@ -0,0 +1,465 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.junit; + +import org.junit.Assert; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.core.Task; + +/** + * Similar to {@link Assert} which waits on {@link Promise} argument before + * calling correspondent Assert... function. + *

+ * To avoid overload conflicts "WaitFor" postfix is used for methods that define + * varargs "waitFor" argument. + *

+ * For example when AsyncAssert.assertEquals("expected", "expected", + * waitForMe) is called Java resolves it to + * void assertEquals(final String message, final Object expected, final Promise actual) + * when + * void assertEquals(final Object expected, final Object actual, Promise... waitFor) + * was assumed. + * + * + * @see Assert + */ +public class AsyncAssert { + + protected AsyncAssert() { + } + + static public void assertReady(String message, Promise condition) { + Assert.assertTrue(message, condition.isReady()); + } + + static public void assertReady(Promise condition) { + Assert.assertTrue(condition.isReady()); + } + + static public void assertNotReady(String message, Promise condition) { + Assert.assertFalse(message, condition.isReady()); + } + + static public void assertNotReady(Promise condition) { + Assert.assertFalse(condition.isReady()); + } + + static public void assertTrueWaitFor(final String message, final boolean condition, Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertTrue(message, condition); + } + }; + } + + static public void assertTrue(final String message, final Promise condition) { + new Task(condition) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertTrue(message, condition.get()); + } + }; + } + + static public void assertTrueWaitFor(final boolean condition, Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertTrue(condition); + } + }; + } + + static public void assertTrue(final Promise condition) { + new Task(condition) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertTrue(condition.get()); + } + }; + } + + static public void assertFalseWaitFor(final String message, final boolean condition, Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertFalse(message, condition); + } + }; + } + + static public void assertFalse(final String message, final Promise condition) { + new Task(condition) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertFalse(message, condition.get()); + } + }; + } + + static public void assertFalseWaitFor(final boolean condition, Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertFalse(condition); + } + }; + } + + static public void assertFalse(final Promise condition) { + new Task(condition) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertFalse(condition.get()); + } + }; + } + + static public void assertEquals(final String message, final Object expected, final Promise actual) { + new Task(actual) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertEquals(message, expected, actual.get()); + } + }; + } + + static public void assertEqualsWaitFor(final String message, final Object expected, final Object actual, + Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertEquals(message, expected, actual); + } + }; + } + + static public void assertEquals(final Object expected, final Promise actual) { + new Task(actual) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertEquals(expected, actual.get()); + } + }; + } + + static public void assertEqualsWaitFor(final Object expected, final Object actual, Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertEquals(expected, actual); + } + }; + } + + public static void assertArrayEquals(final String message, final Object[] expected, final Object[] actual, + Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertArrayEquals(message, expected, actual); + } + }; + } + + public static void assertArrayEquals(final String message, final Object[] expected, final Promise actual) { + new Task(actual) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertArrayEquals(message, expected, actual.get()); + } + }; + } + + public static void assertArrayEqualsWaitFor(final Object[] expected, final Object[] actual, Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertArrayEquals(expected, actual); + } + }; + } + + public static void assertArrayEquals(final Object[] expected, final Promise actual) { + new Task(actual) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertArrayEquals(expected, actual.get()); + } + }; + } + + static public void assertEqualsWaitFor(final String message, final double expected, final double actual, final double delta, + Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertEquals(message, expected, actual, delta); + } + }; + } + + static public void assertEquals(final String message, final double expected, final Promise actual, final double delta) { + new Task(actual) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertEquals(message, expected, actual.get(), delta); + } + }; + } + + static public void assertEqualsWaitFor(final double expected, final double actual, final double delta, Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertEquals(expected, actual, delta); + } + }; + } + + static public void assertEquals(final double expected, final Promise actual, final double delta) { + new Task(actual) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertEquals(expected, actual.get(), delta); + } + }; + } + + static public void assertNotNullWaitFor(final String message, final Object object, Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertNotNull(message, object); + } + }; + } + + /** + * Asserts that an object Promise and its content isn't null. If it is an + * {@link AssertionError} is thrown with the given message. + * + * @param message + * the identifying message for the {@link AssertionError} ( + * null okay) + * @param object + * Object to check or null + */ + static public void assertNotNull(final String message, final Promise object) { + Assert.assertNotNull(message, object); + new Task(object) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertNotNull(message, object.get()); + } + }; + } + + static public void assertNotNullWaitFor(final Object object, Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertNotNull(object); + } + }; + } + + /** + * Asserts that an object its content isn't null. + */ + static public void assertNotNull(final Promise object) { + Assert.assertNotNull(object); + new Task(object) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertNotNull(object.get()); + } + }; + } + + static public void assertNullWaitFor(final String message, final Object object, Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertNull(message, object); + } + }; + } + + /** + * Asserts that an object is not null while + * object.get() is null. + */ + static public void assertNull(final String message, final Promise object) { + Assert.assertNotNull(object); + new Task(object) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertNull(message, object.get()); + } + }; + } + + static public void assertNullWaitFor(final Object object, Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertNull(object); + } + }; + } + + /** + * Asserts that an object is not null while + * object.get() is null. + */ + static public void assertNull(final Promise object) { + Assert.assertNotNull(object); + new Task(object) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertNull(object.get()); + } + }; + } + + static public void assertSameWaitFor(final String message, final Object expected, final Object actual, Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertSame(message, expected, actual); + } + }; + } + + /** + * Asserts that two Promises content refer to the same object. If they are + * not, an {@link AssertionError} is thrown with the given message. + */ + static public void assertSame(final String message, final Object expected, final Promise actual) { + new Task(actual) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertSame(message, expected, actual.get()); + } + }; + } + + static public void assertSameWaitFor(final Object expected, final Object actual, Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertSame(expected, actual); + } + }; + } + + /** + * Asserts that two Promises content refer to the same object. If they are + * not, an {@link AssertionError} is thrown with the given message. + */ + static public void assertSame(final Object expected, final Promise actual) { + new Task(actual) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertSame(expected, actual.get()); + } + }; + } + + static public void assertNotSameWaitFor(final String message, final Object expected, final Object actual, + Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertNotSame(message, expected, actual); + } + }; + } + + /** + * Asserts that two Promises content do not refer to the same object. If + * they are an {@link AssertionError} is thrown with the given message. + */ + static public void assertNotSame(final String message, final Object expected, final Promise actual) { + new Task(actual) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertNotSame(message, expected, actual.get()); + } + }; + } + + static public void assertNotSameWaitFor(final Object expected, final Object actual, Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertNotSame(expected, actual); + } + }; + } + + /** + * Asserts that two Promises content do not refer to the same object. If + * they are an {@link AssertionError} is thrown with the given message. + */ + static public void assertNotSame(final Object expected, final Promise actual) { + new Task(actual) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertNotSame(expected, actual.get()); + } + }; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/FlowBlockJUnit4ClassRunner.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/FlowBlockJUnit4ClassRunner.java new file mode 100644 index 000000000000..a18fd4411664 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/FlowBlockJUnit4ClassRunner.java @@ -0,0 +1,72 @@ +package com.amazonaws.services.simpleworkflow.flow.junit; + +import java.util.List; + +import org.junit.Test; +import org.junit.rules.MethodRule; +import org.junit.runners.BlockJUnit4ClassRunner; +import org.junit.runners.model.FrameworkMethod; +import org.junit.runners.model.InitializationError; +import org.junit.runners.model.Statement; + +/** + * To be used instead of {@link BlockJUnit4ClassRunner} when testing + * asynchronous code. Requires {@link WorkflowTest} rule (annotated with @Rule) + * to be present in the tested class. + * + * @author fateev + */ +public class FlowBlockJUnit4ClassRunner extends BlockJUnit4ClassRunner { + + private WorkflowTestBase workflowTestRule; + + private long timeout; + + private Class expectedException; + + public FlowBlockJUnit4ClassRunner(Class klass) throws InitializationError { + super(klass); + } + + @Override + protected Statement withPotentialTimeout(FrameworkMethod method, final Object test, Statement next) { + Test annotation = method.getAnnotation(Test.class); + timeout = annotation.timeout(); + if (timeout > 0 && workflowTestRule != null) { + workflowTestRule.setTestTimeoutActualTimeMilliseconds(timeout); + } + return next; + } + + @Override + protected List rules(Object test) { + List result = super.rules(test); + for (MethodRule methodRule : result) { + if (WorkflowTestBase.class.isAssignableFrom(methodRule.getClass())) { + workflowTestRule = (WorkflowTestBase) methodRule; + workflowTestRule.setFlowTestRunner(true); + if (timeout > 0) { + workflowTestRule.setTestTimeoutActualTimeMilliseconds(timeout); + } + if (expectedException != null) { + workflowTestRule.setExpectedException(expectedException); + } + } + } + return result; + } + + @Override + protected Statement possiblyExpectingExceptions(FrameworkMethod method, Object test, Statement next) { + Test annotation = method.getAnnotation(Test.class); + Class expected = annotation.expected(); + if (expected != Test.None.class) { + expectedException = expected; + if (workflowTestRule != null) { + workflowTestRule.setExpectedException(expectedException); + } + } + return next; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/GenericWorkflowTest.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/GenericWorkflowTest.java new file mode 100644 index 000000000000..6fd50b3e2384 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/GenericWorkflowTest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.junit; + +import com.amazonaws.services.simpleworkflow.flow.generic.ActivityImplementationFactory; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinitionFactoryFactory; +import com.amazonaws.services.simpleworkflow.flow.test.TestDecisionContext; +import com.amazonaws.services.simpleworkflow.flow.test.TestGenericActivityClient; +import com.amazonaws.services.simpleworkflow.flow.test.TestGenericWorkflowClient; +import com.amazonaws.services.simpleworkflow.flow.test.TestWorkflowClock; +import com.amazonaws.services.simpleworkflow.flow.test.TestWorkflowContext; + +public class GenericWorkflowTest extends WorkflowTestBase { + + private TestGenericActivityClient activityClient; + + public GenericWorkflowTest(WorkflowDefinitionFactoryFactory factoryFactory) { + super(new TestDecisionContext(new TestGenericActivityClient(), + new TestGenericWorkflowClient(factoryFactory), new TestWorkflowClock(), new TestWorkflowContext())); + activityClient = (TestGenericActivityClient) decisionContext.getActivityClient(); + } + + public void addFactory(String taskListToListen, ActivityImplementationFactory factory) { + activityClient.addFactory(taskListToListen, factory); + } + + public void addFactory(ActivityImplementationFactory factory) { + addFactory(defaultActivitiesTaskListToPoll, factory); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/WorkflowTest.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/WorkflowTest.java new file mode 100644 index 000000000000..60b42cea6dec --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/WorkflowTest.java @@ -0,0 +1,128 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.junit; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.flow.test.TestDecisionContext; +import com.amazonaws.services.simpleworkflow.flow.test.TestPOJOActivityImplementationGenericActivityClient; +import com.amazonaws.services.simpleworkflow.flow.test.TestPOJOActivityImplementationWorker; +import com.amazonaws.services.simpleworkflow.flow.test.TestPOJOWorkflowImplementationGenericWorkflowClient; +import com.amazonaws.services.simpleworkflow.flow.test.TestWorkflowClock; +import com.amazonaws.services.simpleworkflow.flow.test.TestWorkflowContext; + +/** + * JUnit Rule that should be present as a public field of the test class + * annotated with @Rule. Requires that test is executed with + * {@link FlowBlockJUnit4ClassRunner}. + * + * @author fateev + */ +public class WorkflowTest extends WorkflowTestBase { + + private TestPOJOActivityImplementationGenericActivityClient activityClient; + + private TestPOJOWorkflowImplementationGenericWorkflowClient workflowClient; + + private Map workers = new HashMap(); + + public WorkflowTest() { + super(new TestDecisionContext(new TestPOJOActivityImplementationGenericActivityClient(), + new TestPOJOWorkflowImplementationGenericWorkflowClient(), new TestWorkflowClock(), new TestWorkflowContext())); + activityClient = (TestPOJOActivityImplementationGenericActivityClient) decisionContext.getActivityClient(); + workflowClient = (TestPOJOWorkflowImplementationGenericWorkflowClient) decisionContext.getWorkflowClient(); + } + + public void addActivitiesImplementation(Object activitiesImplementation) { + addActivitiesImplementation(defaultActivitiesTaskListToPoll, activitiesImplementation); + } + + public void addActivitiesImplementation(String taskList, Object activitiesImplementation) { + try { + TestPOJOActivityImplementationWorker worker = getActivityWorker(taskList); + worker.addActivitiesImplementation(activitiesImplementation); + activityClient.addWorker(worker); + } + catch (Exception e) { + throw new IllegalArgumentException("Invalid activities implementation: " + activitiesImplementation, e); + } + } + + private TestPOJOActivityImplementationWorker getActivityWorker(String taskList) { + TestPOJOActivityImplementationWorker result = workers.get(taskList); + if (result == null) { + result = new TestPOJOActivityImplementationWorker(taskList); + workers.put(taskList, result); + } + return result; + } + + public void addWorkflowImplementationType(Class workflowImplementationType) { + try { + workflowClient.addWorkflowImplementationType(workflowImplementationType); + } + catch (Exception e) { + throw new IllegalArgumentException("Invalid workflow type: " + workflowImplementationType, e); + } + } + + public void setActivitiesImplementations(Iterable activitiesImplementationObjects) { + workers.clear(); + addActivitiesImplementations(defaultActivitiesTaskListToPoll, activitiesImplementationObjects); + } + + public void setTaskListActivitiesImplementationMap(Map map) { + workers.clear(); + for (Entry taskImplPair : map.entrySet()) { + addActivitiesImplementation(taskImplPair.getKey(), taskImplPair.getValue()); + } + } + + public Map getTaskListActivitiesImplementationMap() { + Map result = new HashMap(); + for (Entry pair : workers.entrySet()) { + Iterable implementations = pair.getValue().getActivitiesImplementations(); + for (Object impelementation : implementations) { + result.put(pair.getKey(), impelementation); + } + } + return result; + } + + public void addActivitiesImplementations(String taskList, Iterable activityImplementationObjects) { + try { + TestPOJOActivityImplementationWorker worker = getActivityWorker(taskList); + worker.addActivitiesImplementations(activityImplementationObjects); + activityClient.addWorker(worker); + } + catch (Exception e) { + throw new IllegalArgumentException("Invalid activities implementation: " + activityImplementationObjects, e); + } + } + + public Iterable getActivitiesImplementations() { + TestPOJOActivityImplementationWorker worker = getActivityWorker(defaultActivitiesTaskListToPoll); + return worker.getActivitiesImplementations(); + } + + public void setWorkflowImplementationTypes(Collection> workflowImplementationTypes) + throws InstantiationException, IllegalAccessException { + workflowClient.setWorkflowImplementationTypes(workflowImplementationTypes); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/WorkflowTestBase.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/WorkflowTestBase.java new file mode 100644 index 000000000000..fa6b3e1cbe5b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/WorkflowTestBase.java @@ -0,0 +1,233 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.junit; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Callable; + +import org.junit.rules.MethodRule; +import org.junit.runners.model.FrameworkMethod; +import org.junit.runners.model.Statement; + +import com.amazonaws.services.simpleworkflow.flow.DecisionContext; +import com.amazonaws.services.simpleworkflow.flow.WorkflowClock; +import com.amazonaws.services.simpleworkflow.flow.core.AsyncScope; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.core.Settable; +import com.amazonaws.services.simpleworkflow.flow.core.Task; +import com.amazonaws.services.simpleworkflow.flow.junit.spring.FlowSpringJUnit4ClassRunner; +import com.amazonaws.services.simpleworkflow.flow.test.TestWorkflowClock; +import com.amazonaws.services.simpleworkflow.flow.test.TestWorkflowContext; +import com.amazonaws.services.simpleworkflow.flow.worker.CurrentDecisionContext; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +public abstract class WorkflowTestBase implements MethodRule { + + protected String defaultActivitiesTaskListToPoll = "TestTaskList"; + + boolean disableOutstandingTasksCheck; + + protected DecisionContext decisionContext; + + protected TestWorkflowContext workflowContext; + + protected TestWorkflowClock workflowClock; + + AsyncScope scope; + + List> waits = new ArrayList>(); + + double clockAcceleration = 1.0; + + boolean flowTestRunner; + + private long testTimeoutActualTimeMilliseconds; + + private WorkflowTestStatement workflowTestStatement; + + private Class expectedException; + + public WorkflowTestBase(DecisionContext decisionContext) { + this.decisionContext = decisionContext; + workflowContext = (TestWorkflowContext) decisionContext.getWorkflowContext(); + workflowClock = (TestWorkflowClock) decisionContext.getWorkflowClock(); + WorkflowExecution we = new WorkflowExecution(); + we.setWorkflowId("testWorkflowId"); + we.setRunId("testRunId"); + workflowContext.setWorkflowExecution(we); + WorkflowType wt = new WorkflowType(); + wt.setName("testWorkflow"); + wt.setVersion("0.0"); + workflowContext.setWorkflowType(wt); + } + + public boolean isDisableOutstandingTasksCheck() { + return disableOutstandingTasksCheck; + } + + /** + * When set to true it is considered a test failure to have + * outstanding tasks that are blocked on non external events or timers. Such + * blockage is usually indicates a bug that can lead to a workflow + * "getting stuck". Default is true. + */ + public void setDisableOutstandingTasksCheck(boolean disableOutstandingTasksCheck) { + this.disableOutstandingTasksCheck = disableOutstandingTasksCheck; + } + + public DecisionContext getDecisionContext() { + return decisionContext; + } + + public void setWorkflowExecution(WorkflowExecution workflowExecution) { + workflowContext.setWorkflowExecution(workflowExecution); + } + + public void setWorkflowType(WorkflowType workflowType) { + workflowContext.setWorkflowType(workflowType); + } + + public WorkflowExecution getWorkflowExecution() { + return workflowContext.getWorkflowExecution(); + } + + public WorkflowType getWorkflowType() { + return workflowContext.getWorkflowType(); + } + + public String getDefaultActivitiesTaskListToPoll() { + return defaultActivitiesTaskListToPoll; + } + + public void setDefaultActivitiesTaskListToPoll(String defaultActivitiesTaskListToPoll) { + this.defaultActivitiesTaskListToPoll = defaultActivitiesTaskListToPoll; + } + + public double getClockAcceleration() { + return clockAcceleration; + } + + /** + * Accelerate workflow clock according the coefficient. Note that the clock + * acceleration affects time returned by {@link WorkflowClock} and timers + * firing only. The default is 1.0 (no acceleration). + * + * @param clockAcceleration + * value that is larger then 1.0 + */ + public void setClockAccelerationCoefficient(double clockAcceleration) { + if (clockAcceleration < 1.0) { + throw new IllegalArgumentException("clock acceleration less then 1: " + clockAcceleration); + } + this.clockAcceleration = clockAcceleration; + } + + @Override + public Statement apply(final Statement base, FrameworkMethod method, Object target) { + Callable accessor = new Callable() { + + @Override + public WorkflowTestBase call() throws Exception { + return WorkflowTestBase.this; + } + }; + workflowTestStatement = new WorkflowTestStatement(accessor, base, testTimeoutActualTimeMilliseconds, expectedException); + workflowTestStatement.setFlowTestRunner(flowTestRunner); + return workflowTestStatement; + } + + /** + * Here blocked means that there are no any tasks that are ready to be + * executed. Usually these tasks wait for timers or some other external + * events. + * + * @return Promise that becomes ready when there are not tasks to execute + */ + public Promise waitBlocked(Promise... waitFor) { + if (scope == null) { + throw new IllegalArgumentException("Called outside of test method"); + } + final Settable result = new Settable(); + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + waits.add(result); + } + + }; + return result; + } + + public void setClockCurrentTimeMillis(long timeMillis) { + workflowClock.setCurrentTimeMillis(timeMillis); + } + + public void clockAdvanceSeconds(final long seconds) { + workflowClock.advanceSeconds(seconds); + } + + public void clockAdvanceSeconds(final long seconds, Promise... waitFor) { + new Task(waitFor) { + + @Override + protected void doExecute() throws Throwable { + workflowClock.advanceSeconds(seconds); + } + }; + } + + protected void beforeEvaluate(DecisionContext decisionContext) { + CurrentDecisionContext.set(decisionContext); + } + + protected void afterEvaluate() { + CurrentDecisionContext.unset(); + } + + /** + * Test timeout time. Uses real clock that ignores acceleration (see + * {@link #setClockAccelerationCoefficient(double)}). Instead of calling + * this method consider using {@link FlowBlockJUnit4ClassRunner} or + * {@link FlowSpringJUnit4ClassRunner} and timeout parameter of @Test + * annotation. + * + * @param timeout + * time in milliseconds. + */ + public void setTestTimeoutActualTimeMilliseconds(long timeout) { + this.testTimeoutActualTimeMilliseconds = timeout; + if (workflowTestStatement != null) { + workflowTestStatement.setTestTimeoutActualTimeMilliseconds(timeout); + } + } + + public void setExpectedException(Class expectedException) { + this.expectedException = expectedException; + if (workflowTestStatement != null) { + workflowTestStatement.setExpectedException(expectedException); + } + } + + public void setFlowTestRunner(boolean flowTestRunner) { + this.flowTestRunner = flowTestRunner; + if (workflowTestStatement != null) { + workflowTestStatement.setFlowTestRunner(flowTestRunner); + } + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/WorkflowTestStatement.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/WorkflowTestStatement.java new file mode 100644 index 000000000000..0197d6a2def4 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/WorkflowTestStatement.java @@ -0,0 +1,185 @@ +package com.amazonaws.services.simpleworkflow.flow.junit; + +import java.util.concurrent.Callable; + +import org.junit.runners.model.Statement; + +import com.amazonaws.services.simpleworkflow.flow.core.AsyncScope; +import com.amazonaws.services.simpleworkflow.flow.core.Settable; +import com.amazonaws.services.simpleworkflow.flow.core.TryCatchFinally; + +public class WorkflowTestStatement extends Statement { + + private final Callable workflowTestAccessor; + + private final Statement base; + + private Long timeout; + + boolean completed; + + private Throwable failure; + + boolean waitingOnTimer; + + private Class expectedException; + + private boolean flowTestRunner; + + public WorkflowTestStatement(Callable workflowTestAccessor, Statement base, Long timeout, + Class expectedException) { + this.workflowTestAccessor = workflowTestAccessor; + this.base = base; + this.timeout = timeout; + this.expectedException = expectedException; + } + + @Override + public void evaluate() throws Throwable { + if (!flowTestRunner) { + throw new IllegalStateException( + "WorkflowTest rule can be used only with flow specific test runners: FlowBlockJUnit4ClassRunner and FlowSpringJUnit4ClassRunner"); + } + final WorkflowTestBase workflowTest = workflowTestAccessor.call(); + Thread t = null; + if (timeout == null || timeout == 0) { + try { + asyncEvaluate(workflowTest); + completed = true; + } + catch (Throwable e) { + failure = e; + } + } + else { + t = new Thread() { + + public void run() { + try { + asyncEvaluate(workflowTest); + completed = true; + } + catch (Throwable e) { + failure = e; + } + } + }; + t.start(); + t.join(timeout); + } + if (failure != null) { + if (expectedException != null && expectedException.isAssignableFrom(failure.getClass())) { + return; + } + throw failure; + } + if (!completed) { + if (waitingOnTimer) { + AssertionError e = new AssertionError("Test timed out after " + timeout + + " milliseconds. The following asynchrous tasks are outstanding: \n" + + workflowTest.scope.getAsynchronousThreadDumpAsString()); + throw e; + } + else { + AssertionError e = new AssertionError("Test timed out after " + timeout + " milliseconds"); + if (t != null) { + e.setStackTrace(t.getStackTrace()); + } + throw e; + } + } + if (expectedException != null) { + throw new AssertionError("Expected exception: " + expectedException); + } + + } + + private void asyncEvaluate(final WorkflowTestBase workflowTest) throws Throwable, InterruptedException { + try { + workflowTest.scope = new AsyncScope() { + + @Override + protected void doAsync() throws Throwable { + new TryCatchFinally() { + + @Override + protected void doTry() throws Throwable { + workflowTest.beforeEvaluate(workflowTest.decisionContext); + base.evaluate(); + } + + @Override + protected void doCatch(Throwable e) throws Throwable { + if (e instanceof IllegalStateException) { + if ("Called outside of the workflow definition code.".equals(e.getMessage())) { + throw new RuntimeException( + "Possible use of \"timeout\" parameter of @Test annotation without using Flow JUnit runner. " + + "Supported runners are FlowBlockJUnit4ClassRunner and FlowSpringJUnit4ClassRunner.", + e); + } + } + throw e; + } + + @Override + protected void doFinally() throws Throwable { + workflowTest.afterEvaluate(); + } + + }; + } + }; + boolean outstandingTasks = false; + while (!workflowTest.scope.isComplete()) { + outstandingTasks = workflowTest.scope.eventLoop(); + if (workflowTest.waits.size() == 0) { + Long toNextTimerDelay = workflowTest.workflowClock.fireTimers(); + if (toNextTimerDelay == null) { + break; + } + long timeToSleep = (long) (toNextTimerDelay / workflowTest.clockAcceleration); + if (timeToSleep > 5) { + waitingOnTimer = true; + try { + // If you are using @Test(timeout=...) annotation and your test timed out + // pointing to the Thread.sleep that follows this comment consider + // changing test runner to FlowBlockJUnit4ClassRunner or + // FlowSpringJUnit4ClassRunner to enable asynchronous thread dump. + Thread.sleep(timeToSleep); + } + finally { + waitingOnTimer = false; + } + } + workflowTest.workflowClock.advanceMilliseconds(toNextTimerDelay); + continue; + } + for (Settable listener : workflowTest.waits) { + listener.set(null); + } + workflowTest.waits.clear(); + } + if (!workflowTest.disableOutstandingTasksCheck && !outstandingTasks) { + throw new IllegalStateException("There are outstanding tasks after test completed execution: \n" + + workflowTest.scope.getAsynchronousThreadDumpAsString()); + } + } + finally { + workflowTest.afterEvaluate(); + } + } + + public void setTestTimeoutActualTimeMilliseconds(long timeout) { + if (timeout > 0) { + this.timeout = timeout; + } + } + + public void setExpectedException(Class expectedException) { + this.expectedException = expectedException; + } + + public void setFlowTestRunner(boolean flowTestRunner) { + this.flowTestRunner = flowTestRunner; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/spring/FlowSpringJUnit4ClassRunner.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/spring/FlowSpringJUnit4ClassRunner.java new file mode 100644 index 000000000000..abb58295bb53 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/spring/FlowSpringJUnit4ClassRunner.java @@ -0,0 +1,76 @@ +package com.amazonaws.services.simpleworkflow.flow.junit.spring; + +import java.util.List; + +import org.junit.Test; +import org.junit.rules.MethodRule; +import org.junit.runners.model.FrameworkMethod; +import org.junit.runners.model.InitializationError; +import org.junit.runners.model.Statement; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import com.amazonaws.services.simpleworkflow.flow.junit.WorkflowTestBase; + +/** + * To be used instead of {@link SpringJUnit4ClassRunner} when testing + * asynchronous code. Requires {@link SpringWorkflowTest} rule (annotated with + * @Rule) to be present in the tested class. + * + * @author fateev + */ +public class FlowSpringJUnit4ClassRunner extends SpringJUnit4ClassRunner { + + private WorkflowTestBase workflowTestRule; + + private long timeout; + + private Class expectedException; + + public FlowSpringJUnit4ClassRunner(Class clazz) throws InitializationError { + super(clazz); + } + + @Override + protected Statement withPotentialTimeout(final FrameworkMethod method, final Object test, Statement next) { + Test annotation = method.getAnnotation(Test.class); + long timeout = annotation.timeout(); + if (timeout > 0) { + long springTimeout = getSpringTimeout(method); + if (workflowTestRule != null && springTimeout == 0) { + workflowTestRule.setTestTimeoutActualTimeMilliseconds(timeout); + } + } + return next; + } + + @Override + protected List rules(Object test) { + List result = super.rules(test); + for (MethodRule methodRule : result) { + if (WorkflowTestBase.class.isAssignableFrom(methodRule.getClass())) { + workflowTestRule = (WorkflowTestBase) methodRule; + workflowTestRule.setFlowTestRunner(true); + if (timeout > 0) { + workflowTestRule.setTestTimeoutActualTimeMilliseconds(timeout); + } + if (expectedException != null) { + workflowTestRule.setExpectedException(expectedException); + } + } + } + return result; + } + + @Override + protected Statement possiblyExpectingExceptions(FrameworkMethod method, Object test, Statement next) { + Test annotation = method.getAnnotation(Test.class); + Class expected = annotation.expected(); + if (expected != Test.None.class) { + expectedException = expected; + if (workflowTestRule != null) { + workflowTestRule.setExpectedException(expectedException); + } + } + return next; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/spring/SpringTestPOJOWorkflowImplementationGenericWorkflowClient.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/spring/SpringTestPOJOWorkflowImplementationGenericWorkflowClient.java new file mode 100644 index 000000000000..cf177ff0dd02 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/spring/SpringTestPOJOWorkflowImplementationGenericWorkflowClient.java @@ -0,0 +1,144 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.junit.spring; + +import java.util.HashMap; +import java.util.Map; + +import com.amazonaws.services.simpleworkflow.flow.DataConverter; +import com.amazonaws.services.simpleworkflow.flow.DecisionContext; +import com.amazonaws.services.simpleworkflow.flow.DecisionContextProvider; +import com.amazonaws.services.simpleworkflow.flow.WorkflowException; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.generic.ContinueAsNewWorkflowExecutionParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClient; +import com.amazonaws.services.simpleworkflow.flow.generic.SignalExternalWorkflowParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.StartChildWorkflowExecutionParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.StartChildWorkflowReply; +import com.amazonaws.services.simpleworkflow.flow.pojo.POJOWorkflowDefinitionFactoryFactory; +import com.amazonaws.services.simpleworkflow.flow.pojo.POJOWorkflowImplementationFactory; +import com.amazonaws.services.simpleworkflow.flow.spring.WorkflowScope; +import com.amazonaws.services.simpleworkflow.flow.test.TestGenericWorkflowClient; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +public class SpringTestPOJOWorkflowImplementationGenericWorkflowClient implements GenericWorkflowClient { + + private final TestGenericWorkflowClient genericClient; + + public SpringTestPOJOWorkflowImplementationGenericWorkflowClient() { + genericClient = new TestGenericWorkflowClient(); + genericClient.setFactoryFactory(new POJOWorkflowDefinitionFactoryFactory() { + + @Override + protected POJOWorkflowImplementationFactory getImplementationFactory(Class workflowImplementationType, + Class workflowInteface, WorkflowType workflowType) { + final Object instanceProxy = workflowImplementations.get(workflowImplementationType); + if (instanceProxy == null) { + throw new IllegalArgumentException("unknown workflowImplementationType: " + workflowImplementationType); + } + return new POJOWorkflowImplementationFactory() { + + @Override + public Object newInstance(DecisionContext decisionContext) throws Exception { + WorkflowScope.setDecisionContext(decisionContext); + return instanceProxy; + } + + @Override + public void deleteInstance(Object instance) { + WorkflowScope.removeDecisionContext(); + } + }; + } + }); + } + + private final Map, Object> workflowImplementations = new HashMap, Object>(); + + public void setWorkflowImplementations(Iterable workflowImplementations) + throws InstantiationException, IllegalAccessException { + for (Object workflowImplementation : workflowImplementations) { + addWorkflowImplementation(workflowImplementation); + } + } + + public Iterable getWorkflowImplementations() { + return workflowImplementations.values(); + } + + public void addWorkflowImplementation(Object workflowImplementation) throws InstantiationException, IllegalAccessException { + Class implementationClass = workflowImplementation.getClass(); + workflowImplementations.put(implementationClass, workflowImplementation); + getFactoryFactory().addWorkflowImplementationType(implementationClass); + } + + private POJOWorkflowDefinitionFactoryFactory getFactoryFactory() { + return ((POJOWorkflowDefinitionFactoryFactory)genericClient.getFactoryFactory()); + } + + public DecisionContextProvider getDecisionContextProvider() { + return genericClient.getDecisionContextProvider(); + } + + public void setDecisionContextProvider(DecisionContextProvider decisionContextProvider) { + genericClient.setDecisionContextProvider(decisionContextProvider); + } + + public Promise startChildWorkflow(StartChildWorkflowExecutionParameters parameters) { + return genericClient.startChildWorkflow(parameters); + } + + public Promise startChildWorkflow(String workflow, String version, String input) { + return genericClient.startChildWorkflow(workflow, version, input); + } + + public Promise startChildWorkflow(String workflow, String version, Promise input) { + return genericClient.startChildWorkflow(workflow, version, input); + } + + public Promise signalWorkflowExecution(SignalExternalWorkflowParameters signalParameters) { + return genericClient.signalWorkflowExecution(signalParameters); + } + + public void requestCancelWorkflowExecution(WorkflowExecution execution) { + genericClient.requestCancelWorkflowExecution(execution); + } + + public String getWorkflowState(WorkflowExecution execution) throws WorkflowException { + return genericClient.getWorkflowState(execution); + } + + public void continueAsNewOnCompletion(ContinueAsNewWorkflowExecutionParameters parameters) { + genericClient.continueAsNewOnCompletion(parameters); + } + + public String generateUniqueId() { + return genericClient.generateUniqueId(); + } + + public DataConverter getDataConverter() { + return getFactoryFactory().getDataConverter(); + } + + public void setDataConverter(DataConverter converter) { + getFactoryFactory().setDataConverter(converter); + } + + public Iterable getWorkflowTypesToRegister() { + return getFactoryFactory().getWorkflowTypesToRegister(); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/spring/SpringWorkflowTest.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/spring/SpringWorkflowTest.java new file mode 100644 index 000000000000..fa0aa67c196c --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/junit/spring/SpringWorkflowTest.java @@ -0,0 +1,159 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.junit.spring; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.flow.DataConverter; +import com.amazonaws.services.simpleworkflow.flow.DecisionContext; +import com.amazonaws.services.simpleworkflow.flow.junit.WorkflowTestBase; +import com.amazonaws.services.simpleworkflow.flow.spring.WorkflowScope; +import com.amazonaws.services.simpleworkflow.flow.test.TestDecisionContext; +import com.amazonaws.services.simpleworkflow.flow.test.TestPOJOActivityImplementationGenericActivityClient; +import com.amazonaws.services.simpleworkflow.flow.test.TestPOJOActivityImplementationWorker; +import com.amazonaws.services.simpleworkflow.flow.test.TestWorkflowClock; +import com.amazonaws.services.simpleworkflow.flow.test.TestWorkflowContext; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +/** + * JUnit Rule that should be present as a public field of the test class + * annotated with @Rule. Requires that test is executed with + * {@link FlowSpringJUnit4ClassRunner}. + * + */ +public class SpringWorkflowTest extends WorkflowTestBase { + + private TestPOJOActivityImplementationGenericActivityClient activityClient; + + private SpringTestPOJOWorkflowImplementationGenericWorkflowClient workflowClient; + + private Map workers = new HashMap(); + + private DataConverter dataConverter; + + public SpringWorkflowTest() { + super(new TestDecisionContext(new TestPOJOActivityImplementationGenericActivityClient(), + new SpringTestPOJOWorkflowImplementationGenericWorkflowClient(), new TestWorkflowClock(), + new TestWorkflowContext())); + activityClient = (TestPOJOActivityImplementationGenericActivityClient) decisionContext.getActivityClient(); + workflowClient = (SpringTestPOJOWorkflowImplementationGenericWorkflowClient) decisionContext.getWorkflowClient(); + } + + public void addActivitiesImplementation(Object activitiesImplementation) { + addActivitiesImplementation(defaultActivitiesTaskListToPoll, activitiesImplementation); + } + + public void addActivitiesImplementation(String taskList, Object activitiesImplementation) { + try { + TestPOJOActivityImplementationWorker worker = getActivityWorker(taskList); + worker.addActivitiesImplementation(activitiesImplementation); + activityClient.addWorker(worker); + } + catch (Exception e) { + throw new IllegalArgumentException("Invalid activities implementation: " + activitiesImplementation, e); + } + } + + private TestPOJOActivityImplementationWorker getActivityWorker(String taskList) { + TestPOJOActivityImplementationWorker result = workers.get(taskList); + if (result == null) { + result = new TestPOJOActivityImplementationWorker(taskList); + if (dataConverter != null) { + result.setDataConverter(dataConverter); + } + workers.put(taskList, result); + } + return result; + } + + public void setActivitiesImplementations(Iterable activityImplementationObjects) { + workers.clear(); + addActivitiesImplementations(defaultActivitiesTaskListToPoll, activityImplementationObjects); + } + + public void addActivitiesImplementations(String taskList, Iterable activityImplementationObjects) { + try { + TestPOJOActivityImplementationWorker worker = getActivityWorker(taskList); + worker.setActivitiesImplementations(activityImplementationObjects); + activityClient.addWorker(worker); + } + catch (Exception e) { + throw new IllegalArgumentException("Invalid activities implementation: " + activityImplementationObjects, e); + } + } + + public void setTaskListActivitiesImplementationMap(Map map) { + workers.clear(); + for (Entry taskImplPair: map.entrySet()) { + addActivitiesImplementation(taskImplPair.getKey(), taskImplPair.getValue()); + } + } + + public Map getTaskListActivitiesImplementationMap() { + Map result = new HashMap(); + for (Entry pair: workers.entrySet()) { + Iterable implementations = pair.getValue().getActivitiesImplementations(); + for (Object impelementation : implementations) { + result.put(pair.getKey(), impelementation); + } + } + return result; + } + + public Iterable getActivitiesImplementations() { + TestPOJOActivityImplementationWorker worker = getActivityWorker(defaultActivitiesTaskListToPoll); + return worker.getActivitiesImplementations(); + } + + public void setWorkflowImplementations(Iterable workflowImplementations) + throws InstantiationException, IllegalAccessException { + workflowClient.setWorkflowImplementations(workflowImplementations); + } + + public Iterable getWorkflowImplementations() { + return workflowClient.getWorkflowImplementations(); + } + + public void addWorkflowImplementation(Object workflowImplementation) throws InstantiationException, IllegalAccessException { + workflowClient.addWorkflowImplementation(workflowImplementation); + } + + public DataConverter getDataConverter() { + return dataConverter; + } + + public void setDataConverter(DataConverter converter) { + dataConverter = converter; + workflowClient.setDataConverter(converter); + } + + public Iterable getWorkflowTypesToRegister() { + return workflowClient.getWorkflowTypesToRegister(); + } + + @Override + protected void beforeEvaluate(DecisionContext decisionContext) { + WorkflowScope.setDecisionContext(decisionContext); + } + + @Override + protected void afterEvaluate() { + } + + + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/MethodConverterPair.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/MethodConverterPair.java new file mode 100644 index 000000000000..c8764c17ea12 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/MethodConverterPair.java @@ -0,0 +1,38 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.pojo; + +import java.lang.reflect.Method; + +import com.amazonaws.services.simpleworkflow.flow.DataConverter; + + +class MethodConverterPair { + private final Method method; + private final DataConverter converter; + public MethodConverterPair(Method method, DataConverter converter) { + super(); + this.method = method; + this.converter = converter; + } + + Method getMethod() { + return method; + } + + DataConverter getConverter() { + return converter; + } +} \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOActivityImplementation.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOActivityImplementation.java new file mode 100644 index 000000000000..e29479c5cd5a --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOActivityImplementation.java @@ -0,0 +1,119 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.pojo; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.concurrent.CancellationException; + +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; +import com.amazonaws.services.simpleworkflow.flow.ActivityFailureException; +import com.amazonaws.services.simpleworkflow.flow.DataConverter; +import com.amazonaws.services.simpleworkflow.flow.DataConverterException; +import com.amazonaws.services.simpleworkflow.flow.generic.ActivityImplementationBase; +import com.amazonaws.services.simpleworkflow.flow.worker.ActivityTypeExecutionOptions; +import com.amazonaws.services.simpleworkflow.flow.worker.ActivityTypeRegistrationOptions; +import com.amazonaws.services.simpleworkflow.flow.worker.CurrentActivityExecutionContext; + +class POJOActivityImplementation extends ActivityImplementationBase { + + private final Method activity; + + private final Object activitiesImplmentationObject; + + private final ActivityTypeExecutionOptions executionOptions; + + private final DataConverter converter; + + private final ActivityTypeRegistrationOptions registrationOptions; + + public POJOActivityImplementation(Object activitiesImplmentationObject, Method activity, + ActivityTypeRegistrationOptions registrationOptions, ActivityTypeExecutionOptions executionOptions, + DataConverter converter) { + this.activitiesImplmentationObject = activitiesImplmentationObject; + this.activity = activity; + this.registrationOptions = registrationOptions; + this.executionOptions = executionOptions; + this.converter = converter; + } + + @Override + protected String execute(String input, ActivityExecutionContext context) + throws ActivityFailureException, CancellationException { + //TODO: Support ability to call activity using old client + // after new parameters were added to activity method + // It requires creation of inputParameters array of the correct size and + // populating the new parameter values with default values for each type + Object[] inputParameters = converter.fromData(input, Object[].class); + CurrentActivityExecutionContext.set(context); + Object result = null; + try { + result = activity.invoke(activitiesImplmentationObject, inputParameters); + } + catch (InvocationTargetException invocationException) { + throwActivityFailureException(invocationException.getTargetException() != null + ? invocationException.getTargetException() : invocationException); + } + catch (IllegalArgumentException illegalArgumentException) { + throwActivityFailureException(illegalArgumentException); + } + catch (IllegalAccessException illegalAccessException) { + throwActivityFailureException(illegalAccessException); + } + finally { + CurrentActivityExecutionContext.unset(); + } + return converter.toData(result); + } + + @Override + public ActivityTypeRegistrationOptions getRegistrationOptions() { + return registrationOptions; + } + + @Override + public ActivityTypeExecutionOptions getExecutionOptions() { + return executionOptions; + } + + void throwActivityFailureException(Throwable exception) + throws ActivityFailureException, CancellationException { + + if (exception instanceof CancellationException) { + throw (CancellationException)exception; + } + + String reason = exception.getMessage(); + String details = null; + try { + details = converter.toData(exception); + } catch (DataConverterException dataConverterException) { + if (dataConverterException.getCause() == null) { + dataConverterException.initCause(exception); + } + throw dataConverterException; + } + + throw new ActivityFailureException(reason, details); + } + + public Method getMethod() { + return activity; + } + + public Object getActivitiesImplementation() { + return activitiesImplmentationObject; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOActivityImplementationFactory.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOActivityImplementationFactory.java new file mode 100644 index 000000000000..3cc7d1156428 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOActivityImplementationFactory.java @@ -0,0 +1,420 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.pojo; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.amazonaws.services.simpleworkflow.flow.DataConverter; +import com.amazonaws.services.simpleworkflow.flow.JsonDataConverter; +import com.amazonaws.services.simpleworkflow.flow.annotations.Activities; +import com.amazonaws.services.simpleworkflow.flow.annotations.Activity; +import com.amazonaws.services.simpleworkflow.flow.annotations.ActivityRegistrationOptions; +import com.amazonaws.services.simpleworkflow.flow.annotations.ManualActivityCompletion; +import com.amazonaws.services.simpleworkflow.flow.annotations.NullDataConverter; +import com.amazonaws.services.simpleworkflow.flow.annotations.SkipTypeRegistration; +import com.amazonaws.services.simpleworkflow.flow.common.FlowConstants; +import com.amazonaws.services.simpleworkflow.flow.generic.ActivityImplementation; +import com.amazonaws.services.simpleworkflow.flow.generic.ActivityImplementationFactory; +import com.amazonaws.services.simpleworkflow.flow.worker.ActivityTypeExecutionOptions; +import com.amazonaws.services.simpleworkflow.flow.worker.ActivityTypeRegistrationOptions; +import com.amazonaws.services.simpleworkflow.model.ActivityType; + +public class POJOActivityImplementationFactory extends ActivityImplementationFactory { + + private static class ParentInterfaceOptions { + + private String version; + + private String prefix; + + private ActivityRegistrationOptions registrationOptions; + + private boolean skipRegistration; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + public ActivityRegistrationOptions getRegistrationOptions() { + return registrationOptions; + } + + public void setRegistrationOptions(ActivityRegistrationOptions options) { + if (options != null) { + setSkipRegistration(false); + } + this.registrationOptions = options; + } + + public boolean isSkipRegistration() { + return skipRegistration; + } + + public void setSkipRegistration(boolean skipRegistration) { + if (skipRegistration) { + registrationOptions = null; + } + this.skipRegistration = skipRegistration; + } + + } + + private List activityTypesToRegister = new ArrayList(); + + private Map implementationsMap = new HashMap(); + + private DataConverter dataConverter = new JsonDataConverter(); + + public POJOActivityImplementationFactory() { + super(); + } + + public POJOActivityImplementationFactory(Iterable activityImplementationObjects) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + this(); + addActivitiesImplementations(activityImplementationObjects, null); + } + + public POJOActivityImplementationFactory(Iterable activityImplementationObjects, DataConverter dataConverter) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + this(); + addActivitiesImplementations(activityImplementationObjects, dataConverter); + } + + public DataConverter getDataConverter() { + return dataConverter; + } + + public void setDataConverter(DataConverter dataConverter) { + if (dataConverter == null) { + throw new IllegalArgumentException("null dataConverter"); + } + this.dataConverter = dataConverter; + } + + public void setActivitiesImplementations(Iterable activitiesImplementations) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + addActivitiesImplementations(activitiesImplementations, null); + } + + public Iterable getActivitiesImplementations() { + List result = new ArrayList(); + for (POJOActivityImplementation impl : implementationsMap.values()) { + result.add(impl.getActivitiesImplementation()); + } + return result; + } + + public List addActivitiesImplementations(Iterable activitiesImplementations) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + return addActivitiesImplementations(activitiesImplementations, null); + } + + public List addActivitiesImplementations(Iterable activitiesImplementations, DataConverter dataConverter) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + List result = new ArrayList(); + for (Object activityImplementationObject : activitiesImplementations) { + result.addAll(addActivitiesImplementation(activityImplementationObject, dataConverter)); + } + return result; + } + + public List addActivitiesImplementation(Object activitiesImplementation) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + return addActivitiesImplementation(activitiesImplementation, null); + } + + public List addActivitiesImplementation(Object activitiesImplementation, DataConverter converter) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + if (activitiesImplementation == null) { + throw new IllegalArgumentException("activitiesImplementation is null."); + } + Set result = new HashSet(); + Set> activitiesInterfaces = new HashSet>(); + getImplementedInterfacesAnnotatedWithActivities(activitiesImplementation.getClass(), activitiesInterfaces); + if (activitiesInterfaces.size() == 0) { + throw new IllegalArgumentException( + "Activity implementation object does not implement any interface annotated with @Activities: " + + activitiesImplementation.getClass()); + } + for (Class interfaze : activitiesInterfaces) { + Map methods = new HashMap(); + ParentInterfaceOptions parentOptions = new ParentInterfaceOptions(); + addActivities(activitiesImplementation, interfaze, methods, parentOptions, converter, result); + } + return new ArrayList(result); + } + + private void addActivities(Object implementation, Class interfaze, Map methods, + ParentInterfaceOptions parentOptions, DataConverter converter, Set addedTypes) + throws SecurityException, NoSuchMethodException, InstantiationException, IllegalAccessException { + Activities activitiesAnnotation = interfaze.getAnnotation(Activities.class); + for (Class parent : interfaze.getInterfaces()) { + addActivities(implementation, parent, methods, parentOptions, converter, addedTypes); + } + if (activitiesAnnotation != null) { + String interfaceName = interfaze.getSimpleName(); + if (!nullOrEmpty(activitiesAnnotation.activityNamePrefix())) { + parentOptions.setPrefix(activitiesAnnotation.activityNamePrefix()); + } + if (!nullOrEmpty(activitiesAnnotation.version())) { + parentOptions.setVersion(activitiesAnnotation.version()); + } + converter = (converter == null) ? createConverter(activitiesAnnotation.dataConverter()) : converter; + ActivityRegistrationOptions interfaceRegistrationOptionsAnnotation = interfaze.getAnnotation(ActivityRegistrationOptions.class); + SkipTypeRegistration interfaceSkipTypeRegistrationAnnotation = interfaze.getAnnotation(SkipTypeRegistration.class); + if (interfaceRegistrationOptionsAnnotation != null) { + if (interfaceSkipTypeRegistrationAnnotation != null) { + throw new IllegalArgumentException( + "@ActivityRegistrationOptions is not allowed for the interface annotated with @SkipTypeRegistration."); + + } + parentOptions.setRegistrationOptions(interfaceRegistrationOptionsAnnotation); + } + else if (interfaceSkipTypeRegistrationAnnotation != null) { + parentOptions.setSkipRegistration(true); + } + for (Method method : interfaze.getMethods()) { + if (!method.getDeclaringClass().equals(interfaze)) { + continue; + } + Activity activityAnnotation = method.getAnnotation(Activity.class); + ActivityType activityType = getActivityType(interfaceName, method, activityAnnotation, parentOptions); + ActivityRegistrationOptions registrationOptionsAnnotation = method.getAnnotation(ActivityRegistrationOptions.class); + SkipTypeRegistration skipTypeRegistrationAnnotation = interfaze.getAnnotation(SkipTypeRegistration.class); + ActivityTypeRegistrationOptions registrationOptions = null; + if (skipTypeRegistrationAnnotation != null) { + if (registrationOptionsAnnotation != null) { + throw new IllegalArgumentException( + "@ActivityRegistrationOptions is not allowed for the method annotated with @SkipTypeRegistration: " + + method); + } + } + else { + if (registrationOptionsAnnotation != null || parentOptions.getRegistrationOptions() != null) { + POJOActivityImplementation existingImplementation = implementationsMap.get(activityType); + if (existingImplementation != null && !addedTypes.contains(activityType)) { + String message = "Duplicate declaration for activity type=" + activityType.getName() + ", version=" + + activityType.getVersion() + ": " + existingImplementation.getMethod() + " and " + method; + throw new IllegalArgumentException(message); + } + registrationOptions = createRegistrationOptions(registrationOptionsAnnotation, + parentOptions.getRegistrationOptions()); + } + else if (!parentOptions.isSkipRegistration()) { + throw new IllegalArgumentException( + "No @ActivityRegistationOptions found either on interface or method for " + method); + } + } + //TODO: support methods defined in parents as well as overrides + if (!addedTypes.contains(activityType)) { + Method activityImplementationMethod = implementation.getClass().getMethod(method.getName(), + method.getParameterTypes()); + ActivityTypeExecutionOptions executionOptions = createExecutionOptions(activityType, activityImplementationMethod); + + + POJOActivityImplementation activityImplementation = new POJOActivityImplementation(implementation, method, + registrationOptions, executionOptions, converter); + activityTypesToRegister.add(activityType); + addedTypes.add(activityType); + implementationsMap.put(activityType, activityImplementation); + } + } + } + + } + + @Override + public Iterable getActivityTypesToRegister() { + return activityTypesToRegister; + } + + @Override + public ActivityImplementation getActivityImplementation(ActivityType activityType) { + return implementationsMap.get(activityType); + } + + private DataConverter createConverter(Class converterType) + throws InstantiationException, IllegalAccessException { + if (converterType == null || converterType.equals(NullDataConverter.class)) { + return dataConverter == null ? new JsonDataConverter() : dataConverter; + } + return converterType.newInstance(); + } + + private static ActivityType getActivityType(String interfaceName, Method activity, Activity activityAnnotation, + ParentInterfaceOptions parentOptions) { + ActivityType activityType = new ActivityType(); + + String activityName = null; + String activityVersion = null; + if (activityAnnotation != null) { + if (!nullOrEmpty(activityAnnotation.name())) { + activityName = activityAnnotation.name(); + } + if (!nullOrEmpty(activityAnnotation.version())) { + activityVersion = activityAnnotation.version(); + } + + } + if (activityName == null) { + if (!nullOrEmpty(parentOptions.getPrefix())) { + activityName = parentOptions.getPrefix() + activity.getName(); + } + else { + activityName = interfaceName + "." + activity.getName(); + } + } + if (activityVersion == null) { + if (!nullOrEmpty(parentOptions.getVersion())) { + activityVersion = parentOptions.getVersion(); + } + else { + throw new IllegalArgumentException("No version found for activity defined by " + activity); + } + } + + activityType.setName(activityName); + activityType.setVersion(activityVersion); + return activityType; + } + + private static boolean nullOrEmpty(String nameFromAnnotation) { + return nameFromAnnotation == null || nameFromAnnotation.isEmpty(); + } + + /** + * Recursively find all interfaces annotated with @Activities that given + * class implements. Do not include interfaces that @Activities annotated + * interface extends. + */ + private void getImplementedInterfacesAnnotatedWithActivities(Class implementationType, Set> implementedInterfaces) { + Class superClass = implementationType.getSuperclass(); + if (superClass != null) { + getImplementedInterfacesAnnotatedWithActivities(superClass, implementedInterfaces); + } + + Class[] interfaces = implementationType.getInterfaces(); + for (Class i : interfaces) { + if (i.getAnnotation(Activities.class) != null && !implementedInterfaces.contains(i)) { + boolean skipAdd = removeSuperInterfaces(i, implementedInterfaces); + if (!skipAdd) { + implementedInterfaces.add(i); + } + } + else { + getImplementedInterfacesAnnotatedWithActivities(i, implementedInterfaces); + } + } + } + + private boolean removeSuperInterfaces(Class interfaceToAdd, Set> implementedInterfaces) { + boolean skipAdd = false; + List> interfacesToRemove = new ArrayList>(); + for (Class addedInterface : implementedInterfaces) { + if (addedInterface.isAssignableFrom(interfaceToAdd)) { + interfacesToRemove.add(addedInterface); + } + if (interfaceToAdd.isAssignableFrom(addedInterface)) { + skipAdd = true; + } + } + + for (Class interfaceToRemove : interfacesToRemove) { + implementedInterfaces.remove(interfaceToRemove); + } + + return skipAdd; + } + + private static ActivityTypeRegistrationOptions createRegistrationOptions(ActivityRegistrationOptions registrationOptions, + ActivityRegistrationOptions parentRegistrationOptions) { + + ActivityRegistrationOptions registrationOptionsAnnotation = registrationOptions != null ? registrationOptions + : parentRegistrationOptions; + + ActivityTypeRegistrationOptions result = new ActivityTypeRegistrationOptions(); + + result.setDescription(emptyStringToNull(registrationOptionsAnnotation.description())); + + long taskHeartbeatTimeoutSeconds = registrationOptionsAnnotation.defaultTaskHeartbeatTimeoutSeconds(); + if (taskHeartbeatTimeoutSeconds > FlowConstants.USE_REGISTERED_DEFAULTS) { + result.setDefaultTaskHeartbeatTimeoutSeconds(taskHeartbeatTimeoutSeconds); + } + + long taskScheduleToCloseTimeoutSeconds = registrationOptionsAnnotation.defaultTaskScheduleToCloseTimeoutSeconds(); + if (taskScheduleToCloseTimeoutSeconds > FlowConstants.USE_REGISTERED_DEFAULTS) { + result.setDefaultTaskScheduleToCloseTimeoutSeconds(taskScheduleToCloseTimeoutSeconds); + } + + long taskScheduleToStartTimeoutSeconds = registrationOptionsAnnotation.defaultTaskScheduleToStartTimeoutSeconds(); + if (taskScheduleToStartTimeoutSeconds > FlowConstants.USE_REGISTERED_DEFAULTS) { + result.setDefaultTaskScheduleToStartTimeoutSeconds(taskScheduleToStartTimeoutSeconds); + } + + long taskStartToCloseTimeoutSeconds = registrationOptionsAnnotation.defaultTaskStartToCloseTimeoutSeconds(); + if (taskStartToCloseTimeoutSeconds > FlowConstants.USE_REGISTERED_DEFAULTS) { + result.setDefaultTaskStartToCloseTimeoutSeconds(taskStartToCloseTimeoutSeconds); + } + + String taskList = registrationOptionsAnnotation.defaultTaskList(); + if (!taskList.equals(FlowConstants.USE_WORKER_TASK_LIST)) { + result.setDefaultTaskList(taskList); + } + else if (taskList.equals(FlowConstants.NO_DEFAULT_TASK_LIST)) { + result.setDefaultTaskList(null); + } + + return result; + } + + private static ActivityTypeExecutionOptions createExecutionOptions(ActivityType activityType, Method activityImplementation) { + assert (activityType != null); + + ActivityTypeExecutionOptions executionOptions = new ActivityTypeExecutionOptions(); + if (activityImplementation != null) { + ManualActivityCompletion manualCompletion = activityImplementation.getAnnotation(ManualActivityCompletion.class); + executionOptions.setManualActivityCompletion(manualCompletion != null); + } + + return executionOptions; + } + + private static String emptyStringToNull(String value) { + if (value.length() == 0) { + return null; + } + return value; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOWorkflowDefinition.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOWorkflowDefinition.java new file mode 100644 index 000000000000..44a5f3ef5f3d --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOWorkflowDefinition.java @@ -0,0 +1,182 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.pojo; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Map; +import java.util.concurrent.CancellationException; +import java.util.concurrent.atomic.AtomicReference; + +import com.amazonaws.services.simpleworkflow.flow.*; +import com.amazonaws.services.simpleworkflow.flow.core.*; +import com.amazonaws.services.simpleworkflow.flow.generic.*; + +@SuppressWarnings("rawtypes") +public class POJOWorkflowDefinition extends WorkflowDefinition { + + private final MethodConverterPair workflowMethod; + + private final Map signals; + + private final MethodConverterPair getStateMethod; + + private final Object workflowImplementationInstance; + + private final DataConverter converter; + + private final DecisionContext context; + + public POJOWorkflowDefinition(Object workflowImplmentationInstance, MethodConverterPair workflowImplementationMethod, + Map signals, MethodConverterPair getStateMethod, DataConverter converter, + DecisionContext context) + throws ClassNotFoundException, SecurityException, NoSuchMethodException, NoSuchFieldException { + this.workflowImplementationInstance = workflowImplmentationInstance; + this.workflowMethod = workflowImplementationMethod; + this.getStateMethod = getStateMethod; + this.signals = signals; + this.converter = converter; + this.context = context; + } + + @Override + public Promise execute(final String input) throws WorkflowException { + final DataConverter c; + if (workflowMethod.getConverter() == null) { + c = converter; + } + else { + c = workflowMethod.getConverter(); + } + final Settable result = new Settable(); + final AtomicReference methodResult = new AtomicReference(); + new TryCatchFinally() { + + @Override + protected void doTry() throws Throwable { + //TODO: Support ability to call workflow using old client + // after new parameters were added to @Execute method + // It requires creation of parameters array of the correct size and + // populating the new parameter values with default values for each type + Object[] parameters = c.fromData(input, Object[].class); + Method method = workflowMethod.getMethod(); + Object r = invokeMethod(method, parameters); + if (!method.getReturnType().equals(Void.TYPE)) { + methodResult.set((Promise) r); + } + } + + @Override + protected void doCatch(Throwable e) throws Throwable { + if (!(e instanceof CancellationException) || !context.getWorkflowContext().isCancelRequested()) { + throwWorkflowException(c, e); + } + } + + @Override + protected void doFinally() throws Throwable { + Promise r = methodResult.get(); + if (r == null || r.isReady()) { + Object workflowResult = r == null ? null : r.get(); + String convertedResult = c.toData(workflowResult); + result.set(convertedResult); + } + } + }; + return result; + } + + @Override + public void signalRecieved(String signalName, String details) throws WorkflowException { + MethodConverterPair signalMethod = signals.get(signalName); + if (signalMethod != null) { + DataConverter c = signalMethod.getConverter(); + if (c == null) { + c = converter; + } + Method method = signalMethod.getMethod(); + Object[] parameters = c.fromData(details, Object[].class); + try { + invokeMethod(method, parameters); + } + catch (Throwable e) { + throwWorkflowException(c, e); + throw new IllegalStateException("Unreacheable"); + } + } + else { + // TODO: Unhandled signal + } + } + + @Override + public String getWorkflowState() throws WorkflowException { + if (getStateMethod == null) { + return null; + } + final DataConverter c; + if (getStateMethod.getConverter() == null) { + c = converter; + } + else { + c = getStateMethod.getConverter(); + } + try { + Method method = getStateMethod.getMethod(); + Object result = invokeMethod(method, null); + return c.toData(result); + } + catch (Throwable e) { + throwWorkflowException(c, e); + throw new IllegalStateException("Unreacheable"); + } + } + + private Object invokeMethod(final Method method, final Object[] input) throws Throwable { + try { + return method.invoke(workflowImplementationInstance, input); + } + catch (InvocationTargetException invocationException) { + if (invocationException.getTargetException() != null) { + throw invocationException.getTargetException(); + } + throw invocationException; + } + } + + private void throwWorkflowException(DataConverter c, Throwable exception) throws WorkflowException { + if (exception instanceof WorkflowException) { + throw (WorkflowException)exception; + } + String reason = exception.getMessage(); + String details = null; + try { + details = c.toData(exception); + } + catch (DataConverterException dataConverterException) { + if (dataConverterException.getCause() == null) { + dataConverterException.initCause(exception); + } + throw dataConverterException; + } + + throw new WorkflowException(reason, details); + } + + public Object getImplementationInstance() { + return workflowImplementationInstance; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOWorkflowDefinitionFactory.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOWorkflowDefinitionFactory.java new file mode 100644 index 000000000000..cb42fed1a3b9 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOWorkflowDefinitionFactory.java @@ -0,0 +1,81 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.pojo; + +import java.util.Map; +import com.amazonaws.services.simpleworkflow.flow.DataConverter; +import com.amazonaws.services.simpleworkflow.flow.DecisionContext; +import com.amazonaws.services.simpleworkflow.flow.JsonDataConverter; +import com.amazonaws.services.simpleworkflow.flow.WorkflowTypeRegistrationOptions; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinition; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinitionFactory; +import com.amazonaws.services.simpleworkflow.flow.worker.CurrentDecisionContext; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +class POJOWorkflowDefinitionFactory extends WorkflowDefinitionFactory { + + private final DataConverter converter = new JsonDataConverter(); + + private final WorkflowType workflowType; + + private final WorkflowTypeRegistrationOptions registrationOptions; + + private final POJOWorkflowImplementationFactory implementationFactory; + + private final MethodConverterPair workflowImplementationMethod; + + private final MethodConverterPair getStateMethod; + + private final Map signals; + + public POJOWorkflowDefinitionFactory(POJOWorkflowImplementationFactory implementationFactory, WorkflowType workflowType, + WorkflowTypeRegistrationOptions registrationOptions, MethodConverterPair workflowImplementationMethod, + Map signals, MethodConverterPair getStateMethod) { + this.implementationFactory = implementationFactory; + this.workflowType = workflowType; + this.registrationOptions = registrationOptions; + this.workflowImplementationMethod = workflowImplementationMethod; + this.signals = signals; + this.getStateMethod = getStateMethod; + } + + @Override + public WorkflowType getWorkflowType() { + return workflowType; + } + + @Override + public WorkflowTypeRegistrationOptions getWorkflowRegistrationOptions() { + return registrationOptions; + } + + @Override + public WorkflowDefinition getWorkflowDefinition(DecisionContext context) throws Exception { + if (implementationFactory == null) { + return null; + } + CurrentDecisionContext.set(context); + Object workflowDefinitionObject = implementationFactory.newInstance(context); + return new POJOWorkflowDefinition(workflowDefinitionObject, workflowImplementationMethod, signals, getStateMethod, + converter, context); + } + + @Override + public void deleteWorkflowDefinition(WorkflowDefinition instance) { + POJOWorkflowDefinition definition = (POJOWorkflowDefinition) instance; + implementationFactory.deleteInstance(definition.getImplementationInstance()); + CurrentDecisionContext.unset(); + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOWorkflowDefinitionFactoryFactory.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOWorkflowDefinitionFactoryFactory.java new file mode 100644 index 000000000000..3a2a950df073 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOWorkflowDefinitionFactoryFactory.java @@ -0,0 +1,341 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.pojo; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.amazonaws.services.simpleworkflow.flow.DataConverter; +import com.amazonaws.services.simpleworkflow.flow.DecisionContext; +import com.amazonaws.services.simpleworkflow.flow.JsonDataConverter; +import com.amazonaws.services.simpleworkflow.flow.WorkflowTypeRegistrationOptions; +import com.amazonaws.services.simpleworkflow.flow.annotations.Execute; +import com.amazonaws.services.simpleworkflow.flow.annotations.GetState; +import com.amazonaws.services.simpleworkflow.flow.annotations.NullDataConverter; +import com.amazonaws.services.simpleworkflow.flow.annotations.Signal; +import com.amazonaws.services.simpleworkflow.flow.annotations.SkipTypeRegistration; +import com.amazonaws.services.simpleworkflow.flow.annotations.Workflow; +import com.amazonaws.services.simpleworkflow.flow.annotations.WorkflowRegistrationOptions; +import com.amazonaws.services.simpleworkflow.flow.common.FlowConstants; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinitionFactory; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinitionFactoryFactory; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +public class POJOWorkflowDefinitionFactoryFactory extends WorkflowDefinitionFactoryFactory { + + private DataConverter converter = new JsonDataConverter(); + + private List workflowTypesToRegister = new ArrayList(); + + private Map factories = new HashMap(); + + private final Collection> workflowImplementationTypes = new ArrayList>(); + + public DataConverter getDataConverter() { + return converter; + } + + public void setDataConverter(DataConverter converter) { + this.converter = converter; + } + + @Override + public WorkflowDefinitionFactory getWorkflowDefinitionFactory(WorkflowType workflowType) { + return factories.get(workflowType); + } + + @Override + public Iterable getWorkflowTypesToRegister() { + return workflowTypesToRegister; + } + + public void addWorkflowImplementationType(Class workflowImplementationType) + throws InstantiationException, IllegalAccessException { + addWorkflowImplementationType(workflowImplementationType, null); + } + + public void addWorkflowImplementationType(Class workflowImplementationType, DataConverter converterOverride) + throws InstantiationException, IllegalAccessException { + if (workflowImplementationType.isInterface()) { + throw new IllegalArgumentException(workflowImplementationType + " has to be a instantiatable class"); + } + Set> implementedInterfaces = new HashSet>(); + getImplementedInterfacesAnnotatedWithWorkflow(workflowImplementationType, implementedInterfaces); + if (implementedInterfaces.size() == 0) { + throw new IllegalArgumentException("Workflow definition does not implement any @Workflow interface. " + + workflowImplementationType); + } + for (Class interfaze : implementedInterfaces) { + addWorkflowType(interfaze, workflowImplementationType, converterOverride); + } + } + + public void setWorkflowImplementationTypes(Collection> workflowImplementationTypes) + throws InstantiationException, IllegalAccessException { + for (Class type : workflowImplementationTypes) { + addWorkflowImplementationType(type); + } + } + + public Collection> getWorkflowImplementationTypes() { + return workflowImplementationTypes; + } + + private void addWorkflowType(Class interfaze, Class workflowImplementationType, DataConverter converterOverride) + throws InstantiationException, IllegalAccessException { + Workflow workflowAnnotation = interfaze.getAnnotation(Workflow.class); + String interfaceName = interfaze.getSimpleName(); + MethodConverterPair workflowImplementationMethod = null; + MethodConverterPair getStateMethod = null; + WorkflowType workflowType = null; + WorkflowTypeRegistrationOptions registrationOptions = null; + Map signals = new HashMap(); + for (Method method : interfaze.getMethods()) { + if (method.getDeclaringClass().getAnnotation(Workflow.class) == null) { + continue; + } + Execute executeAnnotation = method.getAnnotation(Execute.class); + Signal signalAnnotation = method.getAnnotation(Signal.class); + GetState getStateAnnotation = method.getAnnotation(GetState.class); + checkAnnotationUniqueness(method, executeAnnotation, signalAnnotation, getStateAnnotation); + if (executeAnnotation != null) { + if (workflowImplementationMethod != null) { + throw new IllegalArgumentException( + "Interface annotated with @Workflow is allowed to have only one method annotated with @Execute. Found " + + getMethodFullName(workflowImplementationMethod.getMethod()) + " and " + + getMethodFullName(method)); + } + if (!method.getReturnType().equals(void.class) && !(Promise.class.isAssignableFrom(method.getReturnType()))) { + throw new IllegalArgumentException( + "Workflow implementation method annotated with @Execute can return only Promise or void: " + + getMethodFullName(method)); + } + if (!method.getDeclaringClass().equals(interfaze)) { + throw new IllegalArgumentException("Interface " + interfaze.getName() + + " cannot inherit workflow implementation method annotated with @Execute: " + + getMethodFullName(method)); + + } + DataConverter converter = createConverter(workflowAnnotation.dataConverter(), converterOverride); + workflowImplementationMethod = new MethodConverterPair(method, converter); + workflowType = getWorkflowType(interfaceName, method, executeAnnotation); + + WorkflowRegistrationOptions registrationOptionsAnnotation = interfaze.getAnnotation(WorkflowRegistrationOptions.class); + SkipTypeRegistration skipRegistrationAnnotation = interfaze.getAnnotation(SkipTypeRegistration.class); + if (skipRegistrationAnnotation == null) { + if (registrationOptionsAnnotation == null) { + throw new IllegalArgumentException( + "@WorkflowRegistrationOptions is required for the interface that contains method annotated with @Execute"); + } + registrationOptions = createRegistrationOptions(registrationOptionsAnnotation); + } + else { + if (registrationOptionsAnnotation != null) { + throw new IllegalArgumentException( + "@WorkflowRegistrationOptions is not allowed for the interface annotated with @SkipTypeRegistration."); + } + } + } + if (signalAnnotation != null) { + String signalName = signalAnnotation.name(); + if (signalName == null || signalName.isEmpty()) { + signalName = method.getName(); + } + DataConverter signalConverter = createConverter(workflowAnnotation.dataConverter(), converterOverride); + signals.put(signalName, new MethodConverterPair(method, signalConverter)); + } + if (getStateAnnotation != null) { + if (getStateMethod != null) { + throw new IllegalArgumentException( + "Interface annotated with @Workflow is allowed to have only one method annotated with @GetState. Found " + + getMethodFullName(getStateMethod.getMethod()) + " and " + getMethodFullName(method)); + } + if (method.getReturnType().equals(void.class) || (Promise.class.isAssignableFrom(method.getReturnType()))) { + throw new IllegalArgumentException( + "Workflow method annotated with @GetState cannot have void or Promise return type: " + + getMethodFullName(method)); + } + DataConverter converter = createConverter(workflowAnnotation.dataConverter(), converterOverride); + getStateMethod = new MethodConverterPair(method, converter); + } + } + if (workflowImplementationMethod == null) { + throw new IllegalArgumentException("Workflow definition does not implement any method annotated with @Execute. " + + workflowImplementationType); + } + POJOWorkflowImplementationFactory implementationFactory = getImplementationFactory(workflowImplementationType, interfaze, + workflowType); + WorkflowDefinitionFactory factory = new POJOWorkflowDefinitionFactory(implementationFactory, workflowType, + registrationOptions, workflowImplementationMethod, signals, getStateMethod); + factories.put(workflowType, factory); + workflowImplementationTypes.add(workflowImplementationType); + if (factory.getWorkflowRegistrationOptions() != null) { + workflowTypesToRegister.add(workflowType); + } + } + + private void checkAnnotationUniqueness(Method method, Object... annotations) { + List notNullOnes = new ArrayList(); + for (Object annotation : annotations) { + if (annotation != null) { + notNullOnes.add(annotation); + } + } + if (notNullOnes.size() > 1) { + throw new IllegalArgumentException("Method " + method.getName() + " is annotated with both " + notNullOnes); + } + } + + /** + * Override to control how implementation is instantiated. + * + * @param workflowImplementationType + * type that was registered with the factory + * @param workflowInteface + * interface that defines external workflow contract + * @param workflowType + * type of the workflow that implementation implements + * @return factory that creates new instances of the POJO that implements + * workflow + */ + protected POJOWorkflowImplementationFactory getImplementationFactory(final Class workflowImplementationType, + Class workflowInteface, WorkflowType workflowType) { + return new POJOWorkflowImplementationFactory() { + + @Override + public Object newInstance(DecisionContext decisionContext) throws Exception { + return workflowImplementationType.newInstance(); + } + + @Override + public void deleteInstance(Object instance) { + } + }; + } + + /** + * Recursively find all interfaces annotated with @Workflow that given class + * implements. Don not include interfaces that @Workflow annotated interface + * extends. + */ + private void getImplementedInterfacesAnnotatedWithWorkflow(Class workflowImplementationType, + Set> implementedInterfaces) { + Class superClass = workflowImplementationType.getSuperclass(); + if (superClass != null) { + getImplementedInterfacesAnnotatedWithWorkflow(superClass, implementedInterfaces); + } + + Class[] interfaces = workflowImplementationType.getInterfaces(); + for (Class i : interfaces) { + if (i.getAnnotation(Workflow.class) != null && !implementedInterfaces.contains(i)) { + boolean skipAdd = removeSuperInterfaces(i, implementedInterfaces); + if (!skipAdd) { + implementedInterfaces.add(i); + } + } + else { + getImplementedInterfacesAnnotatedWithWorkflow(i, implementedInterfaces); + } + } + } + + private boolean removeSuperInterfaces(Class interfaceToAdd, Set> implementedInterfaces) { + boolean skipAdd = false; + List> interfacesToRemove = new ArrayList>(); + for (Class addedInterface : implementedInterfaces) { + if (addedInterface.isAssignableFrom(interfaceToAdd)) { + interfacesToRemove.add(addedInterface); + } + if (interfaceToAdd.isAssignableFrom(addedInterface)) { + skipAdd = true; + } + } + + for (Class interfaceToRemove : interfacesToRemove) { + implementedInterfaces.remove(interfaceToRemove); + } + + return skipAdd; + } + + private static String getMethodFullName(Method m) { + return m.getDeclaringClass().getName() + "." + m.getName(); + } + + private DataConverter createConverter(Class converterTypeFromAnnotation, + DataConverter converterOverride) throws InstantiationException, IllegalAccessException { + if (converterOverride != null) { + return converterOverride; + } + if (converterTypeFromAnnotation == null || converterTypeFromAnnotation.equals(NullDataConverter.class)) { + return converter; + } + return converterTypeFromAnnotation.newInstance(); + } + + protected WorkflowType getWorkflowType(String interfaceName, Method method, Execute executeAnnotation) { + assert (method != null); + assert (executeAnnotation != null); + + WorkflowType workflowType = new WorkflowType(); + + String workflowName = null; + if (executeAnnotation.name() != null && !executeAnnotation.name().isEmpty()) { + workflowName = executeAnnotation.name(); + } + else { + workflowName = interfaceName + "." + method.getName(); + } + + if (executeAnnotation.version().isEmpty()) { + throw new IllegalArgumentException( + "Empty value of the required \"version\" parameter of the @Execute annotation found on " + + getMethodFullName(method)); + } + workflowType.setName(workflowName); + workflowType.setVersion(executeAnnotation.version()); + return workflowType; + } + + protected WorkflowTypeRegistrationOptions createRegistrationOptions(WorkflowRegistrationOptions registrationOptionsAnnotation) { + + WorkflowTypeRegistrationOptions result = new WorkflowTypeRegistrationOptions(); + + result.setDescription(emptyStringToNull(registrationOptionsAnnotation.description())); + result.setDefaultExecutionStartToCloseTimeoutSeconds(registrationOptionsAnnotation.defaultExecutionStartToCloseTimeoutSeconds()); + result.setDefaultTaskStartToCloseTimeoutSeconds(registrationOptionsAnnotation.defaultTaskStartToCloseTimeoutSeconds()); + + String taskList = registrationOptionsAnnotation.defaultTaskList(); + if (!taskList.equals(FlowConstants.USE_WORKER_TASK_LIST)) { + result.setDefaultTaskList(taskList); + } + result.setDefaultChildPolicy(registrationOptionsAnnotation.defaultChildPolicy()); + return result; + } + + private static String emptyStringToNull(String value) { + if (value.length() == 0) { + return null; + } + return value; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOWorkflowImplementationFactory.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOWorkflowImplementationFactory.java new file mode 100644 index 000000000000..b20e4a3a1d18 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/pojo/POJOWorkflowImplementationFactory.java @@ -0,0 +1,25 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.pojo; + +import com.amazonaws.services.simpleworkflow.flow.DecisionContext; + +public interface POJOWorkflowImplementationFactory { + + public Object newInstance(DecisionContext decisionContext) throws Exception; + + public void deleteInstance(Object instance); + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/SpringActivityWorker.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/SpringActivityWorker.java new file mode 100644 index 000000000000..8a77886ce8ec --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/SpringActivityWorker.java @@ -0,0 +1,295 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.spring; + +import java.lang.Thread.UncaughtExceptionHandler; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.springframework.context.SmartLifecycle; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.DataConverter; +import com.amazonaws.services.simpleworkflow.flow.WorkerBase; +import com.amazonaws.services.simpleworkflow.flow.pojo.POJOActivityImplementationFactory; +import com.amazonaws.services.simpleworkflow.flow.worker.GenericActivityWorker; +import com.amazonaws.services.simpleworkflow.model.ActivityType; + +public class SpringActivityWorker implements WorkerBase, SmartLifecycle { + + private final GenericActivityWorker genericWorker; + + private final POJOActivityImplementationFactory factory = new POJOActivityImplementationFactory(); + + private int startPhase; + + private long terminationTimeoutSeconds = 60; + + private boolean disableAutoStartup; + + public SpringActivityWorker() { + genericWorker = new GenericActivityWorker(); + genericWorker.setActivityImplementationFactory(factory); + } + + public SpringActivityWorker(AmazonSimpleWorkflow service, String domain, String taskListToPoll) { + genericWorker = new GenericActivityWorker(service, domain, taskListToPoll); + genericWorker.setActivityImplementationFactory(factory); + } + + public AmazonSimpleWorkflow getService() { + return genericWorker.getService(); + } + + public void setService(AmazonSimpleWorkflow service) { + genericWorker.setService(service); + } + + public String getDomain() { + return genericWorker.getDomain(); + } + + public void setDomain(String domain) { + genericWorker.setDomain(domain); + } + + public boolean isRegisterDomain() { + return genericWorker.isRegisterDomain(); + } + + public void setRegisterDomain(boolean registerDomain) { + genericWorker.setRegisterDomain(registerDomain); + } + + public long getDomainRetentionPeriodInDays() { + return genericWorker.getDomainRetentionPeriodInDays(); + } + + public void setDomainRetentionPeriodInDays(long domainRetentionPeriodInDays) { + genericWorker.setDomainRetentionPeriodInDays(domainRetentionPeriodInDays); + } + + public String getTaskListToPoll() { + return genericWorker.getTaskListToPoll(); + } + + public void setTaskListToPoll(String taskListToPoll) { + genericWorker.setTaskListToPoll(taskListToPoll); + } + + public DataConverter getDataConverter() { + return factory.getDataConverter(); + } + + public void setDataConverter(DataConverter dataConverter) { + factory.setDataConverter(dataConverter); + } + + public double getMaximumPollRatePerSecond() { + return genericWorker.getMaximumPollRatePerSecond(); + } + + public void setMaximumPollRatePerSecond(double maximumPollRatePerSecond) { + genericWorker.setMaximumPollRatePerSecond(maximumPollRatePerSecond); + } + + public int getMaximumPollRateIntervalMilliseconds() { + return genericWorker.getMaximumPollRateIntervalMilliseconds(); + } + + public void setMaximumPollRateIntervalMilliseconds(int maximumPollRateIntervalMilliseconds) { + genericWorker.setMaximumPollRateIntervalMilliseconds(maximumPollRateIntervalMilliseconds); + } + + public String getIdentity() { + return genericWorker.getIdentity(); + } + + public void setIdentity(String identity) { + genericWorker.setIdentity(identity); + } + + public UncaughtExceptionHandler getUncaughtExceptionHandler() { + return genericWorker.getUncaughtExceptionHandler(); + } + + public void setUncaughtExceptionHandler(UncaughtExceptionHandler uncaughtExceptionHandler) { + genericWorker.setUncaughtExceptionHandler(uncaughtExceptionHandler); + } + + public long getPollBackoffInitialInterval() { + return genericWorker.getPollBackoffInitialInterval(); + } + + public void setPollBackoffInitialInterval(long backoffInitialInterval) { + genericWorker.setPollBackoffInitialInterval(backoffInitialInterval); + } + + public long getPollBackoffMaximumInterval() { + return genericWorker.getPollBackoffMaximumInterval(); + } + + public void setPollBackoffMaximumInterval(long backoffMaximumInterval) { + genericWorker.setPollBackoffMaximumInterval(backoffMaximumInterval); + } + + public double getPollBackoffCoefficient() { + return genericWorker.getPollBackoffCoefficient(); + } + + public void setPollBackoffCoefficient(double backoffCoefficient) { + genericWorker.setPollBackoffCoefficient(backoffCoefficient); + } + + public int getPollThreadCount() { + return genericWorker.getPollThreadCount(); + } + + public void setPollThreadCount(int threadCount) { + genericWorker.setPollThreadCount(threadCount); + } + + public int getTaskExecutorThreadPoolSize() { + return genericWorker.getTaskExecutorThreadPoolSize(); + } + + public void setTaskExecutorThreadPoolSize(int taskExecutorThreadPoolSize) { + genericWorker.setTaskExecutorThreadPoolSize(taskExecutorThreadPoolSize); + } + + public boolean isDisableServiceShutdownOnStop() { + return genericWorker.isDisableServiceShutdownOnStop(); + } + + public void setDisableServiceShutdownOnStop(boolean disableServiceShutdownOnStop) { + genericWorker.setDisableServiceShutdownOnStop(disableServiceShutdownOnStop); + } + + public void suspendPolling() { + genericWorker.suspendPolling(); + } + + public void resumePolling() { + genericWorker.resumePolling(); + } + + @Override + public void start() { + genericWorker.start(); + } + + public void stopNow() { + genericWorker.shutdownNow(); + } + + @Override + public void shutdown() { + genericWorker.shutdown(); + } + + @Override + public void shutdownNow() { + genericWorker.shutdownNow(); + } + + @Override + public boolean shutdownAndAwaitTermination(long timeout, TimeUnit unit) throws InterruptedException { + return genericWorker.shutdownAndAwaitTermination(timeout, unit); + } + public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { + return genericWorker.awaitTermination(timeout, unit); + } + + @Override + public void stop() { + shutdown(); + try { + awaitTermination(terminationTimeoutSeconds, TimeUnit.SECONDS); + } + catch (InterruptedException e) { + } + } + + public boolean isRunning() { + return genericWorker.isRunning(); + } + + public void setActivitiesImplementations(Iterable activitiesImplementations) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + for (Object activitiesImplementation : activitiesImplementations) { + addActivitiesImplementation(activitiesImplementation); + } + } + + public Iterable getActivitiesImplementations() { + return factory.getActivitiesImplementations(); + } + + public List addActivitiesImplementation(Object activitiesImplementation) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + return factory.addActivitiesImplementation(activitiesImplementation); + } + + @Override + public void registerTypesToPoll() { + genericWorker.registerTypesToPoll(); + } + + /** + * @return default is 0 + */ + @Override + public int getPhase() { + return startPhase; + } + + public void setPhase(int startPhase) { + this.startPhase = startPhase; + } + + @Override + public boolean isAutoStartup() { + return !disableAutoStartup; + } + + public long getTerminationTimeoutSeconds() { + return terminationTimeoutSeconds; + } + + public void setTerminationTimeoutSeconds(long terminationTimeoutSeconds) { + this.terminationTimeoutSeconds = terminationTimeoutSeconds; + } + + public boolean isDisableAutoStartup() { + return disableAutoStartup; + } + + public void setDisableAutoStartup(boolean disableAutoStartup) { + this.disableAutoStartup = disableAutoStartup; + } + + @Override + public void stop(Runnable callback) { + stop(); + callback.run(); + } + + @Override + public String toString() { + return this.getClass().getSimpleName() + "[genericWorker=" + genericWorker + ", factory=" + factory + "]"; + } + + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/SpringWorkflowDefinitionFactoryFactory.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/SpringWorkflowDefinitionFactoryFactory.java new file mode 100644 index 000000000000..32d4998ff7a6 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/SpringWorkflowDefinitionFactoryFactory.java @@ -0,0 +1,94 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.spring; + +import java.util.HashMap; +import java.util.Map; + +import com.amazonaws.services.simpleworkflow.flow.DataConverter; +import com.amazonaws.services.simpleworkflow.flow.DecisionContext; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinitionFactory; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinitionFactoryFactory; +import com.amazonaws.services.simpleworkflow.flow.pojo.POJOWorkflowDefinitionFactoryFactory; +import com.amazonaws.services.simpleworkflow.flow.pojo.POJOWorkflowImplementationFactory; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +class SpringWorkflowDefinitionFactoryFactory extends WorkflowDefinitionFactoryFactory { + + private final POJOWorkflowDefinitionFactoryFactory impl = new POJOWorkflowDefinitionFactoryFactory() { + + @Override + protected POJOWorkflowImplementationFactory getImplementationFactory(Class workflowImplementationType, + Class workflowInteface, WorkflowType workflowType) { + final Object instanceProxy = workflowImplementations.get(workflowImplementationType); + if (instanceProxy == null) { + throw new IllegalArgumentException("unknown workflowImplementationType: " + workflowImplementationType); + } + return new POJOWorkflowImplementationFactory() { + + @Override + public Object newInstance(DecisionContext decisionContext) throws Exception { + WorkflowScope.setDecisionContext(decisionContext); + return instanceProxy; + } + + @Override + public void deleteInstance(Object instance) { + WorkflowScope.removeDecisionContext(); + } + + }; + } + + }; + + private final Map, Object> workflowImplementations = new HashMap, Object>(); + + @Override + public WorkflowDefinitionFactory getWorkflowDefinitionFactory(WorkflowType workflowType) { + return impl.getWorkflowDefinitionFactory(workflowType); + } + + @Override + public Iterable getWorkflowTypesToRegister() { + return impl.getWorkflowTypesToRegister(); + } + + public void setWorkflowImplementations(Iterable workflowImplementations) + throws InstantiationException, IllegalAccessException { + for (Object workflowImplementation : workflowImplementations) { + addWorkflowImplementation(workflowImplementation); + } + } + + public Iterable getWorkflowImplementations() { + return workflowImplementations.values(); + } + + public void addWorkflowImplementation(Object workflowImplementation) throws InstantiationException, IllegalAccessException { + Class implementationClass = workflowImplementation.getClass(); + workflowImplementations.put(implementationClass, workflowImplementation); + impl.addWorkflowImplementationType(implementationClass); + } + + public DataConverter getDataConverter() { + return impl.getDataConverter(); + } + + public void setDataConverter(DataConverter converter) { + impl.setDataConverter(converter); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/SpringWorkflowWorker.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/SpringWorkflowWorker.java new file mode 100644 index 000000000000..b84ca317b30d --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/SpringWorkflowWorker.java @@ -0,0 +1,295 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.spring; + +import java.lang.Thread.UncaughtExceptionHandler; +import java.util.concurrent.TimeUnit; + +import org.springframework.context.SmartLifecycle; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.DataConverter; +import com.amazonaws.services.simpleworkflow.flow.WorkerBase; +import com.amazonaws.services.simpleworkflow.flow.worker.GenericWorkflowWorker; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +/** + * To be used with Spring. Assumes that injected implementation bean has + * "workflow" scope. Otherwise the same object instance will be reused for + * multiple decisions which is guaranteed to break replay if any instance fields + * are used. + */ +public class SpringWorkflowWorker implements WorkerBase, SmartLifecycle { + + private final GenericWorkflowWorker genericWorker; + + private final SpringWorkflowDefinitionFactoryFactory factoryFactory = new SpringWorkflowDefinitionFactoryFactory(); + + private int startPhase; + + private long terminationTimeoutSeconds = 60; + + private boolean disableAutoStartup; + + public SpringWorkflowWorker() { + genericWorker = new GenericWorkflowWorker(); + genericWorker.setWorkflowDefinitionFactoryFactory(factoryFactory); + } + + public SpringWorkflowWorker(AmazonSimpleWorkflow service, String domain, String taskListToPoll) { + genericWorker = new GenericWorkflowWorker(service, domain, taskListToPoll); + genericWorker.setWorkflowDefinitionFactoryFactory(factoryFactory); + } + + public AmazonSimpleWorkflow getService() { + return genericWorker.getService(); + } + + public void setService(AmazonSimpleWorkflow service) { + genericWorker.setService(service); + } + + public String getDomain() { + return genericWorker.getDomain(); + } + + public void setDomain(String domain) { + genericWorker.setDomain(domain); + } + + public boolean isRegisterDomain() { + return genericWorker.isRegisterDomain(); + } + + public void setRegisterDomain(boolean registerDomain) { + genericWorker.setRegisterDomain(registerDomain); + } + + public long getDomainRetentionPeriodInDays() { + return genericWorker.getDomainRetentionPeriodInDays(); + } + + public void setDomainRetentionPeriodInDays(long domainRetentionPeriodInDays) { + genericWorker.setDomainRetentionPeriodInDays(domainRetentionPeriodInDays); + } + + public String getTaskListToPoll() { + return genericWorker.getTaskListToPoll(); + } + + public void setTaskListToPoll(String taskListToPoll) { + genericWorker.setTaskListToPoll(taskListToPoll); + } + + public DataConverter getDataConverter() { + return factoryFactory.getDataConverter(); + } + + public void setDataConverter(DataConverter converter) { + factoryFactory.setDataConverter(converter); + } + + public double getMaximumPollRatePerSecond() { + return genericWorker.getMaximumPollRatePerSecond(); + } + + public void setMaximumPollRatePerSecond(double maximumPollRatePerSecond) { + genericWorker.setMaximumPollRatePerSecond(maximumPollRatePerSecond); + } + + public int getMaximumPollRateIntervalMilliseconds() { + return genericWorker.getMaximumPollRateIntervalMilliseconds(); + } + + public void setMaximumPollRateIntervalMilliseconds(int maximumPollRateIntervalMilliseconds) { + genericWorker.setMaximumPollRateIntervalMilliseconds(maximumPollRateIntervalMilliseconds); + } + + public UncaughtExceptionHandler getUncaughtExceptionHandler() { + return genericWorker.getUncaughtExceptionHandler(); + } + + public void setUncaughtExceptionHandler(UncaughtExceptionHandler uncaughtExceptionHandler) { + genericWorker.setUncaughtExceptionHandler(uncaughtExceptionHandler); + } + + public String getIdentity() { + return genericWorker.getIdentity(); + } + + public void setIdentity(String identity) { + genericWorker.setIdentity(identity); + } + + public long getPollBackoffInitialInterval() { + return genericWorker.getPollBackoffInitialInterval(); + } + + public void setPollBackoffInitialInterval(long backoffInitialInterval) { + genericWorker.setPollBackoffInitialInterval(backoffInitialInterval); + } + + public long getPollBackoffMaximumInterval() { + return genericWorker.getPollBackoffMaximumInterval(); + } + + public void setPollBackoffMaximumInterval(long backoffMaximumInterval) { + genericWorker.setPollBackoffMaximumInterval(backoffMaximumInterval); + } + + public boolean isDisableServiceShutdownOnStop() { + return genericWorker.isDisableServiceShutdownOnStop(); + } + + public void setDisableServiceShutdownOnStop(boolean disableServiceShutdownOnStop) { + genericWorker.setDisableServiceShutdownOnStop(disableServiceShutdownOnStop); + } + + public double getPollBackoffCoefficient() { + return genericWorker.getPollBackoffCoefficient(); + } + + public void setPollBackoffCoefficient(double backoffCoefficient) { + genericWorker.setPollBackoffCoefficient(backoffCoefficient); + } + + public int getPollThreadCount() { + return genericWorker.getPollThreadCount(); + } + + public void setPollThreadCount(int threadCount) { + genericWorker.setPollThreadCount(threadCount); + } + + public void suspendPolling() { + genericWorker.suspendPolling(); + } + + public void resumePolling() { + genericWorker.resumePolling(); + } + + public Iterable getWorkflowTypesToRegister() { + return factoryFactory.getWorkflowTypesToRegister(); + } + + @Override + public void start() { + genericWorker.start(); + } + + @Override + public void shutdown() { + genericWorker.shutdown(); + } + + @Override + public void shutdownNow() { + genericWorker.shutdownNow(); + } + + @Override + public boolean shutdownAndAwaitTermination(long timeout, TimeUnit unit) throws InterruptedException { + return genericWorker.shutdownAndAwaitTermination(timeout, unit); + } + + public void stopNow() { + genericWorker.shutdownNow(); + } + + public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { + return genericWorker.awaitTermination(timeout, unit); + } + + public void setWorkflowImplementations(Iterable workflowImplementations) + throws InstantiationException, IllegalAccessException { + for (Object workflowImplementation : workflowImplementations) { + addWorkflowImplementation(workflowImplementation); + } + } + + public Iterable getWorkflowImplementations() { + return factoryFactory.getWorkflowImplementations(); + } + + public void addWorkflowImplementation(Object workflowImplementation) throws InstantiationException, IllegalAccessException { + factoryFactory.addWorkflowImplementation(workflowImplementation); + } + + @Override + public String toString() { + return this.getClass().getSimpleName() + "[genericWorker=" + genericWorker + ", factoryFactory=" + factoryFactory + "]"; + } + + @Override + public void stop() { + shutdown(); + try { + awaitTermination(terminationTimeoutSeconds, TimeUnit.SECONDS); + } + catch (InterruptedException e) { + } + } + + @Override + public boolean isRunning() { + return genericWorker.isRunning(); + } + + /** + * @return default is 0 + */ + @Override + public int getPhase() { + return startPhase; + } + + public void setPhase(int startPhase) { + this.startPhase = startPhase; + } + + @Override + public boolean isAutoStartup() { + return !disableAutoStartup; + } + + public long getTerminationTimeoutSeconds() { + return terminationTimeoutSeconds; + } + + public void setTerminationTimeoutSeconds(long terminationTimeoutSeconds) { + this.terminationTimeoutSeconds = terminationTimeoutSeconds; + } + + public boolean isDisableAutoStartup() { + return disableAutoStartup; + } + + public void setDisableAutoStartup(boolean disableAutoStartup) { + this.disableAutoStartup = disableAutoStartup; + } + + @Override + public void stop(Runnable callback) { + stop(); + callback.run(); + } + + @Override + public void registerTypesToPoll() { + genericWorker.registerTypesToPoll(); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/WorkflowScope.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/WorkflowScope.java new file mode 100644 index 000000000000..578fa28be754 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/WorkflowScope.java @@ -0,0 +1,146 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.spring; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.ObjectFactory; +import org.springframework.beans.factory.config.AutowireCapableBeanFactory; +import org.springframework.beans.factory.config.Scope; +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; + +import com.amazonaws.services.simpleworkflow.flow.DecisionContext; +import com.amazonaws.services.simpleworkflow.flow.DecisionContextProvider; +import com.amazonaws.services.simpleworkflow.flow.DecisionContextProviderImpl; +import com.amazonaws.services.simpleworkflow.flow.WorkflowClock; +import com.amazonaws.services.simpleworkflow.flow.WorkflowContext; +import com.amazonaws.services.simpleworkflow.flow.WorkflowExecutionLocal; +import com.amazonaws.services.simpleworkflow.flow.generic.GenericActivityClient; +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClient; +import com.amazonaws.services.simpleworkflow.flow.worker.CurrentDecisionContext; + +/** + * + */ +public class WorkflowScope implements Scope, ApplicationContextAware { + + public static final String NAME = "workflow"; + + private DecisionContextProvider contextProvider = new DecisionContextProviderImpl(); + + private static WorkflowExecutionLocal> objects = new WorkflowExecutionLocal>() { + + @Override + protected Map initialValue() { + return new HashMap(); + } + }; + + private static WorkflowExecutionLocal> destructionCallbacks = new WorkflowExecutionLocal>() { + + @Override + protected List initialValue() { + return new ArrayList(); + } + + }; + + public static void setDecisionContext(DecisionContext context) { + CurrentDecisionContext.set(context); + destructionCallbacks.get().clear(); + set(WorkflowScopeBeanNames.GENERIC_ACTIVITY_CLIENT, context.getActivityClient()); + set(WorkflowScopeBeanNames.GENERIC_WORKFLOW_CLIENT, context.getWorkflowClient()); + set(WorkflowScopeBeanNames.WORKFLOW_CLOCK, context.getWorkflowClock()); + set(WorkflowScopeBeanNames.WORKFLOW_CONTEXT, context.getWorkflowContext()); + set(WorkflowScopeBeanNames.DECISION_CONTEXT, context); + } + + public static void removeDecisionContext() { + for (Runnable callback: destructionCallbacks.get()) { + callback.run(); + } + CurrentDecisionContext.unset(); + } + + @Override + public Object get(String name, ObjectFactory objectFactory) { + Map map = objects.get(); + Object result = map.get(name); + if (result == null) { + result = objectFactory.getObject(); + map.put(name, result); + } + return result; + } + + private static void set(String name, Object bean) { + Map map = objects.get(); + map.put(name, bean); + } + + + + @Override + public String getConversationId() { + return contextProvider.getDecisionContext().getWorkflowContext().getWorkflowExecution().getRunId(); + } + + @Override + public void registerDestructionCallback(String name, Runnable callback) { + destructionCallbacks.get().add(callback); + } + + @Override + public Object remove(String name) { + Map map = objects.get(); + return map.remove(name); + } + + @Override + public Object resolveContextualObject(String name) { + //TODO: Understand why WorkflowScopeBeans cannot be returned from this method + return null; + } + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + AutowireCapableBeanFactory autowireCapableBeanFactory = applicationContext.getAutowireCapableBeanFactory(); + if (!(autowireCapableBeanFactory instanceof DefaultListableBeanFactory)) { + throw new IllegalArgumentException( + "The implementation returned from applicationContext.getAutowireCapableBeanFactory() " + + "doesn't implement DefaultListableBeanFactory"); + } + DefaultListableBeanFactory factory = (DefaultListableBeanFactory) autowireCapableBeanFactory; + registerBean(factory, WorkflowScopeBeanNames.GENERIC_ACTIVITY_CLIENT, GenericActivityClient.class); + registerBean(factory, WorkflowScopeBeanNames.GENERIC_WORKFLOW_CLIENT, GenericWorkflowClient.class); + registerBean(factory, WorkflowScopeBeanNames.WORKFLOW_CLOCK, WorkflowClock.class); + registerBean(factory, WorkflowScopeBeanNames.WORKFLOW_CONTEXT, WorkflowContext.class); + registerBean(factory, WorkflowScopeBeanNames.DECISION_CONTEXT, DecisionContext.class); + } + + private void registerBean(DefaultListableBeanFactory factory, String beanName, Class beanClass) { + BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(beanClass); + builder.setScope(NAME); + factory.registerBeanDefinition(beanName, builder.getBeanDefinition()); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/WorkflowScopeBeanNames.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/WorkflowScopeBeanNames.java new file mode 100644 index 000000000000..5f89129331f6 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/spring/WorkflowScopeBeanNames.java @@ -0,0 +1,48 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.spring; + + +public class WorkflowScopeBeanNames { + + public static final String GENERIC_ACTIVITY_CLIENT = "genericActivityClient"; + + public static final String GENERIC_WORKFLOW_CLIENT = "genericWorkflowClient"; + + public static final String WORKFLOW_CLOCK = "workflowClock"; + + public static final String WORKFLOW_CONTEXT = "workflowContext"; + + public static final String DECISION_CONTEXT = "decisionContext"; + + public static boolean isWorkflowScopeBeanName(String name) { + if (GENERIC_ACTIVITY_CLIENT.equals(name)) { + return true; + } + if (GENERIC_WORKFLOW_CLIENT.equals(name)) { + return true; + } + if (WORKFLOW_CLOCK.equals(name)) { + return true; + } + if (WORKFLOW_CONTEXT.equals(name)) { + return true; + } + if (DECISION_CONTEXT.equals(name)) { + return true; + } + return false; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestDecisionContext.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestDecisionContext.java new file mode 100644 index 000000000000..aeed64e5ac30 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestDecisionContext.java @@ -0,0 +1,55 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.test; + +import com.amazonaws.services.simpleworkflow.flow.*; +import com.amazonaws.services.simpleworkflow.flow.generic.*; + +public class TestDecisionContext extends DecisionContext { + + private final GenericActivityClient activityClient; + private final GenericWorkflowClient workflowClient; + private final WorkflowClock workflowClock; + private final WorkflowContext workfowContext; + + public TestDecisionContext(GenericActivityClient activityClient, GenericWorkflowClient workflowClient, + WorkflowClock workflowClock, WorkflowContext workfowContext) { + this.activityClient = activityClient; + this.workflowClient = workflowClient; + this.workflowClock = workflowClock; + this.workfowContext = workfowContext; + } + + @Override + public GenericActivityClient getActivityClient() { + return activityClient; + } + + @Override + public GenericWorkflowClient getWorkflowClient() { + return workflowClient; + } + + @Override + public WorkflowClock getWorkflowClock() { + return workflowClock; + } + + @Override + public WorkflowContext getWorkflowContext() { + return workfowContext; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestGenericActivityClient.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestGenericActivityClient.java new file mode 100644 index 000000000000..011d4b3657e0 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestGenericActivityClient.java @@ -0,0 +1,200 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.test; + +import java.util.HashMap; +import java.util.Map; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.AmazonServiceException; +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; +import com.amazonaws.services.simpleworkflow.flow.ActivityFailureException; +import com.amazonaws.services.simpleworkflow.flow.ActivityTaskFailedException; +import com.amazonaws.services.simpleworkflow.flow.ActivityTaskTimedOutException; +import com.amazonaws.services.simpleworkflow.flow.DecisionContext; +import com.amazonaws.services.simpleworkflow.flow.DecisionContextProvider; +import com.amazonaws.services.simpleworkflow.flow.DecisionContextProviderImpl; +import com.amazonaws.services.simpleworkflow.flow.ScheduleActivityTaskFailedException; +import com.amazonaws.services.simpleworkflow.flow.common.FlowConstants; +import com.amazonaws.services.simpleworkflow.flow.core.*; +import com.amazonaws.services.simpleworkflow.flow.generic.*; +import com.amazonaws.services.simpleworkflow.flow.worker.ActivityTypeRegistrationOptions; +import com.amazonaws.services.simpleworkflow.model.ActivityTask; +import com.amazonaws.services.simpleworkflow.model.ActivityTaskTimeoutType; +import com.amazonaws.services.simpleworkflow.model.ActivityType; +import com.amazonaws.services.simpleworkflow.model.ScheduleActivityTaskFailedCause; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +public class TestGenericActivityClient implements GenericActivityClient { + + private final class TestActivityExecutionContext extends ActivityExecutionContext { + + private final ActivityTask activityTask; + + private final WorkflowExecution workflowExecution; + + private TestActivityExecutionContext(ActivityTask activityTask, WorkflowExecution workflowExecution) { + this.activityTask = activityTask; + this.workflowExecution = workflowExecution; + } + + @Override + public void recordActivityHeartbeat(String details) throws AmazonServiceException, AmazonClientException { + //TODO: timeouts + } + + @Override + public ActivityTask getTask() { + return activityTask; + } + + @Override + public AmazonSimpleWorkflow getService() { + throw new UnsupportedOperationException("not implemented"); + } + + @Override + public String getTaskToken() { + return activityTask.getTaskToken(); + } + + @Override + public WorkflowExecution getWorkflowExecution() { + return workflowExecution; + } + } + + /** + * Key is TaskList + */ + protected final Map factories = new HashMap(); + + protected final Map registrationOptions = new HashMap(); + + protected final Map workerTaskLists = new HashMap(); + + protected final DecisionContextProvider decisionContextProvider; + + public TestGenericActivityClient(DecisionContextProvider decisionContextProvider) { + this.decisionContextProvider = decisionContextProvider; + } + + public TestGenericActivityClient() { + this(new DecisionContextProviderImpl()); + } + + public void addFactory(String taskListToListen, ActivityImplementationFactory factory) { + factories.put(taskListToListen, factory); + Iterable typesToRegister = factory.getActivityTypesToRegister(); + for (ActivityType activityType : typesToRegister) { + ActivityImplementation implementation = factory.getActivityImplementation(activityType); + ActivityTypeRegistrationOptions ro = implementation.getRegistrationOptions(); + registrationOptions.put(activityType, ro); + workerTaskLists.put(activityType, taskListToListen); + } + } + + @Override + public Promise scheduleActivityTask(final ExecuteActivityParameters parameters) { + final ActivityType activityType = parameters.getActivityType(); + final Settable result = new Settable(); + final ActivityTask activityTask = new ActivityTask(); + String activityId = parameters.getActivityId(); + if (activityId == null) { + activityId = decisionContextProvider.getDecisionContext().getWorkflowClient().generateUniqueId(); + } + activityTask.setActivityId(activityId); + activityTask.setActivityType(activityType); + activityTask.setInput(parameters.getInput()); + activityTask.setStartedEventId(0L); + activityTask.setTaskToken("dummyTaskToken"); + DecisionContext decisionContext = decisionContextProvider.getDecisionContext(); + final WorkflowExecution workflowExecution = decisionContext.getWorkflowContext().getWorkflowExecution(); + activityTask.setWorkflowExecution(workflowExecution); + String taskList = parameters.getTaskList(); + if (taskList == null) { + ActivityTypeRegistrationOptions ro = registrationOptions.get(activityType); + if (ro == null) { + String cause = ScheduleActivityTaskFailedCause.ACTIVITY_TYPE_DOES_NOT_EXIST.toString(); + throw new ScheduleActivityTaskFailedException(0, activityType, activityId, cause); + } + taskList = ro.getDefaultTaskList(); + if (FlowConstants.NO_DEFAULT_TASK_LIST.equals(taskList)) { + String cause = ScheduleActivityTaskFailedCause.DEFAULT_TASK_LIST_UNDEFINED.toString(); + throw new ScheduleActivityTaskFailedException(0, activityType, activityId, cause); + } + else if (taskList == null) { + taskList = workerTaskLists.get(activityType); + } + } + ActivityImplementationFactory factory = factories.get(taskList); + // Nobody listens on the specified task list. So in case of a real service it causes + // ScheduleToStart timeout. + //TODO: Activity heartbeats and passing details to the exception. + if (factory == null) { + String timeoutType = ActivityTaskTimeoutType.SCHEDULE_TO_START.toString(); + throw new ActivityTaskTimedOutException(0, activityType, activityId, timeoutType, null); + } + final ActivityImplementation impl = factory.getActivityImplementation(activityType); + if (impl == null) { + String cause = ScheduleActivityTaskFailedCause.ACTIVITY_TYPE_DOES_NOT_EXIST.toString(); + throw new ScheduleActivityTaskFailedException(0, activityType, activityId, cause); + } + ActivityExecutionContext executionContext = new TestActivityExecutionContext(activityTask, workflowExecution); + try { + String activityResult = impl.execute(executionContext); + result.set(activityResult); + } + catch (Throwable e) { + if (e instanceof ActivityFailureException) { + ActivityFailureException falure = (ActivityFailureException) e; + throw new ActivityTaskFailedException(0, activityType, parameters.getActivityId(), falure.getReason(), + falure.getDetails()); + } + // Unless there is problem in the framework or generic activity implementation this shouldn't be executed + ActivityTaskFailedException failure = new ActivityTaskFailedException(0, activityType, parameters.getActivityId(), + e.getMessage(), null); + failure.initCause(e); + throw failure; + } + return result; + } + + @Override + public Promise scheduleActivityTask(String activity, String version, String input) { + ExecuteActivityParameters parameters = new ExecuteActivityParameters(); + ActivityType activityType = new ActivityType(); + activityType.setName(activity); + activityType.setVersion(version); + parameters.setActivityType(activityType); + parameters.setInput(input); + return scheduleActivityTask(parameters); + } + + @Override + public Promise scheduleActivityTask(final String activity, final String version, final Promise input) { + final Settable result = new Settable(); + new Task(input) { + + @Override + protected void doExecute() throws Throwable { + result.chain(scheduleActivityTask(activity, version, input.get())); + } + }; + return result; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestGenericWorkflowClient.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestGenericWorkflowClient.java new file mode 100644 index 000000000000..9b1d088a1b75 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestGenericWorkflowClient.java @@ -0,0 +1,443 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.test; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.CancellationException; + +import com.amazonaws.services.simpleworkflow.flow.ChildWorkflowFailedException; +import com.amazonaws.services.simpleworkflow.flow.DecisionContext; +import com.amazonaws.services.simpleworkflow.flow.DecisionContextProvider; +import com.amazonaws.services.simpleworkflow.flow.DecisionContextProviderImpl; +import com.amazonaws.services.simpleworkflow.flow.SignalExternalWorkflowException; +import com.amazonaws.services.simpleworkflow.flow.StartChildWorkflowFailedException; +import com.amazonaws.services.simpleworkflow.flow.WorkflowClock; +import com.amazonaws.services.simpleworkflow.flow.WorkflowContext; +import com.amazonaws.services.simpleworkflow.flow.WorkflowException; +import com.amazonaws.services.simpleworkflow.flow.common.FlowConstants; +import com.amazonaws.services.simpleworkflow.flow.core.Functor; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.core.Settable; +import com.amazonaws.services.simpleworkflow.flow.core.Task; +import com.amazonaws.services.simpleworkflow.flow.core.TryCatchFinally; +import com.amazonaws.services.simpleworkflow.flow.generic.ContinueAsNewWorkflowExecutionParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.GenericActivityClient; +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClient; +import com.amazonaws.services.simpleworkflow.flow.generic.SignalExternalWorkflowParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.StartChildWorkflowExecutionParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.StartChildWorkflowReply; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinition; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinitionFactory; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinitionFactoryFactory; +import com.amazonaws.services.simpleworkflow.model.StartChildWorkflowExecutionFailedCause; +import com.amazonaws.services.simpleworkflow.model.UnknownResourceException; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +public class TestGenericWorkflowClient implements GenericWorkflowClient { + + private static class StartChildWorkflowReplyImpl implements StartChildWorkflowReply { + + private final Settable result; + + private final String runId; + + private StartChildWorkflowReplyImpl(Settable result, String runId) { + this.result = result; + this.runId = runId; + } + + @Override + public String getRunId() { + return runId; + } + + @Override + public Promise getResult() { + return result; + } + } + + private static final class TestWorkflowContext implements WorkflowContext { + + private TryCatchFinally encosingTryCatch; + + private final StartChildWorkflowExecutionParameters parameters; + + private final WorkflowExecution childExecution; + + private ContinueAsNewWorkflowExecutionParameters continueParameters; + + private TestWorkflowContext(StartChildWorkflowExecutionParameters parameters, WorkflowExecution childExecution) { + this.parameters = parameters; + this.childExecution = childExecution; + } + + public void setEncosingTryCatch(TryCatchFinally encosingTryCatch) { + this.encosingTryCatch = encosingTryCatch; + } + + @Override + public void setContinueAsNewOnCompletion(ContinueAsNewWorkflowExecutionParameters continueParameters) { + this.continueParameters = continueParameters; + } + + @Override + public boolean isCancelRequested() { + return encosingTryCatch.isCancelRequested(); + } + + @Override + public WorkflowType getWorkflowType() { + return parameters.getWorkflowType(); + } + + @Override + public WorkflowExecution getWorkflowExecution() { + return childExecution; + } + + @Override + public ContinueAsNewWorkflowExecutionParameters getContinueAsNewOnCompletion() { + return continueParameters; + } + + } + + private final class ChildWorkflowTryCatchFinally extends TryCatchFinally { + + private final StartChildWorkflowExecutionParameters parameters; + + private final WorkflowExecution childExecution; + + private final Settable result; + + /** + * Child workflow doesn't set result to ready state before completing + * all its tasks. So we need to set external result only in doFinally. + */ + private final Settable executeResult = new Settable(); + + private final WorkflowDefinition childWorkflowDefinition; + + private final DecisionContext childContext; + + private boolean failed; + + private final Settable continueAsNew = new Settable(); + + private ChildWorkflowTryCatchFinally(StartChildWorkflowExecutionParameters parameters, WorkflowExecution childExecution, + WorkflowDefinition childWorkflowDefinition, DecisionContext context, Settable result) { + this.parameters = parameters; + this.childExecution = childExecution; + this.childWorkflowDefinition = childWorkflowDefinition; + this.childContext = context; + this.result = result; + } + + @Override + protected void doTry() throws Throwable { + executeResult.chain(childWorkflowDefinition.execute(parameters.getInput())); + } + + @Override + protected void doCatch(Throwable e) throws Throwable { + failed = true; + if (e instanceof WorkflowException) { + WorkflowException we = (WorkflowException) e; + throw new ChildWorkflowFailedException(0, childExecution, parameters.getWorkflowType(), e.getMessage(), + we.getDetails()); + } + else if (e instanceof CancellationException) { + throw e; + } + // Unless there is problem in the framework or generic workflow implementation this shouldn't be executed + Exception failure = new ChildWorkflowFailedException(0, childExecution, parameters.getWorkflowType(), e.getMessage(), + "null"); + failure.initCause(e); + throw failure; + } + + @Override + protected void doFinally() throws Throwable { + if (!failed) { + continueAsNew.set(childContext.getWorkflowContext().getContinueAsNewOnCompletion()); + if (continueAsNew.get() == null && executeResult.isReady()) { + result.set(executeResult.get()); + return; + } + } + else { + continueAsNew.set(null); + } + workflowExecutions.remove(this.childExecution.getWorkflowId()); + } + + public void signalRecieved(final String signalName, final String details) { + if (getState() != State.TRYING) { + throw new SignalExternalWorkflowException(0, childExecution, "Completed"); + } + new Task(this) { + + @Override + protected void doExecute() throws Throwable { + childWorkflowDefinition.signalRecieved(signalName, details); + } + }; + } + + public StartChildWorkflowExecutionParameters getParameters() { + return parameters; + } + + public String getWorkflowState() throws WorkflowException { + return childWorkflowDefinition.getWorkflowState(); + } + + public WorkflowExecution getWorkflowExecution() { + return childExecution; + } + + public Promise getContinueAsNew() { + return continueAsNew; + } + + } + + private final Map workflowExecutions = new HashMap(); + + protected WorkflowDefinitionFactoryFactory factoryFactory; + + protected DecisionContextProvider decisionContextProvider; + + public TestGenericWorkflowClient(WorkflowDefinitionFactoryFactory factoryFactory, + DecisionContextProvider decisionContextProvider) { + this.factoryFactory = factoryFactory; + this.decisionContextProvider = decisionContextProvider; + } + + public TestGenericWorkflowClient(WorkflowDefinitionFactoryFactory factoryFactory) { + this(factoryFactory, new DecisionContextProviderImpl()); + } + + public TestGenericWorkflowClient() { + this(null, new DecisionContextProviderImpl()); + } + + public WorkflowDefinitionFactoryFactory getFactoryFactory() { + return factoryFactory; + } + + public void setFactoryFactory(WorkflowDefinitionFactoryFactory factoryFactory) { + this.factoryFactory = factoryFactory; + } + + public DecisionContextProvider getDecisionContextProvider() { + return decisionContextProvider; + } + + public void setDecisionContextProvider(DecisionContextProvider decisionContextProvider) { + this.decisionContextProvider = decisionContextProvider; + } + + @Override + public Promise startChildWorkflow(final StartChildWorkflowExecutionParameters parameters) { + Settable reply = new Settable(); + Settable result = new Settable(); + startChildWorkflow(parameters, reply, result); + return reply; + } + + private void startChildWorkflow(final StartChildWorkflowExecutionParameters parameters, + final Settable reply, final Settable result) { + String workflowId = parameters.getWorkflowId(); + WorkflowType workflowType = parameters.getWorkflowType(); + WorkflowExecution childExecution = new WorkflowExecution(); + final String runId = UUID.randomUUID().toString(); + //TODO: Validate parameters against registration options to find missing timeouts or other options + try { + DecisionContext parentDecisionContext = decisionContextProvider.getDecisionContext(); + if (workflowId == null) { + workflowId = decisionContextProvider.getDecisionContext().getWorkflowClient().generateUniqueId(); + } + childExecution.setWorkflowId(workflowId); + childExecution.setRunId(runId); + + final GenericActivityClient activityClient = parentDecisionContext.getActivityClient(); + final WorkflowClock workflowClock = parentDecisionContext.getWorkflowClock(); + WorkflowDefinitionFactory factory; + if (factoryFactory == null) { + throw new IllegalStateException("required property factoryFactory is null"); + } + factory = factoryFactory.getWorkflowDefinitionFactory(workflowType); + if (factory == null) { + String cause = StartChildWorkflowExecutionFailedCause.WORKFLOW_TYPE_DOES_NOT_EXIST.toString(); + throw new StartChildWorkflowFailedException(0, childExecution, workflowType, cause); + } + TestWorkflowContext workfowContext = new TestWorkflowContext(parameters, childExecution); + DecisionContext context = new TestDecisionContext(activityClient, TestGenericWorkflowClient.this, workflowClock, + workfowContext); + //this, parameters, childExecution, workflowClock, activityClient); + final WorkflowDefinition childWorkflowDefinition = factory.getWorkflowDefinition(context); + final ChildWorkflowTryCatchFinally tryCatch = new ChildWorkflowTryCatchFinally(parameters, childExecution, + childWorkflowDefinition, context, result); + workfowContext.setEncosingTryCatch(tryCatch); + ChildWorkflowTryCatchFinally currentRun = workflowExecutions.get(workflowId); + if (currentRun != null) { + String cause = StartChildWorkflowExecutionFailedCause.WORKFLOW_ALREADY_RUNNING.toString(); + throw new StartChildWorkflowFailedException(0, childExecution, workflowType, cause); + } + workflowExecutions.put(workflowId, tryCatch); + continueAsNewWorkflowExecution(tryCatch, result); + } + catch (StartChildWorkflowFailedException e) { + throw e; + } + catch (Throwable e) { + // This cause is chosen to represent internal error for sub-workflow creation + String cause = StartChildWorkflowExecutionFailedCause.OPEN_CHILDREN_LIMIT_EXCEEDED.toString(); + StartChildWorkflowFailedException failure = new StartChildWorkflowFailedException(0, childExecution, workflowType, + cause); + failure.initCause(e); + throw failure; + } + finally { + reply.set(new StartChildWorkflowReplyImpl(result, runId)); + } + } + + private void continueAsNewWorkflowExecution(final ChildWorkflowTryCatchFinally tryCatch, final Settable result) { + // It is always set to ready with null if no continuation is necessary + final Promise continueAsNew = tryCatch.getContinueAsNew(); + new Task(continueAsNew) { + + @Override + protected void doExecute() throws Throwable { + ContinueAsNewWorkflowExecutionParameters cp = continueAsNew.get(); + if (cp == null) { + return; + } + StartChildWorkflowExecutionParameters nextParameters = new StartChildWorkflowExecutionParameters(); + nextParameters.setInput(cp.getInput()); + WorkflowExecution previousWorkflowExecution = tryCatch.getWorkflowExecution(); + String workflowId = previousWorkflowExecution.getWorkflowId(); + nextParameters.setWorkflowId(workflowId); + StartChildWorkflowExecutionParameters previousParameters = tryCatch.getParameters(); + nextParameters.setWorkflowType(previousParameters.getWorkflowType()); + long startToClose = cp.getExecutionStartToCloseTimeoutSeconds(); + if (startToClose == FlowConstants.NONE) { + startToClose = previousParameters.getExecutionStartToCloseTimeoutSeconds(); + } + nextParameters.setExecutionStartToCloseTimeoutSeconds(startToClose); + long taskStartToClose = cp.getTaskStartToCloseTimeoutSeconds(); + if (taskStartToClose == FlowConstants.NONE) { + taskStartToClose = previousParameters.getTaskStartToCloseTimeoutSeconds(); + } + nextParameters.setTaskStartToCloseTimeoutSeconds(taskStartToClose); + workflowExecutions.remove(workflowId); + Settable reply = new Settable(); + startChildWorkflow(nextParameters, reply, result); + } + + }; + } + + @Override + public Promise startChildWorkflow(String workflow, String version, String input) { + StartChildWorkflowExecutionParameters parameters = new StartChildWorkflowExecutionParameters(); + WorkflowType workflowType = new WorkflowType().withName(workflow).withVersion(version); + parameters.setWorkflowType(workflowType); + parameters.setInput(input); + Settable reply = new Settable(); + Settable result = new Settable(); + startChildWorkflow(parameters, reply, result); + return result; + } + + @Override + public Promise startChildWorkflow(final String workflow, final String version, final Promise input) { + return new Functor(input) { + + @Override + protected Promise doExecute() throws Throwable { + return startChildWorkflow(workflow, version, input.get()); + } + }; + } + + @Override + public Promise signalWorkflowExecution(final SignalExternalWorkflowParameters signalParameters) { + WorkflowExecution signaledExecution = new WorkflowExecution(); + signaledExecution.setWorkflowId(signalParameters.getWorkflowId()); + signaledExecution.setRunId(signalParameters.getRunId()); + final ChildWorkflowTryCatchFinally childTryCatch = workflowExecutions.get(signalParameters.getWorkflowId()); + if (childTryCatch == null) { + throw new SignalExternalWorkflowException(0, signaledExecution, "Unknown Execution"); + } + String openExecutionRunId = childTryCatch.getWorkflowExecution().getRunId(); + if (signalParameters.getRunId() != null && !openExecutionRunId.equals(signalParameters.getRunId())) { + throw new SignalExternalWorkflowException(0, signaledExecution, "Unknown Execution (runId doesn't match)"); + } + childTryCatch.signalRecieved(signalParameters.getSignalName(), signalParameters.getInput()); + return Promise.Void(); + } + + @Override + public void requestCancelWorkflowExecution(WorkflowExecution execution) { + String workflowId = execution.getWorkflowId(); + if (workflowId == null) { + throw new IllegalArgumentException("null workflowId"); + } + final ChildWorkflowTryCatchFinally childTryCatch = workflowExecutions.get(workflowId); + if (childTryCatch == null) { + throw new UnknownResourceException("Unknown excution: " + execution.toString()); + } + String openExecutionRunId = childTryCatch.getWorkflowExecution().getRunId(); + if (execution.getRunId() != null && !openExecutionRunId.equals(execution.getRunId())) { + throw new UnknownResourceException("Unknown Execution (runId doesn't match)"); + } + childTryCatch.cancel(new CancellationException()); + } + + public String getWorkflowState(WorkflowExecution execution) throws WorkflowException { + String workflowId = execution.getWorkflowId(); + if (workflowId == null) { + throw new IllegalArgumentException("null workflowId"); + } + final ChildWorkflowTryCatchFinally childTryCatch = workflowExecutions.get(workflowId); + if (childTryCatch == null) { + throw new UnknownResourceException(execution.toString()); + } + String openExecutionRunId = childTryCatch.getWorkflowExecution().getRunId(); + if (execution.getRunId() != null && !openExecutionRunId.equals(execution.getRunId())) { + throw new UnknownResourceException("Unknown Execution (runId doesn't match)"); + } + return childTryCatch.getWorkflowState(); + } + + @Override + public void continueAsNewOnCompletion(ContinueAsNewWorkflowExecutionParameters parameters) { + DecisionContext decisionContext = decisionContextProvider.getDecisionContext(); + decisionContext.getWorkflowContext().setContinueAsNewOnCompletion(parameters); + } + + @Override + public String generateUniqueId() { + return UUID.randomUUID().toString(); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestPOJOActivityImplementationGenericActivityClient.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestPOJOActivityImplementationGenericActivityClient.java new file mode 100644 index 000000000000..89bbbce835e7 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestPOJOActivityImplementationGenericActivityClient.java @@ -0,0 +1,47 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.test; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.generic.ExecuteActivityParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.GenericActivityClient; + + +public class TestPOJOActivityImplementationGenericActivityClient implements GenericActivityClient { + + private final TestGenericActivityClient genericClient; + + public TestPOJOActivityImplementationGenericActivityClient() { + genericClient = new TestGenericActivityClient(); + } + + public void addWorker(TestPOJOActivityImplementationWorker worker) { + genericClient.addFactory(worker.getTaskList(), worker.getFactory()); + } + + public Promise scheduleActivityTask(ExecuteActivityParameters parameters) { + return genericClient.scheduleActivityTask(parameters); + } + + public Promise scheduleActivityTask(String activity, String version, String input) { + return genericClient.scheduleActivityTask(activity, version, input); + } + + public Promise scheduleActivityTask(String activity, String version, Promise input) { + return genericClient.scheduleActivityTask(activity, version, input); + } + + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestPOJOActivityImplementationWorker.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestPOJOActivityImplementationWorker.java new file mode 100644 index 000000000000..5c56ff39a51b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestPOJOActivityImplementationWorker.java @@ -0,0 +1,88 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.test; + +import java.util.List; + +import com.amazonaws.services.simpleworkflow.flow.DataConverter; +import com.amazonaws.services.simpleworkflow.flow.generic.ActivityImplementation; +import com.amazonaws.services.simpleworkflow.flow.pojo.POJOActivityImplementationFactory; +import com.amazonaws.services.simpleworkflow.model.ActivityType; + + +public class TestPOJOActivityImplementationWorker { + + private final POJOActivityImplementationFactory factory = new POJOActivityImplementationFactory(); + + private final String taskList; + + public TestPOJOActivityImplementationWorker(String taskList) { + this.taskList = taskList; + } + + POJOActivityImplementationFactory getFactory() { + return factory; + } + + public String getTaskList() { + return taskList; + } + + public void setActivitiesImplementations(Iterable activitiesImplementations) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + factory.setActivitiesImplementations(activitiesImplementations); + } + + public Iterable getActivitiesImplementations() { + return factory.getActivitiesImplementations(); + } + + public List addActivitiesImplementations(Iterable activitiesImplementations) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + return factory.addActivitiesImplementations(activitiesImplementations); + } + + public List addActivitiesImplementations(Iterable activitiesImplementations, DataConverter dataConverter) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + return factory.addActivitiesImplementations(activitiesImplementations, dataConverter); + } + + public List addActivitiesImplementation(Object activitiesImplementation) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + return factory.addActivitiesImplementation(activitiesImplementation); + } + + public List addActivitiesImplementation(Object activitiesImplementation, DataConverter converter) + throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException { + return factory.addActivitiesImplementation(activitiesImplementation, converter); + } + + public Iterable getActivityTypesToRegister() { + return factory.getActivityTypesToRegister(); + } + + public ActivityImplementation getActivityImplementation(ActivityType activityType) { + return factory.getActivityImplementation(activityType); + } + + public DataConverter getDataConverter() { + return factory.getDataConverter(); + } + + public void setDataConverter(DataConverter dataConverter) { + factory.setDataConverter(dataConverter); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestPOJOWorkflowImplementationGenericWorkflowClient.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestPOJOWorkflowImplementationGenericWorkflowClient.java new file mode 100644 index 000000000000..20dc0b51f4de --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestPOJOWorkflowImplementationGenericWorkflowClient.java @@ -0,0 +1,106 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.test; + +import java.util.Collection; + +import com.amazonaws.services.simpleworkflow.flow.DataConverter; +import com.amazonaws.services.simpleworkflow.flow.DecisionContextProvider; +import com.amazonaws.services.simpleworkflow.flow.WorkflowException; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.generic.ContinueAsNewWorkflowExecutionParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClient; +import com.amazonaws.services.simpleworkflow.flow.generic.SignalExternalWorkflowParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.StartChildWorkflowExecutionParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.StartChildWorkflowReply; +import com.amazonaws.services.simpleworkflow.flow.pojo.POJOWorkflowDefinitionFactoryFactory; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + + +public class TestPOJOWorkflowImplementationGenericWorkflowClient implements GenericWorkflowClient { + + private final TestGenericWorkflowClient genericClient; + private final POJOWorkflowDefinitionFactoryFactory factoryFactory; + + public TestPOJOWorkflowImplementationGenericWorkflowClient() { + factoryFactory = new POJOWorkflowDefinitionFactoryFactory(); + genericClient = new TestGenericWorkflowClient(factoryFactory); + } + + public DecisionContextProvider getDecisionContextProvider() { + return genericClient.getDecisionContextProvider(); + } + + public void setDecisionContextProvider(DecisionContextProvider decisionContextProvider) { + genericClient.setDecisionContextProvider(decisionContextProvider); + } + + public Promise startChildWorkflow(StartChildWorkflowExecutionParameters parameters) { + return genericClient.startChildWorkflow(parameters); + } + + public Promise startChildWorkflow(String workflow, String version, String input) { + return genericClient.startChildWorkflow(workflow, version, input); + } + + public Promise startChildWorkflow(String workflow, String version, Promise input) { + return genericClient.startChildWorkflow(workflow, version, input); + } + + public Promise signalWorkflowExecution(SignalExternalWorkflowParameters signalParameters) { + return genericClient.signalWorkflowExecution(signalParameters); + } + + public void requestCancelWorkflowExecution(WorkflowExecution execution) { + genericClient.requestCancelWorkflowExecution(execution); + } + + public String getWorkflowState(WorkflowExecution execution) throws WorkflowException { + return genericClient.getWorkflowState(execution); + } + + public void continueAsNewOnCompletion(ContinueAsNewWorkflowExecutionParameters parameters) { + genericClient.continueAsNewOnCompletion(parameters); + } + + public String generateUniqueId() { + return genericClient.generateUniqueId(); + } + + public void setDataConverter(DataConverter converter) { + factoryFactory.setDataConverter(converter); + } + + public Iterable getWorkflowTypesToRegister() { + return factoryFactory.getWorkflowTypesToRegister(); + } + + public void addWorkflowImplementationType(Class workflowImplementationType) + throws InstantiationException, IllegalAccessException { + factoryFactory.addWorkflowImplementationType(workflowImplementationType); + } + + public void addWorkflowImplementationType(Class workflowImplementationType, DataConverter converterOverride) + throws InstantiationException, IllegalAccessException { + factoryFactory.addWorkflowImplementationType(workflowImplementationType, converterOverride); + } + + public void setWorkflowImplementationTypes(Collection> workflowImplementationTypes) + throws InstantiationException, IllegalAccessException { + factoryFactory.setWorkflowImplementationTypes(workflowImplementationTypes); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestWorkflowClock.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestWorkflowClock.java new file mode 100644 index 000000000000..f28f879c6e37 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestWorkflowClock.java @@ -0,0 +1,178 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.test; + +import java.util.PriorityQueue; + +import com.amazonaws.services.simpleworkflow.flow.WorkflowClock; +import com.amazonaws.services.simpleworkflow.flow.core.ExternalTask; +import com.amazonaws.services.simpleworkflow.flow.core.ExternalTaskCancellationHandler; +import com.amazonaws.services.simpleworkflow.flow.core.ExternalTaskCompletionHandle; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.core.Settable; +import com.amazonaws.services.simpleworkflow.flow.core.Task; + +public class TestWorkflowClock implements WorkflowClock { + + private static final int SECOND = 1000; + + private static class TimerInfo implements Comparable> { + + final Long fireTime; + + final Settable timerResult = new Settable(); + + final T context; + + private Settable handle = new Settable(); + + public TimerInfo(long fireTime, T context) { + this.fireTime = fireTime; + this.context = context; + } + + public void fire() { + timerResult.set(context); + if (handle.isReady()) { + handle.get().complete(); + } + else { + new Task(handle) { + + @Override + protected void doExecute() throws Throwable { + handle.get().complete(); + } + + }; + } + } + + public Promise getResult() { + return timerResult; + } + + @Override + public int compareTo(TimerInfo o) { + return fireTime.compareTo(o.fireTime); + } + + public void cancel() { + handle.get().complete(); + } + + public long getFireTime() { + return fireTime; + } + + public void setCompletionHandle(ExternalTaskCompletionHandle handle) { + this.handle.set(handle); + } + + public void setResultDescription(String description) { + timerResult.setDescription(description); + } + } + + private long clockTime = 0L; + + private PriorityQueue> timers = new PriorityQueue>(); + + @Override + public long currentTimeMillis() { + return clockTime; + } + + public void setCurrentTimeMillis(long timeMillis) { + clockTime = timeMillis; + } + + @Override + public boolean isReplaying() { + // Unit test never replays + return false; + } + + @Override + public Promise createTimer(long delaySeconds) { + return createTimer(delaySeconds, null); + } + + @Override + public Promise createTimer(final long delaySeconds, final T context) { + if (delaySeconds < 0) { + throw new IllegalArgumentException("negative delaySeconds"); + } + if (delaySeconds == 0) { + return Promise.asPromise(context); + } + long fireTime = clockTime + delaySeconds * 1000; + final TimerInfo timer = new TimerInfo(fireTime, context); + String timerName = "delay=" + delaySeconds; + timer.setResultDescription("createTimer " + timerName); + timers.add(timer); + new ExternalTask() { + + @Override + protected ExternalTaskCancellationHandler doExecute(ExternalTaskCompletionHandle handle) throws Throwable { + timer.setCompletionHandle(handle); + return new ExternalTaskCancellationHandler() { + + @Override + public void handleCancellation(Throwable e) { + timers.remove(timer); + timer.cancel(); + } + }; + } + }.setName(timerName); + return timer.getResult(); + } + + public Long fireTimers() { + while (true) { + TimerInfo timer = timers.peek(); + if (timer == null) { + return null; + } + long timerTime = timer.getFireTime(); + if (timerTime > clockTime) { + return timerTime - clockTime; + } + timers.poll(); + timer.fire(); + } + } + + public void advanceSeconds(long seconds) { + advanceMilliseconds(seconds * SECOND); + } + + public void advanceMilliseconds(long milliseconds) { + clockTime += milliseconds; + while (true) { + TimerInfo timer = timers.peek(); + if (timer == null) { + break; + } + long timerTime = timer.getFireTime(); + if (timerTime > clockTime) { + break; + } + timer.fire(); + timers.poll(); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestWorkflowContext.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestWorkflowContext.java new file mode 100644 index 000000000000..93ab2634ba6d --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/test/TestWorkflowContext.java @@ -0,0 +1,62 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.test; + +import com.amazonaws.services.simpleworkflow.flow.WorkflowContext; +import com.amazonaws.services.simpleworkflow.flow.generic.ContinueAsNewWorkflowExecutionParameters; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + + +public class TestWorkflowContext implements WorkflowContext { + + private WorkflowExecution workflowExecution; + private WorkflowType workflowType; + private ContinueAsNewWorkflowExecutionParameters continueAsNewOnCompletion; + + @Override + public WorkflowExecution getWorkflowExecution() { + return workflowExecution; + } + + public void setWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + } + + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + @Override + public WorkflowType getWorkflowType() { + return workflowType; + } + + @Override + public boolean isCancelRequested() { + return false; + } + + @Override + public ContinueAsNewWorkflowExecutionParameters getContinueAsNewOnCompletion() { + return continueAsNewOnCompletion; + } + + @Override + public void setContinueAsNewOnCompletion(ContinueAsNewWorkflowExecutionParameters continueParameters) { + this.continueAsNewOnCompletion = continueParameters; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityDecisionStateMachine.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityDecisionStateMachine.java new file mode 100644 index 000000000000..c75d5d8ab1f2 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityDecisionStateMachine.java @@ -0,0 +1,94 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import com.amazonaws.services.simpleworkflow.model.Decision; +import com.amazonaws.services.simpleworkflow.model.DecisionType; +import com.amazonaws.services.simpleworkflow.model.HistoryEvent; +import com.amazonaws.services.simpleworkflow.model.RequestCancelActivityTaskDecisionAttributes; +import com.amazonaws.services.simpleworkflow.model.ScheduleActivityTaskDecisionAttributes; + +class ActivityDecisionStateMachine extends DecisionStateMachineBase { + + private ScheduleActivityTaskDecisionAttributes scheduleAttributes; + + public ActivityDecisionStateMachine(DecisionId id, ScheduleActivityTaskDecisionAttributes scheduleAttributes) { + super(id); + this.scheduleAttributes = scheduleAttributes; + } + + /** + * Used for unit testing + */ + ActivityDecisionStateMachine(DecisionId id, ScheduleActivityTaskDecisionAttributes scheduleAttributes, DecisionState state) { + super(id, state); + this.scheduleAttributes = scheduleAttributes; + } + + @Override + public Decision getDecision() { + switch (state) { + case CREATED: + return createScheduleActivityTaskDecision(); + case CANCELED_AFTER_INITIATED: + return createRequestCancelActivityTaskDecision(); + default: + return null; + } + } + + @Override + public void handleDecisionTaskStartedEvent() { + switch (state) { + case CANCELED_AFTER_INITIATED: + stateHistory.add("handleDecisionTaskStartedEvent"); + state = DecisionState.CANCELLATION_DECISION_SENT; + stateHistory.add(state.toString()); + break; + default: + super.handleDecisionTaskStartedEvent(); + } + } + + @Override + public void handleCancellationFailureEvent(HistoryEvent event) { + switch (state) { + case CANCELLATION_DECISION_SENT: + stateHistory.add("handleCancellationFailureEvent"); + state = DecisionState.INITIATED; + stateHistory.add(state.toString()); + break; + default: + super.handleCancellationFailureEvent(event); + } + } + + private Decision createRequestCancelActivityTaskDecision() { + RequestCancelActivityTaskDecisionAttributes tryCancel = new RequestCancelActivityTaskDecisionAttributes(); + tryCancel.setActivityId(scheduleAttributes.getActivityId()); + Decision decision = new Decision(); + decision.setRequestCancelActivityTaskDecisionAttributes(tryCancel); + decision.setDecisionType(DecisionType.RequestCancelActivityTask.toString()); + return decision; + } + + private Decision createScheduleActivityTaskDecision() { + Decision decision = new Decision(); + decision.setScheduleActivityTaskDecisionAttributes(scheduleAttributes); + decision.setDecisionType(DecisionType.ScheduleActivityTask.toString()); + return decision; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityExecutionContextImpl.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityExecutionContextImpl.java new file mode 100644 index 000000000000..a4a01c4095d7 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityExecutionContextImpl.java @@ -0,0 +1,101 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.util.concurrent.CancellationException; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; +import com.amazonaws.services.simpleworkflow.model.ActivityTask; +import com.amazonaws.services.simpleworkflow.model.ActivityTaskStatus; +import com.amazonaws.services.simpleworkflow.model.RecordActivityTaskHeartbeatRequest; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +/** + * Base implementation of an {@link ActivityExecutionContext}. + * + * @see ActivityExecutionContext + * + * @author fateev, suskin + * + */ +class ActivityExecutionContextImpl extends ActivityExecutionContext { + + private final ActivityTask task; + + private final AmazonSimpleWorkflow service; + + /** + * Create an ActivityExecutionContextImpl with the given attributes. + * + * @param service + * The {@link AmazonSimpleWorkflow} this + * ActivityExecutionContextImpl will send service calls to. + * @param task + * The {@link ActivityTask} this ActivityExecutionContextImpl + * will be used for. + * + * @see ActivityExecutionContext + */ + public ActivityExecutionContextImpl(AmazonSimpleWorkflow service, ActivityTask task) { + this.service = service; + this.task = task; + } + + /** + * @throws CancellationException + * @see ActivityExecutionContext#recordActivityHeartbeat(int) + */ + @Override + public void recordActivityHeartbeat(String details) throws CancellationException { + //TODO: call service with the specified minimal interval (through @ActivityExecutionOptions) + // allowing more frequent calls of this method. + RecordActivityTaskHeartbeatRequest r = new RecordActivityTaskHeartbeatRequest(); + r.setTaskToken(task.getTaskToken()); + r.setDetails(details); + ActivityTaskStatus status; + status = service.recordActivityTaskHeartbeat(r); + if (status.isCancelRequested()) { + throw new CancellationException(); + } + } + + /** + * @see ActivityExecutionContext#getTask() + */ + @Override + public ActivityTask getTask() { + return task; + } + + /** + * @see ActivityExecutionContext#getService() + */ + @Override + public AmazonSimpleWorkflow getService() { + return service; + } + + @Override + public String getTaskToken() { + return task.getTaskToken(); + } + + @Override + public WorkflowExecution getWorkflowExecution() { + return task.getWorkflowExecution(); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityTaskPoller.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityTaskPoller.java new file mode 100644 index 000000000000..579ba1d83257 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityTaskPoller.java @@ -0,0 +1,142 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.lang.Thread.UncaughtExceptionHandler; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Semaphore; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.generic.ActivityImplementationFactory; +import com.amazonaws.services.simpleworkflow.model.ActivityTask; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +public class ActivityTaskPoller extends SynchronousActivityTaskPoller { + + private static final Log log = LogFactory.getLog(ActivityTaskPoller.class); + + private ThreadPoolExecutor taskExecutorService; + + protected Semaphore pollSemaphore; + + private UncaughtExceptionHandler uncaughtExceptionHandler = new UncaughtExceptionHandler() { + + @Override + public void uncaughtException(Thread t, Throwable e) { + log.error("Failure in thread " + t.getName(), e); + } + }; + + public ActivityTaskPoller(AmazonSimpleWorkflow service, String domain, String pollTaskList, + ActivityImplementationFactory activityImplementationFactory, ThreadPoolExecutor taskExecutorService) { + super(service, domain, pollTaskList, activityImplementationFactory); + setTaskExecutorService(taskExecutorService); + } + + public ExecutorService getTaskExecutorService() { + return taskExecutorService; + } + + public void setTaskExecutorService(ThreadPoolExecutor taskExecutorService) { + this.taskExecutorService = taskExecutorService; + pollSemaphore = new Semaphore(taskExecutorService.getMaximumPoolSize()); + } + + /** + * Poll for a activity task and execute correspondent implementation using + * provided executor service. + * + * @return true if task was polled and decided upon, false if poll timed out + * @throws Exception + */ + @Override + public boolean pollAndProcessSingleTask() throws Exception { + boolean semaphoreNeedsRelease = false; + try { + // Without semaphore task that was polled from a service + // can end up waiting on taskExecutor.execute(...) for a long + // time leading to timeouts and other problems + if (pollSemaphore != null) { + pollSemaphore.acquire(); + } + // we will release the semaphore in a finally clause + semaphoreNeedsRelease = true; + final ActivityTask task = poll(); + if (task == null) { + return false; + } + semaphoreNeedsRelease = false; + try { + taskExecutorService.execute(new Runnable() { + + @Override + public void run() { + try { + execute(task); + } + catch (Throwable ee) { + uncaughtExceptionHandler.uncaughtException(Thread.currentThread(), wrapFailure(task, ee)); + } + finally { + pollSemaphore.release(); + } + } + }); + } + catch (Exception e) { + semaphoreNeedsRelease = true; + throw e; + } catch (Error e) { + semaphoreNeedsRelease = true; + throw e; + } + } + finally { + if (semaphoreNeedsRelease) { + pollSemaphore.release(); + } + } + return true; + } + + private Exception wrapFailure(final ActivityTask task, Throwable failure) { + WorkflowExecution execution = task.getWorkflowExecution(); + + RuntimeException e2 = new RuntimeException( + "Failure taskId=\"" + task.getStartedEventId() + "\" workflowExecutionRunId=\"" + execution.getRunId() + + "\" workflowExecutionId=\"" + execution.getWorkflowId(), failure); + return e2; + } + + @Override + public void shutdown() { + taskExecutorService.shutdown(); + } + + @Override + public void shutdownNow() { + taskExecutorService.shutdownNow(); + } + + @Override + public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { + return taskExecutorService.awaitTermination(timeout, unit); + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityTypeExecutionOptions.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityTypeExecutionOptions.java new file mode 100644 index 000000000000..32da9f70ded2 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityTypeExecutionOptions.java @@ -0,0 +1,77 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +public class ActivityTypeExecutionOptions { + private boolean manualActivityCompletion; + private long respondTaskCompletedRetryInitialInterval = 1000; + private long respondTaskCompletedRetryMaximumInterval = 60000; + private int respondTaskCompletedMaximumRetries = 5; + private double respondTaskCompletedBackoffCoefficient = 2; + private boolean doNotRetryTaskFailed; + + public double getRespondTaskCompletedBackoffCoefficient() { + return respondTaskCompletedBackoffCoefficient; + } + + public void setRespondTaskCompletedBackoffCoefficient(double respondTaskCompletedBackoffCoefficient) { + this.respondTaskCompletedBackoffCoefficient = respondTaskCompletedBackoffCoefficient; + } + + public boolean isManualActivityCompletion() { + return manualActivityCompletion; + } + + public void setManualActivityCompletion(boolean flag) { + this.manualActivityCompletion = flag; + } + + public long getRespondTaskCompletedRetryInitialInterval() { + return respondTaskCompletedRetryInitialInterval; + } + + public void setRespondTaskCompletedRetryInitialInterval(long respondTaskCompletedRetryInitialInterval) { + this.respondTaskCompletedRetryInitialInterval = respondTaskCompletedRetryInitialInterval; + } + + public long getRespondTaskCompletedRetryMaximumInterval() { + return respondTaskCompletedRetryMaximumInterval; + } + + public void setRespondTaskCompletedRetryMaximumInterval(long respondTaskCompletedRetryMaximumInterval) { + this.respondTaskCompletedRetryMaximumInterval = respondTaskCompletedRetryMaximumInterval; + } + + public int getRespondTaskCompletedMaximumRetries() { + return respondTaskCompletedMaximumRetries; + } + + public void setRespondTaskCompletedMaximumRetries(int respondTaskCompletedMaximumRetries) { + this.respondTaskCompletedMaximumRetries = respondTaskCompletedMaximumRetries; + } + + public boolean isDoNotRetryTaskFailed() { + return doNotRetryTaskFailed; + } + + public void setDoNotRetryTaskFailed(boolean doNotRetryTaskFailed) { + this.doNotRetryTaskFailed = doNotRetryTaskFailed; + } + + @Override + public String toString() { + return "ActivityTypeExecutionOptions [isAsynchronous=" + manualActivityCompletion + "]"; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityTypeRegistrationOptions.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityTypeRegistrationOptions.java new file mode 100644 index 000000000000..ff80e3bf3289 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ActivityTypeRegistrationOptions.java @@ -0,0 +1,90 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +public class ActivityTypeRegistrationOptions { + + private String defaultTaskList; + + private String description; + + private Long defaultTaskHeartbeatTimeoutSeconds; + + private Long defaultTaskScheduleToCloseTimeoutSeconds; + + private Long defaultTaskScheduleToStartTimeoutSeconds; + + private Long defaultTaskStartToCloseTimeoutSeconds; + + public String getDefaultTaskList() { + return defaultTaskList; + } + + public void setDefaultTaskList(String defaultTaskList) { + this.defaultTaskList = defaultTaskList; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Long getDefaultTaskHeartbeatTimeoutSeconds() { + return defaultTaskHeartbeatTimeoutSeconds; + } + + public void setDefaultTaskHeartbeatTimeoutSeconds(Long defaultTaskHeartbeatTimeoutSeconds) { + this.defaultTaskHeartbeatTimeoutSeconds = defaultTaskHeartbeatTimeoutSeconds; + } + + public Long getDefaultTaskScheduleToCloseTimeoutSeconds() { + return defaultTaskScheduleToCloseTimeoutSeconds; + } + + public void setDefaultTaskScheduleToCloseTimeoutSeconds(Long defaultTaskScheduleToCloseTimeoutSeconds) { + this.defaultTaskScheduleToCloseTimeoutSeconds = defaultTaskScheduleToCloseTimeoutSeconds; + } + + public Long getDefaultTaskScheduleToStartTimeoutSeconds() { + return defaultTaskScheduleToStartTimeoutSeconds; + } + + public void setDefaultTaskScheduleToStartTimeoutSeconds(Long defaultTaskScheduleToStartTimeoutSeconds) { + this.defaultTaskScheduleToStartTimeoutSeconds = defaultTaskScheduleToStartTimeoutSeconds; + } + + public Long getDefaultTaskStartToCloseTimeoutSeconds() { + return defaultTaskStartToCloseTimeoutSeconds; + } + + public void setDefaultTaskStartToCloseTimeoutSeconds(Long defaultTaskStartToCloseTimeoutSeconds) { + this.defaultTaskStartToCloseTimeoutSeconds = defaultTaskStartToCloseTimeoutSeconds; + } + + @Override + public String toString() { + return "ActivityTypeRegistrationOptions [defaultTaskList=" + ((defaultTaskList != null) ? defaultTaskList.toString() : "null") + + ", description=" + description + + ", defaultTaskHeartbeatTimeoutSeconds=" + defaultTaskHeartbeatTimeoutSeconds + + ", defaultTaskScheduleToCloseTimeoutSeconds=" + defaultTaskScheduleToCloseTimeoutSeconds + + ", defaultTaskScheduleToStartTimeoutSeconds=" + defaultTaskScheduleToStartTimeoutSeconds + + ", defaultTaskStartToCloseTimeoutSeconds=" + defaultTaskStartToCloseTimeoutSeconds + + "]"; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/AsyncDecider.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/AsyncDecider.java new file mode 100644 index 000000000000..aebd0d6a6b6d --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/AsyncDecider.java @@ -0,0 +1,569 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CancellationException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.amazonaws.services.simpleworkflow.flow.DecisionContext; +import com.amazonaws.services.simpleworkflow.flow.WorkflowException; +import com.amazonaws.services.simpleworkflow.flow.core.AsyncScope; +import com.amazonaws.services.simpleworkflow.flow.core.AsyncTaskInfo; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.core.Task; +import com.amazonaws.services.simpleworkflow.flow.generic.ContinueAsNewWorkflowExecutionParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinition; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinitionFactory; +import com.amazonaws.services.simpleworkflow.flow.worker.HistoryHelper.EventsIterator; +import com.amazonaws.services.simpleworkflow.model.DecisionTask; +import com.amazonaws.services.simpleworkflow.model.EventType; +import com.amazonaws.services.simpleworkflow.model.HistoryEvent; +import com.amazonaws.services.simpleworkflow.model.StartTimerFailedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.TimerFiredEventAttributes; +import com.amazonaws.services.simpleworkflow.model.TimerStartedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecutionSignaledEventAttributes; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecutionStartedEventAttributes; + +class AsyncDecider { + + private static abstract class WorkflowAsyncScope extends AsyncScope { + + public WorkflowAsyncScope() { + super(false, true); + } + + public abstract Promise getOutput(); + + } + + private final class WorkflowExecuteAsyncScope extends WorkflowAsyncScope { + + private final WorkflowExecutionStartedEventAttributes attributes; + + private Promise output; + + public WorkflowExecuteAsyncScope(HistoryEvent event) { + assert event.getEventType().equals(EventType.WorkflowExecutionStarted.toString()); + this.attributes = event.getWorkflowExecutionStartedEventAttributes(); + } + + @Override + protected void doAsync() throws Throwable { + output = definition.execute(attributes.getInput()); + } + + @Override + public Promise getOutput() { + return output; + } + + } + + private final class UnhandledSignalAsyncScope extends WorkflowAsyncScope { + + private final Promise output; + + private Throwable failure; + + private boolean cancellation; + + public UnhandledSignalAsyncScope(Promise output, Throwable failure, boolean cancellation) { + this.output = output; + this.failure = failure; + this.cancellation = cancellation; + } + + @Override + protected void doAsync() throws Throwable { + } + + @Override + public Promise getOutput() { + return output; + } + + @Override + public boolean isCancelRequested() { + return super.isCancelRequested() || cancellation; + } + + @Override + public Throwable getFailure() { + Throwable result = super.getFailure(); + if (failure != null) { + result = failure; + } + return result; + } + + @Override + public boolean eventLoop() throws Throwable { + boolean completed = super.eventLoop(); + if (completed && failure != null) { + throw failure; + } + return completed; + } + + } + + private static final Log log = LogFactory.getLog(AsyncDecider.class); + + private final WorkflowDefinitionFactory workflowDefinitionFactory; + + private WorkflowDefinition definition; + + private final HistoryHelper historyHelper; + + private final DecisionsHelper decisionsHelper; + + private final GenericActivityClientImpl activityClient; + + private final GenericWorkflowClientImpl workflowClient; + + private final WorkflowClockImpl workflowClock; + + private final DecisionContext context; + + private WorkflowAsyncScope workflowAsyncScope; + + private boolean cancelRequested; + + private WorkfowContextImpl workflowContext; + + private boolean unhandledDecision; + + private boolean completed; + + private Throwable failure; + + public AsyncDecider(WorkflowDefinitionFactory workflowDefinitionFactory, HistoryHelper historyHelper, + DecisionsHelper decisionsHelper) throws Exception { + this.workflowDefinitionFactory = workflowDefinitionFactory; + this.historyHelper = historyHelper; + this.decisionsHelper = decisionsHelper; + this.activityClient = new GenericActivityClientImpl(decisionsHelper); + DecisionTask decisionTask = historyHelper.getDecisionTask(); + workflowContext = new WorkfowContextImpl(decisionTask); + this.workflowClient = new GenericWorkflowClientImpl(decisionsHelper, workflowContext); + this.workflowClock = new WorkflowClockImpl(decisionsHelper); + context = new DecisionContextImpl(activityClient, workflowClient, workflowClock, workflowContext); + } + + public boolean isCancelRequested() { + return cancelRequested; + } + + private void handleWorkflowExecutionStarted(HistoryEvent event) { + workflowAsyncScope = new WorkflowExecuteAsyncScope(event); + } + + private void processEvent(HistoryEvent event, EventType eventType) throws Throwable { + switch (eventType) { + case ActivityTaskCanceled: + activityClient.handleActivityTaskCanceled(event); + break; + case ActivityTaskCompleted: + activityClient.handleActivityTaskCompleted(event); + break; + case ActivityTaskFailed: + activityClient.handleActivityTaskFailed(event); + break; + case ActivityTaskStarted: + activityClient.handleActivityTaskStarted(event.getActivityTaskStartedEventAttributes()); + break; + case ActivityTaskTimedOut: + activityClient.handleActivityTaskTimedOut(event); + break; + case ExternalWorkflowExecutionCancelRequested: + workflowClient.handleChildWorkflowExecutionCancelRequested(event); + break; + case ChildWorkflowExecutionCanceled: + workflowClient.handleChildWorkflowExecutionCanceled(event); + break; + case ChildWorkflowExecutionCompleted: + workflowClient.handleChildWorkflowExecutionCompleted(event); + break; + case ChildWorkflowExecutionFailed: + workflowClient.handleChildWorkflowExecutionFailed(event); + break; + case ChildWorkflowExecutionStarted: + workflowClient.handleChildWorkflowExecutionStarted(event); + break; + case ChildWorkflowExecutionTerminated: + workflowClient.handleChildWorkflowExecutionTerminated(event); + break; + case ChildWorkflowExecutionTimedOut: + workflowClient.handleChildWorkflowExecutionTimedOut(event); + break; + case DecisionTaskCompleted: + handleDecisionTaskCompleted(event); + break; + case DecisionTaskScheduled: + // NOOP + break; + case DecisionTaskStarted: + handleDecisionTaskStarted(event); + break; + case DecisionTaskTimedOut: + // Handled in the processEvent(event) + break; + case ExternalWorkflowExecutionSignaled: + workflowClient.handleExternalWorkflowExecutionSignaled(event); + break; + case ScheduleActivityTaskFailed: + activityClient.handleScheduleActivityTaskFailed(event); + break; + case SignalExternalWorkflowExecutionFailed: + workflowClient.handleSignalExternalWorkflowExecutionFailed(event); + break; + case StartChildWorkflowExecutionFailed: + workflowClient.handleStartChildWorkflowExecutionFailed(event); + break; + case StartTimerFailed: + handleStartTimerFailed(event); + break; + case TimerFired: + handleTimerFired(event); + break; + case WorkflowExecutionCancelRequested: + handleWorkflowExecutionCancelRequested(event); + break; + case WorkflowExecutionSignaled: + handleWorkflowExecutionSignaled(event); + break; + case WorkflowExecutionStarted: + handleWorkflowExecutionStarted(event); + break; + case WorkflowExecutionTerminated: + // NOOP + break; + case WorkflowExecutionTimedOut: + // NOOP + break; + case ActivityTaskScheduled: + decisionsHelper.handleActivityTaskScheduled(event); + break; + case ActivityTaskCancelRequested: + decisionsHelper.handleActivityTaskCancelRequested(event); + break; + case RequestCancelActivityTaskFailed: + decisionsHelper.handleRequestCancelActivityTaskFailed(event); + break; + case MarkerRecorded: + break; + case WorkflowExecutionCompleted: + break; + case CompleteWorkflowExecutionFailed: + unhandledDecision = true; + decisionsHelper.handleCompleteWorkflowExecutionFailed(event); + break; + case WorkflowExecutionFailed: + break; + case FailWorkflowExecutionFailed: + unhandledDecision = true; + decisionsHelper.handleFailWorkflowExecutionFailed(event); + break; + case WorkflowExecutionCanceled: + break; + case CancelWorkflowExecutionFailed: + unhandledDecision = true; + decisionsHelper.handleCancelWorkflowExecutionFailed(event); + break; + case WorkflowExecutionContinuedAsNew: + break; + case ContinueAsNewWorkflowExecutionFailed: + unhandledDecision = true; + decisionsHelper.handleContinueAsNewWorkflowExecutionFailed(event); + break; + case TimerStarted: + handleTimerStarted(event); + break; + case TimerCanceled: + workflowClock.handleTimerCanceled(event); + break; + case SignalExternalWorkflowExecutionInitiated: + decisionsHelper.handleSignalExternalWorkflowExecutionInitiated(event); + break; + case RequestCancelExternalWorkflowExecutionInitiated: + decisionsHelper.handleRequestCancelExternalWorkflowExecutionInitiated(event); + break; + case RequestCancelExternalWorkflowExecutionFailed: + decisionsHelper.handleRequestCancelExternalWorkflowExecutionFailed(event); + break; + case StartChildWorkflowExecutionInitiated: + decisionsHelper.handleStartChildWorkflowExecutionInitiated(event); + break; + case CancelTimerFailed: + decisionsHelper.handleCancelTimerFailed(event); + } + } + + private void eventLoop(HistoryEvent event) throws Throwable { + if (completed) { + return; + } + try { + completed = workflowAsyncScope.eventLoop(); + } + catch (CancellationException e) { + if (!cancelRequested) { + failure = e; + } + completed = true; + } + catch (Throwable e) { + failure = e; + completed = true; + } + } + + private void completeWorkflow() { + if (completed && !unhandledDecision) { + if (failure != null) { + decisionsHelper.failWorkflowExecution(failure); + } + else if (cancelRequested) { + decisionsHelper.cancelWorkflowExecution(); + } + else { + ContinueAsNewWorkflowExecutionParameters continueAsNewOnCompletion = workflowContext.getContinueAsNewOnCompletion(); + if (continueAsNewOnCompletion != null) { + decisionsHelper.continueAsNewWorkflowExecution(continueAsNewOnCompletion); + } + else { + Promise output = workflowAsyncScope.getOutput(); + if (output != null && output.isReady()) { + String workflowOutput = output.get(); + decisionsHelper.completeWorkflowExecution(workflowOutput); + } + else { + decisionsHelper.completeWorkflowExecution(null); + } + } + } + } + } + + private void handleDecisionTaskStarted(HistoryEvent event) throws Throwable { + } + + private void handleWorkflowExecutionCancelRequested(HistoryEvent event) throws Throwable { + workflowContext.setCancelRequested(true); + workflowAsyncScope.cancel(new CancellationException()); + cancelRequested = true; + } + + private void handleStartTimerFailed(HistoryEvent event) { + StartTimerFailedEventAttributes attributes = event.getStartTimerFailedEventAttributes(); + String timerId = attributes.getTimerId(); + if (timerId.equals(DecisionsHelper.FORCE_IMMEDIATE_DECISION_TIMER)) { + return; + } + workflowClock.handleStartTimerFailed(event); + } + + private void handleTimerFired(HistoryEvent event) throws Throwable { + TimerFiredEventAttributes attributes = event.getTimerFiredEventAttributes(); + String timerId = attributes.getTimerId(); + if (timerId.equals(DecisionsHelper.FORCE_IMMEDIATE_DECISION_TIMER)) { + return; + } + workflowClock.handleTimerFired(event.getEventId(), attributes); + } + + private void handleTimerStarted(HistoryEvent event) { + TimerStartedEventAttributes attributes = event.getTimerStartedEventAttributes(); + String timerId = attributes.getTimerId(); + if (timerId.equals(DecisionsHelper.FORCE_IMMEDIATE_DECISION_TIMER)) { + return; + } + decisionsHelper.handleTimerStarted(event); + } + + private void handleWorkflowExecutionSignaled(HistoryEvent event) throws Throwable { + assert (event.getEventType().equals(EventType.WorkflowExecutionSignaled.toString())); + final WorkflowExecutionSignaledEventAttributes signalAttributes = event.getWorkflowExecutionSignaledEventAttributes(); + if (completed) { + workflowAsyncScope = new UnhandledSignalAsyncScope(workflowAsyncScope.getOutput(), workflowAsyncScope.getFailure(), + workflowAsyncScope.isCancelRequested()); + completed = false; + } + // This task is attached to the root context of the workflowAsyncScope + new Task(workflowAsyncScope) { + + @Override + protected void doExecute() throws Throwable { + definition.signalRecieved(signalAttributes.getSignalName(), signalAttributes.getInput()); + } + + }; + } + + private void handleDecisionTaskCompleted(HistoryEvent event) { + decisionsHelper.handleDecisionCompletion(event.getDecisionTaskCompletedEventAttributes()); + } + + public void decide() throws Exception { + try { + definition = workflowDefinitionFactory.getWorkflowDefinition(context); + if (definition == null) { + throw new IllegalStateException("Unknown workflow type: " + context.getWorkflowContext().getWorkflowType()); + } + long lastNonReplayedEventId = historyHelper.getLastNonReplayEventId(); + // Buffer events until the next DecisionTaskStarted and then process them + // setting current time to the time of DecisionTaskStarted event + EventsIterator eventsIterator = historyHelper.getEvents(); + List reordered = null; + do { + List decisionStartToCompletionEvents = new ArrayList(); + List decisionCompletionToStartEvents = new ArrayList(); + boolean concurrentToDecision = true; + int lastDecisionIndex = -1; + while (eventsIterator.hasNext()) { + HistoryEvent event = eventsIterator.next(); + EventType eventType = EventType.valueOf(event.getEventType()); + if (eventType == EventType.DecisionTaskCompleted) { + decisionsHelper.setWorkflowContextData(event.getDecisionTaskCompletedEventAttributes().getExecutionContext()); + concurrentToDecision = false; + } + else if (eventType == EventType.DecisionTaskStarted) { + if (!eventsIterator.isNextDecisionTimedOut()) { + long replayCurrentTimeMilliseconds = event.getEventTimestamp().getTime(); + workflowClock.setReplayCurrentTimeMilliseconds(replayCurrentTimeMilliseconds); + decisionsHelper.handleDecisionTaskStartedEvent(); + break; + } + } + else if (eventType == EventType.DecisionTaskScheduled || eventType == EventType.DecisionTaskTimedOut) { + // skip + } + else { + if (concurrentToDecision) { + decisionStartToCompletionEvents.add(event); + } + else { + if (isDecisionEvent(eventType)) { + lastDecisionIndex = decisionCompletionToStartEvents.size(); + } + decisionCompletionToStartEvents.add(event); + } + } + } + int size = decisionStartToCompletionEvents.size() + decisionStartToCompletionEvents.size(); + reordered = new ArrayList(size); + if (lastDecisionIndex >= 0) { + reordered.addAll(decisionCompletionToStartEvents.subList(0, lastDecisionIndex + 1)); + } + reordered.addAll(decisionStartToCompletionEvents); + if (decisionCompletionToStartEvents.size() > lastDecisionIndex + 1) { + reordered.addAll(decisionCompletionToStartEvents.subList(lastDecisionIndex + 1, + decisionCompletionToStartEvents.size())); + } + for (HistoryEvent event : reordered) { + if (event.getEventId() >= lastNonReplayedEventId) { + workflowClock.setReplaying(false); + } + EventType eventType = EventType.valueOf(event.getEventType()); + processEvent(event, eventType); + eventLoop(event); + } + completeWorkflow(); + + } + while (eventsIterator.hasNext()); + if (unhandledDecision) { + unhandledDecision = false; + completeWorkflow(); + } + } + catch (Throwable e) { + if (log.isErrorEnabled()) { + log.error("Failing workflow " + workflowContext.getWorkflowExecution(), e); + } + decisionsHelper.failWorkflowDueToUnexpectedError(e); + } + finally { + try { + decisionsHelper.setWorkflowContextData(definition.getWorkflowState()); + } + catch (WorkflowException e) { + decisionsHelper.setWorkflowContextData(e.getDetails()); + } + catch (Throwable e) { + decisionsHelper.setWorkflowContextData(e.getMessage()); + } + workflowDefinitionFactory.deleteWorkflowDefinition(this.definition); + } + } + + private boolean isDecisionEvent(EventType eventType) { + switch (eventType) { + case ActivityTaskScheduled: + case ScheduleActivityTaskFailed: + case ActivityTaskCancelRequested: + case RequestCancelActivityTaskFailed: + case MarkerRecorded: + case WorkflowExecutionCompleted: + case CompleteWorkflowExecutionFailed: + case WorkflowExecutionFailed: + case FailWorkflowExecutionFailed: + case WorkflowExecutionCanceled: + case CancelWorkflowExecutionFailed: + case WorkflowExecutionContinuedAsNew: + case ContinueAsNewWorkflowExecutionFailed: + case TimerStarted: + case StartTimerFailed: + case TimerCanceled: + case CancelTimerFailed: + case SignalExternalWorkflowExecutionInitiated: + case SignalExternalWorkflowExecutionFailed: + case RequestCancelExternalWorkflowExecutionInitiated: + case RequestCancelExternalWorkflowExecutionFailed: + case StartChildWorkflowExecutionInitiated: + case StartChildWorkflowExecutionFailed: + return true; + default: + return false; + } + } + + public List getAsynchronousThreadDump() { + if (workflowAsyncScope == null) { + throw new IllegalStateException("workflow hasn't started yet"); + } + return workflowAsyncScope.getAsynchronousThreadDump(); + } + + public String getAsynchronousThreadDumpAsString() { + if (workflowAsyncScope == null) { + throw new IllegalStateException("workflow hasn't started yet"); + } + return workflowAsyncScope.getAsynchronousThreadDumpAsString(); + } + + public DecisionsHelper getDecisionsHelper() { + return decisionsHelper; + } + + public WorkflowDefinition getWorkflowDefinition() { + return definition; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/AsyncDecisionTaskHandler.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/AsyncDecisionTaskHandler.java new file mode 100644 index 000000000000..d151cb080717 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/AsyncDecisionTaskHandler.java @@ -0,0 +1,114 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.amazonaws.services.simpleworkflow.flow.core.AsyncTaskInfo; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinition; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinitionFactory; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinitionFactoryFactory; +import com.amazonaws.services.simpleworkflow.model.Decision; +import com.amazonaws.services.simpleworkflow.model.DecisionTask; +import com.amazonaws.services.simpleworkflow.model.RespondDecisionTaskCompletedRequest; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +public class AsyncDecisionTaskHandler extends DecisionTaskHandler { + + private static final Log log = LogFactory.getLog(AsyncDecisionTaskHandler.class); + + private static final Log asyncThreadDumpLog = LogFactory.getLog(AsyncDecisionTaskHandler.class.getName() + + ".waitingTasksStacks"); + + private final WorkflowDefinitionFactoryFactory definitionFactoryFactory; + + public AsyncDecisionTaskHandler(WorkflowDefinitionFactoryFactory definitionFactoryFactory) { + this.definitionFactoryFactory = definitionFactoryFactory; + } + + @Override + public RespondDecisionTaskCompletedRequest handleDecisionTask(Iterator decisionTaskIterator) throws Exception { + HistoryHelper historyHelper = new HistoryHelper(decisionTaskIterator); + AsyncDecider decider = createDecider(historyHelper); + decider.decide(); + DecisionsHelper decisionsHelper = decider.getDecisionsHelper(); + Collection decisions = decisionsHelper.getDecisions(); + String context = decisionsHelper.getWorkflowContextDataToReturn(); + DecisionTask decisionTask = historyHelper.getDecisionTask(); + if (log.isDebugEnabled()) { + log.debug("WorkflowTask taskId=" + decisionTask.getStartedEventId() + ", taskToken=" + decisionTask.getTaskToken() + + " completed with " + decisions.size() + " new decisions"); + } + if (decisions.size() == 0 && asyncThreadDumpLog.isTraceEnabled()) { + asyncThreadDumpLog.trace("Empty decision list with the following waiting tasks:\n" + + decider.getAsynchronousThreadDumpAsString()); + } + RespondDecisionTaskCompletedRequest completedRequest = new RespondDecisionTaskCompletedRequest(); + completedRequest.setTaskToken(decisionTask.getTaskToken()); + completedRequest.setDecisions(decisions); + completedRequest.setExecutionContext(context); + return completedRequest; + } + + @Override + public WorkflowDefinition loadWorkflowThroughReplay(Iterator decisionTaskIterator) throws Exception { + HistoryHelper historyHelper = new HistoryHelper(decisionTaskIterator); + AsyncDecider decider = createDecider(historyHelper); + decider.decide(); + return decider.getWorkflowDefinition(); + } + + @Override + public List getAsynchronousThreadDump(Iterator decisionTaskIterator) throws Exception { + HistoryHelper historyHelper = new HistoryHelper(decisionTaskIterator); + AsyncDecider decider = createDecider(historyHelper); + decider.decide(); + return decider.getAsynchronousThreadDump(); + } + + @Override + public String getAsynchronousThreadDumpAsString(Iterator decisionTaskIterator) throws Exception { + HistoryHelper historyHelper = new HistoryHelper(decisionTaskIterator); + AsyncDecider decider = createDecider(historyHelper); + decider.decide(); + return decider.getAsynchronousThreadDumpAsString(); + } + + private AsyncDecider createDecider(HistoryHelper historyHelper) throws Exception { + DecisionTask decisionTask = historyHelper.getDecisionTask(); + WorkflowType workflowType = decisionTask.getWorkflowType(); + if (log.isDebugEnabled()) { + log.debug("WorkflowTask received: taskId=" + decisionTask.getStartedEventId() + ", taskToken=" + + decisionTask.getTaskToken() + ", workflowExecution=" + decisionTask.getWorkflowExecution()); + } + WorkflowDefinitionFactory workflowDefinitionFactory = definitionFactoryFactory.getWorkflowDefinitionFactory(workflowType); + if (workflowDefinitionFactory == null) { + log.error("Received decision task for workflow type not configured with a worker: workflowType=" + + decisionTask.getWorkflowType() + ", taskToken=" + decisionTask.getTaskToken() + ", workflowExecution=" + + decisionTask.getWorkflowExecution()); + if (workflowDefinitionFactory == null) { + throw new IllegalArgumentException("No implementation was found for " + decisionTask.getWorkflowType()); + } + } + DecisionsHelper decisionsHelper = new DecisionsHelper(decisionTask); + AsyncDecider decider = new AsyncDecider(workflowDefinitionFactory, historyHelper, decisionsHelper); + return decider; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/BackoffThrottler.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/BackoffThrottler.java new file mode 100644 index 000000000000..5796b49e26a3 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/BackoffThrottler.java @@ -0,0 +1,102 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.util.concurrent.atomic.AtomicLong; + +/** + * Used to throttle code execution in presence of failures using exponential + * backoff logic. The formula used to calculate the next sleep interval is: + * + *
+ * min(pow(backoffCoefficient, failureCount - 1) * initialSleep, maxSleep);
+ * 
+ *

+ * Example usage: + * + *

+ * BackoffThrottler throttler = new BackoffThrottler(1000, 60000, 2);
+ * while(!stopped) {
+ *     try {
+ *         throttler.throttle();
+ *         // some code that can fail and should be throttled
+ *         ...
+ *         throttler.success();
+ *     }
+ *     catch (Exception e) {
+ *         throttler.failure();
+ *     }
+ * }
+ * 
+ * + * @author fateev + */ +public class BackoffThrottler { + + private final long initialSleep; + + private final long maxSleep; + + private final double backoffCoefficient; + + private final AtomicLong failureCount = new AtomicLong(); + + /** + * Construct an instance of the throttler. + * + * @param initialSleep + * time to sleep on the first failure + * @param maxSleep + * maximum time to sleep independently of number of failures + * @param backoffCoefficient + * coefficient used to calculate the next time to sleep. + */ + public BackoffThrottler(long initialSleep, long maxSleep, double backoffCoefficient) { + this.initialSleep = initialSleep; + this.maxSleep = maxSleep; + this.backoffCoefficient = backoffCoefficient; + } + + private long calculateSleepTime() { + double sleepMillis = (Math.pow(backoffCoefficient, failureCount.get() - 1)) * initialSleep; + return Math.min((long) sleepMillis, maxSleep); + } + + /** + * Sleep if there were failures since the last success call. + * + * @throws InterruptedException + */ + public void throttle() throws InterruptedException { + if (failureCount.get() > 0) { + Thread.sleep(calculateSleepTime()); + } + } + + /** + * Resent failure count to 0. + */ + public void success() { + failureCount.set(0); + } + + /** + * Increment failure count. + */ + public void failure() { + failureCount.incrementAndGet(); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/BlockCallerPolicy.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/BlockCallerPolicy.java new file mode 100644 index 000000000000..6cf40128de9b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/BlockCallerPolicy.java @@ -0,0 +1,34 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.RejectedExecutionHandler; +import java.util.concurrent.ThreadPoolExecutor; + + +class BlockCallerPolicy implements RejectedExecutionHandler { + + @Override + public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { + try { + // block until there's room + executor.getQueue().put(r); + } + catch (InterruptedException e) { + throw new RejectedExecutionException("Unexpected InterruptedException", e); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ChildWorkflowDecisionStateMachine.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ChildWorkflowDecisionStateMachine.java new file mode 100644 index 000000000000..ad2c9d51a3e6 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ChildWorkflowDecisionStateMachine.java @@ -0,0 +1,136 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import com.amazonaws.services.simpleworkflow.model.Decision; +import com.amazonaws.services.simpleworkflow.model.DecisionType; +import com.amazonaws.services.simpleworkflow.model.HistoryEvent; +import com.amazonaws.services.simpleworkflow.model.RequestCancelExternalWorkflowExecutionDecisionAttributes; +import com.amazonaws.services.simpleworkflow.model.StartChildWorkflowExecutionDecisionAttributes; + +class ChildWorkflowDecisionStateMachine extends DecisionStateMachineBase { + + private StartChildWorkflowExecutionDecisionAttributes startAttributes; + + private String runId; + + public ChildWorkflowDecisionStateMachine(DecisionId id, StartChildWorkflowExecutionDecisionAttributes startAttributes) { + super(id); + this.startAttributes = startAttributes; + } + + /** + * Used for unit testing + */ + ChildWorkflowDecisionStateMachine(DecisionId id, StartChildWorkflowExecutionDecisionAttributes startAttributes, DecisionState state) { + super(id, state); + this.startAttributes = startAttributes; + } + + @Override + public Decision getDecision() { + switch (state) { + case CREATED: + return createStartChildWorkflowExecutionDecision(); + case CANCELED_AFTER_STARTED: + return createRequestCancelExternalWorkflowExecutionDecision(); + default: + return null; + } + } + + @Override + public void handleDecisionTaskStartedEvent() { + switch (state) { + case CANCELED_AFTER_STARTED: + state = DecisionState.CANCELLATION_DECISION_SENT; + break; + default: + super.handleDecisionTaskStartedEvent(); + } + } + + @Override + public void handleStartedEvent(HistoryEvent event) { + stateHistory.add("handleStartedEvent"); + switch (state) { + case INITIATED: + state = DecisionState.STARTED; + break; + case CANCELED_AFTER_INITIATED: + state = DecisionState.CANCELED_AFTER_STARTED; + break; + } + stateHistory.add(state.toString()); + } + + @Override + public void handleCancellationFailureEvent(HistoryEvent event) { + switch (state) { + case CANCELLATION_DECISION_SENT: + stateHistory.add("handleCancellationFailureEvent"); + state = DecisionState.STARTED; + stateHistory.add(state.toString()); + break; + default: + super.handleCancellationFailureEvent(event); + } + } + + @Override + public void cancel(Runnable immediateCancellationCallback) { + switch (state) { + case STARTED: + stateHistory.add("cancel"); + state = DecisionState.CANCELED_AFTER_STARTED; + stateHistory.add(state.toString()); + break; + default: + super.cancel(immediateCancellationCallback); + } + } + + @Override + public void handleCompletionEvent() { + switch (state) { + case STARTED: + case CANCELED_AFTER_STARTED: + stateHistory.add("handleCompletionEvent"); + state = DecisionState.COMPLETED; + stateHistory.add(state.toString()); + break; + default: + super.handleCompletionEvent(); + } + } + + private Decision createRequestCancelExternalWorkflowExecutionDecision() { + RequestCancelExternalWorkflowExecutionDecisionAttributes tryCancel = new RequestCancelExternalWorkflowExecutionDecisionAttributes(); + tryCancel.setWorkflowId(startAttributes.getWorkflowId()); + tryCancel.setRunId(runId); + Decision decision = new Decision(); + decision.setRequestCancelExternalWorkflowExecutionDecisionAttributes(tryCancel); + decision.setDecisionType(DecisionType.RequestCancelExternalWorkflowExecution.toString()); + return decision; + } + + private Decision createStartChildWorkflowExecutionDecision() { + Decision decision = new Decision(); + decision.setStartChildWorkflowExecutionDecisionAttributes(startAttributes); + decision.setDecisionType(DecisionType.StartChildWorkflowExecution.toString()); + return decision; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/CircularLongBuffer.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/CircularLongBuffer.java new file mode 100644 index 000000000000..c27ccd262981 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/CircularLongBuffer.java @@ -0,0 +1,70 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.flow.worker; + +class CircularLongBuffer { + + private long[] values_; + + public CircularLongBuffer(int size) { + values_ = new long[size]; + } + + public CircularLongBuffer(long[] values) { + values_ = values; + } + + public void set(long i, long value) { + values_[getArrayOffset(i)] = value; + }; + + public long get(long i) { + return values_[getArrayOffset(i)]; + }; + + public int size() { + return values_.length; + }; + + public CircularLongBuffer copy(long index1, int length) { + if (length == 0) { + return new CircularLongBuffer(0); + } + int i1 = getArrayOffset(index1); + int i2 = getArrayOffset(index1 + Math.min(length, values_.length)); + long[] result = new long[length]; + if (i1 < i2) { + int l = i2 - i1; + System.arraycopy(values_, i1, result, 0, l); + } else { + int tailLength = values_.length - i1; + System.arraycopy(values_, i1, result, 0, tailLength); + System.arraycopy(values_, 0, result, tailLength, i2); + } + return new CircularLongBuffer(result); + } + + private int getArrayOffset(long index) { + if (values_.length == 0) { + throw new IllegalStateException("zero data size"); + } + int result = (int) (index % values_.length); + if (result < 0) { + result = values_.length + result; + } + return result; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/CompleteWorkflowStateMachine.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/CompleteWorkflowStateMachine.java new file mode 100644 index 000000000000..2f9285a541e0 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/CompleteWorkflowStateMachine.java @@ -0,0 +1,103 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import com.amazonaws.services.simpleworkflow.model.Decision; +import com.amazonaws.services.simpleworkflow.model.HistoryEvent; + + +public class CompleteWorkflowStateMachine implements DecisionStateMachine { + + private Decision decision; + private final DecisionId id; + + public CompleteWorkflowStateMachine(DecisionId id, Decision decision) { + this.id = id; + this.decision = decision; + } + + + + public DecisionId getId() { + return id; + } + + + @Override + public Decision getDecision() { + return decision; + } + + @Override + public void handleInitiationFailedEvent(HistoryEvent event) { + decision = null; + } + + @Override + public void cancel(Runnable immediateCancellationCallback) { + throw new UnsupportedOperationException(); + } + + @Override + public void handleStartedEvent(HistoryEvent event) { + throw new UnsupportedOperationException(); + } + + @Override + public void handleCancellationEvent() { + throw new UnsupportedOperationException(); + } + + @Override + public void handleCancellationFailureEvent(HistoryEvent event) { + throw new UnsupportedOperationException(); + } + + @Override + public void handleCompletionEvent() { + throw new UnsupportedOperationException(); + } + + @Override + public void handleInitiatedEvent(HistoryEvent event) { + throw new UnsupportedOperationException(); + } + + @Override + public DecisionState getState() { + return DecisionState.CREATED; + } + + @Override + public void handleCancellationInitiatedEvent() { + throw new UnsupportedOperationException(); + } + + @Override + public boolean isDone() { + return decision != null; + } + + @Override + public void handleDecisionTaskStartedEvent() { + + } + + @Override + public String toString() { + return "CompleteWorkflowStateMachine [decision=" + decision + ", id=" + id + "]"; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/CurrentActivityExecutionContext.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/CurrentActivityExecutionContext.java new file mode 100644 index 000000000000..3106332f378a --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/CurrentActivityExecutionContext.java @@ -0,0 +1,61 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContextProviderImpl; + +/** + * Thread local store of the context object passed to an activity + * implementation. Avoid using this class directly. Use + * {@link ActivityExecutionContextProviderImpl} instead. + * + * @author fateev + */ +public class CurrentActivityExecutionContext { + + private final static ThreadLocal CURRENT = new ThreadLocal(); + + /** + * This is used by activity implementation to get access to the current + * ActivityExecutionContext + */ + public static ActivityExecutionContext get() { + ActivityExecutionContext result = CURRENT.get(); + if (result == null) { + throw new IllegalStateException("ActivityExecutionContext can be used only inside of acitivty implementation methods"); + } + return result; + }; + + public static boolean isSet() { + return CURRENT.get() != null; + } + + public static void set(ActivityExecutionContext context) { + if (context == null) { + throw new IllegalArgumentException("null context"); + } + CURRENT.set(context); + } + + public static void unset() { + CURRENT.set(null); + } + + private CurrentActivityExecutionContext() { + + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/CurrentDecisionContext.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/CurrentDecisionContext.java new file mode 100644 index 000000000000..b2b4e26795cf --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/CurrentDecisionContext.java @@ -0,0 +1,66 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import com.amazonaws.services.simpleworkflow.flow.DecisionContext; +import com.amazonaws.services.simpleworkflow.flow.DecisionContextProviderImpl; +import com.amazonaws.services.simpleworkflow.flow.WorkflowExecutionLocal; + +/** + * Holds DecisionContext for currently executing decision task. Do not use this + * class directly. Instead use {@link DecisionContextProviderImpl}. + */ +public abstract class CurrentDecisionContext { + + private final static WorkflowExecutionLocal CURRENT = new WorkflowExecutionLocal(); + + /** + * retrieves the current DecisionContext for a particular thread + * + * @return current decider context being used for the decision + * @throws IllegalStateException + * if this method is called outside the scope of workflow + * definition. + */ + public static DecisionContext get() { + DecisionContext result = CURRENT.get(); + if (result == null) { + throw new IllegalStateException( + "No context found. It means that the method is called outside of the workflow definition code."); + } + return result; + } + + /** + * @return if context is set which means that code is executed as part of + * the decision. + */ + public static boolean isSet() { + return CURRENT.get() != null; + } + + public static void set(DecisionContext context) { + if (context == null) { + throw new IllegalArgumentException("null context"); + } + WorkflowExecutionLocal.before(); + CURRENT.set(context); + } + + public static void unset() { + WorkflowExecutionLocal.after(); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionContextImpl.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionContextImpl.java new file mode 100644 index 000000000000..f63f36346b5b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionContextImpl.java @@ -0,0 +1,62 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import com.amazonaws.services.simpleworkflow.flow.DecisionContext; +import com.amazonaws.services.simpleworkflow.flow.WorkflowClock; +import com.amazonaws.services.simpleworkflow.flow.WorkflowContext; +import com.amazonaws.services.simpleworkflow.flow.generic.GenericActivityClient; +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClient; + +class DecisionContextImpl extends DecisionContext { + + private final GenericActivityClient activityClient; + + private final GenericWorkflowClient workflowClient; + + private final WorkflowClock workflowClock; + + private final WorkflowContext workflowContext; + + DecisionContextImpl(GenericActivityClient activityClient, GenericWorkflowClient workflowClient, + WorkflowClock workflowClock, WorkflowContext workflowContext) { + this.activityClient = activityClient; + this.workflowClient = workflowClient; + this.workflowClock = workflowClock; + this.workflowContext = workflowContext; + } + + @Override + public GenericActivityClient getActivityClient() { + return activityClient; + } + + @Override + public GenericWorkflowClient getWorkflowClient() { + return workflowClient; + } + + @Override + public WorkflowClock getWorkflowClock() { + return workflowClock; + } + + @Override + public WorkflowContext getWorkflowContext() { + return workflowContext; + } + + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionId.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionId.java new file mode 100644 index 000000000000..8be499dffeb1 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionId.java @@ -0,0 +1,62 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +class DecisionId { + + final DecisionTarget decisionTarget; + + final String id; + + public DecisionId(DecisionTarget decisionTarget, String id) { + this.id = id; + this.decisionTarget = decisionTarget; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((decisionTarget == null) ? 0 : decisionTarget.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + DecisionId other = (DecisionId) obj; + if (decisionTarget != other.decisionTarget) + return false; + if (id == null) { + if (other.id != null) + return false; + } + else if (!id.equals(other.id)) + return false; + return true; + } + + @Override + public String toString() { + return "DecisionId [type=" + decisionTarget + ", id=" + id + "]"; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionState.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionState.java new file mode 100644 index 000000000000..dcb3e7af2c75 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionState.java @@ -0,0 +1,39 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +enum DecisionState { + + CREATED, + + DECISION_SENT, + + CANCELED_BEFORE_INITIATED, + + INITIATED, + + STARTED, + + CANCELED_AFTER_INITIATED, + + CANCELED_AFTER_STARTED, + + CANCELLATION_DECISION_SENT, + + COMPLETED_AFTER_CANCELLATION_DECISION_SENT, + + COMPLETED + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionStateMachine.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionStateMachine.java new file mode 100644 index 000000000000..014df0b90aa8 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionStateMachine.java @@ -0,0 +1,51 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import com.amazonaws.services.simpleworkflow.model.Decision; +import com.amazonaws.services.simpleworkflow.model.HistoryEvent; + + +interface DecisionStateMachine { + + Decision getDecision(); + + void cancel(Runnable immediateCancellationCallback); + + void handleStartedEvent(HistoryEvent event); + + void handleCancellationInitiatedEvent(); + + void handleCancellationEvent(); + + void handleCancellationFailureEvent(HistoryEvent event); + + void handleCompletionEvent(); + + void handleInitiationFailedEvent(HistoryEvent event); + + void handleInitiatedEvent(HistoryEvent event); + + void handleDecisionTaskStartedEvent(); + + DecisionState getState(); + + boolean isDone(); + + DecisionId getId(); + + + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionStateMachineBase.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionStateMachineBase.java new file mode 100644 index 000000000000..ead8c992bd9d --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionStateMachineBase.java @@ -0,0 +1,196 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.util.ArrayList; +import java.util.List; + +import com.amazonaws.services.simpleworkflow.model.HistoryEvent; + +abstract class DecisionStateMachineBase implements DecisionStateMachine { + + protected DecisionState state = DecisionState.CREATED; + + protected List stateHistory = new ArrayList(); + + private final DecisionId id; + + public DecisionStateMachineBase(DecisionId id) { + this.id = id; + stateHistory.add(state.toString()); + + } + + /** + * Used for unit testing. + */ + protected DecisionStateMachineBase(DecisionId id, DecisionState state) { + this.id = id; + this.state = state; + stateHistory.add(state.toString()); + } + + public DecisionState getState() { + return state; + } + + public DecisionId getId() { + return id; + } + + @Override + public boolean isDone() { + return state == DecisionState.COMPLETED || state == DecisionState.COMPLETED_AFTER_CANCELLATION_DECISION_SENT; + } + + @Override + public void handleDecisionTaskStartedEvent() { + switch (state) { + case CREATED: + stateHistory.add("handleDecisionTaskStartedEvent"); + state = DecisionState.DECISION_SENT; + stateHistory.add(state.toString()); + break; + } + } + + @Override + public void cancel(Runnable immediateCancellationCallback) { + stateHistory.add("cancel"); + switch (state) { + case CREATED: + state = DecisionState.COMPLETED; + if (immediateCancellationCallback != null) { + immediateCancellationCallback.run(); + } + break; + case DECISION_SENT: + state = DecisionState.CANCELED_BEFORE_INITIATED; + break; + case INITIATED: + state = DecisionState.CANCELED_AFTER_INITIATED; + break; + default: + failStateTransition(); + } + stateHistory.add(state.toString()); + } + + @Override + public void handleInitiatedEvent(HistoryEvent event) { + stateHistory.add("handleInitiatedEvent"); + switch (state) { + case DECISION_SENT: + state = DecisionState.INITIATED; + break; + case CANCELED_BEFORE_INITIATED: + state = DecisionState.CANCELED_AFTER_INITIATED; + break; + default: + failStateTransition(); + } + stateHistory.add(state.toString()); + + } + + @Override + public void handleInitiationFailedEvent(HistoryEvent event) { + stateHistory.add("handleInitiationFailedEvent"); + switch (state) { + case DECISION_SENT: + case CANCELED_BEFORE_INITIATED: + state = DecisionState.COMPLETED; + break; + default: + failStateTransition(); + } + stateHistory.add(state.toString()); + + } + + @Override + public void handleStartedEvent(HistoryEvent event) { + stateHistory.add("handleStartedEvent"); + } + + @Override + public void handleCompletionEvent() { + stateHistory.add("handleCompletionEvent"); + switch (state) { + case CANCELED_AFTER_INITIATED: + case INITIATED: + state = DecisionState.COMPLETED; + break; + case CANCELLATION_DECISION_SENT: + state = DecisionState.COMPLETED_AFTER_CANCELLATION_DECISION_SENT; + break; + default: + failStateTransition(); + } + stateHistory.add(state.toString()); + } + + @Override + public void handleCancellationInitiatedEvent() { + stateHistory.add("handleCancellationInitiatedEvent"); + switch (state) { + case CANCELLATION_DECISION_SENT: + // No state change + break; + default: + failStateTransition(); + } + stateHistory.add(state.toString()); + + } + + @Override + public void handleCancellationFailureEvent(HistoryEvent event) { + stateHistory.add("handleCancellationFailureEvent"); + switch (state) { + case COMPLETED_AFTER_CANCELLATION_DECISION_SENT: + state = DecisionState.COMPLETED; + break; + default: + failStateTransition(); + } + stateHistory.add(state.toString()); + } + + @Override + public void handleCancellationEvent() { + stateHistory.add("handleCancellationEvent"); + switch (state) { + case CANCELLATION_DECISION_SENT: + state = DecisionState.COMPLETED; + break; + default: + failStateTransition(); + } + stateHistory.add(state.toString()); + + } + + @Override + public String toString() { + return "DecisionStateMachineBase [id=" + id + ", state=" + state + ", isDone()=" + isDone() + ", stateHistory=" + + stateHistory + "]"; + } + + protected void failStateTransition() { + throw new IllegalStateException("id=" + id + ", transitions=" + stateHistory); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionTarget.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionTarget.java new file mode 100644 index 000000000000..b3de7ea5847c --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionTarget.java @@ -0,0 +1,23 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +enum DecisionTarget { + ACTIVITY, + EXTERNAL_WORKFLOW, + SIGNAL, + TIMER, + SELF +} \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionTaskHandler.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionTaskHandler.java new file mode 100644 index 000000000000..b51dbb05ac7a --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionTaskHandler.java @@ -0,0 +1,62 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.core.AsyncTaskInfo; +import com.amazonaws.services.simpleworkflow.model.DecisionTask; +import com.amazonaws.services.simpleworkflow.model.RespondDecisionTaskCompletedRequest; + +/** + * Base class for workflow task handlers. Extend this class to implement custom + * deciders that can be executed using a + * {@link WorkflowTaskPollingExecutorService}. + * + * @author fateev, suskin + * + * @see WorkflowTaskPollingExecutorService + */ +public abstract class DecisionTaskHandler { + + /** + * The implementation should be called when a polling SWF Decider receives a + * new WorkflowTask. Later, that decider should call one of + * {@link #respondWorkflowTaskCompleted(String, Transition, AmazonSimpleWorkflow)} + * or + * {@link #respondWorkflowTaskFailed(String, int, String, Map, AmazonSimpleWorkflow)} + * . + * + * @param workflowTask + * The decision task to handle. The reason for more then one task + * being received is pagination of the history. All tasks in the + * iterator contain the same information but different pages of + * the history. The tasks are loaded lazily when + * {@link Iterator#next()} is called. It is expected that the + * method implementation aborts decision by rethrowing any + * exception from {@link Iterator#next()}. + */ + public abstract RespondDecisionTaskCompletedRequest handleDecisionTask(Iterator decisionTaskIterator) throws Exception; + + public abstract List getAsynchronousThreadDump(Iterator decisionTaskIterator) throws Exception; + + public abstract String getAsynchronousThreadDumpAsString(Iterator decisionTaskIterator) throws Exception; + + public abstract Object loadWorkflowThroughReplay(Iterator decisionTaskIterator) throws Exception; + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionTaskPoller.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionTaskPoller.java new file mode 100644 index 000000000000..b2cdc565dd1e --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionTaskPoller.java @@ -0,0 +1,270 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.lang.management.ManagementFactory; +import java.util.Iterator; +import java.util.concurrent.TimeUnit; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.common.WorkflowExecutionUtils; +import com.amazonaws.services.simpleworkflow.model.DecisionTask; +import com.amazonaws.services.simpleworkflow.model.PollForDecisionTaskRequest; +import com.amazonaws.services.simpleworkflow.model.RespondDecisionTaskCompletedRequest; +import com.amazonaws.services.simpleworkflow.model.TaskList; + +public class DecisionTaskPoller implements TaskPoller { + + private static final Log log = LogFactory.getLog(DecisionTaskPoller.class); + + private static final Log decisionsLog = LogFactory.getLog(DecisionTaskPoller.class.getName() + ".decisions"); + + private class DecisionTaskIterator implements Iterator { + + private final DecisionTask firstDecisionTask; + + private DecisionTask next; + + public DecisionTaskIterator() { + next = firstDecisionTask = poll(null); + } + + @Override + public boolean hasNext() { + return next != null; + } + + @Override + public DecisionTask next() { + if (!hasNext()) { + throw new IllegalStateException("hasNext() == false"); + } + DecisionTask result = next; + if (next.getNextPageToken() == null) { + next = null; + } + else { + next = poll(next.getNextPageToken()); + // Just to not keep around the history page + if (firstDecisionTask != result) { + firstDecisionTask.setEvents(null); + } + } + return result; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + public DecisionTask getFirstDecisionTask() { + return firstDecisionTask; + } + + } + + private AmazonSimpleWorkflow service; + + private String domain; + + private String taskListToPoll; + + private String identity; + + private boolean validated; + + private DecisionTaskHandler decisionTaskHandler; + + public DecisionTaskPoller() { + identity = ManagementFactory.getRuntimeMXBean().getName(); + } + + public DecisionTaskPoller(AmazonSimpleWorkflow service, String domain, String taskListToPoll, + DecisionTaskHandler decisionTaskHandler) { + this.service = service; + this.domain = domain; + this.taskListToPoll = taskListToPoll; + this.decisionTaskHandler = decisionTaskHandler; + identity = ManagementFactory.getRuntimeMXBean().getName(); + } + + public String getIdentity() { + return identity; + } + + public void setIdentity(String identity) { + validated = false; + this.identity = identity; + } + + public AmazonSimpleWorkflow getService() { + return service; + } + + public String getDomain() { + return domain; + } + + public DecisionTaskHandler getDecisionTaskHandler() { + return decisionTaskHandler; + } + + public void setDecisionTaskHandler(DecisionTaskHandler decisionTaskHandler) { + validated = false; + this.decisionTaskHandler = decisionTaskHandler; + } + + public void setService(AmazonSimpleWorkflow service) { + validated = false; + this.service = service; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getTaskListToPoll() { + return taskListToPoll; + } + + public void setTaskListToPoll(String pollTaskList) { + this.taskListToPoll = pollTaskList; + } + + /** + * Poll for a task using {@link #getPollTimeoutInSeconds()} + * + * @param nextResultToken + * + * @return null if poll timed out + * @throws DeciderExecutorConfigurationException + */ + private DecisionTask poll(String nextResultToken) { + validate(); + PollForDecisionTaskRequest pollRequest = new PollForDecisionTaskRequest(); + + pollRequest.setDomain(domain); + pollRequest.setIdentity(identity); + pollRequest.setNextPageToken(nextResultToken); + + pollRequest.setTaskList(new TaskList().withName(taskListToPoll)); + + if (log.isDebugEnabled()) { + log.debug("poll request begin: " + pollRequest); + } + DecisionTask result = service.pollForDecisionTask(pollRequest); + if (log.isDebugEnabled()) { + log.debug("poll request returned decision task: workflowType=" + result.getWorkflowType() + ", workflowExecution=" + + result.getWorkflowExecution() + ", startedEventId=" + result.getStartedEventId() + ", previousStartedEventId=" + result.getPreviousStartedEventId()); + } + + if (result == null || result.getTaskToken() == null) { + return null; + } + return result; + } + + /** + * Poll for a workflow task and call appropriate decider. This method might + * call the service multiple times to retrieve the whole history it it is + * paginated. + * + * @return true if task was polled and decided upon, false if poll timed out + * @throws Exception + * @throws DeciderConfigurationException + */ + @Override + public boolean pollAndProcessSingleTask() throws Exception { + DecisionTaskIterator tasks = null; + RespondDecisionTaskCompletedRequest taskCompletedRequest = null; + try { + tasks = new DecisionTaskIterator(); + if (!tasks.hasNext()) { + return false; + } + taskCompletedRequest = decisionTaskHandler.handleDecisionTask(tasks); + if (decisionsLog.isTraceEnabled()) { + decisionsLog.trace(WorkflowExecutionUtils.prettyPrintDecisions(taskCompletedRequest.getDecisions())); + } + service.respondDecisionTaskCompleted(taskCompletedRequest); + } + catch (Exception e) { + if (tasks != null) { + DecisionTask firstTask = tasks.getFirstDecisionTask(); + if (firstTask != null) { + if (log.isWarnEnabled()) { + log.warn("DecisionTask failure: taskId= " + firstTask.getStartedEventId() + ", workflowExecution=" + + firstTask.getWorkflowExecution(), e); + } + if (log.isDebugEnabled() && firstTask.getEvents() != null) { + log.debug("Failed taskId=" + firstTask.getStartedEventId() + " history: " + + WorkflowExecutionUtils.prettyPrintHistory(firstTask.getEvents(), true)); + } + } + if (taskCompletedRequest != null && decisionsLog.isWarnEnabled()) { + decisionsLog.warn("Failed taskId=" + firstTask.getStartedEventId() + " decisions=" + + WorkflowExecutionUtils.prettyPrintDecisions(taskCompletedRequest.getDecisions())); + } + } + throw e; + } + return true; + } + + /** + * @param seconds + * @return + */ + + private void validate() throws IllegalStateException { + if (validated) { + return; + } + checkFieldSet("decisionTaskHandler", decisionTaskHandler); + checkFieldSet("service", service); + checkFieldSet("identity", identity); + validated = true; + } + + private void checkFieldSet(String fieldName, Object fieldValue) throws IllegalStateException { + if (fieldValue == null) { + throw new IllegalStateException("Required field " + fieldName + " is not set"); + } + } + + protected void checkFieldNotNegative(String fieldName, long fieldValue) throws IllegalStateException { + if (fieldValue < 0) { + throw new IllegalStateException("Field " + fieldName + " is negative"); + } + } + + @Override + public void shutdown() { + } + + @Override + public void shutdownNow() { + } + + @Override + public boolean awaitTermination(long left, TimeUnit milliseconds) throws InterruptedException { + //TODO: Waiting for all currently running pollAndProcessSingleTask to complete + return false; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionsHelper.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionsHelper.java new file mode 100644 index 000000000000..846214e094a2 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/DecisionsHelper.java @@ -0,0 +1,549 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import com.amazonaws.services.simpleworkflow.flow.WorkflowException; +import com.amazonaws.services.simpleworkflow.flow.common.FlowHelpers; +import com.amazonaws.services.simpleworkflow.flow.common.WorkflowExecutionUtils; +import com.amazonaws.services.simpleworkflow.flow.generic.ContinueAsNewWorkflowExecutionParameters; +import com.amazonaws.services.simpleworkflow.model.ActivityTaskCancelRequestedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.ActivityTaskCanceledEventAttributes; +import com.amazonaws.services.simpleworkflow.model.ActivityTaskCompletedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.ActivityTaskFailedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.ActivityTaskScheduledEventAttributes; +import com.amazonaws.services.simpleworkflow.model.ActivityTaskTimedOutEventAttributes; +import com.amazonaws.services.simpleworkflow.model.CancelTimerFailedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.CancelWorkflowExecutionDecisionAttributes; +import com.amazonaws.services.simpleworkflow.model.ChildWorkflowExecutionStartedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.CompleteWorkflowExecutionDecisionAttributes; +import com.amazonaws.services.simpleworkflow.model.ContinueAsNewWorkflowExecutionDecisionAttributes; +import com.amazonaws.services.simpleworkflow.model.Decision; +import com.amazonaws.services.simpleworkflow.model.DecisionTask; +import com.amazonaws.services.simpleworkflow.model.DecisionTaskCompletedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.DecisionType; +import com.amazonaws.services.simpleworkflow.model.FailWorkflowExecutionDecisionAttributes; +import com.amazonaws.services.simpleworkflow.model.HistoryEvent; +import com.amazonaws.services.simpleworkflow.model.RequestCancelActivityTaskFailedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.RequestCancelExternalWorkflowExecutionDecisionAttributes; +import com.amazonaws.services.simpleworkflow.model.RequestCancelExternalWorkflowExecutionFailedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.ScheduleActivityTaskDecisionAttributes; +import com.amazonaws.services.simpleworkflow.model.ScheduleActivityTaskFailedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.SignalExternalWorkflowExecutionDecisionAttributes; +import com.amazonaws.services.simpleworkflow.model.SignalExternalWorkflowExecutionInitiatedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.StartChildWorkflowExecutionDecisionAttributes; +import com.amazonaws.services.simpleworkflow.model.StartChildWorkflowExecutionFailedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.StartChildWorkflowExecutionInitiatedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.StartTimerDecisionAttributes; +import com.amazonaws.services.simpleworkflow.model.StartTimerFailedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.TaskList; +import com.amazonaws.services.simpleworkflow.model.TimerCanceledEventAttributes; +import com.amazonaws.services.simpleworkflow.model.TimerStartedEventAttributes; + +class DecisionsHelper { + + // private static final Log log = LogFactory.getLog(DecisionsHelper.class); + + static final int MAXIMUM_DECISIONS_PER_COMPLETION = 100; + + static final String FORCE_IMMEDIATE_DECISION_TIMER = "FORCE_IMMEDIATE_DECISION"; + + private final DecisionTask task; + + private long idCounter; + + private final Map activitySchedulingEventIdToActivityId = new HashMap(); + + private final Map signalInitiatedEventIdToSignalId = new HashMap(); + + /** + * Use access-order to ensure that decisions are emitted in order of their + * creation + */ + private final Map decisions = new LinkedHashMap(100, + 0.75f, true); + + private boolean workflowFailed; + + private String workflowContextData; + + private String workfowContextFromLastDecisionCompletion; + + DecisionsHelper(DecisionTask task) { + this.task = task; + } + + void scheduleActivityTask(ScheduleActivityTaskDecisionAttributes schedule) { + DecisionId decisionId = new DecisionId(DecisionTarget.ACTIVITY, schedule.getActivityId()); + addDecision(decisionId, new ActivityDecisionStateMachine(decisionId, schedule)); + } + + /** + * @return + * @return true if cancellation already happened as schedule event was found + * in the new decisions list + */ + boolean requestCancelActivityTask(String activityId, Runnable immediateCancellationCallback) { + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.ACTIVITY, activityId)); + decision.cancel(immediateCancellationCallback); + return decision.isDone(); + } + + boolean handleActivityTaskClosed(String activityId) { + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.ACTIVITY, activityId)); + decision.handleCompletionEvent(); + return decision.isDone(); + } + + boolean handleActivityTaskScheduled(HistoryEvent event) { + ActivityTaskScheduledEventAttributes attributes = event.getActivityTaskScheduledEventAttributes(); + String activityId = attributes.getActivityId(); + activitySchedulingEventIdToActivityId.put(event.getEventId(), activityId); + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.ACTIVITY, activityId)); + decision.handleInitiatedEvent(event); + return decision.isDone(); + } + + public boolean handleScheduleActivityTaskFailed(HistoryEvent event) { + ScheduleActivityTaskFailedEventAttributes attributes = event.getScheduleActivityTaskFailedEventAttributes(); + String activityId = attributes.getActivityId(); + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.ACTIVITY, activityId)); + decision.handleInitiationFailedEvent(event); + return decision.isDone(); + } + + boolean handleActivityTaskCancelRequested(HistoryEvent event) { + ActivityTaskCancelRequestedEventAttributes attributes = event.getActivityTaskCancelRequestedEventAttributes(); + String activityId = attributes.getActivityId(); + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.ACTIVITY, activityId)); + decision.handleCancellationInitiatedEvent(); + return decision.isDone(); + } + + public boolean handleActivityTaskCanceled(HistoryEvent event) { + ActivityTaskCanceledEventAttributes attributes = event.getActivityTaskCanceledEventAttributes(); + String activityId = getActivityId(attributes); + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.ACTIVITY, activityId)); + decision.handleCancellationEvent(); + return decision.isDone(); + } + + boolean handleRequestCancelActivityTaskFailed(HistoryEvent event) { + RequestCancelActivityTaskFailedEventAttributes attributes = event.getRequestCancelActivityTaskFailedEventAttributes(); + String activityId = attributes.getActivityId(); + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.ACTIVITY, activityId)); + decision.handleCancellationFailureEvent(event); + return decision.isDone(); + } + + void startChildWorkflowExecution(StartChildWorkflowExecutionDecisionAttributes schedule) { + DecisionId decisionId = new DecisionId(DecisionTarget.EXTERNAL_WORKFLOW, schedule.getWorkflowId()); + addDecision(decisionId, new ChildWorkflowDecisionStateMachine(decisionId, schedule)); + } + + void handleStartChildWorkflowExecutionInitiated(HistoryEvent event) { + StartChildWorkflowExecutionInitiatedEventAttributes attributes = event.getStartChildWorkflowExecutionInitiatedEventAttributes(); + String workflowId = attributes.getWorkflowId(); + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.EXTERNAL_WORKFLOW, workflowId)); + decision.handleInitiatedEvent(event); + } + + public boolean handleStartChildWorkflowExecutionFailed(HistoryEvent event) { + StartChildWorkflowExecutionFailedEventAttributes attributes = event.getStartChildWorkflowExecutionFailedEventAttributes(); + String workflowId = attributes.getWorkflowId(); + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.EXTERNAL_WORKFLOW, workflowId)); + decision.handleInitiationFailedEvent(event); + return decision.isDone(); + } + + /** + * @return + * @return true if cancellation already happened as schedule event was found + * in the new decisions list + */ + boolean requestCancelExternalWorkflowExecution(boolean childWorkflow, + RequestCancelExternalWorkflowExecutionDecisionAttributes request, Runnable immediateCancellationCallback) { + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.EXTERNAL_WORKFLOW, request.getWorkflowId())); + decision.cancel(immediateCancellationCallback); + return decision.isDone(); + } + + void handleRequestCancelExternalWorkflowExecutionInitiated(HistoryEvent event) { + RequestCancelExternalWorkflowExecutionInitiatedEventAttributes attributes = event.getRequestCancelExternalWorkflowExecutionInitiatedEventAttributes(); + String workflowId = attributes.getWorkflowId(); + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.EXTERNAL_WORKFLOW, workflowId)); + decision.handleCancellationInitiatedEvent(); + } + + void handleRequestCancelExternalWorkflowExecutionFailed(HistoryEvent event) { + RequestCancelExternalWorkflowExecutionFailedEventAttributes attributes = event.getRequestCancelExternalWorkflowExecutionFailedEventAttributes(); + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.EXTERNAL_WORKFLOW, attributes.getWorkflowId())); + decision.handleCancellationFailureEvent(event); + } + + void signalExternalWorkflowExecution(SignalExternalWorkflowExecutionDecisionAttributes signal) { + DecisionId decisionId = new DecisionId(DecisionTarget.SIGNAL, signal.getControl()); + addDecision(decisionId, new SignalDecisionStateMachine(decisionId, signal)); + } + + void cancelSignalExternalWorkflowExecution(String signalId, Runnable immediateCancellationCallback) { + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.SIGNAL, signalId)); + decision.cancel(immediateCancellationCallback); + } + + void handleSignalExternalWorkflowExecutionInitiated(HistoryEvent event) { + SignalExternalWorkflowExecutionInitiatedEventAttributes attributes = event.getSignalExternalWorkflowExecutionInitiatedEventAttributes(); + String signalId = attributes.getControl(); + signalInitiatedEventIdToSignalId.put(event.getEventId(), signalId); + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.SIGNAL, signalId)); + decision.handleInitiatedEvent(event); + } + + public boolean handleSignalExternalWorkflowExecutionFailed(String signalId) { + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.SIGNAL, signalId)); + decision.handleCompletionEvent(); + return decision.isDone(); + } + + public boolean handleExternalWorkflowExecutionSignaled(String signalId) { + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.SIGNAL, signalId)); + decision.handleCompletionEvent(); + return decision.isDone(); + } + + void startTimer(StartTimerDecisionAttributes request, Object createTimerUserContext) { + String timerId = request.getTimerId(); + DecisionId decisionId = new DecisionId(DecisionTarget.TIMER, timerId); + addDecision(decisionId, new TimerDecisionStateMachine(decisionId, request)); + } + + boolean cancelTimer(String timerId, Runnable immediateCancellationCallback) { + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.TIMER, timerId)); + decision.cancel(immediateCancellationCallback); + return decision.isDone(); + } + + public void handleChildWorkflowExecutionStarted(HistoryEvent event) { + ChildWorkflowExecutionStartedEventAttributes attributes = event.getChildWorkflowExecutionStartedEventAttributes(); + String workflowId = attributes.getWorkflowExecution().getWorkflowId(); + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.EXTERNAL_WORKFLOW, workflowId)); + decision.handleStartedEvent(event); + } + + boolean handleChildWorkflowExecutionClosed(String workflowId) { + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.EXTERNAL_WORKFLOW, workflowId)); + decision.handleCompletionEvent(); + return decision.isDone(); + } + + public void handleChildWorkflowExecutionCancelRequested(HistoryEvent event) { + } + + public boolean handleChildWorkflowExecutionCanceled(String workflowId) { + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.EXTERNAL_WORKFLOW, workflowId)); + decision.handleCancellationEvent(); + return decision.isDone(); + } + + boolean handleTimerClosed(String timerId) { + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.TIMER, timerId)); + decision.handleCompletionEvent(); + return decision.isDone(); + } + + boolean handleTimerStarted(HistoryEvent event) { + TimerStartedEventAttributes attributes = event.getTimerStartedEventAttributes(); + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.TIMER, attributes.getTimerId())); + decision.handleInitiatedEvent(event); + return decision.isDone(); + } + + public boolean handleStartTimerFailed(HistoryEvent event) { + StartTimerFailedEventAttributes attributes = event.getStartTimerFailedEventAttributes(); + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.TIMER, attributes.getTimerId())); + decision.handleInitiationFailedEvent(event); + return decision.isDone(); + } + + boolean handleTimerCanceled(HistoryEvent event) { + TimerCanceledEventAttributes attributes = event.getTimerCanceledEventAttributes(); + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.TIMER, attributes.getTimerId())); + decision.handleCancellationEvent(); + return decision.isDone(); + } + + boolean handleCancelTimerFailed(HistoryEvent event) { + CancelTimerFailedEventAttributes attributes = event.getCancelTimerFailedEventAttributes(); + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.TIMER, attributes.getTimerId())); + decision.handleCancellationFailureEvent(event); + return decision.isDone(); + } + + void completeWorkflowExecution(String output) { + Decision decision = new Decision(); + CompleteWorkflowExecutionDecisionAttributes complete = new CompleteWorkflowExecutionDecisionAttributes(); + complete.setResult(output); + decision.setCompleteWorkflowExecutionDecisionAttributes(complete); + decision.setDecisionType(DecisionType.CompleteWorkflowExecution.toString()); + DecisionId decisionId = new DecisionId(DecisionTarget.SELF, null); + addDecision(decisionId, new CompleteWorkflowStateMachine(decisionId, decision)); + } + + void continueAsNewWorkflowExecution(ContinueAsNewWorkflowExecutionParameters continueParameters) { + ContinueAsNewWorkflowExecutionDecisionAttributes attributes = new ContinueAsNewWorkflowExecutionDecisionAttributes(); + attributes.setInput(continueParameters.getInput()); + attributes.setExecutionStartToCloseTimeout(FlowHelpers.secondsToDuration(continueParameters.getExecutionStartToCloseTimeoutSeconds())); + attributes.setTaskStartToCloseTimeout(FlowHelpers.secondsToDuration(continueParameters.getTaskStartToCloseTimeoutSeconds())); + List tagList = continueParameters.getTagList(); + if (tagList != null) { + attributes.setTagList(tagList); + } + String taskList = continueParameters.getTaskList(); + if (taskList != null && !taskList.isEmpty()) { + attributes.setTaskList(new TaskList().withName(taskList)); + } + + Decision decision = new Decision(); + decision.setDecisionType(DecisionType.ContinueAsNewWorkflowExecution.toString()); + decision.setContinueAsNewWorkflowExecutionDecisionAttributes(attributes); + + DecisionId decisionId = new DecisionId(DecisionTarget.SELF, null); + addDecision(decisionId, new CompleteWorkflowStateMachine(decisionId, decision)); + } + + void failWorkflowExecution(Throwable e) { + Decision decision = new Decision(); + FailWorkflowExecutionDecisionAttributes fail = createFailWorkflowInstanceAttributes(e); + decision.setFailWorkflowExecutionDecisionAttributes(fail); + decision.setDecisionType(DecisionType.FailWorkflowExecution.toString()); + DecisionId decisionId = new DecisionId(DecisionTarget.SELF, null); + addDecision(decisionId, new CompleteWorkflowStateMachine(decisionId, decision)); + workflowFailed = true; + } + + void failWorkflowDueToUnexpectedError(Throwable e) { + // To make sure that failure goes through do not make any other decisions + decisions.clear(); + this.failWorkflowExecution(e); + } + + void handleCompleteWorkflowExecutionFailed(HistoryEvent event) { + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.SELF, null)); + decision.handleInitiationFailedEvent(event); + } + + void handleFailWorkflowExecutionFailed(HistoryEvent event) { + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.SELF, null)); + decision.handleInitiationFailedEvent(event); + } + + void handleCancelWorkflowExecutionFailed(HistoryEvent event) { + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.SELF, null)); + decision.handleInitiationFailedEvent(event); + } + + void handleContinueAsNewWorkflowExecutionFailed(HistoryEvent event) { + DecisionStateMachine decision = getDecision(new DecisionId(DecisionTarget.SELF, null)); + decision.handleInitiationFailedEvent(event); + } + + /** + * @return false means that cancel failed, true + * that CancelWorkflowExecution was created. + */ + void cancelWorkflowExecution() { + Decision decision = new Decision(); + CancelWorkflowExecutionDecisionAttributes cancel = new CancelWorkflowExecutionDecisionAttributes(); + cancel.setDetails(null); + decision.setCancelWorkflowExecutionDecisionAttributes(cancel); + decision.setDecisionType(DecisionType.CancelWorkflowExecution.toString()); + DecisionId decisionId = new DecisionId(DecisionTarget.SELF, null); + addDecision(decisionId, new CompleteWorkflowStateMachine(decisionId, decision)); + } + + List getDecisions() { + List result = new ArrayList(MAXIMUM_DECISIONS_PER_COMPLETION + 1); + for (DecisionStateMachine decisionStateMachine : decisions.values()) { + Decision decision = decisionStateMachine.getDecision(); + if (decision != null) { + result.add(decision); + } + } + // Include FORCE_IMMEDIATE_DECISION timer only if there are more then 100 events + int size = result.size(); + if (size > MAXIMUM_DECISIONS_PER_COMPLETION && !isCompletionEvent(result.get(MAXIMUM_DECISIONS_PER_COMPLETION - 2))) { + result = result.subList(0, MAXIMUM_DECISIONS_PER_COMPLETION - 1); + StartTimerDecisionAttributes attributes = new StartTimerDecisionAttributes(); + attributes.setStartToFireTimeout("0"); + attributes.setTimerId(FORCE_IMMEDIATE_DECISION_TIMER); + Decision d = new Decision(); + d.setStartTimerDecisionAttributes(attributes); + d.setDecisionType(DecisionType.StartTimer.toString()); + result.add(d); + } + + return result; + } + + private boolean isCompletionEvent(Decision decision) { + DecisionType type = DecisionType.fromValue(decision.getDecisionType()); + switch (type) { + case CancelWorkflowExecution: + case CompleteWorkflowExecution: + case FailWorkflowExecution: + case ContinueAsNewWorkflowExecution: + return true; + default: + return false; + } + } + + public void handleDecisionTaskStartedEvent() { + int count = 0; + Iterator iterator = decisions.values().iterator(); + DecisionStateMachine next = null; + + DecisionStateMachine decisionStateMachine = getNextDecision(iterator); + while (decisionStateMachine != null) { + next = getNextDecision(iterator); + if (++count == MAXIMUM_DECISIONS_PER_COMPLETION && next != null && !isCompletionEvent(next.getDecision())) { + break; + } + decisionStateMachine.handleDecisionTaskStartedEvent(); + decisionStateMachine = next; + } + if (next != null && count < MAXIMUM_DECISIONS_PER_COMPLETION) { + next.handleDecisionTaskStartedEvent(); + } + } + + private DecisionStateMachine getNextDecision(Iterator iterator) { + DecisionStateMachine result = null; + while (result == null && iterator.hasNext()) { + result = iterator.next(); + if (result.getDecision() == null) { + result = null; + } + } + return result; + } + + public String toString() { + return WorkflowExecutionUtils.prettyPrintDecisions(getDecisions()); + } + + boolean isWorkflowFailed() { + return workflowFailed; + } + + String getWorkflowContextData() { + return workflowContextData; + } + + void setWorkflowContextData(String workflowState) { + this.workflowContextData = workflowState; + } + + /** + * @return new workflow state or null if it didn't change since the last + * decision completion + */ + String getWorkflowContextDataToReturn() { + if (workfowContextFromLastDecisionCompletion == null + || !workfowContextFromLastDecisionCompletion.equals(workflowContextData)) { + return workflowContextData; + } + return null; + } + + void handleDecisionCompletion(DecisionTaskCompletedEventAttributes decisionTaskCompletedEventAttributes) { + workfowContextFromLastDecisionCompletion = decisionTaskCompletedEventAttributes.getExecutionContext(); + } + + DecisionTask getTask() { + return task; + } + + String getActivityId(ActivityTaskCanceledEventAttributes attributes) { + Long sourceId = attributes.getScheduledEventId(); + return activitySchedulingEventIdToActivityId.get(sourceId); + } + + String getActivityId(ActivityTaskCompletedEventAttributes attributes) { + Long sourceId = attributes.getScheduledEventId(); + return activitySchedulingEventIdToActivityId.get(sourceId); + } + + String getActivityId(ActivityTaskFailedEventAttributes attributes) { + Long sourceId = attributes.getScheduledEventId(); + return activitySchedulingEventIdToActivityId.get(sourceId); + } + + String getActivityId(ActivityTaskTimedOutEventAttributes attributes) { + Long sourceId = attributes.getScheduledEventId(); + return activitySchedulingEventIdToActivityId.get(sourceId); + } + + String getSignalIdFromExternalWorkflowExecutionSignaled(long initiatedEventId) { + return signalInitiatedEventIdToSignalId.get(initiatedEventId); + } + + private FailWorkflowExecutionDecisionAttributes createFailWorkflowInstanceAttributes(Throwable failure) { + String reason; + String details; + if (failure instanceof WorkflowException) { + WorkflowException f = (WorkflowException) failure; + reason = f.getReason(); + details = f.getDetails(); + } + else { + reason = failure.getMessage(); + StringWriter sw = new StringWriter(); + failure.printStackTrace(new PrintWriter(sw)); + details = sw.toString(); + } + FailWorkflowExecutionDecisionAttributes result = new FailWorkflowExecutionDecisionAttributes(); + result.setReason(WorkflowExecutionUtils.truncateReason(reason)); + result.setDetails(WorkflowExecutionUtils.truncateDetails(details)); + return result; + } + + void addDecision(DecisionId decisionId, DecisionStateMachine decision) { + decisions.put(decisionId, decision); + } + + private DecisionStateMachine getDecision(DecisionId decisionId) { + DecisionStateMachine result = decisions.get(decisionId); + if (result == null) { + throw new IllegalArgumentException("Unknown " + decisionId + ". The possible causes are " + + "nondeterministic workflow definition code or incompatible change in the workflow definition."); + } + return result; + } + + public String getNextId() { + return String.valueOf(++idCounter); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ExponentialRetryParameters.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ExponentialRetryParameters.java new file mode 100644 index 000000000000..120da63cb88a --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/ExponentialRetryParameters.java @@ -0,0 +1,122 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +public class ExponentialRetryParameters { + + private long initialInterval = 500; + + private double backoffCoefficient = 2.0d; + + private int maximumRetries = Integer.MAX_VALUE; + + private long expirationInterval = 60000; + + private long maximumRetryInterval = 20000; + + private int minimumRetries; + + public long getInitialInterval() { + return initialInterval; + } + + public void setInitialInterval(long initialInterval) { + this.initialInterval = initialInterval; + } + + public double getBackoffCoefficient() { + return backoffCoefficient; + } + + public void setBackoffCoefficient(double backoffCoefficient) { + this.backoffCoefficient = backoffCoefficient; + } + + public int getMaximumRetries() { + return maximumRetries; + } + + public void setMaximumRetries(int maximumRetries) { + this.maximumRetries = maximumRetries; + } + + public long getExpirationInterval() { + return expirationInterval; + } + + public void setExpirationInterval(long expirationInterval) { + this.expirationInterval = expirationInterval; + } + + public long getMaximumRetryInterval() { + return maximumRetryInterval; + } + + + public void setMaximumRetryInterval(long maximumRetryInterval) { + this.maximumRetryInterval = maximumRetryInterval; + } + + + public int getMinimumRetries() { + return minimumRetries; + } + + + public void setMinimumRetries(int minimumRetries) { + this.minimumRetries = minimumRetries; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + long temp; + temp = Double.doubleToLongBits(backoffCoefficient); + result = prime * result + (int) (temp ^ (temp >>> 32)); + result = prime * result + (int) (expirationInterval ^ (expirationInterval >>> 32)); + result = prime * result + (int) (initialInterval ^ (initialInterval >>> 32)); + result = prime * result + maximumRetries; + result = prime * result + (int) (maximumRetryInterval ^ (maximumRetryInterval >>> 32)); + result = prime * result + minimumRetries; + return result; + } + + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ExponentialRetryParameters other = (ExponentialRetryParameters) obj; + if (Double.doubleToLongBits(backoffCoefficient) != Double.doubleToLongBits(other.backoffCoefficient)) + return false; + if (expirationInterval != other.expirationInterval) + return false; + if (initialInterval != other.initialInterval) + return false; + if (maximumRetries != other.maximumRetries) + return false; + if (maximumRetryInterval != other.maximumRetryInterval) + return false; + if (minimumRetries != other.minimumRetries) + return false; + return true; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericActivityClientImpl.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericActivityClientImpl.java new file mode 100644 index 000000000000..7f7076a4d375 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericActivityClientImpl.java @@ -0,0 +1,216 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CancellationException; + +import com.amazonaws.services.simpleworkflow.flow.ActivityTaskFailedException; +import com.amazonaws.services.simpleworkflow.flow.ActivityTaskTimedOutException; +import com.amazonaws.services.simpleworkflow.flow.ScheduleActivityTaskFailedException; +import com.amazonaws.services.simpleworkflow.flow.common.FlowHelpers; +import com.amazonaws.services.simpleworkflow.flow.core.ExternalTask; +import com.amazonaws.services.simpleworkflow.flow.core.ExternalTaskCancellationHandler; +import com.amazonaws.services.simpleworkflow.flow.core.ExternalTaskCompletionHandle; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.core.Settable; +import com.amazonaws.services.simpleworkflow.flow.core.Task; +import com.amazonaws.services.simpleworkflow.flow.generic.ExecuteActivityParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.GenericActivityClient; +import com.amazonaws.services.simpleworkflow.model.ActivityTaskCanceledEventAttributes; +import com.amazonaws.services.simpleworkflow.model.ActivityTaskCompletedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.ActivityTaskFailedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.ActivityTaskStartedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.ActivityTaskTimedOutEventAttributes; +import com.amazonaws.services.simpleworkflow.model.ActivityType; +import com.amazonaws.services.simpleworkflow.model.HistoryEvent; +import com.amazonaws.services.simpleworkflow.model.ScheduleActivityTaskDecisionAttributes; +import com.amazonaws.services.simpleworkflow.model.ScheduleActivityTaskFailedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.TaskList; + +class GenericActivityClientImpl implements GenericActivityClient { + + private final class ActivityCancellationHandler implements ExternalTaskCancellationHandler { + + private final String activityId; + + private final ExternalTaskCompletionHandle handle; + + private ActivityCancellationHandler(String activityId, ExternalTaskCompletionHandle handle) { + this.activityId = activityId; + this.handle = handle; + } + + @Override + public void handleCancellation(Throwable cause) { + decisions.requestCancelActivityTask(activityId, new Runnable() { + + @Override + public void run() { + OpenRequestInfo scheduled = scheduledActivities.remove(activityId); + if (scheduled == null) { + throw new IllegalArgumentException("Activity \"" + activityId + "\" wasn't scheduled"); + } + handle.complete(); + } + }); + } + } + + private final DecisionsHelper decisions; + + private final Map> scheduledActivities = new HashMap>(); + + public GenericActivityClientImpl(DecisionsHelper decisions) { + this.decisions = decisions; + } + + @Override + public Promise scheduleActivityTask(final ExecuteActivityParameters parameters) { + final OpenRequestInfo context = new OpenRequestInfo( + parameters.getActivityType()); + final ScheduleActivityTaskDecisionAttributes attributes = new ScheduleActivityTaskDecisionAttributes(); + attributes.setActivityType(parameters.getActivityType()); + attributes.setInput(parameters.getInput()); + attributes.setHeartbeatTimeout(FlowHelpers.secondsToDuration(parameters.getHeartbeatTimeoutSeconds())); + attributes.setScheduleToCloseTimeout(FlowHelpers.secondsToDuration(parameters.getScheduleToCloseTimeoutSeconds())); + attributes.setScheduleToStartTimeout(FlowHelpers.secondsToDuration(parameters.getScheduleToStartTimeoutSeconds())); + attributes.setStartToCloseTimeout(FlowHelpers.secondsToDuration(parameters.getStartToCloseTimeoutSeconds())); + String activityId = parameters.getActivityId(); + if (activityId == null) { + activityId = String.valueOf(decisions.getNextId()); + } + attributes.setActivityId(activityId); + + String taskList = parameters.getTaskList(); + if (taskList != null && !taskList.isEmpty()) { + attributes.setTaskList(new TaskList().withName(taskList)); + } + String taskName = "activityId=" + activityId + ", activityType=" + attributes.getActivityType(); + new ExternalTask() { + + @Override + protected ExternalTaskCancellationHandler doExecute(final ExternalTaskCompletionHandle handle) throws Throwable { + + decisions.scheduleActivityTask(attributes); + context.setCompletionHandle(handle); + scheduledActivities.put(attributes.getActivityId(), context); + return new ActivityCancellationHandler(attributes.getActivityId(), handle); + } + }.setName(taskName); + context.setResultDescription("scheduleActivityTask " + taskName); + return context.getResult(); + } + + @Override + public Promise scheduleActivityTask(final String activity, final String version, final Promise input) { + final Settable result = new Settable(); + new Task(input) { + + @Override + protected void doExecute() throws Throwable { + result.chain(scheduleActivityTask(activity, version, input.get())); + } + }; + return result; + } + + @Override + public Promise scheduleActivityTask(String activity, String version, String input) { + ExecuteActivityParameters parameters = new ExecuteActivityParameters(); + parameters.setActivityType(new ActivityType().withName(activity).withVersion(version)); + parameters.setInput(input); + return scheduleActivityTask(parameters); + } + + void handleActivityTaskStarted(ActivityTaskStartedEventAttributes attributes) { + } + + void handleActivityTaskCanceled(HistoryEvent event) { + ActivityTaskCanceledEventAttributes attributes = event.getActivityTaskCanceledEventAttributes(); + String activityId = decisions.getActivityId(attributes); + if (decisions.handleActivityTaskCanceled(event)) { + CancellationException e = new CancellationException(); + OpenRequestInfo scheduled = scheduledActivities.remove(activityId); + if (scheduled != null) { + ExternalTaskCompletionHandle completionHandle = scheduled.getCompletionHandle(); + // It is OK to fail with subclass of CancellationException when cancellation requested. + // It allows passing information about cancellation (details in this case) to the surrounding doCatch block + completionHandle.fail(e); + } + } + } + + void handleScheduleActivityTaskFailed(HistoryEvent event) { + ScheduleActivityTaskFailedEventAttributes attributes = event.getScheduleActivityTaskFailedEventAttributes(); + String activityId = attributes.getActivityId(); + OpenRequestInfo scheduled = scheduledActivities.remove(activityId); + if (decisions.handleScheduleActivityTaskFailed(event)) { + String cause = attributes.getCause(); + ScheduleActivityTaskFailedException failure = new ScheduleActivityTaskFailedException(event.getEventId(), + attributes.getActivityType(), activityId, cause); + ExternalTaskCompletionHandle completionHandle = scheduled.getCompletionHandle(); + completionHandle.fail(failure); + } + } + + void handleActivityTaskCompleted(HistoryEvent event) { + ActivityTaskCompletedEventAttributes attributes = event.getActivityTaskCompletedEventAttributes(); + String activityId = decisions.getActivityId(attributes); + if (decisions.handleActivityTaskClosed(activityId)) { + OpenRequestInfo scheduled = scheduledActivities.remove(activityId); + if (scheduled != null) { + String result = attributes.getResult(); + scheduled.getResult().set(result); + ExternalTaskCompletionHandle completionHandle = scheduled.getCompletionHandle(); + completionHandle.complete(); + } + } + } + + void handleActivityTaskFailed(HistoryEvent event) { + ActivityTaskFailedEventAttributes attributes = event.getActivityTaskFailedEventAttributes(); + String activityId = decisions.getActivityId(attributes); + if (decisions.handleActivityTaskClosed(activityId)) { + OpenRequestInfo scheduled = scheduledActivities.remove(activityId); + if (scheduled != null) { + String reason = attributes.getReason(); + String details = attributes.getDetails(); + ActivityTaskFailedException failure = new ActivityTaskFailedException(event.getEventId(), + scheduled.getUserContext(), activityId, reason, details); + ExternalTaskCompletionHandle completionHandle = scheduled.getCompletionHandle(); + completionHandle.fail(failure); + } + } + } + + void handleActivityTaskTimedOut(HistoryEvent event) { + ActivityTaskTimedOutEventAttributes attributes = event.getActivityTaskTimedOutEventAttributes(); + String activityId = decisions.getActivityId(attributes); + if (decisions.handleActivityTaskClosed(activityId)) { + OpenRequestInfo scheduled = scheduledActivities.remove(activityId); + if (scheduled != null) { + String timeoutType = attributes.getTimeoutType(); + String details = attributes.getDetails(); + ActivityTaskTimedOutException failure = new ActivityTaskTimedOutException(event.getEventId(), + scheduled.getUserContext(), activityId, timeoutType, details); + ExternalTaskCompletionHandle completionHandle = scheduled.getCompletionHandle(); + completionHandle.fail(failure); + } + } + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericActivityWorker.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericActivityWorker.java new file mode 100644 index 000000000000..55db1592aa8a --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericActivityWorker.java @@ -0,0 +1,164 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.util.concurrent.Semaphore; +import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.amazonaws.AmazonServiceException; +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.common.FlowConstants; +import com.amazonaws.services.simpleworkflow.flow.common.FlowHelpers; +import com.amazonaws.services.simpleworkflow.flow.generic.ActivityImplementation; +import com.amazonaws.services.simpleworkflow.flow.generic.ActivityImplementationFactory; +import com.amazonaws.services.simpleworkflow.model.ActivityType; +import com.amazonaws.services.simpleworkflow.model.RegisterActivityTypeRequest; +import com.amazonaws.services.simpleworkflow.model.TaskList; +import com.amazonaws.services.simpleworkflow.model.TypeAlreadyExistsException; + +public class GenericActivityWorker extends GenericWorker { + + private static final Log log = LogFactory.getLog(GenericActivityWorker.class); + + private static final String POLL_THREAD_NAME_PREFIX = "SWF Activity Poll "; + + private static final String ACTIVITY_THREAD_NAME_PREFIX = "SWF Activity "; + + private ActivityImplementationFactory activityImplementationFactory; + + private int taskExecutorThreadPoolSize = 100; + + public GenericActivityWorker(AmazonSimpleWorkflow service, String domain, String taskListToPoll) { + super(service, domain, taskListToPoll); + if (service == null) { + throw new IllegalArgumentException("service"); + } + } + + public GenericActivityWorker() { + super(); + } + + public ActivityImplementationFactory getActivityImplementationFactory() { + return activityImplementationFactory; + } + + public void setActivityImplementationFactory(ActivityImplementationFactory activityImplementationFactory) { + this.activityImplementationFactory = activityImplementationFactory; + } + + public int getTaskExecutorThreadPoolSize() { + return taskExecutorThreadPoolSize; + } + + public void setTaskExecutorThreadPoolSize(int taskExecutorThreadPoolSize) { + if (taskExecutorThreadPoolSize < 1) { + throw new IllegalArgumentException("0 or negative taskExecutorThreadPoolSize"); + } + checkStarted(); + this.taskExecutorThreadPoolSize = taskExecutorThreadPoolSize; + } + + protected Semaphore createPollSemaphore() { + return new Semaphore(taskExecutorThreadPoolSize); + } + + @Override + public String toString() { + return this.getClass().getSimpleName() + " [super=" + super.toString() + ", taskExecutorThreadPoolSize=" + + taskExecutorThreadPoolSize + "]"; + } + + @Override + protected String getPollThreadNamePrefix() { + return POLL_THREAD_NAME_PREFIX + getTaskListToPoll() + " "; + } + + @Override + protected TaskPoller createPoller() { + ThreadPoolExecutor tasksExecutor = new ThreadPoolExecutor(1, taskExecutorThreadPoolSize, 1, TimeUnit.MINUTES, + new SynchronousQueue()); + tasksExecutor.setThreadFactory(new ExecutorThreadFactory(ACTIVITY_THREAD_NAME_PREFIX + " " + getTaskListToPoll() + " ")); + tasksExecutor.setRejectedExecutionHandler(new BlockCallerPolicy()); + return new ActivityTaskPoller(service, domain, getTaskListToPoll(), activityImplementationFactory, tasksExecutor); + } + + @Override + public void registerTypesToPoll() { + registerActivityTypes(service, domain, getTaskListToPoll(), activityImplementationFactory); + } + + public static void registerActivityTypes(AmazonSimpleWorkflow service, String domain, String defaultTaskList, + ActivityImplementationFactory activityImplementationFactory) { + for (ActivityType activityType : activityImplementationFactory.getActivityTypesToRegister()) { + try { + ActivityImplementation implementation = activityImplementationFactory.getActivityImplementation(activityType); + if (implementation == null) { + throw new IllegalStateException("No implementation found for type needed registration: " + activityType); + } + ActivityTypeRegistrationOptions registrationOptions = implementation.getRegistrationOptions(); + if (registrationOptions != null) { + registerActivityType(service, domain, activityType, registrationOptions, defaultTaskList); + } + } + catch (TypeAlreadyExistsException ex) { + if (log.isTraceEnabled()) { + log.trace("Activity version already registered: " + activityType.getName() + "_" + activityType.getVersion()); + } + } + } + } + + public static void registerActivityType(AmazonSimpleWorkflow service, String domain, ActivityType activityType, + ActivityTypeRegistrationOptions registrationOptions, String taskListToPoll) throws AmazonServiceException { + RegisterActivityTypeRequest registerActivity = new RegisterActivityTypeRequest(); + registerActivity.setDomain(domain); + String taskList = registrationOptions.getDefaultTaskList(); + if (taskList == null) { + taskList = taskListToPoll; + } + else if (taskList.equals(FlowConstants.NO_DEFAULT_TASK_LIST)) { + taskList = null; + } + if (taskList != null && !taskList.isEmpty()) { + registerActivity.setDefaultTaskList(new TaskList().withName(taskList)); + } + registerActivity.setName(activityType.getName()); + registerActivity.setVersion(activityType.getVersion()); + registerActivity.setDefaultTaskStartToCloseTimeout(FlowHelpers.secondsToDuration(registrationOptions.getDefaultTaskStartToCloseTimeoutSeconds())); + registerActivity.setDefaultTaskScheduleToCloseTimeout(FlowHelpers.secondsToDuration(registrationOptions.getDefaultTaskScheduleToCloseTimeoutSeconds())); + registerActivity.setDefaultTaskHeartbeatTimeout(FlowHelpers.secondsToDuration(registrationOptions.getDefaultTaskHeartbeatTimeoutSeconds())); + registerActivity.setDefaultTaskScheduleToStartTimeout(FlowHelpers.secondsToDuration(registrationOptions.getDefaultTaskScheduleToStartTimeoutSeconds())); + + if (registrationOptions.getDescription() != null) { + registerActivity.setDescription(registrationOptions.getDescription()); + } + service.registerActivityType(registerActivity); + if (log.isInfoEnabled()) { + log.info("regisered activity type: " + activityType); + } + } + + @Override + protected void checkRequredProperties() { + checkRequiredProperty(activityImplementationFactory, "activityImplementationFactory"); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericWorker.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericWorker.java new file mode 100644 index 000000000000..032f1ba9ae84 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericWorker.java @@ -0,0 +1,508 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.lang.Thread.UncaughtExceptionHandler; +import java.lang.management.ManagementFactory; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.WorkerBase; +import com.amazonaws.services.simpleworkflow.flow.common.FlowConstants; +import com.amazonaws.services.simpleworkflow.model.DomainAlreadyExistsException; +import com.amazonaws.services.simpleworkflow.model.RegisterDomainRequest; + +public abstract class GenericWorker implements WorkerBase { + + class ExecutorThreadFactory implements ThreadFactory { + + private AtomicInteger threadIndex = new AtomicInteger(); + + private final String threadPrefix; + + public ExecutorThreadFactory(String threadPrefix) { + this.threadPrefix = threadPrefix; + } + + @Override + public Thread newThread(Runnable r) { + Thread result = new Thread(r); + result.setName(threadPrefix + (threadIndex.incrementAndGet())); + result.setUncaughtExceptionHandler(uncaughtExceptionHandler); + return result; + } + } + + private class PollServiceTask implements Runnable { + + private final TaskPoller poller; + + PollServiceTask(TaskPoller poller) { + this.poller = poller; + } + + @Override + public void run() { + try { + if (log.isDebugEnabled()) { + log.debug("poll task begin"); + } + + if (pollExecutor.isTerminating()) { + return; + } + pollBackoffThrottler.throttle(); + if (pollExecutor.isTerminating()) { + return; + } + if (pollRateThrottler != null) { + pollRateThrottler.throttle(); + } + + CountDownLatch suspender = GenericWorker.this.suspendLatch.get(); + if (suspender != null) { + if (log.isDebugEnabled()) { + log.debug("poll task suspending latchCount=" + suspender.getCount()); + } + suspender.await(); + } + + if (pollExecutor.isTerminating()) { + return; + } + poller.pollAndProcessSingleTask(); + pollBackoffThrottler.success(); + } + catch (Throwable e) { + pollBackoffThrottler.failure(); + if (!(e.getCause() instanceof InterruptedException)) { + uncaughtExceptionHandler.uncaughtException(Thread.currentThread(), e); + } + } + finally { + // Resubmit itself back to pollExecutor + if (!pollExecutor.isShutdown()) { + pollExecutor.execute(this); + } + } + } + } + + private static final Log log = LogFactory.getLog(GenericWorker.class); + + protected static final int MAX_IDENTITY_LENGTH = 256; + + protected AmazonSimpleWorkflow service; + + protected String domain; + + protected boolean registerDomain; + + protected long domainRetentionPeriodInDays = FlowConstants.NONE; + + private String taskListToPoll; + + private int maximumPollRateIntervalMilliseconds = 1000; + + private double maximumPollRatePerSecond; + + private double pollBackoffCoefficient = 2; + + private long pollBackoffInitialInterval = 100; + + private long pollBackoffMaximumInterval = 60000; + + private boolean disableServiceShutdownOnStop; + + private ThreadPoolExecutor pollExecutor; + + private String identity = ManagementFactory.getRuntimeMXBean().getName(); + + protected final AtomicReference suspendLatch = new AtomicReference(); + + private int pollThreadCount = 1; + + private BackoffThrottler pollBackoffThrottler; + + private Throttler pollRateThrottler; + + protected UncaughtExceptionHandler uncaughtExceptionHandler = new UncaughtExceptionHandler() { + + @Override + public void uncaughtException(Thread t, Throwable e) { + log.error("Failure in thread " + t.getName(), e); + } + }; + + private TaskPoller poller; + + public GenericWorker(AmazonSimpleWorkflow service, String domain, String taskListToPoll) { + this.service = service; + this.domain = domain; + this.taskListToPoll = taskListToPoll; + } + + public GenericWorker() { + identity = ManagementFactory.getRuntimeMXBean().getName(); + int length = Math.min(identity.length(), GenericWorker.MAX_IDENTITY_LENGTH); + identity = identity.substring(0, length); + } + + @Override + public AmazonSimpleWorkflow getService() { + return service; + } + + public void setService(AmazonSimpleWorkflow service) { + this.service = service; + } + + @Override + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + @Override + public boolean isRegisterDomain() { + return registerDomain; + } + + /** + * Should domain be registered on startup. Default is false. + * When enabled {@link #setDomainRetentionPeriodInDays(Long)} property is + * required. + */ + @Override + public void setRegisterDomain(boolean registerDomain) { + this.registerDomain = registerDomain; + } + + @Override + public long getDomainRetentionPeriodInDays() { + return domainRetentionPeriodInDays; + } + + @Override + public void setDomainRetentionPeriodInDays(long domainRetentionPeriodInDays) { + this.domainRetentionPeriodInDays = domainRetentionPeriodInDays; + } + + @Override + public String getTaskListToPoll() { + return taskListToPoll; + } + + public void setTaskListToPoll(String taskListToPoll) { + this.taskListToPoll = taskListToPoll; + } + + @Override + public double getMaximumPollRatePerSecond() { + return maximumPollRatePerSecond; + } + + @Override + public void setMaximumPollRatePerSecond(double maximumPollRatePerSecond) { + this.maximumPollRatePerSecond = maximumPollRatePerSecond; + } + + @Override + public int getMaximumPollRateIntervalMilliseconds() { + return maximumPollRateIntervalMilliseconds; + } + + @Override + public void setMaximumPollRateIntervalMilliseconds(int maximumPollRateIntervalMilliseconds) { + this.maximumPollRateIntervalMilliseconds = maximumPollRateIntervalMilliseconds; + } + + @Override + public UncaughtExceptionHandler getUncaughtExceptionHandler() { + return uncaughtExceptionHandler; + } + + @Override + public void setUncaughtExceptionHandler(UncaughtExceptionHandler uncaughtExceptionHandler) { + this.uncaughtExceptionHandler = uncaughtExceptionHandler; + } + + @Override + public String getIdentity() { + return identity; + } + + @Override + public void setIdentity(String identity) { + this.identity = identity; + } + + @Override + public long getPollBackoffInitialInterval() { + return pollBackoffInitialInterval; + } + + @Override + public void setPollBackoffInitialInterval(long backoffInitialInterval) { + if (backoffInitialInterval < 0) { + throw new IllegalArgumentException("expected value should be positive or 0: " + backoffInitialInterval); + } + this.pollBackoffInitialInterval = backoffInitialInterval; + } + + @Override + public long getPollBackoffMaximumInterval() { + return pollBackoffMaximumInterval; + } + + @Override + public void setPollBackoffMaximumInterval(long backoffMaximumInterval) { + if (backoffMaximumInterval <= 0) { + throw new IllegalArgumentException("expected value should be positive: " + backoffMaximumInterval); + } + this.pollBackoffMaximumInterval = backoffMaximumInterval; + } + + /** + * @see #setDisableServiceShutdownOnStop(boolean) + */ + @Override + public boolean isDisableServiceShutdownOnStop() { + return disableServiceShutdownOnStop; + } + + /** + * By default when @{link {@link #shutdown()} or @{link + * {@link #shutdownNow()} is called the worker calls + * {@link AmazonSimpleWorkflow#shutdown()} on the service instance it is + * configured with before shutting down internal thread pools. Otherwise + * threads that are waiting on a poll request might block shutdown for the + * duration of a poll. This flag allows disabling this behavior. + * + * @param disableServiceShutdownOnStop + * true means do not call + * {@link AmazonSimpleWorkflow#shutdown()} + */ + @Override + public void setDisableServiceShutdownOnStop(boolean disableServiceShutdownOnStop) { + this.disableServiceShutdownOnStop = disableServiceShutdownOnStop; + } + + @Override + public double getPollBackoffCoefficient() { + return pollBackoffCoefficient; + } + + @Override + public void setPollBackoffCoefficient(double backoffCoefficient) { + if (backoffCoefficient < 1.0) { + throw new IllegalArgumentException("expected value should be bigger or equal to 1.0: " + backoffCoefficient); + } + this.pollBackoffCoefficient = backoffCoefficient; + } + + @Override + public int getPollThreadCount() { + return pollThreadCount; + } + + @Override + public void setPollThreadCount(int threadCount) { + checkStarted(); + this.pollThreadCount = threadCount; + } + + @Override + public void start() { + if (log.isInfoEnabled()) { + log.info("start: " + toString()); + } + checkStarted(); + checkRequiredProperty(service, "service"); + checkRequiredProperty(domain, "domain"); + checkRequiredProperty(taskListToPoll, "taskListToPoll"); + checkRequredProperties(); + + if (registerDomain) { + registerDomain(); + } + + registerTypesToPoll(); + + if (maximumPollRatePerSecond > 0.0) { + pollRateThrottler = new Throttler("pollRateThrottler " + taskListToPoll, maximumPollRatePerSecond, + maximumPollRateIntervalMilliseconds); + } + + pollExecutor = new ThreadPoolExecutor(pollThreadCount, pollThreadCount, 1, TimeUnit.MINUTES, + new LinkedBlockingQueue(pollThreadCount)); + ExecutorThreadFactory pollExecutorThreadFactory = getExecutorThreadFactory(); + pollExecutor.setThreadFactory(pollExecutorThreadFactory); + + pollBackoffThrottler = new BackoffThrottler(pollBackoffInitialInterval, pollBackoffMaximumInterval, + pollBackoffCoefficient); + poller = createPoller(); + for (int i = 0; i < pollThreadCount; i++) { + pollExecutor.execute(new PollServiceTask(poller)); + } + } + + private ExecutorThreadFactory getExecutorThreadFactory() { + ExecutorThreadFactory pollExecutorThreadFactory = new ExecutorThreadFactory(getPollThreadNamePrefix()); + return pollExecutorThreadFactory; + } + + protected abstract String getPollThreadNamePrefix(); + + protected abstract TaskPoller createPoller(); + + protected abstract void checkRequredProperties(); + + private void registerDomain() { + if (domainRetentionPeriodInDays == FlowConstants.NONE) { + throw new IllegalStateException("required property domainRetentionPeriodInSeconds is not set"); + } + try { + service.registerDomain(new RegisterDomainRequest().withName(domain).withWorkflowExecutionRetentionPeriodInDays( + String.valueOf(domainRetentionPeriodInDays))); + } + catch (DomainAlreadyExistsException e) { + if (log.isTraceEnabled()) { + log.trace("Domain is already registered: " + domain); + } + } + } + + protected void checkRequiredProperty(Object value, String name) { + if (value == null) { + throw new IllegalStateException("required property " + name + " is not set"); + } + } + + protected void checkStarted() { + if (isStarted()) { + throw new IllegalStateException("started"); + } + } + + private boolean isStarted() { + return pollExecutor != null; + } + + @Override + public void shutdown() { + if (log.isInfoEnabled()) { + log.info("shutdown"); + } + if (!isStarted()) { + return; + } + if (!disableServiceShutdownOnStop) { + service.shutdown(); + } + pollExecutor.shutdown(); + poller.shutdown(); + } + + @Override + public void shutdownNow() { + if (log.isInfoEnabled()) { + log.info("shutdownNow"); + } + if (!isStarted()) { + return; + } + if (!disableServiceShutdownOnStop) { + service.shutdown(); + } + pollExecutor.shutdownNow(); + poller.shutdownNow(); + } + + @Override + public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { + long start = System.currentTimeMillis(); + boolean terminated = pollExecutor.awaitTermination(timeout, unit); + long elapsed = System.currentTimeMillis() - start; + long left = TimeUnit.MILLISECONDS.convert(timeout, unit) - elapsed; + return poller.awaitTermination(left, TimeUnit.MILLISECONDS) && terminated; + } + + @Override + public boolean shutdownAndAwaitTermination(long timeout, TimeUnit unit) throws InterruptedException { + if (!isStarted()) { + return true; + } + long start = System.currentTimeMillis(); + if (!disableServiceShutdownOnStop) { + service.shutdown(); + } + pollExecutor.shutdownNow(); + try { + pollExecutor.awaitTermination(timeout, unit); + } + finally { + poller.shutdown(); + } + long elapsed = System.currentTimeMillis() - start; + long left = TimeUnit.MILLISECONDS.convert(timeout, unit) - elapsed; + return awaitTermination(left, TimeUnit.MILLISECONDS); + } + + @Override + public String toString() { + return this.getClass().getSimpleName() + "[service=" + service + ", domain=" + domain + ", taskListToPoll=" + + taskListToPoll + ", identity=" + identity + ", backoffInitialInterval=" + pollBackoffInitialInterval + + ", backoffMaximumInterval=" + pollBackoffMaximumInterval + ", backoffCoefficient=" + pollBackoffCoefficient + + "]"; + } + + @Override + public boolean isRunning() { + return isStarted() && !pollExecutor.isTerminated(); + } + + @Override + public void suspendPolling() { + if (log.isInfoEnabled()) { + log.info("suspendPolling"); + } + suspendLatch.set(new CountDownLatch(1)); + } + + @Override + public void resumePolling() { + if (log.isInfoEnabled()) { + log.info("resumePolling"); + } + CountDownLatch existing = suspendLatch.getAndSet(null); + if (existing != null) { + existing.countDown(); + } + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericWorkflowClientExternalImpl.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericWorkflowClientExternalImpl.java new file mode 100644 index 000000000000..5b20c82520df --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericWorkflowClientExternalImpl.java @@ -0,0 +1,119 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.util.UUID; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.common.FlowHelpers; +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClientExternal; +import com.amazonaws.services.simpleworkflow.flow.generic.SignalExternalWorkflowParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.StartWorkflowExecutionParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.TerminateWorkflowExecutionParameters; +import com.amazonaws.services.simpleworkflow.model.DescribeWorkflowExecutionRequest; +import com.amazonaws.services.simpleworkflow.model.RequestCancelWorkflowExecutionRequest; +import com.amazonaws.services.simpleworkflow.model.Run; +import com.amazonaws.services.simpleworkflow.model.SignalWorkflowExecutionRequest; +import com.amazonaws.services.simpleworkflow.model.StartWorkflowExecutionRequest; +import com.amazonaws.services.simpleworkflow.model.TaskList; +import com.amazonaws.services.simpleworkflow.model.TerminateWorkflowExecutionRequest; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecutionDetail; + +public class GenericWorkflowClientExternalImpl implements GenericWorkflowClientExternal { + + private final String domain; + + private final AmazonSimpleWorkflow service; + + public GenericWorkflowClientExternalImpl(AmazonSimpleWorkflow service, String domain) { + this.service = service; + this.domain = domain; + } + + @Override + public WorkflowExecution startWorkflow(StartWorkflowExecutionParameters startParameters) { + StartWorkflowExecutionRequest request = new StartWorkflowExecutionRequest(); + request.setDomain(domain); + + request.setInput(startParameters.getInput()); + request.setExecutionStartToCloseTimeout(FlowHelpers.secondsToDuration(startParameters.getExecutionStartToCloseTimeout())); + request.setTaskStartToCloseTimeout(FlowHelpers.secondsToDuration(startParameters.getTaskStartToCloseTimeoutSeconds())); + request.setTagList(startParameters.getTagList()); + String taskList = startParameters.getTaskList(); + if (taskList != null && !taskList.isEmpty()) { + request.setTaskList(new TaskList().withName(taskList)); + } + request.setWorkflowId(startParameters.getWorkflowId()); + request.setWorkflowType(startParameters.getWorkflowType()); + + Run result = service.startWorkflowExecution(request); + WorkflowExecution execution = new WorkflowExecution().withRunId(result.getRunId()).withWorkflowId(request.getWorkflowId()); + + return execution; + } + + @Override + public void signalWorkflowExecution(SignalExternalWorkflowParameters signalParameters) { + SignalWorkflowExecutionRequest request = new SignalWorkflowExecutionRequest(); + request.setDomain(domain); + + request.setInput(signalParameters.getInput()); + request.setSignalName(signalParameters.getSignalName()); + request.setRunId(signalParameters.getRunId()); + request.setWorkflowId(signalParameters.getWorkflowId()); + + service.signalWorkflowExecution(request); + } + + @Override + public void requestCancelWorkflowExecution(WorkflowExecution execution) { + RequestCancelWorkflowExecutionRequest request = new RequestCancelWorkflowExecutionRequest(); + request.setDomain(domain); + + request.setRunId(execution.getRunId()); + request.setWorkflowId(execution.getWorkflowId()); + + service.requestCancelWorkflowExecution(request); + } + + @Override + public String generateUniqueId() { + String workflowId = UUID.randomUUID().toString(); + return workflowId; + } + + @Override + public String getWorkflowState(WorkflowExecution execution) { + DescribeWorkflowExecutionRequest request = new DescribeWorkflowExecutionRequest(); + request.setDomain(domain); + request.setExecution(execution); + WorkflowExecutionDetail details = service.describeWorkflowExecution(request); + return details.getLatestExecutionContext(); + } + + @Override + public void terminateWorkflowExecution(TerminateWorkflowExecutionParameters terminateParameters) { + TerminateWorkflowExecutionRequest request = new TerminateWorkflowExecutionRequest(); + WorkflowExecution workflowExecution = terminateParameters.getWorkflowExecution(); + request.setWorkflowId(workflowExecution.getWorkflowId()); + request.setRunId(workflowExecution.getRunId()); + request.setDomain(domain); + request.setDetails(terminateParameters.getDetails()); + request.setReason(terminateParameters.getReason()); + request.setChildPolicy(terminateParameters.getChildPolicy()); + service.terminateWorkflowExecution(request); + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericWorkflowClientImpl.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericWorkflowClientImpl.java new file mode 100644 index 000000000000..6b34b1e3c98e --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericWorkflowClientImpl.java @@ -0,0 +1,403 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CancellationException; + +import com.amazonaws.services.simpleworkflow.flow.ChildWorkflowFailedException; +import com.amazonaws.services.simpleworkflow.flow.ChildWorkflowTerminatedException; +import com.amazonaws.services.simpleworkflow.flow.ChildWorkflowTimedOutException; +import com.amazonaws.services.simpleworkflow.flow.SignalExternalWorkflowException; +import com.amazonaws.services.simpleworkflow.flow.StartChildWorkflowFailedException; +import com.amazonaws.services.simpleworkflow.flow.WorkflowContext; +import com.amazonaws.services.simpleworkflow.flow.common.FlowHelpers; +import com.amazonaws.services.simpleworkflow.flow.core.ExternalTask; +import com.amazonaws.services.simpleworkflow.flow.core.ExternalTaskCancellationHandler; +import com.amazonaws.services.simpleworkflow.flow.core.ExternalTaskCompletionHandle; +import com.amazonaws.services.simpleworkflow.flow.core.Functor; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.core.Settable; +import com.amazonaws.services.simpleworkflow.flow.core.Task; +import com.amazonaws.services.simpleworkflow.flow.generic.ContinueAsNewWorkflowExecutionParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClient; +import com.amazonaws.services.simpleworkflow.flow.generic.SignalExternalWorkflowParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.StartChildWorkflowExecutionParameters; +import com.amazonaws.services.simpleworkflow.flow.generic.StartChildWorkflowReply; +import com.amazonaws.services.simpleworkflow.model.ChildWorkflowExecutionCanceledEventAttributes; +import com.amazonaws.services.simpleworkflow.model.ChildWorkflowExecutionCompletedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.ChildWorkflowExecutionFailedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.ChildWorkflowExecutionStartedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.ChildWorkflowExecutionTerminatedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.ChildWorkflowExecutionTimedOutEventAttributes; +import com.amazonaws.services.simpleworkflow.model.ExternalWorkflowExecutionSignaledEventAttributes; +import com.amazonaws.services.simpleworkflow.model.HistoryEvent; +import com.amazonaws.services.simpleworkflow.model.RequestCancelExternalWorkflowExecutionDecisionAttributes; +import com.amazonaws.services.simpleworkflow.model.SignalExternalWorkflowExecutionDecisionAttributes; +import com.amazonaws.services.simpleworkflow.model.SignalExternalWorkflowExecutionFailedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.StartChildWorkflowExecutionDecisionAttributes; +import com.amazonaws.services.simpleworkflow.model.StartChildWorkflowExecutionFailedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.TaskList; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +class GenericWorkflowClientImpl implements GenericWorkflowClient { + + private static class StartChildWorkflowReplyImpl implements StartChildWorkflowReply { + + private String runId; + + private final Settable result = new Settable(); + + public StartChildWorkflowReplyImpl(String runId, String description) { + this.runId = runId; + result.setDescription(description); + } + + @Override + public String getRunId() { + return runId; + } + + @Override + public Promise getResult() { + return result; + } + + public void setResult(String value) { + result.set(value); + } + + } + + private final class ChildWorkflowCancellationHandler implements ExternalTaskCancellationHandler { + + private final String workflowId; + + private final ExternalTaskCompletionHandle handle; + + private ChildWorkflowCancellationHandler(String workflowId, ExternalTaskCompletionHandle handle) { + this.workflowId = workflowId; + this.handle = handle; + } + + @Override + public void handleCancellation(Throwable cause) { + RequestCancelExternalWorkflowExecutionDecisionAttributes cancelAttributes = new RequestCancelExternalWorkflowExecutionDecisionAttributes(); + cancelAttributes.setWorkflowId(workflowId); + + decisions.requestCancelExternalWorkflowExecution(true, cancelAttributes, new Runnable() { + + @Override + public void run() { + OpenRequestInfo scheduled = scheduledExternalWorkflows.remove(workflowId); + if (scheduled == null) { + throw new IllegalArgumentException("Workflow \"" + workflowId + "\" wasn't scheduled"); + } + handle.complete(); + } + }); + } + } + + private final DecisionsHelper decisions; + + private final WorkflowContext workflowContext; + + private final Map> scheduledExternalWorkflows = new HashMap>(); + + private final Map> scheduledSignals = new HashMap>(); + + GenericWorkflowClientImpl(DecisionsHelper decisions, WorkflowContext workflowContext) { + this.decisions = decisions; + this.workflowContext = workflowContext; + } + + @Override + public Promise startChildWorkflow(final StartChildWorkflowExecutionParameters parameters) { + final OpenRequestInfo context = new OpenRequestInfo(); + final StartChildWorkflowExecutionDecisionAttributes attributes = new StartChildWorkflowExecutionDecisionAttributes(); + attributes.setWorkflowType(parameters.getWorkflowType()); + String workflowId = parameters.getWorkflowId(); + if (workflowId == null) { + workflowId = generateUniqueId(); + } + attributes.setWorkflowId(workflowId); + attributes.setInput(parameters.getInput()); + attributes.setExecutionStartToCloseTimeout(FlowHelpers.secondsToDuration(parameters.getExecutionStartToCloseTimeoutSeconds())); + attributes.setTaskStartToCloseTimeout(FlowHelpers.secondsToDuration(parameters.getTaskStartToCloseTimeoutSeconds())); + List tagList = parameters.getTagList(); + if (tagList != null) { + attributes.setTagList(tagList); + } + String taskList = parameters.getTaskList(); + if (taskList != null && !taskList.isEmpty()) { + attributes.setTaskList(new TaskList().withName(taskList)); + } + String taskName = "workflowId=" + workflowId + ", workflowType=" + attributes.getWorkflowType(); + new ExternalTask() { + + @Override + protected ExternalTaskCancellationHandler doExecute(final ExternalTaskCompletionHandle handle) throws Throwable { + decisions.startChildWorkflowExecution(attributes); + context.setCompletionHandle(handle); + scheduledExternalWorkflows.put(attributes.getWorkflowId(), context); + return new ChildWorkflowCancellationHandler(attributes.getWorkflowId(), handle); + } + }.setName(taskName); + context.setResultDescription("startChildWorkflow " + taskName); + return context.getResult(); + } + + @Override + public Promise startChildWorkflow(String workflow, String version, String input) { + StartChildWorkflowExecutionParameters parameters = new StartChildWorkflowExecutionParameters(); + parameters.setWorkflowType(new WorkflowType().withName(workflow).withVersion(version)); + parameters.setInput(input); + final Promise started = startChildWorkflow(parameters); + return new Functor(started) { + + @Override + protected Promise doExecute() throws Throwable { + return started.get().getResult(); + } + }; + } + + @Override + public Promise startChildWorkflow(final String workflow, final String version, final Promise input) { + final Settable result = new Settable(); + + new Task(input) { + + @Override + protected void doExecute() throws Throwable { + result.chain(startChildWorkflow(workflow, version, input.get())); + } + }; + return result; + } + + @Override + public Promise signalWorkflowExecution(final SignalExternalWorkflowParameters parameters) { + final OpenRequestInfo context = new OpenRequestInfo(); + final SignalExternalWorkflowExecutionDecisionAttributes attributes = new SignalExternalWorkflowExecutionDecisionAttributes(); + String signalId = decisions.getNextId(); + attributes.setControl(signalId); + attributes.setSignalName(parameters.getSignalName()); + attributes.setInput(parameters.getInput()); + attributes.setRunId(parameters.getRunId()); + attributes.setWorkflowId(parameters.getWorkflowId()); + String taskName = "signalId=" + signalId + ", workflowId=" + parameters.getWorkflowId() + ", workflowRunId=" + + parameters.getRunId(); + new ExternalTask() { + + @Override + protected ExternalTaskCancellationHandler doExecute(final ExternalTaskCompletionHandle handle) throws Throwable { + + decisions.signalExternalWorkflowExecution(attributes); + context.setCompletionHandle(handle); + final String finalSignalId = attributes.getControl(); + scheduledSignals.put(finalSignalId, context); + return new ExternalTaskCancellationHandler() { + + @Override + public void handleCancellation(Throwable cause) { + decisions.cancelSignalExternalWorkflowExecution(finalSignalId, null); + OpenRequestInfo scheduled = scheduledSignals.remove(finalSignalId); + if (scheduled == null) { + throw new IllegalArgumentException("Signal \"" + finalSignalId + "\" wasn't scheduled"); + } + handle.complete(); + } + }; + } + }.setName(taskName); + context.setResultDescription("signalWorkflowExecution " + taskName); + return context.getResult(); + } + + @Override + public void requestCancelWorkflowExecution(WorkflowExecution execution) { + RequestCancelExternalWorkflowExecutionDecisionAttributes attributes = new RequestCancelExternalWorkflowExecutionDecisionAttributes(); + String workflowId = execution.getWorkflowId(); + attributes.setWorkflowId(workflowId); + attributes.setRunId(execution.getRunId()); + boolean childWorkflow = scheduledExternalWorkflows.containsKey(workflowId); + // TODO: See if immediate cancellation needed + decisions.requestCancelExternalWorkflowExecution(childWorkflow, attributes, null); + } + + @Override + public void continueAsNewOnCompletion(ContinueAsNewWorkflowExecutionParameters continueParameters) { + // TODO: add validation to check if continueAsNew is not set + workflowContext.setContinueAsNewOnCompletion(continueParameters); + } + + @Override + public String generateUniqueId() { + WorkflowExecution workflowExecution = workflowContext.getWorkflowExecution(); + String runId = workflowExecution.getRunId(); + return runId + ":" + decisions.getNextId(); + } + + public void handleChildWorkflowExecutionCancelRequested(HistoryEvent event) { + decisions.handleChildWorkflowExecutionCancelRequested(event); + } + + void handleChildWorkflowExecutionCanceled(HistoryEvent event) { + ChildWorkflowExecutionCanceledEventAttributes attributes = event.getChildWorkflowExecutionCanceledEventAttributes(); + WorkflowExecution execution = attributes.getWorkflowExecution(); + String workflowId = execution.getWorkflowId(); + if (decisions.handleChildWorkflowExecutionCanceled(workflowId)) { + OpenRequestInfo scheduled = scheduledExternalWorkflows.remove(workflowId); + if (scheduled != null) { + CancellationException e = new CancellationException(); + ExternalTaskCompletionHandle completionHandle = scheduled.getCompletionHandle(); + // It is OK to fail with subclass of CancellationException when cancellation requested. + // It allows passing information about cancellation (details in this case) to the surrounding doCatch block + completionHandle.fail(e); + } + } + } + + void handleChildWorkflowExecutionStarted(HistoryEvent event) { + ChildWorkflowExecutionStartedEventAttributes attributes = event.getChildWorkflowExecutionStartedEventAttributes(); + WorkflowExecution execution = attributes.getWorkflowExecution(); + String workflowId = execution.getWorkflowId(); + decisions.handleChildWorkflowExecutionStarted(event); + OpenRequestInfo scheduled = scheduledExternalWorkflows.get(workflowId); + if (scheduled != null) { + String runId = attributes.getWorkflowExecution().getRunId(); + Settable result = scheduled.getResult(); + if (!result.isReady()) { + String description = "startChildWorkflow workflowId=" + workflowId + ", runId=" + runId; + result.set(new StartChildWorkflowReplyImpl(runId, description)); + } + } + } + + void handleChildWorkflowExecutionTimedOut(HistoryEvent event) { + ChildWorkflowExecutionTimedOutEventAttributes attributes = event.getChildWorkflowExecutionTimedOutEventAttributes(); + WorkflowExecution execution = attributes.getWorkflowExecution(); + String workflowId = execution.getWorkflowId(); + if (decisions.handleChildWorkflowExecutionClosed(workflowId)) { + OpenRequestInfo scheduled = scheduledExternalWorkflows.remove(workflowId); + if (scheduled != null) { + Exception failure = new ChildWorkflowTimedOutException(event.getEventId(), execution, + attributes.getWorkflowType()); + ExternalTaskCompletionHandle context = scheduled.getCompletionHandle(); + context.fail(failure); + } + } + } + + void handleChildWorkflowExecutionTerminated(HistoryEvent event) { + ChildWorkflowExecutionTerminatedEventAttributes attributes = event.getChildWorkflowExecutionTerminatedEventAttributes(); + WorkflowExecution execution = attributes.getWorkflowExecution(); + String workflowId = execution.getWorkflowId(); + if (decisions.handleChildWorkflowExecutionClosed(workflowId)) { + OpenRequestInfo scheduled = scheduledExternalWorkflows.remove(workflowId); + if (scheduled != null) { + Exception failure = new ChildWorkflowTerminatedException(event.getEventId(), execution, + attributes.getWorkflowType()); + ExternalTaskCompletionHandle context = scheduled.getCompletionHandle(); + context.fail(failure); + } + } + } + + void handleStartChildWorkflowExecutionFailed(HistoryEvent event) { + StartChildWorkflowExecutionFailedEventAttributes attributes = event.getStartChildWorkflowExecutionFailedEventAttributes(); + String workflowId = attributes.getWorkflowId(); + if (decisions.handleStartChildWorkflowExecutionFailed(event)) { + OpenRequestInfo scheduled = scheduledExternalWorkflows.remove(workflowId); + if (scheduled != null) { + WorkflowExecution workflowExecution = new WorkflowExecution(); + workflowExecution.setWorkflowId(workflowId); + WorkflowType workflowType = attributes.getWorkflowType(); + String cause = attributes.getCause(); + Exception failure = new StartChildWorkflowFailedException(event.getEventId(), workflowExecution, workflowType, + cause); + ExternalTaskCompletionHandle context = scheduled.getCompletionHandle(); + context.fail(failure); + } + } + } + + void handleChildWorkflowExecutionFailed(HistoryEvent event) { + ChildWorkflowExecutionFailedEventAttributes attributes = event.getChildWorkflowExecutionFailedEventAttributes(); + WorkflowExecution execution = attributes.getWorkflowExecution(); + String workflowId = execution.getWorkflowId(); + if (decisions.handleChildWorkflowExecutionClosed(workflowId)) { + OpenRequestInfo scheduled = scheduledExternalWorkflows.remove(workflowId); + if (scheduled != null) { + String reason = attributes.getReason(); + String details = attributes.getDetails(); + Exception failure = new ChildWorkflowFailedException(event.getEventId(), execution, attributes.getWorkflowType(), + reason, details); + ExternalTaskCompletionHandle context = scheduled.getCompletionHandle(); + context.fail(failure); + } + } + } + + void handleChildWorkflowExecutionCompleted(HistoryEvent event) { + ChildWorkflowExecutionCompletedEventAttributes attributes = event.getChildWorkflowExecutionCompletedEventAttributes(); + WorkflowExecution execution = attributes.getWorkflowExecution(); + String workflowId = execution.getWorkflowId(); + if (decisions.handleChildWorkflowExecutionClosed(workflowId)) { + OpenRequestInfo scheduled = scheduledExternalWorkflows.remove(workflowId); + if (scheduled != null) { + ExternalTaskCompletionHandle context = scheduled.getCompletionHandle(); + String result = attributes.getResult(); + StartChildWorkflowReplyImpl startedReply = (StartChildWorkflowReplyImpl) scheduled.getResult().get(); + startedReply.setResult(result); + context.complete(); + } + } + } + + void handleSignalExternalWorkflowExecutionFailed(HistoryEvent event) { + SignalExternalWorkflowExecutionFailedEventAttributes attributes = event.getSignalExternalWorkflowExecutionFailedEventAttributes(); + String signalId = attributes.getControl(); + if (decisions.handleSignalExternalWorkflowExecutionFailed(signalId)) { + OpenRequestInfo signalContextAndResult = scheduledSignals.remove(signalId); + if (signalContextAndResult != null) { + WorkflowExecution signaledExecution = new WorkflowExecution(); + signaledExecution.setWorkflowId(attributes.getWorkflowId()); + signaledExecution.setRunId(attributes.getRunId()); + Throwable failure = new SignalExternalWorkflowException(event.getEventId(), signaledExecution, + attributes.getCause()); + signalContextAndResult.getCompletionHandle().fail(failure); + } + } + } + + void handleExternalWorkflowExecutionSignaled(HistoryEvent event) { + ExternalWorkflowExecutionSignaledEventAttributes attributes = event.getExternalWorkflowExecutionSignaledEventAttributes(); + String signalId = decisions.getSignalIdFromExternalWorkflowExecutionSignaled(attributes.getInitiatedEventId()); + if (decisions.handleExternalWorkflowExecutionSignaled(signalId)) { + OpenRequestInfo signalContextAndResult = scheduledSignals.remove(signalId); + if (signalContextAndResult != null) { + signalContextAndResult.getResult().set(null); + signalContextAndResult.getCompletionHandle().complete(); + } + } + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericWorkflowWorker.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericWorkflowWorker.java new file mode 100644 index 000000000000..bccd9a1a1421 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/GenericWorkflowWorker.java @@ -0,0 +1,145 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.lang.management.ManagementFactory; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.WorkflowTypeRegistrationOptions; +import com.amazonaws.services.simpleworkflow.flow.common.FlowConstants; +import com.amazonaws.services.simpleworkflow.flow.common.FlowHelpers; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinitionFactory; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinitionFactoryFactory; +import com.amazonaws.services.simpleworkflow.model.RegisterWorkflowTypeRequest; +import com.amazonaws.services.simpleworkflow.model.TaskList; +import com.amazonaws.services.simpleworkflow.model.TypeAlreadyExistsException; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +public class GenericWorkflowWorker extends GenericWorker { + + private static final Log log = LogFactory.getLog(GenericWorkflowWorker.class); + + private static final String THREAD_NAME_PREFIX = "SWF Decider "; + + private WorkflowDefinitionFactoryFactory workflowDefinitionFactoryFactory; + + public GenericWorkflowWorker() { + setIdentity(ManagementFactory.getRuntimeMXBean().getName()); + } + + public GenericWorkflowWorker(AmazonSimpleWorkflow service, String domain, String taskListToPoll) { + this(); + setService(service); + setDomain(domain); + setTaskListToPoll(taskListToPoll); + } + + public WorkflowDefinitionFactoryFactory getWorkflowDefinitionFactoryFactory() { + return workflowDefinitionFactoryFactory; + } + + public void setWorkflowDefinitionFactoryFactory(WorkflowDefinitionFactoryFactory workflowDefinitionFactoryFactory) { + this.workflowDefinitionFactoryFactory = workflowDefinitionFactoryFactory; + } + + protected DecisionTaskPoller createWorkflowPoller() { + DecisionTaskPoller poller = new DecisionTaskPoller(); + return poller; + } + + @Override + protected void checkRequredProperties() { + checkRequiredProperty(workflowDefinitionFactoryFactory, "workflowDefinitionFactoryFactory"); + } + + @Override + protected String getPollThreadNamePrefix() { + return THREAD_NAME_PREFIX + getTaskListToPoll() + " "; + } + + @Override + protected TaskPoller createPoller() { + DecisionTaskPoller result = new DecisionTaskPoller(); + result.setDecisionTaskHandler(new AsyncDecisionTaskHandler(workflowDefinitionFactoryFactory)); + result.setDomain(getDomain()); + result.setIdentity(getIdentity()); + result.setService(getService()); + result.setTaskListToPoll(getTaskListToPoll()); + return result; + } + + @Override + public void registerTypesToPoll() { + registerWorkflowTypes(service, domain, getTaskListToPoll(), workflowDefinitionFactoryFactory); + } + + @Override + public String toString() { + return this.getClass().getSimpleName() + "[super=" + super.toString() + ", workflowDefinitionFactoryFactory=" + + workflowDefinitionFactoryFactory + "]"; + } + + public static void registerWorkflowTypes(AmazonSimpleWorkflow service, String domain, String defaultTaskList, + WorkflowDefinitionFactoryFactory workflowDefinitionFactoryFactory) { + for (WorkflowType typeToRegister : workflowDefinitionFactoryFactory.getWorkflowTypesToRegister()) { + WorkflowDefinitionFactory workflowDefinitionFactory = workflowDefinitionFactoryFactory.getWorkflowDefinitionFactory(typeToRegister); + WorkflowTypeRegistrationOptions registrationOptions = workflowDefinitionFactory.getWorkflowRegistrationOptions(); + if (registrationOptions != null) { + WorkflowType workflowType = workflowDefinitionFactory.getWorkflowType(); + try { + registerWorkflowType(service, domain, workflowType, registrationOptions, defaultTaskList); + } + catch (TypeAlreadyExistsException ex) { + if (log.isTraceEnabled()) { + log.trace("Workflow Type already registered: " + workflowType); + } + } + } + } + } + + public static void registerWorkflowType(AmazonSimpleWorkflow service, String domain, WorkflowType workflowType, + WorkflowTypeRegistrationOptions registrationOptions, String defaultTaskList) { + RegisterWorkflowTypeRequest registerWorkflow = new RegisterWorkflowTypeRequest(); + + registerWorkflow.setDomain(domain); + registerWorkflow.setName(workflowType.getName()); + registerWorkflow.setVersion(workflowType.getVersion()); + String taskList = registrationOptions.getDefaultTaskList(); + if (taskList == null) { + taskList = defaultTaskList; + } + else if (taskList.equals(FlowConstants.NO_DEFAULT_TASK_LIST)) { + taskList = null; + } + if (taskList != null && !taskList.isEmpty()) { + registerWorkflow.setDefaultTaskList(new TaskList().withName(taskList)); + } + registerWorkflow.setDefaultChildPolicy(registrationOptions.getDefaultChildPolicy().toString()); + registerWorkflow.setDefaultTaskStartToCloseTimeout(FlowHelpers.secondsToDuration(registrationOptions.getDefaultTaskStartToCloseTimeoutSeconds())); + registerWorkflow.setDefaultExecutionStartToCloseTimeout(FlowHelpers.secondsToDuration(registrationOptions.getDefaultExecutionStartToCloseTimeoutSeconds())); + + String description = registrationOptions.getDescription(); + if (description != null) { + registerWorkflow.setDescription(description); + } + + service.registerWorkflowType(registerWorkflow); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/HistoryHelper.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/HistoryHelper.java new file mode 100644 index 000000000000..3c3475c3afbf --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/HistoryHelper.java @@ -0,0 +1,139 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.util.Iterator; +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.amazonaws.services.simpleworkflow.flow.common.WorkflowExecutionUtils; +import com.amazonaws.services.simpleworkflow.model.DecisionTask; +import com.amazonaws.services.simpleworkflow.model.EventType; +import com.amazonaws.services.simpleworkflow.model.HistoryEvent; + +class HistoryHelper { + + private static final Log historyLog = LogFactory.getLog(HistoryHelper.class.getName() + ".history"); + + class EventsIterator implements Iterator { + + private final Iterator decisionTasks; + + private DecisionTask decisionTask; + + private List events; + + private int index; + + public EventsIterator(Iterator decisionTasks) { + this.decisionTasks = decisionTasks; + if (decisionTasks.hasNext()) { + decisionTask = decisionTasks.next(); + events = decisionTask.getEvents(); + if (historyLog.isTraceEnabled()) { + historyLog.trace(WorkflowExecutionUtils.prettyPrintHistory(events, true)); + } + } + else { + decisionTask = null; + } + } + + @Override + public boolean hasNext() { + return decisionTask != null && (index < events.size() || decisionTasks.hasNext()); + } + + @Override + public HistoryEvent next() { + if (index == events.size()) { + decisionTask = decisionTasks.next(); + events = decisionTask.getEvents(); + if (historyLog.isTraceEnabled()) { + historyLog.trace(WorkflowExecutionUtils.prettyPrintHistory(events, true)); + } + index = 0; + } + return events.get(index++); + } + + public DecisionTask getDecisionTask() { + return decisionTask; + } + + public List getEvents() { + return events; + } + + public boolean isNextDecisionTimedOut() { + int i = index; + while (true) { + for (; i < events.size(); i++) { + HistoryEvent event = events.get(i); + EventType eventType = EventType.fromValue(event.getEventType()); + if (eventType.equals(EventType.DecisionTaskTimedOut)) { + return true; + } + else if (eventType.equals(EventType.DecisionTaskCompleted)) { + return false; + } + } + if (!decisionTasks.hasNext()) { + return false; + } + decisionTask = decisionTasks.next(); + List nextPageEvents = decisionTask.getEvents(); + if (historyLog.isTraceEnabled()) { + historyLog.trace(WorkflowExecutionUtils.prettyPrintHistory(nextPageEvents, true)); + } + events.addAll(nextPageEvents); + } + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + } + + private final EventsIterator events; + + public HistoryHelper(Iterator decisionTasks) { + this.events = new EventsIterator(decisionTasks); + } + + public EventsIterator getEvents() { + return events; + } + + public String toString() { + return WorkflowExecutionUtils.prettyPrintHistory(events.getEvents(), true); + } + + public DecisionTask getDecisionTask() { + return events.getDecisionTask(); + } + + public long getLastNonReplayEventId() { + Long result = getDecisionTask().getPreviousStartedEventId(); + if (result == null) { + return 0; + } + return result; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/OpenRequestInfo.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/OpenRequestInfo.java new file mode 100644 index 000000000000..56985971ec71 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/OpenRequestInfo.java @@ -0,0 +1,56 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import com.amazonaws.services.simpleworkflow.flow.core.ExternalTaskCompletionHandle; +import com.amazonaws.services.simpleworkflow.flow.core.Settable; + +class OpenRequestInfo { + + ExternalTaskCompletionHandle completionHandle; + + final Settable result = new Settable(); + + final C userContext; + + OpenRequestInfo() { + userContext = null; + } + + OpenRequestInfo(C userContext) { + this.userContext = userContext; + } + + ExternalTaskCompletionHandle getCompletionHandle() { + return completionHandle; + } + + void setCompletionHandle(ExternalTaskCompletionHandle context) { + this.completionHandle = context; + } + + Settable getResult() { + return result; + } + + C getUserContext() { + return userContext; + } + + public void setResultDescription(String description) { + result.setDescription(description); + } + +} \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SignalDecisionStateMachine.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SignalDecisionStateMachine.java new file mode 100644 index 000000000000..1d1ca4eb30db --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SignalDecisionStateMachine.java @@ -0,0 +1,158 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import com.amazonaws.services.simpleworkflow.model.Decision; +import com.amazonaws.services.simpleworkflow.model.DecisionType; +import com.amazonaws.services.simpleworkflow.model.HistoryEvent; +import com.amazonaws.services.simpleworkflow.model.SignalExternalWorkflowExecutionDecisionAttributes; + +class SignalDecisionStateMachine extends DecisionStateMachineBase { + + private SignalExternalWorkflowExecutionDecisionAttributes attributes; + + private boolean canceled; + + public SignalDecisionStateMachine(DecisionId id, SignalExternalWorkflowExecutionDecisionAttributes attributes) { + super(id); + this.attributes = attributes; + } + + /** + * Used for unit testing + */ + SignalDecisionStateMachine(DecisionId id, SignalExternalWorkflowExecutionDecisionAttributes attributes, DecisionState state) { + super(id, state); + this.attributes = attributes; + } + + @Override + public Decision getDecision() { + switch (state) { + case CREATED: + return createSignalExternalWorkflowExecutionDecision(); + default: + return null; + } + } + + @Override + public boolean isDone() { + return state == DecisionState.COMPLETED || canceled; + } + + @Override + public void handleDecisionTaskStartedEvent() { + switch (state) { + case CREATED: + stateHistory.add("handleDecisionTaskStartedEvent"); + state = DecisionState.DECISION_SENT; + stateHistory.add(state.toString()); + break; + } + } + + @Override + public void cancel(Runnable immediateCancellationCallback) { + stateHistory.add("cancel"); + switch (state) { + case CREATED: + case INITIATED: + state = DecisionState.COMPLETED; + if (immediateCancellationCallback != null) { + immediateCancellationCallback.run(); + } + break; + case DECISION_SENT: + state = DecisionState.CANCELED_BEFORE_INITIATED; + if (immediateCancellationCallback != null) { + immediateCancellationCallback.run(); + } + break; + default: + failStateTransition(); + } + canceled = true; + stateHistory.add(state.toString()); + } + + @Override + public void handleInitiatedEvent(HistoryEvent event) { + stateHistory.add("handleInitiatedEvent"); + switch (state) { + case DECISION_SENT: + state = DecisionState.INITIATED; + break; + case CANCELED_BEFORE_INITIATED: + // No state change + break; + default: + failStateTransition(); + } + stateHistory.add(state.toString()); + + } + + @Override + public void handleInitiationFailedEvent(HistoryEvent event) { + throw new UnsupportedOperationException(); + } + + @Override + public void handleStartedEvent(HistoryEvent event) { + throw new UnsupportedOperationException(); + } + + @Override + public void handleCompletionEvent() { + stateHistory.add("handleCompletionEvent"); + switch (state) { + case DECISION_SENT: + case INITIATED: + case CANCELED_BEFORE_INITIATED: + state = DecisionState.COMPLETED; + break; + case COMPLETED: + // No state change + break; + default: + failStateTransition(); + } + stateHistory.add(state.toString()); + } + + @Override + public void handleCancellationInitiatedEvent() { + throw new UnsupportedOperationException(); + } + + @Override + public void handleCancellationFailureEvent(HistoryEvent event) { + throw new UnsupportedOperationException(); + } + + @Override + public void handleCancellationEvent() { + throw new UnsupportedOperationException(); + } + + private Decision createSignalExternalWorkflowExecutionDecision() { + Decision decision = new Decision(); + decision.setSignalExternalWorkflowExecutionDecisionAttributes(attributes); + decision.setDecisionType(DecisionType.SignalExternalWorkflowExecution.toString()); + return decision; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SimpleWorkflowDefinitionFactoryFactory.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SimpleWorkflowDefinitionFactoryFactory.java new file mode 100644 index 000000000000..afbc93cbb464 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SimpleWorkflowDefinitionFactoryFactory.java @@ -0,0 +1,62 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.amazonaws.services.simpleworkflow.flow.WorkflowTypeRegistrationOptions; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinitionFactory; +import com.amazonaws.services.simpleworkflow.flow.generic.WorkflowDefinitionFactoryFactory; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + +public class SimpleWorkflowDefinitionFactoryFactory extends WorkflowDefinitionFactoryFactory { + + private final Map factoriesMap = new HashMap(); + + private final List typesToRegister = new ArrayList(); + + @Override + public WorkflowDefinitionFactory getWorkflowDefinitionFactory(WorkflowType workflowType) { + return factoriesMap.get(workflowType); + } + + @Override + public Iterable getWorkflowTypesToRegister() { + return typesToRegister; + } + + public void setWorkflowDefinitionFactories(Collection factories) { + for (WorkflowDefinitionFactory factory : factories) { + addWorkflowDefinitionFactory(factory); + } + } + + public Collection getWorkflowDefinitionFactories() { + return factoriesMap.values(); + } + + public void addWorkflowDefinitionFactory(WorkflowDefinitionFactory factory) { + WorkflowType workflowType = factory.getWorkflowType(); + factoriesMap.put(workflowType, factory); + WorkflowTypeRegistrationOptions registrationOptions = factory.getWorkflowRegistrationOptions(); + if (registrationOptions != null) { + typesToRegister.add(workflowType); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SynchronousActivityTaskPoller.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SynchronousActivityTaskPoller.java new file mode 100644 index 000000000000..17e7fea0a119 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SynchronousActivityTaskPoller.java @@ -0,0 +1,312 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.management.ManagementFactory; +import java.util.concurrent.CancellationException; +import java.util.concurrent.TimeUnit; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; +import com.amazonaws.services.simpleworkflow.flow.ActivityFailureException; +import com.amazonaws.services.simpleworkflow.flow.generic.ActivityImplementation; +import com.amazonaws.services.simpleworkflow.flow.generic.ActivityImplementationFactory; +import com.amazonaws.services.simpleworkflow.model.ActivityTask; +import com.amazonaws.services.simpleworkflow.model.ActivityType; +import com.amazonaws.services.simpleworkflow.model.PollForActivityTaskRequest; +import com.amazonaws.services.simpleworkflow.model.RespondActivityTaskCanceledRequest; +import com.amazonaws.services.simpleworkflow.model.RespondActivityTaskCompletedRequest; +import com.amazonaws.services.simpleworkflow.model.RespondActivityTaskFailedRequest; +import com.amazonaws.services.simpleworkflow.model.TaskList; +import com.amazonaws.services.simpleworkflow.model.UnknownResourceException; + +public class SynchronousActivityTaskPoller implements TaskPoller { + + private static final Log log = LogFactory.getLog(SynchronousActivityTaskPoller.class); + + private AmazonSimpleWorkflow service; + + private String domain; + + private String taskListToPoll; + + private ActivityImplementationFactory activityImplementationFactory; + + private String identity; + + private SynchronousRetrier reportCompletionRetrier; + + private SynchronousRetrier reportFailureRetrier; + + private boolean initialized; + + public SynchronousActivityTaskPoller(AmazonSimpleWorkflow service, String domain, String taskListToPoll, + ActivityImplementationFactory activityImplementationFactory) { + this(); + this.service = service; + this.domain = domain; + this.taskListToPoll = taskListToPoll; + this.activityImplementationFactory = activityImplementationFactory; + setReportCompletionRetryParameters(new ExponentialRetryParameters()); + setReportFailureRetryParameters(new ExponentialRetryParameters()); + } + + public SynchronousActivityTaskPoller() { + identity = ManagementFactory.getRuntimeMXBean().getName(); + int length = Math.min(identity.length(), GenericWorker.MAX_IDENTITY_LENGTH); + identity = identity.substring(0, length); + } + + public AmazonSimpleWorkflow getService() { + return service; + } + + public void setService(AmazonSimpleWorkflow service) { + this.service = service; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getPollTaskList() { + return taskListToPoll; + } + + public void setTaskListToPoll(String taskList) { + this.taskListToPoll = taskList; + } + + public ActivityImplementationFactory getActivityImplementationFactory() { + return activityImplementationFactory; + } + + public void setActivityImplementationFactory(ActivityImplementationFactory activityImplementationFactory) { + this.activityImplementationFactory = activityImplementationFactory; + } + + public String getIdentity() { + return identity; + } + + public void setIdentity(String identity) { + this.identity = identity; + } + + public ExponentialRetryParameters getReportCompletionRetryParameters() { + return reportCompletionRetrier.getRetryParameters(); + } + + public void setReportCompletionRetryParameters(ExponentialRetryParameters reportCompletionRetryParameters) { + this.reportCompletionRetrier = new SynchronousRetrier(reportCompletionRetryParameters, UnknownResourceException.class); + } + + public ExponentialRetryParameters getReportFailureRetryParameters() { + return reportFailureRetrier.getRetryParameters(); + } + + public void setReportFailureRetryParameters(ExponentialRetryParameters reportFailureRetryParameters) { + this.reportFailureRetrier = new SynchronousRetrier(reportFailureRetryParameters, UnknownResourceException.class); + } + + public String getTaskListToPoll() { + return taskListToPoll; + } + + /** + * Poll for a task using {@link #getPollTimeoutInSeconds()} + * + * @return null if poll timed out + */ + public ActivityTask poll() { + if (!initialized) { + checkRequiredProperty(service, "service"); + checkRequiredProperty(domain, "domain"); + checkRequiredProperty(taskListToPoll, "taskListToPoll"); + initialized = true; + } + + PollForActivityTaskRequest pollRequest = new PollForActivityTaskRequest(); + pollRequest.setDomain(domain); + pollRequest.setIdentity(identity); + pollRequest.setTaskList(new TaskList().withName(taskListToPoll)); + if (log.isDebugEnabled()) { + log.debug("poll request begin: " + pollRequest); + } + ActivityTask result = service.pollForActivityTask(pollRequest); + if (result == null || result.getTaskToken() == null) { + if (log.isDebugEnabled()) { + log.debug("poll request returned no task"); + } + return null; + } + if (log.isTraceEnabled()) { + log.trace("poll request returned " + result); + } + return result; + } + + /** + * Poll for a activity task and execute correspondent implementation. + * + * @return true if task was polled and decided upon, false if poll timed out + * @throws Exception + */ + @Override + public boolean pollAndProcessSingleTask() throws Exception { + ActivityTask task = poll(); + if (task == null) { + return false; + } + execute(task); + return true; + } + + protected void execute(final ActivityTask task) throws Exception { + String output = null; + ActivityType activityType = task.getActivityType(); + try { + ActivityExecutionContext context = new ActivityExecutionContextImpl(service, task); + ActivityImplementation activityImplementation = activityImplementationFactory.getActivityImplementation(activityType); + if (activityImplementation == null) { + throw new ActivityFailureException("Unknown activity type: " + activityType); + } + output = activityImplementation.execute(context); + if (!activityImplementation.getExecutionOptions().isManualActivityCompletion()) { + respondActivityTaskCompletedWithRetry(task.getTaskToken(), output); + } + } + catch (CancellationException e) { + respondActivityTaskCanceledWithRetry(task.getTaskToken(), null); + return; + } + catch (ActivityFailureException e) { + if (log.isErrorEnabled()) { + log.error("Failure processing activity task with taskId=" + task.getStartedEventId() + ", workflowGenerationId=" + + task.getWorkflowExecution().getWorkflowId() + ", activity=" + activityType + + ", activityInstanceId=" + task.getActivityId(), e); + } + respondActivityTaskFailedWithRetry(task.getTaskToken(), e.getReason(), e.getDetails()); + } + catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Failure processing activity task with taskId=" + task.getStartedEventId() + ", workflowGenerationId=" + + task.getWorkflowExecution().getWorkflowId() + ", activity=" + activityType + + ", activityInstanceId=" + task.getActivityId(), e); + } + String reason = e.getMessage(); + StringWriter sw = new StringWriter(); + e.printStackTrace(new PrintWriter(sw)); + String details = sw.toString(); + respondActivityTaskFailedWithRetry(task.getTaskToken(), reason, details); + } + } + + protected void respondActivityTaskFailedWithRetry(final String taskToken, final String reason, final String details) { + if (reportFailureRetrier == null) { + respondActivityTaskFailed(taskToken, reason, details); + } + else { + reportFailureRetrier.retry(new Runnable() { + + @Override + public void run() { + respondActivityTaskFailed(taskToken, reason, details); + } + }); + } + } + + protected void respondActivityTaskFailed(String taskToken, String reason, String details) { + RespondActivityTaskFailedRequest failedResponse = new RespondActivityTaskFailedRequest(); + failedResponse.setTaskToken(taskToken); + failedResponse.setReason(reason); + failedResponse.setDetails(details); + service.respondActivityTaskFailed(failedResponse); + } + + protected void respondActivityTaskCanceledWithRetry(final String taskToken, final String details) { + if (reportFailureRetrier == null) { + respondActivityTaskCanceled(taskToken, details); + } + else { + reportFailureRetrier.retry(new Runnable() { + + @Override + public void run() { + respondActivityTaskCanceled(taskToken, details); + } + }); + } + } + + protected void respondActivityTaskCanceled(String taskToken, String details) { + RespondActivityTaskCanceledRequest canceledResponse = new RespondActivityTaskCanceledRequest(); + canceledResponse.setTaskToken(taskToken); + canceledResponse.setDetails(details); + service.respondActivityTaskCanceled(canceledResponse); + } + + protected void respondActivityTaskCompletedWithRetry(final String taskToken, final String output) { + if (reportCompletionRetrier == null) { + respondActivityTaskCompleted(taskToken, output); + } + else { + reportCompletionRetrier.retry(new Runnable() { + + @Override + public void run() { + respondActivityTaskCompleted(taskToken, output); + } + }); + } + } + + protected void respondActivityTaskCompleted(String taskToken, String output) { + RespondActivityTaskCompletedRequest completedReponse = new RespondActivityTaskCompletedRequest(); + completedReponse.setTaskToken(taskToken); + completedReponse.setResult(output); + service.respondActivityTaskCompleted(completedReponse); + } + + protected void checkRequiredProperty(Object value, String name) { + if (value == null) { + throw new IllegalStateException("required property " + name + " is not set"); + } + } + + @Override + public void shutdown() { + } + + @Override + public void shutdownNow() { + } + + @Override + public boolean awaitTermination(long left, TimeUnit milliseconds) throws InterruptedException { + //TODO: Waiting for all currently running pollAndProcessSingleTask to complete + return true; + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SynchronousRetrier.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SynchronousRetrier.java new file mode 100644 index 000000000000..ae3f5f1c2a26 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/SynchronousRetrier.java @@ -0,0 +1,89 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class SynchronousRetrier { + + private static final Log log = LogFactory.getLog(SynchronousRetrier.class); + + private final ExponentialRetryParameters retryParameters; + + private final Class[] exceptionsToNotRetry; + + public SynchronousRetrier(ExponentialRetryParameters retryParameters, Class... exceptionsToNotRetry) { + if (retryParameters.getBackoffCoefficient() < 0) { + throw new IllegalArgumentException("negative backoffCoefficient"); + } + if (retryParameters.getInitialInterval() < 10) { + throw new IllegalArgumentException("initialInterval cannot be less then 10: " + retryParameters.getInitialInterval()); + } + if (retryParameters.getExpirationInterval() < retryParameters.getInitialInterval()) { + throw new IllegalArgumentException("expirationInterval < initialInterval"); + } + if (retryParameters.getMaximumRetries() < retryParameters.getMinimumRetries()) { + throw new IllegalArgumentException("maximumRetries < minimumRetries"); + } + this.retryParameters = retryParameters; + this.exceptionsToNotRetry = exceptionsToNotRetry; + } + + public ExponentialRetryParameters getRetryParameters() { + return retryParameters; + } + + public Class[] getExceptionsToNotRetry() { + return exceptionsToNotRetry; + } + + public void retry(Runnable r) { + int attempt = 0; + long startTime = System.currentTimeMillis(); + BackoffThrottler throttler = new BackoffThrottler(retryParameters.getInitialInterval(), + retryParameters.getMaximumRetryInterval(), retryParameters.getBackoffCoefficient()); + boolean success = false; + do { + try { + attempt++; + throttler.throttle(); + r.run(); + success = true; + throttler.success(); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + return; + } + catch (RuntimeException e) { + throttler.failure(); + for (Class exceptionToNotRetry : exceptionsToNotRetry) { + if (exceptionToNotRetry.isAssignableFrom(e.getClass())) { + throw e; + } + } + long elapsed = System.currentTimeMillis() - startTime; + if (attempt > retryParameters.getMaximumRetries() + || (elapsed >= retryParameters.getExpirationInterval() && attempt > retryParameters.getMinimumRetries())) { + throw e; + } + log.warn("Retrying after failure", e); + } + } + while (!success); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/TaskPoller.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/TaskPoller.java new file mode 100644 index 000000000000..d17dbdf1f2c1 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/TaskPoller.java @@ -0,0 +1,30 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.util.concurrent.TimeUnit; + + +public interface TaskPoller { + + boolean pollAndProcessSingleTask() throws Exception; + + void shutdown(); + + void shutdownNow(); + + boolean awaitTermination(long left, TimeUnit milliseconds) throws InterruptedException; + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/Throttler.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/Throttler.java new file mode 100644 index 000000000000..0e6987216fd9 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/Throttler.java @@ -0,0 +1,134 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class Throttler { + + private static final Log log = LogFactory.getLog(Throttler.class); + + /** + * Human readable name of the resource being throttled. + * Used for logging only. + */ + private final String name_; + + /** + * Used as a circular buffer + */ + private CircularLongBuffer checkPointTimes_; + + /** + * Used as an index to a circular buffer + */ + private long index_; + + /** + * Interval used to measure the rate. Shorter interval allows less spikey + * rates. + */ + private long rateInterval_; + + private long rateIntervalMilliseconds_; + + private long overslept_; + + /** + * Construct throttler. + * @param name Human readable name of the resource being throttled. Used for logging only. + * @param maxRatePerSecond maximum rate allowed + * @param rateIntervalMilliseconds rate measurement interval. Interval should be at least + * 1000 / maxRatePerSecond. + */ + public Throttler(String name, double maxRatePerSecond, long rateIntervalMilliseconds) { + if (null == name) { + throw new IllegalArgumentException("null name"); + } + name_ = name; + if (maxRatePerSecond <= 0) { + throw new IllegalArgumentException("0 or negative maxRatePerSecond"); + } + if (rateIntervalMilliseconds <= 0) { + throw new IllegalArgumentException("0 or negative rateIntervalMilliseconds"); + } + synchronized(this) { + rateIntervalMilliseconds_ = rateIntervalMilliseconds; + setMaxRatePerSecond(maxRatePerSecond); + } + } + + public synchronized void setMaxRatePerSecond(double maxRatePerSecond) { + int maxMessagesPerRateInterval = (int) (maxRatePerSecond * rateIntervalMilliseconds_ / 1000); + if (maxMessagesPerRateInterval == 0) { + maxMessagesPerRateInterval = 1; + rateInterval_ = (long) (1.0 / maxRatePerSecond * 1000.0); + } else { + rateInterval_ = rateIntervalMilliseconds_; + } + if (checkPointTimes_ != null) { + int oldSize = checkPointTimes_.size(); + checkPointTimes_ = checkPointTimes_.copy(index_ - maxMessagesPerRateInterval, maxMessagesPerRateInterval); + index_ = Math.min(checkPointTimes_.size(), oldSize); + } else { + checkPointTimes_ = new CircularLongBuffer(maxMessagesPerRateInterval); + index_ = 0; + } + log.debug("new rate=" + maxRatePerSecond + " (msg/sec)"); + } + + public synchronized void throttle(int count) throws InterruptedException { + for(int i=0; i 0) { + long elapsed = now - checkPoint; + + // if the time for this window is less than the minimum per window + if (elapsed >= 0 && elapsed < rateInterval_) { + long sleepInterval = rateInterval_ - elapsed - overslept_; + overslept_ = 0; + if (sleepInterval > 0) { + if (log.isTraceEnabled()) { + log.debug("Throttling " + + name_ + + ": called " + + checkPointTimes_.size() + + " times in last " + + elapsed + + " milliseconds. Going to sleep for " + + sleepInterval + + " milliseconds."); + } + long t = System.currentTimeMillis(); + Thread.sleep(sleepInterval); + overslept_ = System.currentTimeMillis() - t - sleepInterval; + } + } + } + checkPointTimes_.set(index_++, System.currentTimeMillis()); + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/TimerDecisionStateMachine.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/TimerDecisionStateMachine.java new file mode 100644 index 000000000000..467cfa49a81a --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/TimerDecisionStateMachine.java @@ -0,0 +1,119 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import com.amazonaws.services.simpleworkflow.model.CancelTimerDecisionAttributes; +import com.amazonaws.services.simpleworkflow.model.Decision; +import com.amazonaws.services.simpleworkflow.model.DecisionType; +import com.amazonaws.services.simpleworkflow.model.HistoryEvent; +import com.amazonaws.services.simpleworkflow.model.StartTimerDecisionAttributes; + +/** + * Timer doesn't have separate initiation decision as it is started immediately. + * But from the state machine point of view it is modeled the same as activity + * with no TimerStarted event used as initiation event. + * + * @author fateev + */ +class TimerDecisionStateMachine extends DecisionStateMachineBase { + + private StartTimerDecisionAttributes attributes; + + private boolean canceled; + + public TimerDecisionStateMachine(DecisionId id, StartTimerDecisionAttributes attributes) { + super(id); + this.attributes = attributes; + } + + /** + * Used for unit testing + */ + TimerDecisionStateMachine(DecisionId id, StartTimerDecisionAttributes attributes, DecisionState state) { + super(id, state); + this.attributes = attributes; + } + + @Override + public Decision getDecision() { + switch (state) { + case CREATED: + return createStartTimerDecision(); + case CANCELED_AFTER_INITIATED: + return createCancelTimerDecision(); + default: + return null; + } + } + + @Override + public void handleDecisionTaskStartedEvent() { + switch (state) { + case CANCELED_AFTER_INITIATED: + stateHistory.add("handleDecisionTaskStartedEvent"); + state = DecisionState.CANCELLATION_DECISION_SENT; + stateHistory.add(state.toString()); + break; + default: + super.handleDecisionTaskStartedEvent(); + } + } + + @Override + public void handleCancellationFailureEvent(HistoryEvent event) { + switch (state) { + case CANCELLATION_DECISION_SENT: + stateHistory.add("handleCancellationFailureEvent"); + state = DecisionState.INITIATED; + stateHistory.add(state.toString()); + break; + default: + super.handleCancellationFailureEvent(event); + } + } + + @Override + public void cancel(Runnable immediateCancellationCallback) { + canceled = true; + immediateCancellationCallback.run(); + super.cancel(null); + } + + /** + * As timer is canceled immediately there is no need for waiting after + * cancellation decision was sent. + */ + @Override + public boolean isDone() { + return state == DecisionState.COMPLETED || canceled; + } + + private Decision createCancelTimerDecision() { + CancelTimerDecisionAttributes tryCancel = new CancelTimerDecisionAttributes(); + tryCancel.setTimerId(attributes.getTimerId()); + Decision decision = new Decision(); + decision.setCancelTimerDecisionAttributes(tryCancel); + decision.setDecisionType(DecisionType.CancelTimer.toString()); + return decision; + } + + private Decision createStartTimerDecision() { + Decision decision = new Decision(); + decision.setStartTimerDecisionAttributes(attributes); + decision.setDecisionType(DecisionType.StartTimer.toString()); + return decision; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/WorkflowClockImpl.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/WorkflowClockImpl.java new file mode 100644 index 000000000000..c31518166918 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/WorkflowClockImpl.java @@ -0,0 +1,178 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CancellationException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.amazonaws.services.simpleworkflow.flow.StartTimerFailedException; +import com.amazonaws.services.simpleworkflow.flow.WorkflowClock; +import com.amazonaws.services.simpleworkflow.flow.common.FlowHelpers; +import com.amazonaws.services.simpleworkflow.flow.core.ExternalTask; +import com.amazonaws.services.simpleworkflow.flow.core.ExternalTaskCancellationHandler; +import com.amazonaws.services.simpleworkflow.flow.core.ExternalTaskCompletionHandle; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.model.HistoryEvent; +import com.amazonaws.services.simpleworkflow.model.StartTimerDecisionAttributes; +import com.amazonaws.services.simpleworkflow.model.StartTimerFailedEventAttributes; +import com.amazonaws.services.simpleworkflow.model.TimerCanceledEventAttributes; +import com.amazonaws.services.simpleworkflow.model.TimerFiredEventAttributes; + +class WorkflowClockImpl implements WorkflowClock { + + private static final Log log = LogFactory.getLog(WorkflowClockImpl.class); + + private final class TimerCancellationHandler implements ExternalTaskCancellationHandler { + + private final String timerId; + + private TimerCancellationHandler(String timerId) { + this.timerId = timerId; + } + + @Override + public void handleCancellation(Throwable cause) { + decisions.cancelTimer(timerId, new Runnable() { + + @Override + public void run() { + OpenRequestInfo scheduled = scheduledTimers.remove(timerId); + ExternalTaskCompletionHandle context = scheduled.getCompletionHandle(); + context.complete(); + } + }); + } + } + + private final DecisionsHelper decisions; + + private final Map> scheduledTimers = new HashMap>(); + + private long replayCurrentTimeMilliseconds; + + private boolean replaying = true; + + WorkflowClockImpl(DecisionsHelper decisions) { + this.decisions = decisions; + } + + @Override + public long currentTimeMillis() { + return replayCurrentTimeMilliseconds; + } + + void setReplayCurrentTimeMilliseconds(long replayCurrentTimeMilliseconds) { + this.replayCurrentTimeMilliseconds = replayCurrentTimeMilliseconds; + } + + @Override + public boolean isReplaying() { + return replaying; + } + + void setReplaying(boolean replaying) { + this.replaying = replaying; + } + + @Override + public Promise createTimer(long delaySeconds) { + return createTimer(delaySeconds, null); + } + + @Override + public Promise createTimer(final long delaySeconds, final T userContext) { + if (delaySeconds < 0) { + throw new IllegalArgumentException("Negative delaySeconds: " + delaySeconds); + } + if (delaySeconds == 0) { + return Promise.asPromise(userContext); + } + final OpenRequestInfo context = new OpenRequestInfo(userContext); + final StartTimerDecisionAttributes timer = new StartTimerDecisionAttributes(); + timer.setStartToFireTimeout(FlowHelpers.secondsToDuration(delaySeconds)); + final String timerId = decisions.getNextId(); + timer.setTimerId(timerId); + String taskName = "timerId=" + timer.getTimerId() + ", delaySeconds=" + timer.getStartToFireTimeout(); + new ExternalTask() { + + @Override + protected ExternalTaskCancellationHandler doExecute(ExternalTaskCompletionHandle handle) throws Throwable { + + decisions.startTimer(timer, userContext); + context.setCompletionHandle(handle); + scheduledTimers.put(timerId, context); + return new TimerCancellationHandler(timerId); + } + }.setName(taskName); + context.setResultDescription("createTimer " + taskName); + return context.getResult(); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + void handleTimerFired(Long eventId, TimerFiredEventAttributes attributes) { + String timerId = attributes.getTimerId(); + if (decisions.handleTimerClosed(timerId)) { + OpenRequestInfo scheduled = scheduledTimers.remove(timerId); + if (scheduled != null) { + ExternalTaskCompletionHandle completionHandle = scheduled.getCompletionHandle(); + scheduled.getResult().set(scheduled.getUserContext()); + completionHandle.complete(); + } + } + else { + log.debug("handleTimerFired not complete"); + } + } + + @SuppressWarnings({ "rawtypes" }) + void handleStartTimerFailed(HistoryEvent event) { + StartTimerFailedEventAttributes attributes = event.getStartTimerFailedEventAttributes(); + String timerId = attributes.getTimerId(); + if (decisions.handleStartTimerFailed(event)) { + OpenRequestInfo scheduled = scheduledTimers.remove(timerId); + if (scheduled != null) { + ExternalTaskCompletionHandle completionHandle = scheduled.getCompletionHandle(); + Object createTimerUserContext = scheduled.getUserContext(); + String cause = attributes.getCause(); + Throwable failure = new StartTimerFailedException(event.getEventId(), timerId, createTimerUserContext, cause); + completionHandle.fail(failure); + } + } + else { + log.debug("handleStartTimerFailed not complete"); + } + } + + void handleTimerCanceled(HistoryEvent event) { + TimerCanceledEventAttributes attributes = event.getTimerCanceledEventAttributes(); + String timerId = attributes.getTimerId(); + if (decisions.handleTimerCanceled(event)) { + OpenRequestInfo scheduled = scheduledTimers.remove(timerId); + if (scheduled != null) { + ExternalTaskCompletionHandle completionHandle = scheduled.getCompletionHandle(); + CancellationException exception = new CancellationException(); + completionHandle.fail(exception); + } + } + else { + log.debug("handleTimerCanceled not complete"); + } + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/WorkfowContextImpl.java b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/WorkfowContextImpl.java new file mode 100644 index 000000000000..021c72b31755 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/flow/worker/WorkfowContextImpl.java @@ -0,0 +1,63 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.worker; + +import com.amazonaws.services.simpleworkflow.flow.WorkflowContext; +import com.amazonaws.services.simpleworkflow.flow.generic.ContinueAsNewWorkflowExecutionParameters; +import com.amazonaws.services.simpleworkflow.model.DecisionTask; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowType; + + +class WorkfowContextImpl implements WorkflowContext { + + private final DecisionTask decisionTask; + private boolean cancelRequested; + private ContinueAsNewWorkflowExecutionParameters continueAsNewOnCompletion; + + public WorkfowContextImpl(DecisionTask decisionTask) { + this.decisionTask = decisionTask; + } + + @Override + public WorkflowExecution getWorkflowExecution() { + return decisionTask.getWorkflowExecution(); + } + + @Override + public WorkflowType getWorkflowType() { + return decisionTask.getWorkflowType(); + } + + @Override + public boolean isCancelRequested() { + return cancelRequested; + } + + void setCancelRequested(boolean flag) { + cancelRequested = flag; + } + + @Override + public ContinueAsNewWorkflowExecutionParameters getContinueAsNewOnCompletion() { + return continueAsNewOnCompletion; + } + + @Override + public void setContinueAsNewOnCompletion(ContinueAsNewWorkflowExecutionParameters continueParameters) { + this.continueAsNewOnCompletion = continueParameters; + } + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTask.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTask.java new file mode 100644 index 000000000000..8e0ab2efa498 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTask.java @@ -0,0 +1,389 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Unit of work sent to an activity worker. + *

+ */ +public class ActivityTask { + + /** + * The opaque string used as a handle on the task. This token is used by + * workers to communicate progress and response information back to the + * system about the task. + *

+ * Constraints:
+ * Length: 1 - 1024
+ */ + private String taskToken; + + /** + * The unique ID of the task. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String activityId; + + /** + * The id of the ActivityTaskStarted event recorded in the + * history. + */ + private Long startedEventId; + + /** + * The workflow execution that started this activity task. + */ + private WorkflowExecution workflowExecution; + + /** + * The type of this activity task. + */ + private ActivityType activityType; + + /** + * The inputs provided when the activity task was scheduled. The form of + * the input is user defined and should be meaningful to the activity + * implementation. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String input; + + /** + * The opaque string used as a handle on the task. This token is used by + * workers to communicate progress and response information back to the + * system about the task. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @return The opaque string used as a handle on the task. This token is used by + * workers to communicate progress and response information back to the + * system about the task. + */ + public String getTaskToken() { + return taskToken; + } + + /** + * The opaque string used as a handle on the task. This token is used by + * workers to communicate progress and response information back to the + * system about the task. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @param taskToken The opaque string used as a handle on the task. This token is used by + * workers to communicate progress and response information back to the + * system about the task. + */ + public void setTaskToken(String taskToken) { + this.taskToken = taskToken; + } + + /** + * The opaque string used as a handle on the task. This token is used by + * workers to communicate progress and response information back to the + * system about the task. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @param taskToken The opaque string used as a handle on the task. This token is used by + * workers to communicate progress and response information back to the + * system about the task. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTask withTaskToken(String taskToken) { + this.taskToken = taskToken; + return this; + } + + + /** + * The unique ID of the task. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The unique ID of the task. + */ + public String getActivityId() { + return activityId; + } + + /** + * The unique ID of the task. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param activityId The unique ID of the task. + */ + public void setActivityId(String activityId) { + this.activityId = activityId; + } + + /** + * The unique ID of the task. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param activityId The unique ID of the task. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTask withActivityId(String activityId) { + this.activityId = activityId; + return this; + } + + + /** + * The id of the ActivityTaskStarted event recorded in the + * history. + * + * @return The id of the ActivityTaskStarted event recorded in the + * history. + */ + public Long getStartedEventId() { + return startedEventId; + } + + /** + * The id of the ActivityTaskStarted event recorded in the + * history. + * + * @param startedEventId The id of the ActivityTaskStarted event recorded in the + * history. + */ + public void setStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + } + + /** + * The id of the ActivityTaskStarted event recorded in the + * history. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startedEventId The id of the ActivityTaskStarted event recorded in the + * history. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTask withStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + return this; + } + + + /** + * The workflow execution that started this activity task. + * + * @return The workflow execution that started this activity task. + */ + public WorkflowExecution getWorkflowExecution() { + return workflowExecution; + } + + /** + * The workflow execution that started this activity task. + * + * @param workflowExecution The workflow execution that started this activity task. + */ + public void setWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + } + + /** + * The workflow execution that started this activity task. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowExecution The workflow execution that started this activity task. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTask withWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + return this; + } + + + /** + * The type of this activity task. + * + * @return The type of this activity task. + */ + public ActivityType getActivityType() { + return activityType; + } + + /** + * The type of this activity task. + * + * @param activityType The type of this activity task. + */ + public void setActivityType(ActivityType activityType) { + this.activityType = activityType; + } + + /** + * The type of this activity task. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param activityType The type of this activity task. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTask withActivityType(ActivityType activityType) { + this.activityType = activityType; + return this; + } + + + /** + * The inputs provided when the activity task was scheduled. The form of + * the input is user defined and should be meaningful to the activity + * implementation. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The inputs provided when the activity task was scheduled. The form of + * the input is user defined and should be meaningful to the activity + * implementation. + */ + public String getInput() { + return input; + } + + /** + * The inputs provided when the activity task was scheduled. The form of + * the input is user defined and should be meaningful to the activity + * implementation. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input The inputs provided when the activity task was scheduled. The form of + * the input is user defined and should be meaningful to the activity + * implementation. + */ + public void setInput(String input) { + this.input = input; + } + + /** + * The inputs provided when the activity task was scheduled. The form of + * the input is user defined and should be meaningful to the activity + * implementation. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input The inputs provided when the activity task was scheduled. The form of + * the input is user defined and should be meaningful to the activity + * implementation. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTask withInput(String input) { + this.input = input; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (taskToken != null) sb.append("TaskToken: " + taskToken + ", "); + if (activityId != null) sb.append("ActivityId: " + activityId + ", "); + if (startedEventId != null) sb.append("StartedEventId: " + startedEventId + ", "); + if (workflowExecution != null) sb.append("WorkflowExecution: " + workflowExecution + ", "); + if (activityType != null) sb.append("ActivityType: " + activityType + ", "); + if (input != null) sb.append("Input: " + input + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTaskToken() == null) ? 0 : getTaskToken().hashCode()); + hashCode = prime * hashCode + ((getActivityId() == null) ? 0 : getActivityId().hashCode()); + hashCode = prime * hashCode + ((getStartedEventId() == null) ? 0 : getStartedEventId().hashCode()); + hashCode = prime * hashCode + ((getWorkflowExecution() == null) ? 0 : getWorkflowExecution().hashCode()); + hashCode = prime * hashCode + ((getActivityType() == null) ? 0 : getActivityType().hashCode()); + hashCode = prime * hashCode + ((getInput() == null) ? 0 : getInput().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ActivityTask == false) return false; + ActivityTask other = (ActivityTask)obj; + + if (other.getTaskToken() == null ^ this.getTaskToken() == null) return false; + if (other.getTaskToken() != null && other.getTaskToken().equals(this.getTaskToken()) == false) return false; + if (other.getActivityId() == null ^ this.getActivityId() == null) return false; + if (other.getActivityId() != null && other.getActivityId().equals(this.getActivityId()) == false) return false; + if (other.getStartedEventId() == null ^ this.getStartedEventId() == null) return false; + if (other.getStartedEventId() != null && other.getStartedEventId().equals(this.getStartedEventId()) == false) return false; + if (other.getWorkflowExecution() == null ^ this.getWorkflowExecution() == null) return false; + if (other.getWorkflowExecution() != null && other.getWorkflowExecution().equals(this.getWorkflowExecution()) == false) return false; + if (other.getActivityType() == null ^ this.getActivityType() == null) return false; + if (other.getActivityType() != null && other.getActivityType().equals(this.getActivityType()) == false) return false; + if (other.getInput() == null ^ this.getInput() == null) return false; + if (other.getInput() != null && other.getInput().equals(this.getInput()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskCancelRequestedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskCancelRequestedEventAttributes.java new file mode 100644 index 000000000000..79a9d4327da2 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskCancelRequestedEventAttributes.java @@ -0,0 +1,187 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the ActivityTaskCancelRequested + * event. + *

+ */ +public class ActivityTaskCancelRequestedEventAttributes { + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelActivityTask decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + private Long decisionTaskCompletedEventId; + + /** + * The unique ID of the task. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String activityId; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelActivityTask decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelActivityTask decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelActivityTask decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelActivityTask decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelActivityTask decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelActivityTask decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskCancelRequestedEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * The unique ID of the task. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The unique ID of the task. + */ + public String getActivityId() { + return activityId; + } + + /** + * The unique ID of the task. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param activityId The unique ID of the task. + */ + public void setActivityId(String activityId) { + this.activityId = activityId; + } + + /** + * The unique ID of the task. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param activityId The unique ID of the task. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskCancelRequestedEventAttributes withActivityId(String activityId) { + this.activityId = activityId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + if (activityId != null) sb.append("ActivityId: " + activityId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + hashCode = prime * hashCode + ((getActivityId() == null) ? 0 : getActivityId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ActivityTaskCancelRequestedEventAttributes == false) return false; + ActivityTaskCancelRequestedEventAttributes other = (ActivityTaskCancelRequestedEventAttributes)obj; + + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + if (other.getActivityId() == null ^ this.getActivityId() == null) return false; + if (other.getActivityId() != null && other.getActivityId().equals(this.getActivityId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskCanceledEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskCanceledEventAttributes.java new file mode 100644 index 000000000000..5dcf1241b729 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskCanceledEventAttributes.java @@ -0,0 +1,307 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the ActivityTaskCanceled event. + *

+ */ +public class ActivityTaskCanceledEventAttributes { + + /** + * Details of the cancellation (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String details; + + /** + * The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + private Long scheduledEventId; + + /** + * The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + private Long startedEventId; + + /** + * If set, contains the Id of the last + * ActivityTaskCancelRequested event recorded for this + * activity task. This information can be useful for diagnosing problems + * by tracing back the chain of events leading up to this event. + */ + private Long latestCancelRequestedEventId; + + /** + * Details of the cancellation (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Details of the cancellation (if any). + */ + public String getDetails() { + return details; + } + + /** + * Details of the cancellation (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details Details of the cancellation (if any). + */ + public void setDetails(String details) { + this.details = details; + } + + /** + * Details of the cancellation (if any). + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details Details of the cancellation (if any). + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskCanceledEventAttributes withDetails(String details) { + this.details = details; + return this; + } + + + /** + * The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @return The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + public Long getScheduledEventId() { + return scheduledEventId; + } + + /** + * The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @param scheduledEventId The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + public void setScheduledEventId(Long scheduledEventId) { + this.scheduledEventId = scheduledEventId; + } + + /** + * The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param scheduledEventId The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskCanceledEventAttributes withScheduledEventId(Long scheduledEventId) { + this.scheduledEventId = scheduledEventId; + return this; + } + + + /** + * The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @return The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + public Long getStartedEventId() { + return startedEventId; + } + + /** + * The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @param startedEventId The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + public void setStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + } + + /** + * The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startedEventId The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskCanceledEventAttributes withStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + return this; + } + + + /** + * If set, contains the Id of the last + * ActivityTaskCancelRequested event recorded for this + * activity task. This information can be useful for diagnosing problems + * by tracing back the chain of events leading up to this event. + * + * @return If set, contains the Id of the last + * ActivityTaskCancelRequested event recorded for this + * activity task. This information can be useful for diagnosing problems + * by tracing back the chain of events leading up to this event. + */ + public Long getLatestCancelRequestedEventId() { + return latestCancelRequestedEventId; + } + + /** + * If set, contains the Id of the last + * ActivityTaskCancelRequested event recorded for this + * activity task. This information can be useful for diagnosing problems + * by tracing back the chain of events leading up to this event. + * + * @param latestCancelRequestedEventId If set, contains the Id of the last + * ActivityTaskCancelRequested event recorded for this + * activity task. This information can be useful for diagnosing problems + * by tracing back the chain of events leading up to this event. + */ + public void setLatestCancelRequestedEventId(Long latestCancelRequestedEventId) { + this.latestCancelRequestedEventId = latestCancelRequestedEventId; + } + + /** + * If set, contains the Id of the last + * ActivityTaskCancelRequested event recorded for this + * activity task. This information can be useful for diagnosing problems + * by tracing back the chain of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param latestCancelRequestedEventId If set, contains the Id of the last + * ActivityTaskCancelRequested event recorded for this + * activity task. This information can be useful for diagnosing problems + * by tracing back the chain of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskCanceledEventAttributes withLatestCancelRequestedEventId(Long latestCancelRequestedEventId) { + this.latestCancelRequestedEventId = latestCancelRequestedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (details != null) sb.append("Details: " + details + ", "); + if (scheduledEventId != null) sb.append("ScheduledEventId: " + scheduledEventId + ", "); + if (startedEventId != null) sb.append("StartedEventId: " + startedEventId + ", "); + if (latestCancelRequestedEventId != null) sb.append("LatestCancelRequestedEventId: " + latestCancelRequestedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDetails() == null) ? 0 : getDetails().hashCode()); + hashCode = prime * hashCode + ((getScheduledEventId() == null) ? 0 : getScheduledEventId().hashCode()); + hashCode = prime * hashCode + ((getStartedEventId() == null) ? 0 : getStartedEventId().hashCode()); + hashCode = prime * hashCode + ((getLatestCancelRequestedEventId() == null) ? 0 : getLatestCancelRequestedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ActivityTaskCanceledEventAttributes == false) return false; + ActivityTaskCanceledEventAttributes other = (ActivityTaskCanceledEventAttributes)obj; + + if (other.getDetails() == null ^ this.getDetails() == null) return false; + if (other.getDetails() != null && other.getDetails().equals(this.getDetails()) == false) return false; + if (other.getScheduledEventId() == null ^ this.getScheduledEventId() == null) return false; + if (other.getScheduledEventId() != null && other.getScheduledEventId().equals(this.getScheduledEventId()) == false) return false; + if (other.getStartedEventId() == null ^ this.getStartedEventId() == null) return false; + if (other.getStartedEventId() != null && other.getStartedEventId().equals(this.getStartedEventId()) == false) return false; + if (other.getLatestCancelRequestedEventId() == null ^ this.getLatestCancelRequestedEventId() == null) return false; + if (other.getLatestCancelRequestedEventId() != null && other.getLatestCancelRequestedEventId().equals(this.getLatestCancelRequestedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskCompletedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskCompletedEventAttributes.java new file mode 100644 index 000000000000..9469ba0a9e27 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskCompletedEventAttributes.java @@ -0,0 +1,243 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the ActivityTaskCompleted event. + *

+ */ +public class ActivityTaskCompletedEventAttributes { + + /** + * The results of the activity task (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String result; + + /** + * The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + private Long scheduledEventId; + + /** + * The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + private Long startedEventId; + + /** + * The results of the activity task (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The results of the activity task (if any). + */ + public String getResult() { + return result; + } + + /** + * The results of the activity task (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param result The results of the activity task (if any). + */ + public void setResult(String result) { + this.result = result; + } + + /** + * The results of the activity task (if any). + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param result The results of the activity task (if any). + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskCompletedEventAttributes withResult(String result) { + this.result = result; + return this; + } + + + /** + * The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @return The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + public Long getScheduledEventId() { + return scheduledEventId; + } + + /** + * The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @param scheduledEventId The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + public void setScheduledEventId(Long scheduledEventId) { + this.scheduledEventId = scheduledEventId; + } + + /** + * The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param scheduledEventId The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskCompletedEventAttributes withScheduledEventId(Long scheduledEventId) { + this.scheduledEventId = scheduledEventId; + return this; + } + + + /** + * The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @return The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + public Long getStartedEventId() { + return startedEventId; + } + + /** + * The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @param startedEventId The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + public void setStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + } + + /** + * The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startedEventId The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskCompletedEventAttributes withStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (result != null) sb.append("Result: " + result + ", "); + if (scheduledEventId != null) sb.append("ScheduledEventId: " + scheduledEventId + ", "); + if (startedEventId != null) sb.append("StartedEventId: " + startedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getResult() == null) ? 0 : getResult().hashCode()); + hashCode = prime * hashCode + ((getScheduledEventId() == null) ? 0 : getScheduledEventId().hashCode()); + hashCode = prime * hashCode + ((getStartedEventId() == null) ? 0 : getStartedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ActivityTaskCompletedEventAttributes == false) return false; + ActivityTaskCompletedEventAttributes other = (ActivityTaskCompletedEventAttributes)obj; + + if (other.getResult() == null ^ this.getResult() == null) return false; + if (other.getResult() != null && other.getResult().equals(this.getResult()) == false) return false; + if (other.getScheduledEventId() == null ^ this.getScheduledEventId() == null) return false; + if (other.getScheduledEventId() != null && other.getScheduledEventId().equals(this.getScheduledEventId()) == false) return false; + if (other.getStartedEventId() == null ^ this.getStartedEventId() == null) return false; + if (other.getStartedEventId() != null && other.getStartedEventId().equals(this.getStartedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskFailedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskFailedEventAttributes.java new file mode 100644 index 000000000000..4c5a6a6458b5 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskFailedEventAttributes.java @@ -0,0 +1,298 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the ActivityTaskFailed event. + *

+ */ +public class ActivityTaskFailedEventAttributes { + + /** + * The reason provided for the failure (if any). + *

+ * Constraints:
+ * Length: 0 - 256
+ */ + private String reason; + + /** + * The details of the failure (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String details; + + /** + * The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + private Long scheduledEventId; + + /** + * The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + private Long startedEventId; + + /** + * The reason provided for the failure (if any). + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @return The reason provided for the failure (if any). + */ + public String getReason() { + return reason; + } + + /** + * The reason provided for the failure (if any). + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param reason The reason provided for the failure (if any). + */ + public void setReason(String reason) { + this.reason = reason; + } + + /** + * The reason provided for the failure (if any). + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param reason The reason provided for the failure (if any). + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskFailedEventAttributes withReason(String reason) { + this.reason = reason; + return this; + } + + + /** + * The details of the failure (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The details of the failure (if any). + */ + public String getDetails() { + return details; + } + + /** + * The details of the failure (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details The details of the failure (if any). + */ + public void setDetails(String details) { + this.details = details; + } + + /** + * The details of the failure (if any). + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details The details of the failure (if any). + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskFailedEventAttributes withDetails(String details) { + this.details = details; + return this; + } + + + /** + * The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @return The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + public Long getScheduledEventId() { + return scheduledEventId; + } + + /** + * The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @param scheduledEventId The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + public void setScheduledEventId(Long scheduledEventId) { + this.scheduledEventId = scheduledEventId; + } + + /** + * The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param scheduledEventId The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskFailedEventAttributes withScheduledEventId(Long scheduledEventId) { + this.scheduledEventId = scheduledEventId; + return this; + } + + + /** + * The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @return The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + public Long getStartedEventId() { + return startedEventId; + } + + /** + * The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @param startedEventId The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + public void setStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + } + + /** + * The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startedEventId The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskFailedEventAttributes withStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (reason != null) sb.append("Reason: " + reason + ", "); + if (details != null) sb.append("Details: " + details + ", "); + if (scheduledEventId != null) sb.append("ScheduledEventId: " + scheduledEventId + ", "); + if (startedEventId != null) sb.append("StartedEventId: " + startedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getReason() == null) ? 0 : getReason().hashCode()); + hashCode = prime * hashCode + ((getDetails() == null) ? 0 : getDetails().hashCode()); + hashCode = prime * hashCode + ((getScheduledEventId() == null) ? 0 : getScheduledEventId().hashCode()); + hashCode = prime * hashCode + ((getStartedEventId() == null) ? 0 : getStartedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ActivityTaskFailedEventAttributes == false) return false; + ActivityTaskFailedEventAttributes other = (ActivityTaskFailedEventAttributes)obj; + + if (other.getReason() == null ^ this.getReason() == null) return false; + if (other.getReason() != null && other.getReason().equals(this.getReason()) == false) return false; + if (other.getDetails() == null ^ this.getDetails() == null) return false; + if (other.getDetails() != null && other.getDetails().equals(this.getDetails()) == false) return false; + if (other.getScheduledEventId() == null ^ this.getScheduledEventId() == null) return false; + if (other.getScheduledEventId() != null && other.getScheduledEventId().equals(this.getScheduledEventId()) == false) return false; + if (other.getStartedEventId() == null ^ this.getStartedEventId() == null) return false; + if (other.getStartedEventId() != null && other.getStartedEventId().equals(this.getStartedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskScheduledEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskScheduledEventAttributes.java new file mode 100644 index 000000000000..75081f2d8b08 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskScheduledEventAttributes.java @@ -0,0 +1,644 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the ActivityTaskScheduled event. + *

+ */ +public class ActivityTaskScheduledEventAttributes { + + /** + * The type of the activity task. + */ + private ActivityType activityType; + + /** + * The unique id of the activity task. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String activityId; + + /** + * The input provided to the activity task. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String input; + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the activity. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String control; + + /** + * The maximum amount of time the activity task can wait to be assigned + * to a worker. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String scheduleToStartTimeout; + + /** + * The maximum amount of time for this activity task. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String scheduleToCloseTimeout; + + /** + * The maximum amount of time a worker may take to process the activity + * task. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String startToCloseTimeout; + + /** + * The task list in which the activity task has been scheduled. + */ + private TaskList taskList; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision that resulted in the scheduling of this activity task. + * This information can be useful for diagnosing problems by tracing back + * the chain of events leading up to this event. + */ + private Long decisionTaskCompletedEventId; + + /** + * The maximum time before which the worker processing this task must + * report progress by calling RecordActivityTaskHeartbeat. If the + * timeout is exceeded, the activity task is automatically timed out. If + * the worker subsequently attempts to record a heartbeat or return a + * result, it will be ignored. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String heartbeatTimeout; + + /** + * The type of the activity task. + * + * @return The type of the activity task. + */ + public ActivityType getActivityType() { + return activityType; + } + + /** + * The type of the activity task. + * + * @param activityType The type of the activity task. + */ + public void setActivityType(ActivityType activityType) { + this.activityType = activityType; + } + + /** + * The type of the activity task. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param activityType The type of the activity task. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskScheduledEventAttributes withActivityType(ActivityType activityType) { + this.activityType = activityType; + return this; + } + + + /** + * The unique id of the activity task. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The unique id of the activity task. + */ + public String getActivityId() { + return activityId; + } + + /** + * The unique id of the activity task. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param activityId The unique id of the activity task. + */ + public void setActivityId(String activityId) { + this.activityId = activityId; + } + + /** + * The unique id of the activity task. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param activityId The unique id of the activity task. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskScheduledEventAttributes withActivityId(String activityId) { + this.activityId = activityId; + return this; + } + + + /** + * The input provided to the activity task. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The input provided to the activity task. + */ + public String getInput() { + return input; + } + + /** + * The input provided to the activity task. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input The input provided to the activity task. + */ + public void setInput(String input) { + this.input = input; + } + + /** + * The input provided to the activity task. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input The input provided to the activity task. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskScheduledEventAttributes withInput(String input) { + this.input = input; + return this; + } + + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the activity. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the activity. + */ + public String getControl() { + return control; + } + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the activity. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the activity. + */ + public void setControl(String control) { + this.control = control; + } + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the activity. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the activity. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskScheduledEventAttributes withControl(String control) { + this.control = control; + return this; + } + + + /** + * The maximum amount of time the activity task can wait to be assigned + * to a worker. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return The maximum amount of time the activity task can wait to be assigned + * to a worker. + */ + public String getScheduleToStartTimeout() { + return scheduleToStartTimeout; + } + + /** + * The maximum amount of time the activity task can wait to be assigned + * to a worker. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param scheduleToStartTimeout The maximum amount of time the activity task can wait to be assigned + * to a worker. + */ + public void setScheduleToStartTimeout(String scheduleToStartTimeout) { + this.scheduleToStartTimeout = scheduleToStartTimeout; + } + + /** + * The maximum amount of time the activity task can wait to be assigned + * to a worker. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param scheduleToStartTimeout The maximum amount of time the activity task can wait to be assigned + * to a worker. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskScheduledEventAttributes withScheduleToStartTimeout(String scheduleToStartTimeout) { + this.scheduleToStartTimeout = scheduleToStartTimeout; + return this; + } + + + /** + * The maximum amount of time for this activity task. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return The maximum amount of time for this activity task. + */ + public String getScheduleToCloseTimeout() { + return scheduleToCloseTimeout; + } + + /** + * The maximum amount of time for this activity task. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param scheduleToCloseTimeout The maximum amount of time for this activity task. + */ + public void setScheduleToCloseTimeout(String scheduleToCloseTimeout) { + this.scheduleToCloseTimeout = scheduleToCloseTimeout; + } + + /** + * The maximum amount of time for this activity task. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param scheduleToCloseTimeout The maximum amount of time for this activity task. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskScheduledEventAttributes withScheduleToCloseTimeout(String scheduleToCloseTimeout) { + this.scheduleToCloseTimeout = scheduleToCloseTimeout; + return this; + } + + + /** + * The maximum amount of time a worker may take to process the activity + * task. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return The maximum amount of time a worker may take to process the activity + * task. + */ + public String getStartToCloseTimeout() { + return startToCloseTimeout; + } + + /** + * The maximum amount of time a worker may take to process the activity + * task. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param startToCloseTimeout The maximum amount of time a worker may take to process the activity + * task. + */ + public void setStartToCloseTimeout(String startToCloseTimeout) { + this.startToCloseTimeout = startToCloseTimeout; + } + + /** + * The maximum amount of time a worker may take to process the activity + * task. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param startToCloseTimeout The maximum amount of time a worker may take to process the activity + * task. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskScheduledEventAttributes withStartToCloseTimeout(String startToCloseTimeout) { + this.startToCloseTimeout = startToCloseTimeout; + return this; + } + + + /** + * The task list in which the activity task has been scheduled. + * + * @return The task list in which the activity task has been scheduled. + */ + public TaskList getTaskList() { + return taskList; + } + + /** + * The task list in which the activity task has been scheduled. + * + * @param taskList The task list in which the activity task has been scheduled. + */ + public void setTaskList(TaskList taskList) { + this.taskList = taskList; + } + + /** + * The task list in which the activity task has been scheduled. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param taskList The task list in which the activity task has been scheduled. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskScheduledEventAttributes withTaskList(TaskList taskList) { + this.taskList = taskList; + return this; + } + + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision that resulted in the scheduling of this activity task. + * This information can be useful for diagnosing problems by tracing back + * the chain of events leading up to this event. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision that resulted in the scheduling of this activity task. + * This information can be useful for diagnosing problems by tracing back + * the chain of events leading up to this event. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision that resulted in the scheduling of this activity task. + * This information can be useful for diagnosing problems by tracing back + * the chain of events leading up to this event. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision that resulted in the scheduling of this activity task. + * This information can be useful for diagnosing problems by tracing back + * the chain of events leading up to this event. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision that resulted in the scheduling of this activity task. + * This information can be useful for diagnosing problems by tracing back + * the chain of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision that resulted in the scheduling of this activity task. + * This information can be useful for diagnosing problems by tracing back + * the chain of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskScheduledEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * The maximum time before which the worker processing this task must + * report progress by calling RecordActivityTaskHeartbeat. If the + * timeout is exceeded, the activity task is automatically timed out. If + * the worker subsequently attempts to record a heartbeat or return a + * result, it will be ignored. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return The maximum time before which the worker processing this task must + * report progress by calling RecordActivityTaskHeartbeat. If the + * timeout is exceeded, the activity task is automatically timed out. If + * the worker subsequently attempts to record a heartbeat or return a + * result, it will be ignored. + */ + public String getHeartbeatTimeout() { + return heartbeatTimeout; + } + + /** + * The maximum time before which the worker processing this task must + * report progress by calling RecordActivityTaskHeartbeat. If the + * timeout is exceeded, the activity task is automatically timed out. If + * the worker subsequently attempts to record a heartbeat or return a + * result, it will be ignored. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param heartbeatTimeout The maximum time before which the worker processing this task must + * report progress by calling RecordActivityTaskHeartbeat. If the + * timeout is exceeded, the activity task is automatically timed out. If + * the worker subsequently attempts to record a heartbeat or return a + * result, it will be ignored. + */ + public void setHeartbeatTimeout(String heartbeatTimeout) { + this.heartbeatTimeout = heartbeatTimeout; + } + + /** + * The maximum time before which the worker processing this task must + * report progress by calling RecordActivityTaskHeartbeat. If the + * timeout is exceeded, the activity task is automatically timed out. If + * the worker subsequently attempts to record a heartbeat or return a + * result, it will be ignored. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param heartbeatTimeout The maximum time before which the worker processing this task must + * report progress by calling RecordActivityTaskHeartbeat. If the + * timeout is exceeded, the activity task is automatically timed out. If + * the worker subsequently attempts to record a heartbeat or return a + * result, it will be ignored. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskScheduledEventAttributes withHeartbeatTimeout(String heartbeatTimeout) { + this.heartbeatTimeout = heartbeatTimeout; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (activityType != null) sb.append("ActivityType: " + activityType + ", "); + if (activityId != null) sb.append("ActivityId: " + activityId + ", "); + if (input != null) sb.append("Input: " + input + ", "); + if (control != null) sb.append("Control: " + control + ", "); + if (scheduleToStartTimeout != null) sb.append("ScheduleToStartTimeout: " + scheduleToStartTimeout + ", "); + if (scheduleToCloseTimeout != null) sb.append("ScheduleToCloseTimeout: " + scheduleToCloseTimeout + ", "); + if (startToCloseTimeout != null) sb.append("StartToCloseTimeout: " + startToCloseTimeout + ", "); + if (taskList != null) sb.append("TaskList: " + taskList + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + if (heartbeatTimeout != null) sb.append("HeartbeatTimeout: " + heartbeatTimeout + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getActivityType() == null) ? 0 : getActivityType().hashCode()); + hashCode = prime * hashCode + ((getActivityId() == null) ? 0 : getActivityId().hashCode()); + hashCode = prime * hashCode + ((getInput() == null) ? 0 : getInput().hashCode()); + hashCode = prime * hashCode + ((getControl() == null) ? 0 : getControl().hashCode()); + hashCode = prime * hashCode + ((getScheduleToStartTimeout() == null) ? 0 : getScheduleToStartTimeout().hashCode()); + hashCode = prime * hashCode + ((getScheduleToCloseTimeout() == null) ? 0 : getScheduleToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getStartToCloseTimeout() == null) ? 0 : getStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getTaskList() == null) ? 0 : getTaskList().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + hashCode = prime * hashCode + ((getHeartbeatTimeout() == null) ? 0 : getHeartbeatTimeout().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ActivityTaskScheduledEventAttributes == false) return false; + ActivityTaskScheduledEventAttributes other = (ActivityTaskScheduledEventAttributes)obj; + + if (other.getActivityType() == null ^ this.getActivityType() == null) return false; + if (other.getActivityType() != null && other.getActivityType().equals(this.getActivityType()) == false) return false; + if (other.getActivityId() == null ^ this.getActivityId() == null) return false; + if (other.getActivityId() != null && other.getActivityId().equals(this.getActivityId()) == false) return false; + if (other.getInput() == null ^ this.getInput() == null) return false; + if (other.getInput() != null && other.getInput().equals(this.getInput()) == false) return false; + if (other.getControl() == null ^ this.getControl() == null) return false; + if (other.getControl() != null && other.getControl().equals(this.getControl()) == false) return false; + if (other.getScheduleToStartTimeout() == null ^ this.getScheduleToStartTimeout() == null) return false; + if (other.getScheduleToStartTimeout() != null && other.getScheduleToStartTimeout().equals(this.getScheduleToStartTimeout()) == false) return false; + if (other.getScheduleToCloseTimeout() == null ^ this.getScheduleToCloseTimeout() == null) return false; + if (other.getScheduleToCloseTimeout() != null && other.getScheduleToCloseTimeout().equals(this.getScheduleToCloseTimeout()) == false) return false; + if (other.getStartToCloseTimeout() == null ^ this.getStartToCloseTimeout() == null) return false; + if (other.getStartToCloseTimeout() != null && other.getStartToCloseTimeout().equals(this.getStartToCloseTimeout()) == false) return false; + if (other.getTaskList() == null ^ this.getTaskList() == null) return false; + if (other.getTaskList() != null && other.getTaskList().equals(this.getTaskList()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + if (other.getHeartbeatTimeout() == null ^ this.getHeartbeatTimeout() == null) return false; + if (other.getHeartbeatTimeout() != null && other.getHeartbeatTimeout().equals(this.getHeartbeatTimeout()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskStartedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskStartedEventAttributes.java new file mode 100644 index 000000000000..b383181aaa10 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskStartedEventAttributes.java @@ -0,0 +1,193 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the ActivityTaskStarted event. + *

+ */ +public class ActivityTaskStartedEventAttributes { + + /** + * Identity of the worker that was assigned this task. This aids + * diagnostics when problems arise. The form of this identity is user + * defined. + *

+ * Constraints:
+ * Length: 0 - 256
+ */ + private String identity; + + /** + * The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + private Long scheduledEventId; + + /** + * Identity of the worker that was assigned this task. This aids + * diagnostics when problems arise. The form of this identity is user + * defined. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @return Identity of the worker that was assigned this task. This aids + * diagnostics when problems arise. The form of this identity is user + * defined. + */ + public String getIdentity() { + return identity; + } + + /** + * Identity of the worker that was assigned this task. This aids + * diagnostics when problems arise. The form of this identity is user + * defined. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param identity Identity of the worker that was assigned this task. This aids + * diagnostics when problems arise. The form of this identity is user + * defined. + */ + public void setIdentity(String identity) { + this.identity = identity; + } + + /** + * Identity of the worker that was assigned this task. This aids + * diagnostics when problems arise. The form of this identity is user + * defined. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param identity Identity of the worker that was assigned this task. This aids + * diagnostics when problems arise. The form of this identity is user + * defined. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskStartedEventAttributes withIdentity(String identity) { + this.identity = identity; + return this; + } + + + /** + * The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @return The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + public Long getScheduledEventId() { + return scheduledEventId; + } + + /** + * The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @param scheduledEventId The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + public void setScheduledEventId(Long scheduledEventId) { + this.scheduledEventId = scheduledEventId; + } + + /** + * The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param scheduledEventId The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskStartedEventAttributes withScheduledEventId(Long scheduledEventId) { + this.scheduledEventId = scheduledEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (identity != null) sb.append("Identity: " + identity + ", "); + if (scheduledEventId != null) sb.append("ScheduledEventId: " + scheduledEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getIdentity() == null) ? 0 : getIdentity().hashCode()); + hashCode = prime * hashCode + ((getScheduledEventId() == null) ? 0 : getScheduledEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ActivityTaskStartedEventAttributes == false) return false; + ActivityTaskStartedEventAttributes other = (ActivityTaskStartedEventAttributes)obj; + + if (other.getIdentity() == null ^ this.getIdentity() == null) return false; + if (other.getIdentity() != null && other.getIdentity().equals(this.getIdentity()) == false) return false; + if (other.getScheduledEventId() == null ^ this.getScheduledEventId() == null) return false; + if (other.getScheduledEventId() != null && other.getScheduledEventId().equals(this.getScheduledEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskStatus.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskStatus.java new file mode 100644 index 000000000000..4c28cbf321d5 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskStatus.java @@ -0,0 +1,112 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Status information about an activity task. + *

+ */ +public class ActivityTaskStatus { + + /** + * Set to true if cancellation of the task is requested. + */ + private Boolean cancelRequested; + + /** + * Set to true if cancellation of the task is requested. + * + * @return Set to true if cancellation of the task is requested. + */ + public Boolean isCancelRequested() { + return cancelRequested; + } + + /** + * Set to true if cancellation of the task is requested. + * + * @param cancelRequested Set to true if cancellation of the task is requested. + */ + public void setCancelRequested(Boolean cancelRequested) { + this.cancelRequested = cancelRequested; + } + + /** + * Set to true if cancellation of the task is requested. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param cancelRequested Set to true if cancellation of the task is requested. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskStatus withCancelRequested(Boolean cancelRequested) { + this.cancelRequested = cancelRequested; + return this; + } + + + /** + * Set to true if cancellation of the task is requested. + * + * @return Set to true if cancellation of the task is requested. + */ + public Boolean getCancelRequested() { + return cancelRequested; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (cancelRequested != null) sb.append("CancelRequested: " + cancelRequested + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((isCancelRequested() == null) ? 0 : isCancelRequested().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ActivityTaskStatus == false) return false; + ActivityTaskStatus other = (ActivityTaskStatus)obj; + + if (other.isCancelRequested() == null ^ this.isCancelRequested() == null) return false; + if (other.isCancelRequested() != null && other.isCancelRequested().equals(this.isCancelRequested()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskTimedOutEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskTimedOutEventAttributes.java new file mode 100644 index 000000000000..00c0406580ce --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskTimedOutEventAttributes.java @@ -0,0 +1,352 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the ActivityTaskTimedOut event. + *

+ */ +public class ActivityTaskTimedOutEventAttributes { + + /** + * The type of the timeout that caused this event. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE, SCHEDULE_TO_START, SCHEDULE_TO_CLOSE, HEARTBEAT + */ + private String timeoutType; + + /** + * The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + private Long scheduledEventId; + + /** + * The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + private Long startedEventId; + + /** + * Contains the content of the details parameter for the + * last call made by the activity to + * RecordActivityTaskHeartbeat. + *

+ * Constraints:
+ * Length: 0 - 2048
+ */ + private String details; + + /** + * The type of the timeout that caused this event. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE, SCHEDULE_TO_START, SCHEDULE_TO_CLOSE, HEARTBEAT + * + * @return The type of the timeout that caused this event. + * + * @see ActivityTaskTimeoutType + */ + public String getTimeoutType() { + return timeoutType; + } + + /** + * The type of the timeout that caused this event. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE, SCHEDULE_TO_START, SCHEDULE_TO_CLOSE, HEARTBEAT + * + * @param timeoutType The type of the timeout that caused this event. + * + * @see ActivityTaskTimeoutType + */ + public void setTimeoutType(String timeoutType) { + this.timeoutType = timeoutType; + } + + /** + * The type of the timeout that caused this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE, SCHEDULE_TO_START, SCHEDULE_TO_CLOSE, HEARTBEAT + * + * @param timeoutType The type of the timeout that caused this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ActivityTaskTimeoutType + */ + public ActivityTaskTimedOutEventAttributes withTimeoutType(String timeoutType) { + this.timeoutType = timeoutType; + return this; + } + + + /** + * The type of the timeout that caused this event. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE, SCHEDULE_TO_START, SCHEDULE_TO_CLOSE, HEARTBEAT + * + * @param timeoutType The type of the timeout that caused this event. + * + * @see ActivityTaskTimeoutType + */ + public void setTimeoutType(ActivityTaskTimeoutType timeoutType) { + this.timeoutType = timeoutType.toString(); + } + + /** + * The type of the timeout that caused this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE, SCHEDULE_TO_START, SCHEDULE_TO_CLOSE, HEARTBEAT + * + * @param timeoutType The type of the timeout that caused this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ActivityTaskTimeoutType + */ + public ActivityTaskTimedOutEventAttributes withTimeoutType(ActivityTaskTimeoutType timeoutType) { + this.timeoutType = timeoutType.toString(); + return this; + } + + /** + * The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @return The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + public Long getScheduledEventId() { + return scheduledEventId; + } + + /** + * The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @param scheduledEventId The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + public void setScheduledEventId(Long scheduledEventId) { + this.scheduledEventId = scheduledEventId; + } + + /** + * The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param scheduledEventId The id of the ActivityTaskScheduled event that was + * recorded when this activity task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskTimedOutEventAttributes withScheduledEventId(Long scheduledEventId) { + this.scheduledEventId = scheduledEventId; + return this; + } + + + /** + * The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @return The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + public Long getStartedEventId() { + return startedEventId; + } + + /** + * The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @param startedEventId The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + public void setStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + } + + /** + * The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startedEventId The Id of the ActivityTaskStarted event recorded when + * this activity task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskTimedOutEventAttributes withStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + return this; + } + + + /** + * Contains the content of the details parameter for the + * last call made by the activity to + * RecordActivityTaskHeartbeat. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @return Contains the content of the details parameter for the + * last call made by the activity to + * RecordActivityTaskHeartbeat. + */ + public String getDetails() { + return details; + } + + /** + * Contains the content of the details parameter for the + * last call made by the activity to + * RecordActivityTaskHeartbeat. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param details Contains the content of the details parameter for the + * last call made by the activity to + * RecordActivityTaskHeartbeat. + */ + public void setDetails(String details) { + this.details = details; + } + + /** + * Contains the content of the details parameter for the + * last call made by the activity to + * RecordActivityTaskHeartbeat. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param details Contains the content of the details parameter for the + * last call made by the activity to + * RecordActivityTaskHeartbeat. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTaskTimedOutEventAttributes withDetails(String details) { + this.details = details; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (timeoutType != null) sb.append("TimeoutType: " + timeoutType + ", "); + if (scheduledEventId != null) sb.append("ScheduledEventId: " + scheduledEventId + ", "); + if (startedEventId != null) sb.append("StartedEventId: " + startedEventId + ", "); + if (details != null) sb.append("Details: " + details + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTimeoutType() == null) ? 0 : getTimeoutType().hashCode()); + hashCode = prime * hashCode + ((getScheduledEventId() == null) ? 0 : getScheduledEventId().hashCode()); + hashCode = prime * hashCode + ((getStartedEventId() == null) ? 0 : getStartedEventId().hashCode()); + hashCode = prime * hashCode + ((getDetails() == null) ? 0 : getDetails().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ActivityTaskTimedOutEventAttributes == false) return false; + ActivityTaskTimedOutEventAttributes other = (ActivityTaskTimedOutEventAttributes)obj; + + if (other.getTimeoutType() == null ^ this.getTimeoutType() == null) return false; + if (other.getTimeoutType() != null && other.getTimeoutType().equals(this.getTimeoutType()) == false) return false; + if (other.getScheduledEventId() == null ^ this.getScheduledEventId() == null) return false; + if (other.getScheduledEventId() != null && other.getScheduledEventId().equals(this.getScheduledEventId()) == false) return false; + if (other.getStartedEventId() == null ^ this.getStartedEventId() == null) return false; + if (other.getStartedEventId() != null && other.getStartedEventId().equals(this.getStartedEventId()) == false) return false; + if (other.getDetails() == null ^ this.getDetails() == null) return false; + if (other.getDetails() != null && other.getDetails().equals(this.getDetails()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskTimeoutType.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskTimeoutType.java new file mode 100644 index 000000000000..01e740d362e6 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTaskTimeoutType.java @@ -0,0 +1,62 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Activity Task Timeout Type + */ +public enum ActivityTaskTimeoutType { + + START_TO_CLOSE("START_TO_CLOSE"), + SCHEDULE_TO_START("SCHEDULE_TO_START"), + SCHEDULE_TO_CLOSE("SCHEDULE_TO_CLOSE"), + HEARTBEAT("HEARTBEAT"); + + private String value; + + private ActivityTaskTimeoutType(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return ActivityTaskTimeoutType corresponding to the value + */ + public static ActivityTaskTimeoutType fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("START_TO_CLOSE".equals(value)) { + return ActivityTaskTimeoutType.START_TO_CLOSE; + } else if ("SCHEDULE_TO_START".equals(value)) { + return ActivityTaskTimeoutType.SCHEDULE_TO_START; + } else if ("SCHEDULE_TO_CLOSE".equals(value)) { + return ActivityTaskTimeoutType.SCHEDULE_TO_CLOSE; + } else if ("HEARTBEAT".equals(value)) { + return ActivityTaskTimeoutType.HEARTBEAT; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityType.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityType.java new file mode 100644 index 000000000000..e6af1781f34f --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityType.java @@ -0,0 +1,184 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Represents an activity type. + *

+ */ +public class ActivityType { + + /** + * The name of this activity. The combination of activity type name + * and version must be unique within a domain. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String name; + + /** + * The version of this activity. The combination of activity type + * name and version must be unique with in a domain. + *

+ * Constraints:
+ * Length: 1 - 64
+ */ + private String version; + + /** + * The name of this activity. The combination of activity type name + * and version must be unique within a domain. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of this activity. The combination of activity type name + * and version must be unique within a domain. + */ + public String getName() { + return name; + } + + /** + * The name of this activity. The combination of activity type name + * and version must be unique within a domain. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name The name of this activity. The combination of activity type name + * and version must be unique within a domain. + */ + public void setName(String name) { + this.name = name; + } + + /** + * The name of this activity. The combination of activity type name + * and version must be unique within a domain. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name The name of this activity. The combination of activity type name + * and version must be unique within a domain. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityType withName(String name) { + this.name = name; + return this; + } + + + /** + * The version of this activity. The combination of activity type + * name and version must be unique with in a domain. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @return The version of this activity. The combination of activity type + * name and version must be unique with in a domain. + */ + public String getVersion() { + return version; + } + + /** + * The version of this activity. The combination of activity type + * name and version must be unique with in a domain. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param version The version of this activity. The combination of activity type + * name and version must be unique with in a domain. + */ + public void setVersion(String version) { + this.version = version; + } + + /** + * The version of this activity. The combination of activity type + * name and version must be unique with in a domain. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param version The version of this activity. The combination of activity type + * name and version must be unique with in a domain. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityType withVersion(String version) { + this.version = version; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (name != null) sb.append("Name: " + name + ", "); + if (version != null) sb.append("Version: " + version + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); + hashCode = prime * hashCode + ((getVersion() == null) ? 0 : getVersion().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ActivityType == false) return false; + ActivityType other = (ActivityType)obj; + + if (other.getName() == null ^ this.getName() == null) return false; + if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; + if (other.getVersion() == null ^ this.getVersion() == null) return false; + if (other.getVersion() != null && other.getVersion().equals(this.getVersion()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTypeConfiguration.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTypeConfiguration.java new file mode 100644 index 000000000000..85c95b648e73 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTypeConfiguration.java @@ -0,0 +1,575 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Configuration settings registered with the activity type. + *

+ */ +public class ActivityTypeConfiguration { + + /** + * The optional default maximum duration for tasks of an activity type + * specified when registering the activity type. You can override this + * default when scheduling a task through the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String defaultTaskStartToCloseTimeout; + + /** + * The optional default maximum time, specified when registering the + * activity type, before which a worker processing a task must report + * progress by calling RecordActivityTaskHeartbeat. You can + * override this default when scheduling a task through the + * ScheduleActivityTask Decision. If the activity + * worker subsequently attempts to record a heartbeat or returns a + * result, the activity worker receives an UnknownResource + * fault. In this case, Amazon SWF no longer considers the activity task + * to be valid; the activity worker should clean up the activity task. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String defaultTaskHeartbeatTimeout; + + /** + * The optional default task list specified for this activity type at + * registration. This default task list is used if a task list is not + * provided when a task is scheduled through the + * ScheduleActivityTask Decision. You can override + * this default when scheduling a task through the + * ScheduleActivityTask Decision. + */ + private TaskList defaultTaskList; + + /** + * The optional default maximum duration, specified when registering the + * activity type, that a task of an activity type can wait before being + * assigned to a worker. You can override this default when scheduling a + * task through the ScheduleActivityTask Decision. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String defaultTaskScheduleToStartTimeout; + + /** + * The optional default maximum duration, specified when registering the + * activity type, for tasks of this activity type. You can override this + * default when scheduling a task through the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String defaultTaskScheduleToCloseTimeout; + + /** + * The optional default maximum duration for tasks of an activity type + * specified when registering the activity type. You can override this + * default when scheduling a task through the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return The optional default maximum duration for tasks of an activity type + * specified when registering the activity type. You can override this + * default when scheduling a task through the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + */ + public String getDefaultTaskStartToCloseTimeout() { + return defaultTaskStartToCloseTimeout; + } + + /** + * The optional default maximum duration for tasks of an activity type + * specified when registering the activity type. You can override this + * default when scheduling a task through the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultTaskStartToCloseTimeout The optional default maximum duration for tasks of an activity type + * specified when registering the activity type. You can override this + * default when scheduling a task through the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + */ + public void setDefaultTaskStartToCloseTimeout(String defaultTaskStartToCloseTimeout) { + this.defaultTaskStartToCloseTimeout = defaultTaskStartToCloseTimeout; + } + + /** + * The optional default maximum duration for tasks of an activity type + * specified when registering the activity type. You can override this + * default when scheduling a task through the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultTaskStartToCloseTimeout The optional default maximum duration for tasks of an activity type + * specified when registering the activity type. You can override this + * default when scheduling a task through the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTypeConfiguration withDefaultTaskStartToCloseTimeout(String defaultTaskStartToCloseTimeout) { + this.defaultTaskStartToCloseTimeout = defaultTaskStartToCloseTimeout; + return this; + } + + + /** + * The optional default maximum time, specified when registering the + * activity type, before which a worker processing a task must report + * progress by calling RecordActivityTaskHeartbeat. You can + * override this default when scheduling a task through the + * ScheduleActivityTask Decision. If the activity + * worker subsequently attempts to record a heartbeat or returns a + * result, the activity worker receives an UnknownResource + * fault. In this case, Amazon SWF no longer considers the activity task + * to be valid; the activity worker should clean up the activity task. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return The optional default maximum time, specified when registering the + * activity type, before which a worker processing a task must report + * progress by calling RecordActivityTaskHeartbeat. You can + * override this default when scheduling a task through the + * ScheduleActivityTask Decision. If the activity + * worker subsequently attempts to record a heartbeat or returns a + * result, the activity worker receives an UnknownResource + * fault. In this case, Amazon SWF no longer considers the activity task + * to be valid; the activity worker should clean up the activity task. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + */ + public String getDefaultTaskHeartbeatTimeout() { + return defaultTaskHeartbeatTimeout; + } + + /** + * The optional default maximum time, specified when registering the + * activity type, before which a worker processing a task must report + * progress by calling RecordActivityTaskHeartbeat. You can + * override this default when scheduling a task through the + * ScheduleActivityTask Decision. If the activity + * worker subsequently attempts to record a heartbeat or returns a + * result, the activity worker receives an UnknownResource + * fault. In this case, Amazon SWF no longer considers the activity task + * to be valid; the activity worker should clean up the activity task. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultTaskHeartbeatTimeout The optional default maximum time, specified when registering the + * activity type, before which a worker processing a task must report + * progress by calling RecordActivityTaskHeartbeat. You can + * override this default when scheduling a task through the + * ScheduleActivityTask Decision. If the activity + * worker subsequently attempts to record a heartbeat or returns a + * result, the activity worker receives an UnknownResource + * fault. In this case, Amazon SWF no longer considers the activity task + * to be valid; the activity worker should clean up the activity task. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + */ + public void setDefaultTaskHeartbeatTimeout(String defaultTaskHeartbeatTimeout) { + this.defaultTaskHeartbeatTimeout = defaultTaskHeartbeatTimeout; + } + + /** + * The optional default maximum time, specified when registering the + * activity type, before which a worker processing a task must report + * progress by calling RecordActivityTaskHeartbeat. You can + * override this default when scheduling a task through the + * ScheduleActivityTask Decision. If the activity + * worker subsequently attempts to record a heartbeat or returns a + * result, the activity worker receives an UnknownResource + * fault. In this case, Amazon SWF no longer considers the activity task + * to be valid; the activity worker should clean up the activity task. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultTaskHeartbeatTimeout The optional default maximum time, specified when registering the + * activity type, before which a worker processing a task must report + * progress by calling RecordActivityTaskHeartbeat. You can + * override this default when scheduling a task through the + * ScheduleActivityTask Decision. If the activity + * worker subsequently attempts to record a heartbeat or returns a + * result, the activity worker receives an UnknownResource + * fault. In this case, Amazon SWF no longer considers the activity task + * to be valid; the activity worker should clean up the activity task. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTypeConfiguration withDefaultTaskHeartbeatTimeout(String defaultTaskHeartbeatTimeout) { + this.defaultTaskHeartbeatTimeout = defaultTaskHeartbeatTimeout; + return this; + } + + + /** + * The optional default task list specified for this activity type at + * registration. This default task list is used if a task list is not + * provided when a task is scheduled through the + * ScheduleActivityTask Decision. You can override + * this default when scheduling a task through the + * ScheduleActivityTask Decision. + * + * @return The optional default task list specified for this activity type at + * registration. This default task list is used if a task list is not + * provided when a task is scheduled through the + * ScheduleActivityTask Decision. You can override + * this default when scheduling a task through the + * ScheduleActivityTask Decision. + */ + public TaskList getDefaultTaskList() { + return defaultTaskList; + } + + /** + * The optional default task list specified for this activity type at + * registration. This default task list is used if a task list is not + * provided when a task is scheduled through the + * ScheduleActivityTask Decision. You can override + * this default when scheduling a task through the + * ScheduleActivityTask Decision. + * + * @param defaultTaskList The optional default task list specified for this activity type at + * registration. This default task list is used if a task list is not + * provided when a task is scheduled through the + * ScheduleActivityTask Decision. You can override + * this default when scheduling a task through the + * ScheduleActivityTask Decision. + */ + public void setDefaultTaskList(TaskList defaultTaskList) { + this.defaultTaskList = defaultTaskList; + } + + /** + * The optional default task list specified for this activity type at + * registration. This default task list is used if a task list is not + * provided when a task is scheduled through the + * ScheduleActivityTask Decision. You can override + * this default when scheduling a task through the + * ScheduleActivityTask Decision. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param defaultTaskList The optional default task list specified for this activity type at + * registration. This default task list is used if a task list is not + * provided when a task is scheduled through the + * ScheduleActivityTask Decision. You can override + * this default when scheduling a task through the + * ScheduleActivityTask Decision. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTypeConfiguration withDefaultTaskList(TaskList defaultTaskList) { + this.defaultTaskList = defaultTaskList; + return this; + } + + + /** + * The optional default maximum duration, specified when registering the + * activity type, that a task of an activity type can wait before being + * assigned to a worker. You can override this default when scheduling a + * task through the ScheduleActivityTask Decision. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return The optional default maximum duration, specified when registering the + * activity type, that a task of an activity type can wait before being + * assigned to a worker. You can override this default when scheduling a + * task through the ScheduleActivityTask Decision. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + */ + public String getDefaultTaskScheduleToStartTimeout() { + return defaultTaskScheduleToStartTimeout; + } + + /** + * The optional default maximum duration, specified when registering the + * activity type, that a task of an activity type can wait before being + * assigned to a worker. You can override this default when scheduling a + * task through the ScheduleActivityTask Decision. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultTaskScheduleToStartTimeout The optional default maximum duration, specified when registering the + * activity type, that a task of an activity type can wait before being + * assigned to a worker. You can override this default when scheduling a + * task through the ScheduleActivityTask Decision. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + */ + public void setDefaultTaskScheduleToStartTimeout(String defaultTaskScheduleToStartTimeout) { + this.defaultTaskScheduleToStartTimeout = defaultTaskScheduleToStartTimeout; + } + + /** + * The optional default maximum duration, specified when registering the + * activity type, that a task of an activity type can wait before being + * assigned to a worker. You can override this default when scheduling a + * task through the ScheduleActivityTask Decision. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultTaskScheduleToStartTimeout The optional default maximum duration, specified when registering the + * activity type, that a task of an activity type can wait before being + * assigned to a worker. You can override this default when scheduling a + * task through the ScheduleActivityTask Decision. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTypeConfiguration withDefaultTaskScheduleToStartTimeout(String defaultTaskScheduleToStartTimeout) { + this.defaultTaskScheduleToStartTimeout = defaultTaskScheduleToStartTimeout; + return this; + } + + + /** + * The optional default maximum duration, specified when registering the + * activity type, for tasks of this activity type. You can override this + * default when scheduling a task through the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return The optional default maximum duration, specified when registering the + * activity type, for tasks of this activity type. You can override this + * default when scheduling a task through the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + */ + public String getDefaultTaskScheduleToCloseTimeout() { + return defaultTaskScheduleToCloseTimeout; + } + + /** + * The optional default maximum duration, specified when registering the + * activity type, for tasks of this activity type. You can override this + * default when scheduling a task through the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultTaskScheduleToCloseTimeout The optional default maximum duration, specified when registering the + * activity type, for tasks of this activity type. You can override this + * default when scheduling a task through the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + */ + public void setDefaultTaskScheduleToCloseTimeout(String defaultTaskScheduleToCloseTimeout) { + this.defaultTaskScheduleToCloseTimeout = defaultTaskScheduleToCloseTimeout; + } + + /** + * The optional default maximum duration, specified when registering the + * activity type, for tasks of this activity type. You can override this + * default when scheduling a task through the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultTaskScheduleToCloseTimeout The optional default maximum duration, specified when registering the + * activity type, for tasks of this activity type. You can override this + * default when scheduling a task through the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTypeConfiguration withDefaultTaskScheduleToCloseTimeout(String defaultTaskScheduleToCloseTimeout) { + this.defaultTaskScheduleToCloseTimeout = defaultTaskScheduleToCloseTimeout; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (defaultTaskStartToCloseTimeout != null) sb.append("DefaultTaskStartToCloseTimeout: " + defaultTaskStartToCloseTimeout + ", "); + if (defaultTaskHeartbeatTimeout != null) sb.append("DefaultTaskHeartbeatTimeout: " + defaultTaskHeartbeatTimeout + ", "); + if (defaultTaskList != null) sb.append("DefaultTaskList: " + defaultTaskList + ", "); + if (defaultTaskScheduleToStartTimeout != null) sb.append("DefaultTaskScheduleToStartTimeout: " + defaultTaskScheduleToStartTimeout + ", "); + if (defaultTaskScheduleToCloseTimeout != null) sb.append("DefaultTaskScheduleToCloseTimeout: " + defaultTaskScheduleToCloseTimeout + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDefaultTaskStartToCloseTimeout() == null) ? 0 : getDefaultTaskStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getDefaultTaskHeartbeatTimeout() == null) ? 0 : getDefaultTaskHeartbeatTimeout().hashCode()); + hashCode = prime * hashCode + ((getDefaultTaskList() == null) ? 0 : getDefaultTaskList().hashCode()); + hashCode = prime * hashCode + ((getDefaultTaskScheduleToStartTimeout() == null) ? 0 : getDefaultTaskScheduleToStartTimeout().hashCode()); + hashCode = prime * hashCode + ((getDefaultTaskScheduleToCloseTimeout() == null) ? 0 : getDefaultTaskScheduleToCloseTimeout().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ActivityTypeConfiguration == false) return false; + ActivityTypeConfiguration other = (ActivityTypeConfiguration)obj; + + if (other.getDefaultTaskStartToCloseTimeout() == null ^ this.getDefaultTaskStartToCloseTimeout() == null) return false; + if (other.getDefaultTaskStartToCloseTimeout() != null && other.getDefaultTaskStartToCloseTimeout().equals(this.getDefaultTaskStartToCloseTimeout()) == false) return false; + if (other.getDefaultTaskHeartbeatTimeout() == null ^ this.getDefaultTaskHeartbeatTimeout() == null) return false; + if (other.getDefaultTaskHeartbeatTimeout() != null && other.getDefaultTaskHeartbeatTimeout().equals(this.getDefaultTaskHeartbeatTimeout()) == false) return false; + if (other.getDefaultTaskList() == null ^ this.getDefaultTaskList() == null) return false; + if (other.getDefaultTaskList() != null && other.getDefaultTaskList().equals(this.getDefaultTaskList()) == false) return false; + if (other.getDefaultTaskScheduleToStartTimeout() == null ^ this.getDefaultTaskScheduleToStartTimeout() == null) return false; + if (other.getDefaultTaskScheduleToStartTimeout() != null && other.getDefaultTaskScheduleToStartTimeout().equals(this.getDefaultTaskScheduleToStartTimeout()) == false) return false; + if (other.getDefaultTaskScheduleToCloseTimeout() == null ^ this.getDefaultTaskScheduleToCloseTimeout() == null) return false; + if (other.getDefaultTaskScheduleToCloseTimeout() != null && other.getDefaultTaskScheduleToCloseTimeout().equals(this.getDefaultTaskScheduleToCloseTimeout()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTypeDetail.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTypeDetail.java new file mode 100644 index 000000000000..608515c76fb9 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTypeDetail.java @@ -0,0 +1,195 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Detailed information about an activity type. + *

+ */ +public class ActivityTypeDetail { + + /** + * General information about the activity type.

The status of + * activity type (returned in the ActivityTypeInfo structure) can be one + * of the following.

  • REGISTERED: The type is registered + * and available. Workers supporting this type should be running.
  • + *
  • DEPRECATED: The type was deprecated using + * DeprecateActivityType, but is still in use. You should keep + * workers supporting this type running. You cannot create new tasks of + * this type.
+ */ + private ActivityTypeInfo typeInfo; + + /** + * The configuration settings registered with the activity type. + */ + private ActivityTypeConfiguration configuration; + + /** + * General information about the activity type.

The status of + * activity type (returned in the ActivityTypeInfo structure) can be one + * of the following.

  • REGISTERED: The type is registered + * and available. Workers supporting this type should be running.
  • + *
  • DEPRECATED: The type was deprecated using + * DeprecateActivityType, but is still in use. You should keep + * workers supporting this type running. You cannot create new tasks of + * this type.
+ * + * @return General information about the activity type.

The status of + * activity type (returned in the ActivityTypeInfo structure) can be one + * of the following.

  • REGISTERED: The type is registered + * and available. Workers supporting this type should be running.
  • + *
  • DEPRECATED: The type was deprecated using + * DeprecateActivityType, but is still in use. You should keep + * workers supporting this type running. You cannot create new tasks of + * this type.
+ */ + public ActivityTypeInfo getTypeInfo() { + return typeInfo; + } + + /** + * General information about the activity type.

The status of + * activity type (returned in the ActivityTypeInfo structure) can be one + * of the following.

  • REGISTERED: The type is registered + * and available. Workers supporting this type should be running.
  • + *
  • DEPRECATED: The type was deprecated using + * DeprecateActivityType, but is still in use. You should keep + * workers supporting this type running. You cannot create new tasks of + * this type.
+ * + * @param typeInfo General information about the activity type.

The status of + * activity type (returned in the ActivityTypeInfo structure) can be one + * of the following.

  • REGISTERED: The type is registered + * and available. Workers supporting this type should be running.
  • + *
  • DEPRECATED: The type was deprecated using + * DeprecateActivityType, but is still in use. You should keep + * workers supporting this type running. You cannot create new tasks of + * this type.
+ */ + public void setTypeInfo(ActivityTypeInfo typeInfo) { + this.typeInfo = typeInfo; + } + + /** + * General information about the activity type.

The status of + * activity type (returned in the ActivityTypeInfo structure) can be one + * of the following.

  • REGISTERED: The type is registered + * and available. Workers supporting this type should be running.
  • + *
  • DEPRECATED: The type was deprecated using + * DeprecateActivityType, but is still in use. You should keep + * workers supporting this type running. You cannot create new tasks of + * this type.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param typeInfo General information about the activity type.

The status of + * activity type (returned in the ActivityTypeInfo structure) can be one + * of the following.

  • REGISTERED: The type is registered + * and available. Workers supporting this type should be running.
  • + *
  • DEPRECATED: The type was deprecated using + * DeprecateActivityType, but is still in use. You should keep + * workers supporting this type running. You cannot create new tasks of + * this type.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTypeDetail withTypeInfo(ActivityTypeInfo typeInfo) { + this.typeInfo = typeInfo; + return this; + } + + + /** + * The configuration settings registered with the activity type. + * + * @return The configuration settings registered with the activity type. + */ + public ActivityTypeConfiguration getConfiguration() { + return configuration; + } + + /** + * The configuration settings registered with the activity type. + * + * @param configuration The configuration settings registered with the activity type. + */ + public void setConfiguration(ActivityTypeConfiguration configuration) { + this.configuration = configuration; + } + + /** + * The configuration settings registered with the activity type. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param configuration The configuration settings registered with the activity type. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTypeDetail withConfiguration(ActivityTypeConfiguration configuration) { + this.configuration = configuration; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (typeInfo != null) sb.append("TypeInfo: " + typeInfo + ", "); + if (configuration != null) sb.append("Configuration: " + configuration + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTypeInfo() == null) ? 0 : getTypeInfo().hashCode()); + hashCode = prime * hashCode + ((getConfiguration() == null) ? 0 : getConfiguration().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ActivityTypeDetail == false) return false; + ActivityTypeDetail other = (ActivityTypeDetail)obj; + + if (other.getTypeInfo() == null ^ this.getTypeInfo() == null) return false; + if (other.getTypeInfo() != null && other.getTypeInfo().equals(this.getTypeInfo()) == false) return false; + if (other.getConfiguration() == null ^ this.getConfiguration() == null) return false; + if (other.getConfiguration() != null && other.getConfiguration().equals(this.getConfiguration()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTypeInfo.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTypeInfo.java new file mode 100644 index 000000000000..a49f41de11d1 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTypeInfo.java @@ -0,0 +1,360 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Detailed information about an activity type. + *

+ */ +public class ActivityTypeInfo { + + /** + * The ActivityType type structure representing the activity type. + */ + private ActivityType activityType; + + /** + * The current status of the activity type. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + */ + private String status; + + /** + * The description of the activity type provided in + * RegisterActivityType. + *

+ * Constraints:
+ * Length: 0 - 1024
+ */ + private String description; + + /** + * The date and time this activity type was created through + * RegisterActivityType. + */ + private java.util.Date creationDate; + + /** + * If DEPRECATED, the date and time DeprecateActivityType was + * called. + */ + private java.util.Date deprecationDate; + + /** + * The ActivityType type structure representing the activity type. + * + * @return The ActivityType type structure representing the activity type. + */ + public ActivityType getActivityType() { + return activityType; + } + + /** + * The ActivityType type structure representing the activity type. + * + * @param activityType The ActivityType type structure representing the activity type. + */ + public void setActivityType(ActivityType activityType) { + this.activityType = activityType; + } + + /** + * The ActivityType type structure representing the activity type. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param activityType The ActivityType type structure representing the activity type. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTypeInfo withActivityType(ActivityType activityType) { + this.activityType = activityType; + return this; + } + + + /** + * The current status of the activity type. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @return The current status of the activity type. + * + * @see RegistrationStatus + */ + public String getStatus() { + return status; + } + + /** + * The current status of the activity type. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param status The current status of the activity type. + * + * @see RegistrationStatus + */ + public void setStatus(String status) { + this.status = status; + } + + /** + * The current status of the activity type. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param status The current status of the activity type. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see RegistrationStatus + */ + public ActivityTypeInfo withStatus(String status) { + this.status = status; + return this; + } + + + /** + * The current status of the activity type. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param status The current status of the activity type. + * + * @see RegistrationStatus + */ + public void setStatus(RegistrationStatus status) { + this.status = status.toString(); + } + + /** + * The current status of the activity type. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param status The current status of the activity type. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see RegistrationStatus + */ + public ActivityTypeInfo withStatus(RegistrationStatus status) { + this.status = status.toString(); + return this; + } + + /** + * The description of the activity type provided in + * RegisterActivityType. + *

+ * Constraints:
+ * Length: 0 - 1024
+ * + * @return The description of the activity type provided in + * RegisterActivityType. + */ + public String getDescription() { + return description; + } + + /** + * The description of the activity type provided in + * RegisterActivityType. + *

+ * Constraints:
+ * Length: 0 - 1024
+ * + * @param description The description of the activity type provided in + * RegisterActivityType. + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * The description of the activity type provided in + * RegisterActivityType. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 1024
+ * + * @param description The description of the activity type provided in + * RegisterActivityType. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTypeInfo withDescription(String description) { + this.description = description; + return this; + } + + + /** + * The date and time this activity type was created through + * RegisterActivityType. + * + * @return The date and time this activity type was created through + * RegisterActivityType. + */ + public java.util.Date getCreationDate() { + return creationDate; + } + + /** + * The date and time this activity type was created through + * RegisterActivityType. + * + * @param creationDate The date and time this activity type was created through + * RegisterActivityType. + */ + public void setCreationDate(java.util.Date creationDate) { + this.creationDate = creationDate; + } + + /** + * The date and time this activity type was created through + * RegisterActivityType. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param creationDate The date and time this activity type was created through + * RegisterActivityType. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTypeInfo withCreationDate(java.util.Date creationDate) { + this.creationDate = creationDate; + return this; + } + + + /** + * If DEPRECATED, the date and time DeprecateActivityType was + * called. + * + * @return If DEPRECATED, the date and time DeprecateActivityType was + * called. + */ + public java.util.Date getDeprecationDate() { + return deprecationDate; + } + + /** + * If DEPRECATED, the date and time DeprecateActivityType was + * called. + * + * @param deprecationDate If DEPRECATED, the date and time DeprecateActivityType was + * called. + */ + public void setDeprecationDate(java.util.Date deprecationDate) { + this.deprecationDate = deprecationDate; + } + + /** + * If DEPRECATED, the date and time DeprecateActivityType was + * called. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param deprecationDate If DEPRECATED, the date and time DeprecateActivityType was + * called. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTypeInfo withDeprecationDate(java.util.Date deprecationDate) { + this.deprecationDate = deprecationDate; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (activityType != null) sb.append("ActivityType: " + activityType + ", "); + if (status != null) sb.append("Status: " + status + ", "); + if (description != null) sb.append("Description: " + description + ", "); + if (creationDate != null) sb.append("CreationDate: " + creationDate + ", "); + if (deprecationDate != null) sb.append("DeprecationDate: " + deprecationDate + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getActivityType() == null) ? 0 : getActivityType().hashCode()); + hashCode = prime * hashCode + ((getStatus() == null) ? 0 : getStatus().hashCode()); + hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); + hashCode = prime * hashCode + ((getCreationDate() == null) ? 0 : getCreationDate().hashCode()); + hashCode = prime * hashCode + ((getDeprecationDate() == null) ? 0 : getDeprecationDate().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ActivityTypeInfo == false) return false; + ActivityTypeInfo other = (ActivityTypeInfo)obj; + + if (other.getActivityType() == null ^ this.getActivityType() == null) return false; + if (other.getActivityType() != null && other.getActivityType().equals(this.getActivityType()) == false) return false; + if (other.getStatus() == null ^ this.getStatus() == null) return false; + if (other.getStatus() != null && other.getStatus().equals(this.getStatus()) == false) return false; + if (other.getDescription() == null ^ this.getDescription() == null) return false; + if (other.getDescription() != null && other.getDescription().equals(this.getDescription()) == false) return false; + if (other.getCreationDate() == null ^ this.getCreationDate() == null) return false; + if (other.getCreationDate() != null && other.getCreationDate().equals(this.getCreationDate()) == false) return false; + if (other.getDeprecationDate() == null ^ this.getDeprecationDate() == null) return false; + if (other.getDeprecationDate() != null && other.getDeprecationDate().equals(this.getDeprecationDate()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTypeInfos.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTypeInfos.java new file mode 100644 index 000000000000..e3bfa623f4c7 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ActivityTypeInfos.java @@ -0,0 +1,207 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Contains a paginated list of activity type information structures. + *

+ */ +public class ActivityTypeInfos { + + /** + * List of activity type information. + */ + private java.util.List typeInfos; + + /** + * Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ */ + private String nextPageToken; + + /** + * List of activity type information. + * + * @return List of activity type information. + */ + public java.util.List getTypeInfos() { + + if (typeInfos == null) { + typeInfos = new java.util.ArrayList(); + } + return typeInfos; + } + + /** + * List of activity type information. + * + * @param typeInfos List of activity type information. + */ + public void setTypeInfos(java.util.Collection typeInfos) { + if (typeInfos == null) { + this.typeInfos = null; + return; + } + + java.util.List typeInfosCopy = new java.util.ArrayList(typeInfos.size()); + typeInfosCopy.addAll(typeInfos); + this.typeInfos = typeInfosCopy; + } + + /** + * List of activity type information. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param typeInfos List of activity type information. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTypeInfos withTypeInfos(ActivityTypeInfo... typeInfos) { + if (getTypeInfos() == null) setTypeInfos(new java.util.ArrayList(typeInfos.length)); + for (ActivityTypeInfo value : typeInfos) { + getTypeInfos().add(value); + } + return this; + } + + /** + * List of activity type information. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param typeInfos List of activity type information. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTypeInfos withTypeInfos(java.util.Collection typeInfos) { + if (typeInfos == null) { + this.typeInfos = null; + } else { + java.util.List typeInfosCopy = new java.util.ArrayList(typeInfos.size()); + typeInfosCopy.addAll(typeInfos); + this.typeInfos = typeInfosCopy; + } + + return this; + } + + /** + * Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @return Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + */ + public String getNextPageToken() { + return nextPageToken; + } + + /** + * Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + */ + public void setNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + } + + /** + * Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ActivityTypeInfos withNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (typeInfos != null) sb.append("TypeInfos: " + typeInfos + ", "); + if (nextPageToken != null) sb.append("NextPageToken: " + nextPageToken + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTypeInfos() == null) ? 0 : getTypeInfos().hashCode()); + hashCode = prime * hashCode + ((getNextPageToken() == null) ? 0 : getNextPageToken().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ActivityTypeInfos == false) return false; + ActivityTypeInfos other = (ActivityTypeInfos)obj; + + if (other.getTypeInfos() == null ^ this.getTypeInfos() == null) return false; + if (other.getTypeInfos() != null && other.getTypeInfos().equals(this.getTypeInfos()) == false) return false; + if (other.getNextPageToken() == null ^ this.getNextPageToken() == null) return false; + if (other.getNextPageToken() != null && other.getNextPageToken().equals(this.getNextPageToken()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/CancelTimerDecisionAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/CancelTimerDecisionAttributes.java new file mode 100644 index 000000000000..c37232f29334 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/CancelTimerDecisionAttributes.java @@ -0,0 +1,115 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the CancelTimer decision. + *

+ */ +public class CancelTimerDecisionAttributes { + + /** + * The unique Id of the timer to cancel. This field is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String timerId; + + /** + * The unique Id of the timer to cancel. This field is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The unique Id of the timer to cancel. This field is required. + */ + public String getTimerId() { + return timerId; + } + + /** + * The unique Id of the timer to cancel. This field is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param timerId The unique Id of the timer to cancel. This field is required. + */ + public void setTimerId(String timerId) { + this.timerId = timerId; + } + + /** + * The unique Id of the timer to cancel. This field is required. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param timerId The unique Id of the timer to cancel. This field is required. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CancelTimerDecisionAttributes withTimerId(String timerId) { + this.timerId = timerId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (timerId != null) sb.append("TimerId: " + timerId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTimerId() == null) ? 0 : getTimerId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof CancelTimerDecisionAttributes == false) return false; + CancelTimerDecisionAttributes other = (CancelTimerDecisionAttributes)obj; + + if (other.getTimerId() == null ^ this.getTimerId() == null) return false; + if (other.getTimerId() != null && other.getTimerId().equals(this.getTimerId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/CancelTimerFailedCause.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/CancelTimerFailedCause.java new file mode 100644 index 000000000000..18f8b0e955f4 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/CancelTimerFailedCause.java @@ -0,0 +1,53 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Cancel Timer Failed Cause + */ +public enum CancelTimerFailedCause { + + TIMER_ID_UNKNOWN("TIMER_ID_UNKNOWN"); + + private String value; + + private CancelTimerFailedCause(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return CancelTimerFailedCause corresponding to the value + */ + public static CancelTimerFailedCause fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("TIMER_ID_UNKNOWN".equals(value)) { + return CancelTimerFailedCause.TIMER_ID_UNKNOWN; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/CancelTimerFailedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/CancelTimerFailedEventAttributes.java new file mode 100644 index 000000000000..2efea0665c16 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/CancelTimerFailedEventAttributes.java @@ -0,0 +1,292 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the CancelTimerFailed event. + *

+ */ +public class CancelTimerFailedEventAttributes { + + /** + * The timerId provided in the CancelTimer decision that + * failed. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String timerId; + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: TIMER_ID_UNKNOWN + */ + private String cause; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the CancelTimer + * decision to cancel this timer. This information can be useful for + * diagnosing problems by tracing back the cause of events. + */ + private Long decisionTaskCompletedEventId; + + /** + * The timerId provided in the CancelTimer decision that + * failed. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The timerId provided in the CancelTimer decision that + * failed. + */ + public String getTimerId() { + return timerId; + } + + /** + * The timerId provided in the CancelTimer decision that + * failed. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param timerId The timerId provided in the CancelTimer decision that + * failed. + */ + public void setTimerId(String timerId) { + this.timerId = timerId; + } + + /** + * The timerId provided in the CancelTimer decision that + * failed. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param timerId The timerId provided in the CancelTimer decision that + * failed. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CancelTimerFailedEventAttributes withTimerId(String timerId) { + this.timerId = timerId; + return this; + } + + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: TIMER_ID_UNKNOWN + * + * @return The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see CancelTimerFailedCause + */ + public String getCause() { + return cause; + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: TIMER_ID_UNKNOWN + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see CancelTimerFailedCause + */ + public void setCause(String cause) { + this.cause = cause; + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TIMER_ID_UNKNOWN + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see CancelTimerFailedCause + */ + public CancelTimerFailedEventAttributes withCause(String cause) { + this.cause = cause; + return this; + } + + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: TIMER_ID_UNKNOWN + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see CancelTimerFailedCause + */ + public void setCause(CancelTimerFailedCause cause) { + this.cause = cause.toString(); + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TIMER_ID_UNKNOWN + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see CancelTimerFailedCause + */ + public CancelTimerFailedEventAttributes withCause(CancelTimerFailedCause cause) { + this.cause = cause.toString(); + return this; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the CancelTimer + * decision to cancel this timer. This information can be useful for + * diagnosing problems by tracing back the cause of events. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the CancelTimer + * decision to cancel this timer. This information can be useful for + * diagnosing problems by tracing back the cause of events. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the CancelTimer + * decision to cancel this timer. This information can be useful for + * diagnosing problems by tracing back the cause of events. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the CancelTimer + * decision to cancel this timer. This information can be useful for + * diagnosing problems by tracing back the cause of events. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the CancelTimer + * decision to cancel this timer. This information can be useful for + * diagnosing problems by tracing back the cause of events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the CancelTimer + * decision to cancel this timer. This information can be useful for + * diagnosing problems by tracing back the cause of events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CancelTimerFailedEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (timerId != null) sb.append("TimerId: " + timerId + ", "); + if (cause != null) sb.append("Cause: " + cause + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTimerId() == null) ? 0 : getTimerId().hashCode()); + hashCode = prime * hashCode + ((getCause() == null) ? 0 : getCause().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof CancelTimerFailedEventAttributes == false) return false; + CancelTimerFailedEventAttributes other = (CancelTimerFailedEventAttributes)obj; + + if (other.getTimerId() == null ^ this.getTimerId() == null) return false; + if (other.getTimerId() != null && other.getTimerId().equals(this.getTimerId()) == false) return false; + if (other.getCause() == null ^ this.getCause() == null) return false; + if (other.getCause() != null && other.getCause().equals(this.getCause()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/CancelWorkflowExecutionDecisionAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/CancelWorkflowExecutionDecisionAttributes.java new file mode 100644 index 000000000000..d620e5917571 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/CancelWorkflowExecutionDecisionAttributes.java @@ -0,0 +1,116 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the CancelWorkflowExecution + * decision. + *

+ */ +public class CancelWorkflowExecutionDecisionAttributes { + + /** + * Optional details of the cancellation. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String details; + + /** + * Optional details of the cancellation. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Optional details of the cancellation. + */ + public String getDetails() { + return details; + } + + /** + * Optional details of the cancellation. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details Optional details of the cancellation. + */ + public void setDetails(String details) { + this.details = details; + } + + /** + * Optional details of the cancellation. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details Optional details of the cancellation. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CancelWorkflowExecutionDecisionAttributes withDetails(String details) { + this.details = details; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (details != null) sb.append("Details: " + details + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDetails() == null) ? 0 : getDetails().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof CancelWorkflowExecutionDecisionAttributes == false) return false; + CancelWorkflowExecutionDecisionAttributes other = (CancelWorkflowExecutionDecisionAttributes)obj; + + if (other.getDetails() == null ^ this.getDetails() == null) return false; + if (other.getDetails() != null && other.getDetails().equals(this.getDetails()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/CancelWorkflowExecutionFailedCause.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/CancelWorkflowExecutionFailedCause.java new file mode 100644 index 000000000000..989e59ab4338 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/CancelWorkflowExecutionFailedCause.java @@ -0,0 +1,53 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Cancel Workflow Execution Failed Cause + */ +public enum CancelWorkflowExecutionFailedCause { + + UNHANDLED_DECISION("UNHANDLED_DECISION"); + + private String value; + + private CancelWorkflowExecutionFailedCause(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return CancelWorkflowExecutionFailedCause corresponding to the value + */ + public static CancelWorkflowExecutionFailedCause fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("UNHANDLED_DECISION".equals(value)) { + return CancelWorkflowExecutionFailedCause.UNHANDLED_DECISION; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/CancelWorkflowExecutionFailedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/CancelWorkflowExecutionFailedEventAttributes.java new file mode 100644 index 000000000000..b06b7dbfbbb0 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/CancelWorkflowExecutionFailedEventAttributes.java @@ -0,0 +1,238 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the CancelWorkflowExecutionFailed + * event. + *

+ */ +public class CancelWorkflowExecutionFailedEventAttributes { + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION + */ + private String cause; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CancelWorkflowExecution decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + private Long decisionTaskCompletedEventId; + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION + * + * @return The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + * + * @see CancelWorkflowExecutionFailedCause + */ + public String getCause() { + return cause; + } + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION + * + * @param cause The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + * + * @see CancelWorkflowExecutionFailedCause + */ + public void setCause(String cause) { + this.cause = cause; + } + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION + * + * @param cause The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see CancelWorkflowExecutionFailedCause + */ + public CancelWorkflowExecutionFailedEventAttributes withCause(String cause) { + this.cause = cause; + return this; + } + + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION + * + * @param cause The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + * + * @see CancelWorkflowExecutionFailedCause + */ + public void setCause(CancelWorkflowExecutionFailedCause cause) { + this.cause = cause.toString(); + } + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION + * + * @param cause The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see CancelWorkflowExecutionFailedCause + */ + public CancelWorkflowExecutionFailedEventAttributes withCause(CancelWorkflowExecutionFailedCause cause) { + this.cause = cause.toString(); + return this; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CancelWorkflowExecution decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CancelWorkflowExecution decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CancelWorkflowExecution decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CancelWorkflowExecution decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CancelWorkflowExecution decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CancelWorkflowExecution decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CancelWorkflowExecutionFailedEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (cause != null) sb.append("Cause: " + cause + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getCause() == null) ? 0 : getCause().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof CancelWorkflowExecutionFailedEventAttributes == false) return false; + CancelWorkflowExecutionFailedEventAttributes other = (CancelWorkflowExecutionFailedEventAttributes)obj; + + if (other.getCause() == null ^ this.getCause() == null) return false; + if (other.getCause() != null && other.getCause().equals(this.getCause()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildPolicy.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildPolicy.java new file mode 100644 index 000000000000..60c900f23e2f --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildPolicy.java @@ -0,0 +1,59 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Child Policy + */ +public enum ChildPolicy { + + TERMINATE("TERMINATE"), + REQUEST_CANCEL("REQUEST_CANCEL"), + ABANDON("ABANDON"); + + private String value; + + private ChildPolicy(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return ChildPolicy corresponding to the value + */ + public static ChildPolicy fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("TERMINATE".equals(value)) { + return ChildPolicy.TERMINATE; + } else if ("REQUEST_CANCEL".equals(value)) { + return ChildPolicy.REQUEST_CANCEL; + } else if ("ABANDON".equals(value)) { + return ChildPolicy.ABANDON; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionCanceledEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionCanceledEventAttributes.java new file mode 100644 index 000000000000..155d9aab6f40 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionCanceledEventAttributes.java @@ -0,0 +1,337 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provide details of the ChildWorkflowExecutionCanceled + * event. + *

+ */ +public class ChildWorkflowExecutionCanceledEventAttributes { + + /** + * The child workflow execution that was canceled. + */ + private WorkflowExecution workflowExecution; + + /** + * The type of the child workflow execution. + */ + private WorkflowType workflowType; + + /** + * Details of the cancellation (if provided). + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String details; + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + private Long initiatedEventId; + + /** + * The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + private Long startedEventId; + + /** + * The child workflow execution that was canceled. + * + * @return The child workflow execution that was canceled. + */ + public WorkflowExecution getWorkflowExecution() { + return workflowExecution; + } + + /** + * The child workflow execution that was canceled. + * + * @param workflowExecution The child workflow execution that was canceled. + */ + public void setWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + } + + /** + * The child workflow execution that was canceled. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowExecution The child workflow execution that was canceled. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionCanceledEventAttributes withWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + return this; + } + + + /** + * The type of the child workflow execution. + * + * @return The type of the child workflow execution. + */ + public WorkflowType getWorkflowType() { + return workflowType; + } + + /** + * The type of the child workflow execution. + * + * @param workflowType The type of the child workflow execution. + */ + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + /** + * The type of the child workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowType The type of the child workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionCanceledEventAttributes withWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + return this; + } + + + /** + * Details of the cancellation (if provided). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Details of the cancellation (if provided). + */ + public String getDetails() { + return details; + } + + /** + * Details of the cancellation (if provided). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details Details of the cancellation (if provided). + */ + public void setDetails(String details) { + this.details = details; + } + + /** + * Details of the cancellation (if provided). + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details Details of the cancellation (if provided). + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionCanceledEventAttributes withDetails(String details) { + this.details = details; + return this; + } + + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public Long getInitiatedEventId() { + return initiatedEventId; + } + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @param initiatedEventId The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public void setInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + } + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param initiatedEventId The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionCanceledEventAttributes withInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + return this; + } + + + /** + * The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public Long getStartedEventId() { + return startedEventId; + } + + /** + * The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @param startedEventId The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public void setStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + } + + /** + * The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startedEventId The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionCanceledEventAttributes withStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowExecution != null) sb.append("WorkflowExecution: " + workflowExecution + ", "); + if (workflowType != null) sb.append("WorkflowType: " + workflowType + ", "); + if (details != null) sb.append("Details: " + details + ", "); + if (initiatedEventId != null) sb.append("InitiatedEventId: " + initiatedEventId + ", "); + if (startedEventId != null) sb.append("StartedEventId: " + startedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowExecution() == null) ? 0 : getWorkflowExecution().hashCode()); + hashCode = prime * hashCode + ((getWorkflowType() == null) ? 0 : getWorkflowType().hashCode()); + hashCode = prime * hashCode + ((getDetails() == null) ? 0 : getDetails().hashCode()); + hashCode = prime * hashCode + ((getInitiatedEventId() == null) ? 0 : getInitiatedEventId().hashCode()); + hashCode = prime * hashCode + ((getStartedEventId() == null) ? 0 : getStartedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ChildWorkflowExecutionCanceledEventAttributes == false) return false; + ChildWorkflowExecutionCanceledEventAttributes other = (ChildWorkflowExecutionCanceledEventAttributes)obj; + + if (other.getWorkflowExecution() == null ^ this.getWorkflowExecution() == null) return false; + if (other.getWorkflowExecution() != null && other.getWorkflowExecution().equals(this.getWorkflowExecution()) == false) return false; + if (other.getWorkflowType() == null ^ this.getWorkflowType() == null) return false; + if (other.getWorkflowType() != null && other.getWorkflowType().equals(this.getWorkflowType()) == false) return false; + if (other.getDetails() == null ^ this.getDetails() == null) return false; + if (other.getDetails() != null && other.getDetails().equals(this.getDetails()) == false) return false; + if (other.getInitiatedEventId() == null ^ this.getInitiatedEventId() == null) return false; + if (other.getInitiatedEventId() != null && other.getInitiatedEventId().equals(this.getInitiatedEventId()) == false) return false; + if (other.getStartedEventId() == null ^ this.getStartedEventId() == null) return false; + if (other.getStartedEventId() != null && other.getStartedEventId().equals(this.getStartedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionCompletedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionCompletedEventAttributes.java new file mode 100644 index 000000000000..f96b41e68af3 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionCompletedEventAttributes.java @@ -0,0 +1,337 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the ChildWorkflowExecutionCompleted + * event. + *

+ */ +public class ChildWorkflowExecutionCompletedEventAttributes { + + /** + * The child workflow execution that was completed. + */ + private WorkflowExecution workflowExecution; + + /** + * The type of the child workflow execution. + */ + private WorkflowType workflowType; + + /** + * The result of the child workflow execution (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String result; + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + private Long initiatedEventId; + + /** + * The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + private Long startedEventId; + + /** + * The child workflow execution that was completed. + * + * @return The child workflow execution that was completed. + */ + public WorkflowExecution getWorkflowExecution() { + return workflowExecution; + } + + /** + * The child workflow execution that was completed. + * + * @param workflowExecution The child workflow execution that was completed. + */ + public void setWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + } + + /** + * The child workflow execution that was completed. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowExecution The child workflow execution that was completed. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionCompletedEventAttributes withWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + return this; + } + + + /** + * The type of the child workflow execution. + * + * @return The type of the child workflow execution. + */ + public WorkflowType getWorkflowType() { + return workflowType; + } + + /** + * The type of the child workflow execution. + * + * @param workflowType The type of the child workflow execution. + */ + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + /** + * The type of the child workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowType The type of the child workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionCompletedEventAttributes withWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + return this; + } + + + /** + * The result of the child workflow execution (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The result of the child workflow execution (if any). + */ + public String getResult() { + return result; + } + + /** + * The result of the child workflow execution (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param result The result of the child workflow execution (if any). + */ + public void setResult(String result) { + this.result = result; + } + + /** + * The result of the child workflow execution (if any). + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param result The result of the child workflow execution (if any). + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionCompletedEventAttributes withResult(String result) { + this.result = result; + return this; + } + + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public Long getInitiatedEventId() { + return initiatedEventId; + } + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @param initiatedEventId The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public void setInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + } + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param initiatedEventId The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionCompletedEventAttributes withInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + return this; + } + + + /** + * The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public Long getStartedEventId() { + return startedEventId; + } + + /** + * The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @param startedEventId The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public void setStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + } + + /** + * The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startedEventId The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionCompletedEventAttributes withStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowExecution != null) sb.append("WorkflowExecution: " + workflowExecution + ", "); + if (workflowType != null) sb.append("WorkflowType: " + workflowType + ", "); + if (result != null) sb.append("Result: " + result + ", "); + if (initiatedEventId != null) sb.append("InitiatedEventId: " + initiatedEventId + ", "); + if (startedEventId != null) sb.append("StartedEventId: " + startedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowExecution() == null) ? 0 : getWorkflowExecution().hashCode()); + hashCode = prime * hashCode + ((getWorkflowType() == null) ? 0 : getWorkflowType().hashCode()); + hashCode = prime * hashCode + ((getResult() == null) ? 0 : getResult().hashCode()); + hashCode = prime * hashCode + ((getInitiatedEventId() == null) ? 0 : getInitiatedEventId().hashCode()); + hashCode = prime * hashCode + ((getStartedEventId() == null) ? 0 : getStartedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ChildWorkflowExecutionCompletedEventAttributes == false) return false; + ChildWorkflowExecutionCompletedEventAttributes other = (ChildWorkflowExecutionCompletedEventAttributes)obj; + + if (other.getWorkflowExecution() == null ^ this.getWorkflowExecution() == null) return false; + if (other.getWorkflowExecution() != null && other.getWorkflowExecution().equals(this.getWorkflowExecution()) == false) return false; + if (other.getWorkflowType() == null ^ this.getWorkflowType() == null) return false; + if (other.getWorkflowType() != null && other.getWorkflowType().equals(this.getWorkflowType()) == false) return false; + if (other.getResult() == null ^ this.getResult() == null) return false; + if (other.getResult() != null && other.getResult().equals(this.getResult()) == false) return false; + if (other.getInitiatedEventId() == null ^ this.getInitiatedEventId() == null) return false; + if (other.getInitiatedEventId() != null && other.getInitiatedEventId().equals(this.getInitiatedEventId()) == false) return false; + if (other.getStartedEventId() == null ^ this.getStartedEventId() == null) return false; + if (other.getStartedEventId() != null && other.getStartedEventId().equals(this.getStartedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionFailedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionFailedEventAttributes.java new file mode 100644 index 000000000000..fa44d369f21b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionFailedEventAttributes.java @@ -0,0 +1,392 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the ChildWorkflowExecutionFailed + * event. + *

+ */ +public class ChildWorkflowExecutionFailedEventAttributes { + + /** + * The child workflow execution that failed. + */ + private WorkflowExecution workflowExecution; + + /** + * The type of the child workflow execution. + */ + private WorkflowType workflowType; + + /** + * The reason for the failure (if provided). + *

+ * Constraints:
+ * Length: 0 - 256
+ */ + private String reason; + + /** + * The details of the failure (if provided). + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String details; + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + private Long initiatedEventId; + + /** + * The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + private Long startedEventId; + + /** + * The child workflow execution that failed. + * + * @return The child workflow execution that failed. + */ + public WorkflowExecution getWorkflowExecution() { + return workflowExecution; + } + + /** + * The child workflow execution that failed. + * + * @param workflowExecution The child workflow execution that failed. + */ + public void setWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + } + + /** + * The child workflow execution that failed. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowExecution The child workflow execution that failed. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionFailedEventAttributes withWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + return this; + } + + + /** + * The type of the child workflow execution. + * + * @return The type of the child workflow execution. + */ + public WorkflowType getWorkflowType() { + return workflowType; + } + + /** + * The type of the child workflow execution. + * + * @param workflowType The type of the child workflow execution. + */ + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + /** + * The type of the child workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowType The type of the child workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionFailedEventAttributes withWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + return this; + } + + + /** + * The reason for the failure (if provided). + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @return The reason for the failure (if provided). + */ + public String getReason() { + return reason; + } + + /** + * The reason for the failure (if provided). + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param reason The reason for the failure (if provided). + */ + public void setReason(String reason) { + this.reason = reason; + } + + /** + * The reason for the failure (if provided). + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param reason The reason for the failure (if provided). + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionFailedEventAttributes withReason(String reason) { + this.reason = reason; + return this; + } + + + /** + * The details of the failure (if provided). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The details of the failure (if provided). + */ + public String getDetails() { + return details; + } + + /** + * The details of the failure (if provided). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details The details of the failure (if provided). + */ + public void setDetails(String details) { + this.details = details; + } + + /** + * The details of the failure (if provided). + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details The details of the failure (if provided). + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionFailedEventAttributes withDetails(String details) { + this.details = details; + return this; + } + + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public Long getInitiatedEventId() { + return initiatedEventId; + } + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @param initiatedEventId The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public void setInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + } + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param initiatedEventId The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionFailedEventAttributes withInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + return this; + } + + + /** + * The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public Long getStartedEventId() { + return startedEventId; + } + + /** + * The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @param startedEventId The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public void setStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + } + + /** + * The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startedEventId The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionFailedEventAttributes withStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowExecution != null) sb.append("WorkflowExecution: " + workflowExecution + ", "); + if (workflowType != null) sb.append("WorkflowType: " + workflowType + ", "); + if (reason != null) sb.append("Reason: " + reason + ", "); + if (details != null) sb.append("Details: " + details + ", "); + if (initiatedEventId != null) sb.append("InitiatedEventId: " + initiatedEventId + ", "); + if (startedEventId != null) sb.append("StartedEventId: " + startedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowExecution() == null) ? 0 : getWorkflowExecution().hashCode()); + hashCode = prime * hashCode + ((getWorkflowType() == null) ? 0 : getWorkflowType().hashCode()); + hashCode = prime * hashCode + ((getReason() == null) ? 0 : getReason().hashCode()); + hashCode = prime * hashCode + ((getDetails() == null) ? 0 : getDetails().hashCode()); + hashCode = prime * hashCode + ((getInitiatedEventId() == null) ? 0 : getInitiatedEventId().hashCode()); + hashCode = prime * hashCode + ((getStartedEventId() == null) ? 0 : getStartedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ChildWorkflowExecutionFailedEventAttributes == false) return false; + ChildWorkflowExecutionFailedEventAttributes other = (ChildWorkflowExecutionFailedEventAttributes)obj; + + if (other.getWorkflowExecution() == null ^ this.getWorkflowExecution() == null) return false; + if (other.getWorkflowExecution() != null && other.getWorkflowExecution().equals(this.getWorkflowExecution()) == false) return false; + if (other.getWorkflowType() == null ^ this.getWorkflowType() == null) return false; + if (other.getWorkflowType() != null && other.getWorkflowType().equals(this.getWorkflowType()) == false) return false; + if (other.getReason() == null ^ this.getReason() == null) return false; + if (other.getReason() != null && other.getReason().equals(this.getReason()) == false) return false; + if (other.getDetails() == null ^ this.getDetails() == null) return false; + if (other.getDetails() != null && other.getDetails().equals(this.getDetails()) == false) return false; + if (other.getInitiatedEventId() == null ^ this.getInitiatedEventId() == null) return false; + if (other.getInitiatedEventId() != null && other.getInitiatedEventId().equals(this.getInitiatedEventId()) == false) return false; + if (other.getStartedEventId() == null ^ this.getStartedEventId() == null) return false; + if (other.getStartedEventId() != null && other.getStartedEventId().equals(this.getStartedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionStartedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionStartedEventAttributes.java new file mode 100644 index 000000000000..5c5f274652c9 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionStartedEventAttributes.java @@ -0,0 +1,218 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the ChildWorkflowExecutionStarted + * event. + *

+ */ +public class ChildWorkflowExecutionStartedEventAttributes { + + /** + * The child workflow execution that was started. + */ + private WorkflowExecution workflowExecution; + + /** + * The type of the child workflow execution. + */ + private WorkflowType workflowType; + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + private Long initiatedEventId; + + /** + * The child workflow execution that was started. + * + * @return The child workflow execution that was started. + */ + public WorkflowExecution getWorkflowExecution() { + return workflowExecution; + } + + /** + * The child workflow execution that was started. + * + * @param workflowExecution The child workflow execution that was started. + */ + public void setWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + } + + /** + * The child workflow execution that was started. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowExecution The child workflow execution that was started. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionStartedEventAttributes withWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + return this; + } + + + /** + * The type of the child workflow execution. + * + * @return The type of the child workflow execution. + */ + public WorkflowType getWorkflowType() { + return workflowType; + } + + /** + * The type of the child workflow execution. + * + * @param workflowType The type of the child workflow execution. + */ + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + /** + * The type of the child workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowType The type of the child workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionStartedEventAttributes withWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + return this; + } + + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public Long getInitiatedEventId() { + return initiatedEventId; + } + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @param initiatedEventId The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public void setInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + } + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param initiatedEventId The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionStartedEventAttributes withInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowExecution != null) sb.append("WorkflowExecution: " + workflowExecution + ", "); + if (workflowType != null) sb.append("WorkflowType: " + workflowType + ", "); + if (initiatedEventId != null) sb.append("InitiatedEventId: " + initiatedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowExecution() == null) ? 0 : getWorkflowExecution().hashCode()); + hashCode = prime * hashCode + ((getWorkflowType() == null) ? 0 : getWorkflowType().hashCode()); + hashCode = prime * hashCode + ((getInitiatedEventId() == null) ? 0 : getInitiatedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ChildWorkflowExecutionStartedEventAttributes == false) return false; + ChildWorkflowExecutionStartedEventAttributes other = (ChildWorkflowExecutionStartedEventAttributes)obj; + + if (other.getWorkflowExecution() == null ^ this.getWorkflowExecution() == null) return false; + if (other.getWorkflowExecution() != null && other.getWorkflowExecution().equals(this.getWorkflowExecution()) == false) return false; + if (other.getWorkflowType() == null ^ this.getWorkflowType() == null) return false; + if (other.getWorkflowType() != null && other.getWorkflowType().equals(this.getWorkflowType()) == false) return false; + if (other.getInitiatedEventId() == null ^ this.getInitiatedEventId() == null) return false; + if (other.getInitiatedEventId() != null && other.getInitiatedEventId().equals(this.getInitiatedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionTerminatedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionTerminatedEventAttributes.java new file mode 100644 index 000000000000..427e352e038d --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionTerminatedEventAttributes.java @@ -0,0 +1,282 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the ChildWorkflowExecutionTerminated + * event. + *

+ */ +public class ChildWorkflowExecutionTerminatedEventAttributes { + + /** + * The child workflow execution that was terminated. + */ + private WorkflowExecution workflowExecution; + + /** + * The type of the child workflow execution. + */ + private WorkflowType workflowType; + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + private Long initiatedEventId; + + /** + * The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + private Long startedEventId; + + /** + * The child workflow execution that was terminated. + * + * @return The child workflow execution that was terminated. + */ + public WorkflowExecution getWorkflowExecution() { + return workflowExecution; + } + + /** + * The child workflow execution that was terminated. + * + * @param workflowExecution The child workflow execution that was terminated. + */ + public void setWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + } + + /** + * The child workflow execution that was terminated. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowExecution The child workflow execution that was terminated. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionTerminatedEventAttributes withWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + return this; + } + + + /** + * The type of the child workflow execution. + * + * @return The type of the child workflow execution. + */ + public WorkflowType getWorkflowType() { + return workflowType; + } + + /** + * The type of the child workflow execution. + * + * @param workflowType The type of the child workflow execution. + */ + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + /** + * The type of the child workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowType The type of the child workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionTerminatedEventAttributes withWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + return this; + } + + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public Long getInitiatedEventId() { + return initiatedEventId; + } + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @param initiatedEventId The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public void setInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + } + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param initiatedEventId The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionTerminatedEventAttributes withInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + return this; + } + + + /** + * The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public Long getStartedEventId() { + return startedEventId; + } + + /** + * The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @param startedEventId The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public void setStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + } + + /** + * The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startedEventId The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionTerminatedEventAttributes withStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowExecution != null) sb.append("WorkflowExecution: " + workflowExecution + ", "); + if (workflowType != null) sb.append("WorkflowType: " + workflowType + ", "); + if (initiatedEventId != null) sb.append("InitiatedEventId: " + initiatedEventId + ", "); + if (startedEventId != null) sb.append("StartedEventId: " + startedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowExecution() == null) ? 0 : getWorkflowExecution().hashCode()); + hashCode = prime * hashCode + ((getWorkflowType() == null) ? 0 : getWorkflowType().hashCode()); + hashCode = prime * hashCode + ((getInitiatedEventId() == null) ? 0 : getInitiatedEventId().hashCode()); + hashCode = prime * hashCode + ((getStartedEventId() == null) ? 0 : getStartedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ChildWorkflowExecutionTerminatedEventAttributes == false) return false; + ChildWorkflowExecutionTerminatedEventAttributes other = (ChildWorkflowExecutionTerminatedEventAttributes)obj; + + if (other.getWorkflowExecution() == null ^ this.getWorkflowExecution() == null) return false; + if (other.getWorkflowExecution() != null && other.getWorkflowExecution().equals(this.getWorkflowExecution()) == false) return false; + if (other.getWorkflowType() == null ^ this.getWorkflowType() == null) return false; + if (other.getWorkflowType() != null && other.getWorkflowType().equals(this.getWorkflowType()) == false) return false; + if (other.getInitiatedEventId() == null ^ this.getInitiatedEventId() == null) return false; + if (other.getInitiatedEventId() != null && other.getInitiatedEventId().equals(this.getInitiatedEventId()) == false) return false; + if (other.getStartedEventId() == null ^ this.getStartedEventId() == null) return false; + if (other.getStartedEventId() != null && other.getStartedEventId().equals(this.getStartedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionTimedOutEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionTimedOutEventAttributes.java new file mode 100644 index 000000000000..79c2df8fb73f --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ChildWorkflowExecutionTimedOutEventAttributes.java @@ -0,0 +1,388 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the ChildWorkflowExecutionTimedOut + * event. + *

+ */ +public class ChildWorkflowExecutionTimedOutEventAttributes { + + /** + * The child workflow execution that timed out. + */ + private WorkflowExecution workflowExecution; + + /** + * The type of the child workflow execution. + */ + private WorkflowType workflowType; + + /** + * The type of the timeout that caused the child workflow execution to + * time out. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE + */ + private String timeoutType; + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + private Long initiatedEventId; + + /** + * The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + private Long startedEventId; + + /** + * The child workflow execution that timed out. + * + * @return The child workflow execution that timed out. + */ + public WorkflowExecution getWorkflowExecution() { + return workflowExecution; + } + + /** + * The child workflow execution that timed out. + * + * @param workflowExecution The child workflow execution that timed out. + */ + public void setWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + } + + /** + * The child workflow execution that timed out. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowExecution The child workflow execution that timed out. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionTimedOutEventAttributes withWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + return this; + } + + + /** + * The type of the child workflow execution. + * + * @return The type of the child workflow execution. + */ + public WorkflowType getWorkflowType() { + return workflowType; + } + + /** + * The type of the child workflow execution. + * + * @param workflowType The type of the child workflow execution. + */ + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + /** + * The type of the child workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowType The type of the child workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionTimedOutEventAttributes withWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + return this; + } + + + /** + * The type of the timeout that caused the child workflow execution to + * time out. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE + * + * @return The type of the timeout that caused the child workflow execution to + * time out. + * + * @see WorkflowExecutionTimeoutType + */ + public String getTimeoutType() { + return timeoutType; + } + + /** + * The type of the timeout that caused the child workflow execution to + * time out. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE + * + * @param timeoutType The type of the timeout that caused the child workflow execution to + * time out. + * + * @see WorkflowExecutionTimeoutType + */ + public void setTimeoutType(String timeoutType) { + this.timeoutType = timeoutType; + } + + /** + * The type of the timeout that caused the child workflow execution to + * time out. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE + * + * @param timeoutType The type of the timeout that caused the child workflow execution to + * time out. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see WorkflowExecutionTimeoutType + */ + public ChildWorkflowExecutionTimedOutEventAttributes withTimeoutType(String timeoutType) { + this.timeoutType = timeoutType; + return this; + } + + + /** + * The type of the timeout that caused the child workflow execution to + * time out. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE + * + * @param timeoutType The type of the timeout that caused the child workflow execution to + * time out. + * + * @see WorkflowExecutionTimeoutType + */ + public void setTimeoutType(WorkflowExecutionTimeoutType timeoutType) { + this.timeoutType = timeoutType.toString(); + } + + /** + * The type of the timeout that caused the child workflow execution to + * time out. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE + * + * @param timeoutType The type of the timeout that caused the child workflow execution to + * time out. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see WorkflowExecutionTimeoutType + */ + public ChildWorkflowExecutionTimedOutEventAttributes withTimeoutType(WorkflowExecutionTimeoutType timeoutType) { + this.timeoutType = timeoutType.toString(); + return this; + } + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public Long getInitiatedEventId() { + return initiatedEventId; + } + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @param initiatedEventId The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public void setInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + } + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param initiatedEventId The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionTimedOutEventAttributes withInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + return this; + } + + + /** + * The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public Long getStartedEventId() { + return startedEventId; + } + + /** + * The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @param startedEventId The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public void setStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + } + + /** + * The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startedEventId The Id of the ChildWorkflowExecutionStarted event + * recorded when this child workflow execution was started. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ChildWorkflowExecutionTimedOutEventAttributes withStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowExecution != null) sb.append("WorkflowExecution: " + workflowExecution + ", "); + if (workflowType != null) sb.append("WorkflowType: " + workflowType + ", "); + if (timeoutType != null) sb.append("TimeoutType: " + timeoutType + ", "); + if (initiatedEventId != null) sb.append("InitiatedEventId: " + initiatedEventId + ", "); + if (startedEventId != null) sb.append("StartedEventId: " + startedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowExecution() == null) ? 0 : getWorkflowExecution().hashCode()); + hashCode = prime * hashCode + ((getWorkflowType() == null) ? 0 : getWorkflowType().hashCode()); + hashCode = prime * hashCode + ((getTimeoutType() == null) ? 0 : getTimeoutType().hashCode()); + hashCode = prime * hashCode + ((getInitiatedEventId() == null) ? 0 : getInitiatedEventId().hashCode()); + hashCode = prime * hashCode + ((getStartedEventId() == null) ? 0 : getStartedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ChildWorkflowExecutionTimedOutEventAttributes == false) return false; + ChildWorkflowExecutionTimedOutEventAttributes other = (ChildWorkflowExecutionTimedOutEventAttributes)obj; + + if (other.getWorkflowExecution() == null ^ this.getWorkflowExecution() == null) return false; + if (other.getWorkflowExecution() != null && other.getWorkflowExecution().equals(this.getWorkflowExecution()) == false) return false; + if (other.getWorkflowType() == null ^ this.getWorkflowType() == null) return false; + if (other.getWorkflowType() != null && other.getWorkflowType().equals(this.getWorkflowType()) == false) return false; + if (other.getTimeoutType() == null ^ this.getTimeoutType() == null) return false; + if (other.getTimeoutType() != null && other.getTimeoutType().equals(this.getTimeoutType()) == false) return false; + if (other.getInitiatedEventId() == null ^ this.getInitiatedEventId() == null) return false; + if (other.getInitiatedEventId() != null && other.getInitiatedEventId().equals(this.getInitiatedEventId()) == false) return false; + if (other.getStartedEventId() == null ^ this.getStartedEventId() == null) return false; + if (other.getStartedEventId() != null && other.getStartedEventId().equals(this.getStartedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/CloseStatus.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/CloseStatus.java new file mode 100644 index 000000000000..9212a692a901 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/CloseStatus.java @@ -0,0 +1,68 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Close Status + */ +public enum CloseStatus { + + COMPLETED("COMPLETED"), + FAILED("FAILED"), + CANCELED("CANCELED"), + TERMINATED("TERMINATED"), + CONTINUED_AS_NEW("CONTINUED_AS_NEW"), + TIMED_OUT("TIMED_OUT"); + + private String value; + + private CloseStatus(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return CloseStatus corresponding to the value + */ + public static CloseStatus fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("COMPLETED".equals(value)) { + return CloseStatus.COMPLETED; + } else if ("FAILED".equals(value)) { + return CloseStatus.FAILED; + } else if ("CANCELED".equals(value)) { + return CloseStatus.CANCELED; + } else if ("TERMINATED".equals(value)) { + return CloseStatus.TERMINATED; + } else if ("CONTINUED_AS_NEW".equals(value)) { + return CloseStatus.CONTINUED_AS_NEW; + } else if ("TIMED_OUT".equals(value)) { + return CloseStatus.TIMED_OUT; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/CloseStatusFilter.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/CloseStatusFilter.java new file mode 100644 index 000000000000..90de7b8086c5 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/CloseStatusFilter.java @@ -0,0 +1,167 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Used to filter the closed workflow executions in visibility APIs by + * their close status. + *

+ */ +public class CloseStatusFilter { + + /** + * The close status that must match the close status of an execution for + * it to meet the criteria of this filter. This field is required. + *

+ * Constraints:
+ * Allowed Values: COMPLETED, FAILED, CANCELED, TERMINATED, CONTINUED_AS_NEW, TIMED_OUT + */ + private String status; + + /** + * The close status that must match the close status of an execution for + * it to meet the criteria of this filter. This field is required. + *

+ * Constraints:
+ * Allowed Values: COMPLETED, FAILED, CANCELED, TERMINATED, CONTINUED_AS_NEW, TIMED_OUT + * + * @return The close status that must match the close status of an execution for + * it to meet the criteria of this filter. This field is required. + * + * @see CloseStatus + */ + public String getStatus() { + return status; + } + + /** + * The close status that must match the close status of an execution for + * it to meet the criteria of this filter. This field is required. + *

+ * Constraints:
+ * Allowed Values: COMPLETED, FAILED, CANCELED, TERMINATED, CONTINUED_AS_NEW, TIMED_OUT + * + * @param status The close status that must match the close status of an execution for + * it to meet the criteria of this filter. This field is required. + * + * @see CloseStatus + */ + public void setStatus(String status) { + this.status = status; + } + + /** + * The close status that must match the close status of an execution for + * it to meet the criteria of this filter. This field is required. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: COMPLETED, FAILED, CANCELED, TERMINATED, CONTINUED_AS_NEW, TIMED_OUT + * + * @param status The close status that must match the close status of an execution for + * it to meet the criteria of this filter. This field is required. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see CloseStatus + */ + public CloseStatusFilter withStatus(String status) { + this.status = status; + return this; + } + + + /** + * The close status that must match the close status of an execution for + * it to meet the criteria of this filter. This field is required. + *

+ * Constraints:
+ * Allowed Values: COMPLETED, FAILED, CANCELED, TERMINATED, CONTINUED_AS_NEW, TIMED_OUT + * + * @param status The close status that must match the close status of an execution for + * it to meet the criteria of this filter. This field is required. + * + * @see CloseStatus + */ + public void setStatus(CloseStatus status) { + this.status = status.toString(); + } + + /** + * The close status that must match the close status of an execution for + * it to meet the criteria of this filter. This field is required. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: COMPLETED, FAILED, CANCELED, TERMINATED, CONTINUED_AS_NEW, TIMED_OUT + * + * @param status The close status that must match the close status of an execution for + * it to meet the criteria of this filter. This field is required. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see CloseStatus + */ + public CloseStatusFilter withStatus(CloseStatus status) { + this.status = status.toString(); + return this; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (status != null) sb.append("Status: " + status + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getStatus() == null) ? 0 : getStatus().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof CloseStatusFilter == false) return false; + CloseStatusFilter other = (CloseStatusFilter)obj; + + if (other.getStatus() == null ^ this.getStatus() == null) return false; + if (other.getStatus() != null && other.getStatus().equals(this.getStatus()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/CompleteWorkflowExecutionDecisionAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/CompleteWorkflowExecutionDecisionAttributes.java new file mode 100644 index 000000000000..bda0374573a5 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/CompleteWorkflowExecutionDecisionAttributes.java @@ -0,0 +1,123 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the CompleteWorkflowExecution + * decision. + *

+ */ +public class CompleteWorkflowExecutionDecisionAttributes { + + /** + * The result of the workflow execution. The form of the result is + * implementation defined. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String result; + + /** + * The result of the workflow execution. The form of the result is + * implementation defined. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The result of the workflow execution. The form of the result is + * implementation defined. + */ + public String getResult() { + return result; + } + + /** + * The result of the workflow execution. The form of the result is + * implementation defined. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param result The result of the workflow execution. The form of the result is + * implementation defined. + */ + public void setResult(String result) { + this.result = result; + } + + /** + * The result of the workflow execution. The form of the result is + * implementation defined. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param result The result of the workflow execution. The form of the result is + * implementation defined. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CompleteWorkflowExecutionDecisionAttributes withResult(String result) { + this.result = result; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (result != null) sb.append("Result: " + result + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getResult() == null) ? 0 : getResult().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof CompleteWorkflowExecutionDecisionAttributes == false) return false; + CompleteWorkflowExecutionDecisionAttributes other = (CompleteWorkflowExecutionDecisionAttributes)obj; + + if (other.getResult() == null ^ this.getResult() == null) return false; + if (other.getResult() != null && other.getResult().equals(this.getResult()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/CompleteWorkflowExecutionFailedCause.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/CompleteWorkflowExecutionFailedCause.java new file mode 100644 index 000000000000..8f9117d42e6b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/CompleteWorkflowExecutionFailedCause.java @@ -0,0 +1,53 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Complete Workflow Execution Failed Cause + */ +public enum CompleteWorkflowExecutionFailedCause { + + UNHANDLED_DECISION("UNHANDLED_DECISION"); + + private String value; + + private CompleteWorkflowExecutionFailedCause(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return CompleteWorkflowExecutionFailedCause corresponding to the value + */ + public static CompleteWorkflowExecutionFailedCause fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("UNHANDLED_DECISION".equals(value)) { + return CompleteWorkflowExecutionFailedCause.UNHANDLED_DECISION; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/CompleteWorkflowExecutionFailedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/CompleteWorkflowExecutionFailedEventAttributes.java new file mode 100644 index 000000000000..c76666797800 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/CompleteWorkflowExecutionFailedEventAttributes.java @@ -0,0 +1,238 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the CompleteWorkflowExecutionFailed + * event. + *

+ */ +public class CompleteWorkflowExecutionFailedEventAttributes { + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION + */ + private String cause; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CompleteWorkflowExecution decision to complete this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + private Long decisionTaskCompletedEventId; + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION + * + * @return The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + * + * @see CompleteWorkflowExecutionFailedCause + */ + public String getCause() { + return cause; + } + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION + * + * @param cause The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + * + * @see CompleteWorkflowExecutionFailedCause + */ + public void setCause(String cause) { + this.cause = cause; + } + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION + * + * @param cause The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see CompleteWorkflowExecutionFailedCause + */ + public CompleteWorkflowExecutionFailedEventAttributes withCause(String cause) { + this.cause = cause; + return this; + } + + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION + * + * @param cause The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + * + * @see CompleteWorkflowExecutionFailedCause + */ + public void setCause(CompleteWorkflowExecutionFailedCause cause) { + this.cause = cause.toString(); + } + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION + * + * @param cause The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see CompleteWorkflowExecutionFailedCause + */ + public CompleteWorkflowExecutionFailedEventAttributes withCause(CompleteWorkflowExecutionFailedCause cause) { + this.cause = cause.toString(); + return this; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CompleteWorkflowExecution decision to complete this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CompleteWorkflowExecution decision to complete this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CompleteWorkflowExecution decision to complete this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CompleteWorkflowExecution decision to complete this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CompleteWorkflowExecution decision to complete this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CompleteWorkflowExecution decision to complete this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CompleteWorkflowExecutionFailedEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (cause != null) sb.append("Cause: " + cause + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getCause() == null) ? 0 : getCause().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof CompleteWorkflowExecutionFailedEventAttributes == false) return false; + CompleteWorkflowExecutionFailedEventAttributes other = (CompleteWorkflowExecutionFailedEventAttributes)obj; + + if (other.getCause() == null ^ this.getCause() == null) return false; + if (other.getCause() != null && other.getCause().equals(this.getCause()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ContinueAsNewWorkflowExecutionDecisionAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ContinueAsNewWorkflowExecutionDecisionAttributes.java new file mode 100644 index 000000000000..f74477847d89 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ContinueAsNewWorkflowExecutionDecisionAttributes.java @@ -0,0 +1,856 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the ContinueAsNewWorkflowExecution + * decision. + *

+ */ +public class ContinueAsNewWorkflowExecutionDecisionAttributes { + + /** + * The input provided to the new workflow execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String input; + + /** + * If set, specifies the total duration for this workflow execution. This + * overrides the defaultExecutionStartToCloseTimeout + * specified when registering the workflow type.

The valid values are + * integers greater than or equal to 0. An integer value can + * be used to specify the duration in seconds while NONE can + * be used to specify unlimited duration. An execution + * start-to-close timeout for this workflow execution must be specified + * either as a default for the workflow type or through this field. If + * neither this field is set nor a default execution start-to-close + * timeout was specified at registration time then a fault will be + * returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String executionStartToCloseTimeout; + + /** + * Represents a task list. + */ + private TaskList taskList; + + /** + * Specifies the maximum duration of decision tasks for the new workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for the new workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String taskStartToCloseTimeout; + + /** + * If set, specifies the policy to use for the child workflow executions + * of the new execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the new workflow execution must be specified + * either as a default registered for its workflow type or through this + * field. If neither this field is set nor a default child policy was + * specified at registration time then a fault will be returned. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + */ + private String childPolicy; + + /** + * The list of tags to associate with the new workflow execution. A + * maximum of 5 tags can be specified. You can list workflow executions + * with a specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + *

+ * Constraints:
+ * Length: 0 - 5
+ */ + private java.util.List tagList; + + private String workflowTypeVersion; + + /** + * The input provided to the new workflow execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The input provided to the new workflow execution. + */ + public String getInput() { + return input; + } + + /** + * The input provided to the new workflow execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input The input provided to the new workflow execution. + */ + public void setInput(String input) { + this.input = input; + } + + /** + * The input provided to the new workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input The input provided to the new workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ContinueAsNewWorkflowExecutionDecisionAttributes withInput(String input) { + this.input = input; + return this; + } + + + /** + * If set, specifies the total duration for this workflow execution. This + * overrides the defaultExecutionStartToCloseTimeout + * specified when registering the workflow type.

The valid values are + * integers greater than or equal to 0. An integer value can + * be used to specify the duration in seconds while NONE can + * be used to specify unlimited duration. An execution + * start-to-close timeout for this workflow execution must be specified + * either as a default for the workflow type or through this field. If + * neither this field is set nor a default execution start-to-close + * timeout was specified at registration time then a fault will be + * returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return If set, specifies the total duration for this workflow execution. This + * overrides the defaultExecutionStartToCloseTimeout + * specified when registering the workflow type.

The valid values are + * integers greater than or equal to 0. An integer value can + * be used to specify the duration in seconds while NONE can + * be used to specify unlimited duration. An execution + * start-to-close timeout for this workflow execution must be specified + * either as a default for the workflow type or through this field. If + * neither this field is set nor a default execution start-to-close + * timeout was specified at registration time then a fault will be + * returned. + */ + public String getExecutionStartToCloseTimeout() { + return executionStartToCloseTimeout; + } + + /** + * If set, specifies the total duration for this workflow execution. This + * overrides the defaultExecutionStartToCloseTimeout + * specified when registering the workflow type.

The valid values are + * integers greater than or equal to 0. An integer value can + * be used to specify the duration in seconds while NONE can + * be used to specify unlimited duration. An execution + * start-to-close timeout for this workflow execution must be specified + * either as a default for the workflow type or through this field. If + * neither this field is set nor a default execution start-to-close + * timeout was specified at registration time then a fault will be + * returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param executionStartToCloseTimeout If set, specifies the total duration for this workflow execution. This + * overrides the defaultExecutionStartToCloseTimeout + * specified when registering the workflow type.

The valid values are + * integers greater than or equal to 0. An integer value can + * be used to specify the duration in seconds while NONE can + * be used to specify unlimited duration. An execution + * start-to-close timeout for this workflow execution must be specified + * either as a default for the workflow type or through this field. If + * neither this field is set nor a default execution start-to-close + * timeout was specified at registration time then a fault will be + * returned. + */ + public void setExecutionStartToCloseTimeout(String executionStartToCloseTimeout) { + this.executionStartToCloseTimeout = executionStartToCloseTimeout; + } + + /** + * If set, specifies the total duration for this workflow execution. This + * overrides the defaultExecutionStartToCloseTimeout + * specified when registering the workflow type.

The valid values are + * integers greater than or equal to 0. An integer value can + * be used to specify the duration in seconds while NONE can + * be used to specify unlimited duration. An execution + * start-to-close timeout for this workflow execution must be specified + * either as a default for the workflow type or through this field. If + * neither this field is set nor a default execution start-to-close + * timeout was specified at registration time then a fault will be + * returned. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param executionStartToCloseTimeout If set, specifies the total duration for this workflow execution. This + * overrides the defaultExecutionStartToCloseTimeout + * specified when registering the workflow type.

The valid values are + * integers greater than or equal to 0. An integer value can + * be used to specify the duration in seconds while NONE can + * be used to specify unlimited duration. An execution + * start-to-close timeout for this workflow execution must be specified + * either as a default for the workflow type or through this field. If + * neither this field is set nor a default execution start-to-close + * timeout was specified at registration time then a fault will be + * returned. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ContinueAsNewWorkflowExecutionDecisionAttributes withExecutionStartToCloseTimeout(String executionStartToCloseTimeout) { + this.executionStartToCloseTimeout = executionStartToCloseTimeout; + return this; + } + + + /** + * Represents a task list. + * + * @return Represents a task list. + */ + public TaskList getTaskList() { + return taskList; + } + + /** + * Represents a task list. + * + * @param taskList Represents a task list. + */ + public void setTaskList(TaskList taskList) { + this.taskList = taskList; + } + + /** + * Represents a task list. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param taskList Represents a task list. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ContinueAsNewWorkflowExecutionDecisionAttributes withTaskList(TaskList taskList) { + this.taskList = taskList; + return this; + } + + + /** + * Specifies the maximum duration of decision tasks for the new workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for the new workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return Specifies the maximum duration of decision tasks for the new workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for the new workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + */ + public String getTaskStartToCloseTimeout() { + return taskStartToCloseTimeout; + } + + /** + * Specifies the maximum duration of decision tasks for the new workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for the new workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param taskStartToCloseTimeout Specifies the maximum duration of decision tasks for the new workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for the new workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + */ + public void setTaskStartToCloseTimeout(String taskStartToCloseTimeout) { + this.taskStartToCloseTimeout = taskStartToCloseTimeout; + } + + /** + * Specifies the maximum duration of decision tasks for the new workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for the new workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param taskStartToCloseTimeout Specifies the maximum duration of decision tasks for the new workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for the new workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ContinueAsNewWorkflowExecutionDecisionAttributes withTaskStartToCloseTimeout(String taskStartToCloseTimeout) { + this.taskStartToCloseTimeout = taskStartToCloseTimeout; + return this; + } + + + /** + * If set, specifies the policy to use for the child workflow executions + * of the new execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the new workflow execution must be specified + * either as a default registered for its workflow type or through this + * field. If neither this field is set nor a default child policy was + * specified at registration time then a fault will be returned. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @return If set, specifies the policy to use for the child workflow executions + * of the new execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the new workflow execution must be specified + * either as a default registered for its workflow type or through this + * field. If neither this field is set nor a default child policy was + * specified at registration time then a fault will be returned. + * + * @see ChildPolicy + */ + public String getChildPolicy() { + return childPolicy; + } + + /** + * If set, specifies the policy to use for the child workflow executions + * of the new execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the new workflow execution must be specified + * either as a default registered for its workflow type or through this + * field. If neither this field is set nor a default child policy was + * specified at registration time then a fault will be returned. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy If set, specifies the policy to use for the child workflow executions + * of the new execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the new workflow execution must be specified + * either as a default registered for its workflow type or through this + * field. If neither this field is set nor a default child policy was + * specified at registration time then a fault will be returned. + * + * @see ChildPolicy + */ + public void setChildPolicy(String childPolicy) { + this.childPolicy = childPolicy; + } + + /** + * If set, specifies the policy to use for the child workflow executions + * of the new execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the new workflow execution must be specified + * either as a default registered for its workflow type or through this + * field. If neither this field is set nor a default child policy was + * specified at registration time then a fault will be returned. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy If set, specifies the policy to use for the child workflow executions + * of the new execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the new workflow execution must be specified + * either as a default registered for its workflow type or through this + * field. If neither this field is set nor a default child policy was + * specified at registration time then a fault will be returned. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public ContinueAsNewWorkflowExecutionDecisionAttributes withChildPolicy(String childPolicy) { + this.childPolicy = childPolicy; + return this; + } + + + /** + * If set, specifies the policy to use for the child workflow executions + * of the new execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the new workflow execution must be specified + * either as a default registered for its workflow type or through this + * field. If neither this field is set nor a default child policy was + * specified at registration time then a fault will be returned. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy If set, specifies the policy to use for the child workflow executions + * of the new execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the new workflow execution must be specified + * either as a default registered for its workflow type or through this + * field. If neither this field is set nor a default child policy was + * specified at registration time then a fault will be returned. + * + * @see ChildPolicy + */ + public void setChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy.toString(); + } + + /** + * If set, specifies the policy to use for the child workflow executions + * of the new execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the new workflow execution must be specified + * either as a default registered for its workflow type or through this + * field. If neither this field is set nor a default child policy was + * specified at registration time then a fault will be returned. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy If set, specifies the policy to use for the child workflow executions + * of the new execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the new workflow execution must be specified + * either as a default registered for its workflow type or through this + * field. If neither this field is set nor a default child policy was + * specified at registration time then a fault will be returned. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public ContinueAsNewWorkflowExecutionDecisionAttributes withChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy.toString(); + return this; + } + + /** + * The list of tags to associate with the new workflow execution. A + * maximum of 5 tags can be specified. You can list workflow executions + * with a specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @return The list of tags to associate with the new workflow execution. A + * maximum of 5 tags can be specified. You can list workflow executions + * with a specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + */ + public java.util.List getTagList() { + + if (tagList == null) { + tagList = new java.util.ArrayList(); + } + return tagList; + } + + /** + * The list of tags to associate with the new workflow execution. A + * maximum of 5 tags can be specified. You can list workflow executions + * with a specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags to associate with the new workflow execution. A + * maximum of 5 tags can be specified. You can list workflow executions + * with a specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + */ + public void setTagList(java.util.Collection tagList) { + if (tagList == null) { + this.tagList = null; + return; + } + + java.util.List tagListCopy = new java.util.ArrayList(tagList.size()); + tagListCopy.addAll(tagList); + this.tagList = tagListCopy; + } + + /** + * The list of tags to associate with the new workflow execution. A + * maximum of 5 tags can be specified. You can list workflow executions + * with a specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags to associate with the new workflow execution. A + * maximum of 5 tags can be specified. You can list workflow executions + * with a specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ContinueAsNewWorkflowExecutionDecisionAttributes withTagList(String... tagList) { + if (getTagList() == null) setTagList(new java.util.ArrayList(tagList.length)); + for (String value : tagList) { + getTagList().add(value); + } + return this; + } + + /** + * The list of tags to associate with the new workflow execution. A + * maximum of 5 tags can be specified. You can list workflow executions + * with a specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags to associate with the new workflow execution. A + * maximum of 5 tags can be specified. You can list workflow executions + * with a specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ContinueAsNewWorkflowExecutionDecisionAttributes withTagList(java.util.Collection tagList) { + if (tagList == null) { + this.tagList = null; + } else { + java.util.List tagListCopy = new java.util.ArrayList(tagList.size()); + tagListCopy.addAll(tagList); + this.tagList = tagListCopy; + } + + return this; + } + + /** + * Returns the value of the WorkflowTypeVersion property for this object. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @return The value of the WorkflowTypeVersion property for this object. + */ + public String getWorkflowTypeVersion() { + return workflowTypeVersion; + } + + /** + * Sets the value of the WorkflowTypeVersion property for this object. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param workflowTypeVersion The new value for the WorkflowTypeVersion property for this object. + */ + public void setWorkflowTypeVersion(String workflowTypeVersion) { + this.workflowTypeVersion = workflowTypeVersion; + } + + /** + * Sets the value of the WorkflowTypeVersion property for this object. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param workflowTypeVersion The new value for the WorkflowTypeVersion property for this object. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ContinueAsNewWorkflowExecutionDecisionAttributes withWorkflowTypeVersion(String workflowTypeVersion) { + this.workflowTypeVersion = workflowTypeVersion; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (input != null) sb.append("Input: " + input + ", "); + if (executionStartToCloseTimeout != null) sb.append("ExecutionStartToCloseTimeout: " + executionStartToCloseTimeout + ", "); + if (taskList != null) sb.append("TaskList: " + taskList + ", "); + if (taskStartToCloseTimeout != null) sb.append("TaskStartToCloseTimeout: " + taskStartToCloseTimeout + ", "); + if (childPolicy != null) sb.append("ChildPolicy: " + childPolicy + ", "); + if (tagList != null) sb.append("TagList: " + tagList + ", "); + if (workflowTypeVersion != null) sb.append("WorkflowTypeVersion: " + workflowTypeVersion + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getInput() == null) ? 0 : getInput().hashCode()); + hashCode = prime * hashCode + ((getExecutionStartToCloseTimeout() == null) ? 0 : getExecutionStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getTaskList() == null) ? 0 : getTaskList().hashCode()); + hashCode = prime * hashCode + ((getTaskStartToCloseTimeout() == null) ? 0 : getTaskStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getChildPolicy() == null) ? 0 : getChildPolicy().hashCode()); + hashCode = prime * hashCode + ((getTagList() == null) ? 0 : getTagList().hashCode()); + hashCode = prime * hashCode + ((getWorkflowTypeVersion() == null) ? 0 : getWorkflowTypeVersion().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ContinueAsNewWorkflowExecutionDecisionAttributes == false) return false; + ContinueAsNewWorkflowExecutionDecisionAttributes other = (ContinueAsNewWorkflowExecutionDecisionAttributes)obj; + + if (other.getInput() == null ^ this.getInput() == null) return false; + if (other.getInput() != null && other.getInput().equals(this.getInput()) == false) return false; + if (other.getExecutionStartToCloseTimeout() == null ^ this.getExecutionStartToCloseTimeout() == null) return false; + if (other.getExecutionStartToCloseTimeout() != null && other.getExecutionStartToCloseTimeout().equals(this.getExecutionStartToCloseTimeout()) == false) return false; + if (other.getTaskList() == null ^ this.getTaskList() == null) return false; + if (other.getTaskList() != null && other.getTaskList().equals(this.getTaskList()) == false) return false; + if (other.getTaskStartToCloseTimeout() == null ^ this.getTaskStartToCloseTimeout() == null) return false; + if (other.getTaskStartToCloseTimeout() != null && other.getTaskStartToCloseTimeout().equals(this.getTaskStartToCloseTimeout()) == false) return false; + if (other.getChildPolicy() == null ^ this.getChildPolicy() == null) return false; + if (other.getChildPolicy() != null && other.getChildPolicy().equals(this.getChildPolicy()) == false) return false; + if (other.getTagList() == null ^ this.getTagList() == null) return false; + if (other.getTagList() != null && other.getTagList().equals(this.getTagList()) == false) return false; + if (other.getWorkflowTypeVersion() == null ^ this.getWorkflowTypeVersion() == null) return false; + if (other.getWorkflowTypeVersion() != null && other.getWorkflowTypeVersion().equals(this.getWorkflowTypeVersion()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ContinueAsNewWorkflowExecutionFailedCause.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ContinueAsNewWorkflowExecutionFailedCause.java new file mode 100644 index 000000000000..93075456f35f --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ContinueAsNewWorkflowExecutionFailedCause.java @@ -0,0 +1,68 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Continue As New Workflow Execution Failed Cause + */ +public enum ContinueAsNewWorkflowExecutionFailedCause { + + UNHANDLED_DECISION("UNHANDLED_DECISION"), + WORKFLOW_TYPE_DEPRECATED("WORKFLOW_TYPE_DEPRECATED"), + DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_UNDEFINED("DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_UNDEFINED"), + DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_UNDEFINED("DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_UNDEFINED"), + DEFAULT_TASK_LIST_UNDEFINED("DEFAULT_TASK_LIST_UNDEFINED"), + DEFAULT_CHILD_POLICY_UNDEFINED("DEFAULT_CHILD_POLICY_UNDEFINED"); + + private String value; + + private ContinueAsNewWorkflowExecutionFailedCause(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return ContinueAsNewWorkflowExecutionFailedCause corresponding to the value + */ + public static ContinueAsNewWorkflowExecutionFailedCause fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("UNHANDLED_DECISION".equals(value)) { + return ContinueAsNewWorkflowExecutionFailedCause.UNHANDLED_DECISION; + } else if ("WORKFLOW_TYPE_DEPRECATED".equals(value)) { + return ContinueAsNewWorkflowExecutionFailedCause.WORKFLOW_TYPE_DEPRECATED; + } else if ("DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_UNDEFINED".equals(value)) { + return ContinueAsNewWorkflowExecutionFailedCause.DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_UNDEFINED; + } else if ("DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_UNDEFINED".equals(value)) { + return ContinueAsNewWorkflowExecutionFailedCause.DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_UNDEFINED; + } else if ("DEFAULT_TASK_LIST_UNDEFINED".equals(value)) { + return ContinueAsNewWorkflowExecutionFailedCause.DEFAULT_TASK_LIST_UNDEFINED; + } else if ("DEFAULT_CHILD_POLICY_UNDEFINED".equals(value)) { + return ContinueAsNewWorkflowExecutionFailedCause.DEFAULT_CHILD_POLICY_UNDEFINED; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ContinueAsNewWorkflowExecutionFailedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ContinueAsNewWorkflowExecutionFailedEventAttributes.java new file mode 100644 index 000000000000..a8f69576ab95 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ContinueAsNewWorkflowExecutionFailedEventAttributes.java @@ -0,0 +1,238 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the + * ContinueAsNewWorkflowExecutionFailed event. + *

+ */ +public class ContinueAsNewWorkflowExecutionFailedEventAttributes { + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION, WORKFLOW_TYPE_DEPRECATED, DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_LIST_UNDEFINED, DEFAULT_CHILD_POLICY_UNDEFINED + */ + private String cause; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * ContinueAsNewWorkflowExecution decision that started this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + private Long decisionTaskCompletedEventId; + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION, WORKFLOW_TYPE_DEPRECATED, DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_LIST_UNDEFINED, DEFAULT_CHILD_POLICY_UNDEFINED + * + * @return The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + * + * @see ContinueAsNewWorkflowExecutionFailedCause + */ + public String getCause() { + return cause; + } + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION, WORKFLOW_TYPE_DEPRECATED, DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_LIST_UNDEFINED, DEFAULT_CHILD_POLICY_UNDEFINED + * + * @param cause The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + * + * @see ContinueAsNewWorkflowExecutionFailedCause + */ + public void setCause(String cause) { + this.cause = cause; + } + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION, WORKFLOW_TYPE_DEPRECATED, DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_LIST_UNDEFINED, DEFAULT_CHILD_POLICY_UNDEFINED + * + * @param cause The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ContinueAsNewWorkflowExecutionFailedCause + */ + public ContinueAsNewWorkflowExecutionFailedEventAttributes withCause(String cause) { + this.cause = cause; + return this; + } + + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION, WORKFLOW_TYPE_DEPRECATED, DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_LIST_UNDEFINED, DEFAULT_CHILD_POLICY_UNDEFINED + * + * @param cause The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + * + * @see ContinueAsNewWorkflowExecutionFailedCause + */ + public void setCause(ContinueAsNewWorkflowExecutionFailedCause cause) { + this.cause = cause.toString(); + } + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION, WORKFLOW_TYPE_DEPRECATED, DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_LIST_UNDEFINED, DEFAULT_CHILD_POLICY_UNDEFINED + * + * @param cause The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ContinueAsNewWorkflowExecutionFailedCause + */ + public ContinueAsNewWorkflowExecutionFailedEventAttributes withCause(ContinueAsNewWorkflowExecutionFailedCause cause) { + this.cause = cause.toString(); + return this; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * ContinueAsNewWorkflowExecution decision that started this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * ContinueAsNewWorkflowExecution decision that started this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * ContinueAsNewWorkflowExecution decision that started this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * ContinueAsNewWorkflowExecution decision that started this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * ContinueAsNewWorkflowExecution decision that started this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * ContinueAsNewWorkflowExecution decision that started this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ContinueAsNewWorkflowExecutionFailedEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (cause != null) sb.append("Cause: " + cause + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getCause() == null) ? 0 : getCause().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ContinueAsNewWorkflowExecutionFailedEventAttributes == false) return false; + ContinueAsNewWorkflowExecutionFailedEventAttributes other = (ContinueAsNewWorkflowExecutionFailedEventAttributes)obj; + + if (other.getCause() == null ^ this.getCause() == null) return false; + if (other.getCause() != null && other.getCause().equals(this.getCause()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/CountClosedWorkflowExecutionsRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/CountClosedWorkflowExecutionsRequest.java new file mode 100644 index 000000000000..79e4eca6f663 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/CountClosedWorkflowExecutionsRequest.java @@ -0,0 +1,543 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#countClosedWorkflowExecutions(CountClosedWorkflowExecutionsRequest) CountClosedWorkflowExecutions operation}. + *

+ * Returns the number of closed workflow executions within the given + * domain that meet the specified filtering criteria. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#countClosedWorkflowExecutions(CountClosedWorkflowExecutionsRequest) + */ +public class CountClosedWorkflowExecutionsRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain containing the workflow executions to count. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * If specified, only workflow executions that meet the start time + * criteria of the filter are counted. startTimeFilter + * and closeTimeFilter are mutually exclusive. You must + * specify one of these in a request but not both. + */ + private ExecutionTimeFilter startTimeFilter; + + /** + * If specified, only workflow executions that meet the close time + * criteria of the filter are counted. startTimeFilter + * and closeTimeFilter are mutually exclusive. You must + * specify one of these in a request but not both. + */ + private ExecutionTimeFilter closeTimeFilter; + + /** + * If specified, only workflow executions matching the + * WorkflowId in the filter are counted. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + */ + private WorkflowExecutionFilter executionFilter; + + /** + * If specified, indicates the type of the workflow executions to be + * counted. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + private WorkflowTypeFilter typeFilter; + + /** + * If specified, only executions that have a tag that matches the filter + * are counted. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + private TagFilter tagFilter; + + /** + * If specified, only workflow executions that match this close status + * are counted. This filter has an affect only if + * executionStatus is specified as CLOSED. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + */ + private CloseStatusFilter closeStatusFilter; + + /** + * The name of the domain containing the workflow executions to count. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain containing the workflow executions to count. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain containing the workflow executions to count. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain containing the workflow executions to count. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain containing the workflow executions to count. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain containing the workflow executions to count. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CountClosedWorkflowExecutionsRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * If specified, only workflow executions that meet the start time + * criteria of the filter are counted. startTimeFilter + * and closeTimeFilter are mutually exclusive. You must + * specify one of these in a request but not both. + * + * @return If specified, only workflow executions that meet the start time + * criteria of the filter are counted. startTimeFilter + * and closeTimeFilter are mutually exclusive. You must + * specify one of these in a request but not both. + */ + public ExecutionTimeFilter getStartTimeFilter() { + return startTimeFilter; + } + + /** + * If specified, only workflow executions that meet the start time + * criteria of the filter are counted. startTimeFilter + * and closeTimeFilter are mutually exclusive. You must + * specify one of these in a request but not both. + * + * @param startTimeFilter If specified, only workflow executions that meet the start time + * criteria of the filter are counted. startTimeFilter + * and closeTimeFilter are mutually exclusive. You must + * specify one of these in a request but not both. + */ + public void setStartTimeFilter(ExecutionTimeFilter startTimeFilter) { + this.startTimeFilter = startTimeFilter; + } + + /** + * If specified, only workflow executions that meet the start time + * criteria of the filter are counted. startTimeFilter + * and closeTimeFilter are mutually exclusive. You must + * specify one of these in a request but not both. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startTimeFilter If specified, only workflow executions that meet the start time + * criteria of the filter are counted. startTimeFilter + * and closeTimeFilter are mutually exclusive. You must + * specify one of these in a request but not both. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CountClosedWorkflowExecutionsRequest withStartTimeFilter(ExecutionTimeFilter startTimeFilter) { + this.startTimeFilter = startTimeFilter; + return this; + } + + + /** + * If specified, only workflow executions that meet the close time + * criteria of the filter are counted. startTimeFilter + * and closeTimeFilter are mutually exclusive. You must + * specify one of these in a request but not both. + * + * @return If specified, only workflow executions that meet the close time + * criteria of the filter are counted. startTimeFilter + * and closeTimeFilter are mutually exclusive. You must + * specify one of these in a request but not both. + */ + public ExecutionTimeFilter getCloseTimeFilter() { + return closeTimeFilter; + } + + /** + * If specified, only workflow executions that meet the close time + * criteria of the filter are counted. startTimeFilter + * and closeTimeFilter are mutually exclusive. You must + * specify one of these in a request but not both. + * + * @param closeTimeFilter If specified, only workflow executions that meet the close time + * criteria of the filter are counted. startTimeFilter + * and closeTimeFilter are mutually exclusive. You must + * specify one of these in a request but not both. + */ + public void setCloseTimeFilter(ExecutionTimeFilter closeTimeFilter) { + this.closeTimeFilter = closeTimeFilter; + } + + /** + * If specified, only workflow executions that meet the close time + * criteria of the filter are counted. startTimeFilter + * and closeTimeFilter are mutually exclusive. You must + * specify one of these in a request but not both. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param closeTimeFilter If specified, only workflow executions that meet the close time + * criteria of the filter are counted. startTimeFilter + * and closeTimeFilter are mutually exclusive. You must + * specify one of these in a request but not both. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CountClosedWorkflowExecutionsRequest withCloseTimeFilter(ExecutionTimeFilter closeTimeFilter) { + this.closeTimeFilter = closeTimeFilter; + return this; + } + + + /** + * If specified, only workflow executions matching the + * WorkflowId in the filter are counted. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + * + * @return If specified, only workflow executions matching the + * WorkflowId in the filter are counted. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + */ + public WorkflowExecutionFilter getExecutionFilter() { + return executionFilter; + } + + /** + * If specified, only workflow executions matching the + * WorkflowId in the filter are counted. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + * + * @param executionFilter If specified, only workflow executions matching the + * WorkflowId in the filter are counted. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + */ + public void setExecutionFilter(WorkflowExecutionFilter executionFilter) { + this.executionFilter = executionFilter; + } + + /** + * If specified, only workflow executions matching the + * WorkflowId in the filter are counted. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param executionFilter If specified, only workflow executions matching the + * WorkflowId in the filter are counted. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CountClosedWorkflowExecutionsRequest withExecutionFilter(WorkflowExecutionFilter executionFilter) { + this.executionFilter = executionFilter; + return this; + } + + + /** + * If specified, indicates the type of the workflow executions to be + * counted. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @return If specified, indicates the type of the workflow executions to be + * counted. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + public WorkflowTypeFilter getTypeFilter() { + return typeFilter; + } + + /** + * If specified, indicates the type of the workflow executions to be + * counted. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @param typeFilter If specified, indicates the type of the workflow executions to be + * counted. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + public void setTypeFilter(WorkflowTypeFilter typeFilter) { + this.typeFilter = typeFilter; + } + + /** + * If specified, indicates the type of the workflow executions to be + * counted. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param typeFilter If specified, indicates the type of the workflow executions to be + * counted. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CountClosedWorkflowExecutionsRequest withTypeFilter(WorkflowTypeFilter typeFilter) { + this.typeFilter = typeFilter; + return this; + } + + + /** + * If specified, only executions that have a tag that matches the filter + * are counted. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @return If specified, only executions that have a tag that matches the filter + * are counted. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + public TagFilter getTagFilter() { + return tagFilter; + } + + /** + * If specified, only executions that have a tag that matches the filter + * are counted. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @param tagFilter If specified, only executions that have a tag that matches the filter + * are counted. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + public void setTagFilter(TagFilter tagFilter) { + this.tagFilter = tagFilter; + } + + /** + * If specified, only executions that have a tag that matches the filter + * are counted. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param tagFilter If specified, only executions that have a tag that matches the filter + * are counted. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CountClosedWorkflowExecutionsRequest withTagFilter(TagFilter tagFilter) { + this.tagFilter = tagFilter; + return this; + } + + + /** + * If specified, only workflow executions that match this close status + * are counted. This filter has an affect only if + * executionStatus is specified as CLOSED. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + * + * @return If specified, only workflow executions that match this close status + * are counted. This filter has an affect only if + * executionStatus is specified as CLOSED. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + */ + public CloseStatusFilter getCloseStatusFilter() { + return closeStatusFilter; + } + + /** + * If specified, only workflow executions that match this close status + * are counted. This filter has an affect only if + * executionStatus is specified as CLOSED. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + * + * @param closeStatusFilter If specified, only workflow executions that match this close status + * are counted. This filter has an affect only if + * executionStatus is specified as CLOSED. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + */ + public void setCloseStatusFilter(CloseStatusFilter closeStatusFilter) { + this.closeStatusFilter = closeStatusFilter; + } + + /** + * If specified, only workflow executions that match this close status + * are counted. This filter has an affect only if + * executionStatus is specified as CLOSED. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param closeStatusFilter If specified, only workflow executions that match this close status + * are counted. This filter has an affect only if + * executionStatus is specified as CLOSED. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CountClosedWorkflowExecutionsRequest withCloseStatusFilter(CloseStatusFilter closeStatusFilter) { + this.closeStatusFilter = closeStatusFilter; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (startTimeFilter != null) sb.append("StartTimeFilter: " + startTimeFilter + ", "); + if (closeTimeFilter != null) sb.append("CloseTimeFilter: " + closeTimeFilter + ", "); + if (executionFilter != null) sb.append("ExecutionFilter: " + executionFilter + ", "); + if (typeFilter != null) sb.append("TypeFilter: " + typeFilter + ", "); + if (tagFilter != null) sb.append("TagFilter: " + tagFilter + ", "); + if (closeStatusFilter != null) sb.append("CloseStatusFilter: " + closeStatusFilter + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getStartTimeFilter() == null) ? 0 : getStartTimeFilter().hashCode()); + hashCode = prime * hashCode + ((getCloseTimeFilter() == null) ? 0 : getCloseTimeFilter().hashCode()); + hashCode = prime * hashCode + ((getExecutionFilter() == null) ? 0 : getExecutionFilter().hashCode()); + hashCode = prime * hashCode + ((getTypeFilter() == null) ? 0 : getTypeFilter().hashCode()); + hashCode = prime * hashCode + ((getTagFilter() == null) ? 0 : getTagFilter().hashCode()); + hashCode = prime * hashCode + ((getCloseStatusFilter() == null) ? 0 : getCloseStatusFilter().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof CountClosedWorkflowExecutionsRequest == false) return false; + CountClosedWorkflowExecutionsRequest other = (CountClosedWorkflowExecutionsRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getStartTimeFilter() == null ^ this.getStartTimeFilter() == null) return false; + if (other.getStartTimeFilter() != null && other.getStartTimeFilter().equals(this.getStartTimeFilter()) == false) return false; + if (other.getCloseTimeFilter() == null ^ this.getCloseTimeFilter() == null) return false; + if (other.getCloseTimeFilter() != null && other.getCloseTimeFilter().equals(this.getCloseTimeFilter()) == false) return false; + if (other.getExecutionFilter() == null ^ this.getExecutionFilter() == null) return false; + if (other.getExecutionFilter() != null && other.getExecutionFilter().equals(this.getExecutionFilter()) == false) return false; + if (other.getTypeFilter() == null ^ this.getTypeFilter() == null) return false; + if (other.getTypeFilter() != null && other.getTypeFilter().equals(this.getTypeFilter()) == false) return false; + if (other.getTagFilter() == null ^ this.getTagFilter() == null) return false; + if (other.getTagFilter() != null && other.getTagFilter().equals(this.getTagFilter()) == false) return false; + if (other.getCloseStatusFilter() == null ^ this.getCloseStatusFilter() == null) return false; + if (other.getCloseStatusFilter() != null && other.getCloseStatusFilter().equals(this.getCloseStatusFilter()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/CountOpenWorkflowExecutionsRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/CountOpenWorkflowExecutionsRequest.java new file mode 100644 index 000000000000..adca90d608d0 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/CountOpenWorkflowExecutionsRequest.java @@ -0,0 +1,373 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#countOpenWorkflowExecutions(CountOpenWorkflowExecutionsRequest) CountOpenWorkflowExecutions operation}. + *

+ * Returns the number of open workflow executions within the given + * domain that meet the specified filtering criteria. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#countOpenWorkflowExecutions(CountOpenWorkflowExecutionsRequest) + */ +public class CountOpenWorkflowExecutionsRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain containing the workflow executions to count. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * Specifies the start time criteria that workflow executions must meet + * in order to be counted. + */ + private ExecutionTimeFilter startTimeFilter; + + /** + * Specifies the type of the workflow executions to be counted. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + private WorkflowTypeFilter typeFilter; + + /** + * If specified, only executions that have a tag that matches the filter + * are counted. executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + */ + private TagFilter tagFilter; + + /** + * If specified, only workflow executions matching the + * WorkflowId in the filter are counted. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + private WorkflowExecutionFilter executionFilter; + + /** + * The name of the domain containing the workflow executions to count. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain containing the workflow executions to count. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain containing the workflow executions to count. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain containing the workflow executions to count. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain containing the workflow executions to count. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain containing the workflow executions to count. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CountOpenWorkflowExecutionsRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * Specifies the start time criteria that workflow executions must meet + * in order to be counted. + * + * @return Specifies the start time criteria that workflow executions must meet + * in order to be counted. + */ + public ExecutionTimeFilter getStartTimeFilter() { + return startTimeFilter; + } + + /** + * Specifies the start time criteria that workflow executions must meet + * in order to be counted. + * + * @param startTimeFilter Specifies the start time criteria that workflow executions must meet + * in order to be counted. + */ + public void setStartTimeFilter(ExecutionTimeFilter startTimeFilter) { + this.startTimeFilter = startTimeFilter; + } + + /** + * Specifies the start time criteria that workflow executions must meet + * in order to be counted. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startTimeFilter Specifies the start time criteria that workflow executions must meet + * in order to be counted. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CountOpenWorkflowExecutionsRequest withStartTimeFilter(ExecutionTimeFilter startTimeFilter) { + this.startTimeFilter = startTimeFilter; + return this; + } + + + /** + * Specifies the type of the workflow executions to be counted. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @return Specifies the type of the workflow executions to be counted. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + public WorkflowTypeFilter getTypeFilter() { + return typeFilter; + } + + /** + * Specifies the type of the workflow executions to be counted. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @param typeFilter Specifies the type of the workflow executions to be counted. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + public void setTypeFilter(WorkflowTypeFilter typeFilter) { + this.typeFilter = typeFilter; + } + + /** + * Specifies the type of the workflow executions to be counted. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param typeFilter Specifies the type of the workflow executions to be counted. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CountOpenWorkflowExecutionsRequest withTypeFilter(WorkflowTypeFilter typeFilter) { + this.typeFilter = typeFilter; + return this; + } + + + /** + * If specified, only executions that have a tag that matches the filter + * are counted. executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + * + * @return If specified, only executions that have a tag that matches the filter + * are counted. executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + */ + public TagFilter getTagFilter() { + return tagFilter; + } + + /** + * If specified, only executions that have a tag that matches the filter + * are counted. executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + * + * @param tagFilter If specified, only executions that have a tag that matches the filter + * are counted. executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + */ + public void setTagFilter(TagFilter tagFilter) { + this.tagFilter = tagFilter; + } + + /** + * If specified, only executions that have a tag that matches the filter + * are counted. executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param tagFilter If specified, only executions that have a tag that matches the filter + * are counted. executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CountOpenWorkflowExecutionsRequest withTagFilter(TagFilter tagFilter) { + this.tagFilter = tagFilter; + return this; + } + + + /** + * If specified, only workflow executions matching the + * WorkflowId in the filter are counted. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @return If specified, only workflow executions matching the + * WorkflowId in the filter are counted. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + public WorkflowExecutionFilter getExecutionFilter() { + return executionFilter; + } + + /** + * If specified, only workflow executions matching the + * WorkflowId in the filter are counted. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @param executionFilter If specified, only workflow executions matching the + * WorkflowId in the filter are counted. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + public void setExecutionFilter(WorkflowExecutionFilter executionFilter) { + this.executionFilter = executionFilter; + } + + /** + * If specified, only workflow executions matching the + * WorkflowId in the filter are counted. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param executionFilter If specified, only workflow executions matching the + * WorkflowId in the filter are counted. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CountOpenWorkflowExecutionsRequest withExecutionFilter(WorkflowExecutionFilter executionFilter) { + this.executionFilter = executionFilter; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (startTimeFilter != null) sb.append("StartTimeFilter: " + startTimeFilter + ", "); + if (typeFilter != null) sb.append("TypeFilter: " + typeFilter + ", "); + if (tagFilter != null) sb.append("TagFilter: " + tagFilter + ", "); + if (executionFilter != null) sb.append("ExecutionFilter: " + executionFilter + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getStartTimeFilter() == null) ? 0 : getStartTimeFilter().hashCode()); + hashCode = prime * hashCode + ((getTypeFilter() == null) ? 0 : getTypeFilter().hashCode()); + hashCode = prime * hashCode + ((getTagFilter() == null) ? 0 : getTagFilter().hashCode()); + hashCode = prime * hashCode + ((getExecutionFilter() == null) ? 0 : getExecutionFilter().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof CountOpenWorkflowExecutionsRequest == false) return false; + CountOpenWorkflowExecutionsRequest other = (CountOpenWorkflowExecutionsRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getStartTimeFilter() == null ^ this.getStartTimeFilter() == null) return false; + if (other.getStartTimeFilter() != null && other.getStartTimeFilter().equals(this.getStartTimeFilter()) == false) return false; + if (other.getTypeFilter() == null ^ this.getTypeFilter() == null) return false; + if (other.getTypeFilter() != null && other.getTypeFilter().equals(this.getTypeFilter()) == false) return false; + if (other.getTagFilter() == null ^ this.getTagFilter() == null) return false; + if (other.getTagFilter() != null && other.getTagFilter().equals(this.getTagFilter()) == false) return false; + if (other.getExecutionFilter() == null ^ this.getExecutionFilter() == null) return false; + if (other.getExecutionFilter() != null && other.getExecutionFilter().equals(this.getExecutionFilter()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/CountPendingActivityTasksRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/CountPendingActivityTasksRequest.java new file mode 100644 index 000000000000..6370a3d96365 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/CountPendingActivityTasksRequest.java @@ -0,0 +1,165 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#countPendingActivityTasks(CountPendingActivityTasksRequest) CountPendingActivityTasks operation}. + *

+ * Returns the estimated number of activity tasks in the specified task + * list. The count returned is an approximation and is not guaranteed to + * be exact. If you specify a task list that no activity task was ever + * scheduled in then 0 will be returned. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#countPendingActivityTasks(CountPendingActivityTasksRequest) + */ +public class CountPendingActivityTasksRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain that contains the task list. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * The name of the task list. + */ + private TaskList taskList; + + /** + * The name of the domain that contains the task list. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain that contains the task list. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain that contains the task list. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain that contains the task list. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain that contains the task list. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain that contains the task list. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CountPendingActivityTasksRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * The name of the task list. + * + * @return The name of the task list. + */ + public TaskList getTaskList() { + return taskList; + } + + /** + * The name of the task list. + * + * @param taskList The name of the task list. + */ + public void setTaskList(TaskList taskList) { + this.taskList = taskList; + } + + /** + * The name of the task list. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param taskList The name of the task list. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CountPendingActivityTasksRequest withTaskList(TaskList taskList) { + this.taskList = taskList; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (taskList != null) sb.append("TaskList: " + taskList + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getTaskList() == null) ? 0 : getTaskList().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof CountPendingActivityTasksRequest == false) return false; + CountPendingActivityTasksRequest other = (CountPendingActivityTasksRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getTaskList() == null ^ this.getTaskList() == null) return false; + if (other.getTaskList() != null && other.getTaskList().equals(this.getTaskList()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/CountPendingDecisionTasksRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/CountPendingDecisionTasksRequest.java new file mode 100644 index 000000000000..9d02fb97fe12 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/CountPendingDecisionTasksRequest.java @@ -0,0 +1,165 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#countPendingDecisionTasks(CountPendingDecisionTasksRequest) CountPendingDecisionTasks operation}. + *

+ * Returns the estimated number of decision tasks in the specified task + * list. The count returned is an approximation and is not guaranteed to + * be exact. If you specify a task list that no decision task was ever + * scheduled in then 0 will be returned. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#countPendingDecisionTasks(CountPendingDecisionTasksRequest) + */ +public class CountPendingDecisionTasksRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain that contains the task list. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * The name of the task list. + */ + private TaskList taskList; + + /** + * The name of the domain that contains the task list. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain that contains the task list. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain that contains the task list. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain that contains the task list. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain that contains the task list. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain that contains the task list. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CountPendingDecisionTasksRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * The name of the task list. + * + * @return The name of the task list. + */ + public TaskList getTaskList() { + return taskList; + } + + /** + * The name of the task list. + * + * @param taskList The name of the task list. + */ + public void setTaskList(TaskList taskList) { + this.taskList = taskList; + } + + /** + * The name of the task list. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param taskList The name of the task list. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public CountPendingDecisionTasksRequest withTaskList(TaskList taskList) { + this.taskList = taskList; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (taskList != null) sb.append("TaskList: " + taskList + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getTaskList() == null) ? 0 : getTaskList().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof CountPendingDecisionTasksRequest == false) return false; + CountPendingDecisionTasksRequest other = (CountPendingDecisionTasksRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getTaskList() == null ^ this.getTaskList() == null) return false; + if (other.getTaskList() != null && other.getTaskList().equals(this.getTaskList()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/Decision.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/Decision.java new file mode 100644 index 000000000000..82b28292e26b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/Decision.java @@ -0,0 +1,903 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Specifies a decision made by the decider. A decision can be one of + * these types: + *

+ * + *
    + *
  • ScheduleActivityTask schedules an activity task.
  • + *
  • RequestCancelActivityTask attempts to cancel a previously + * scheduled activity task. If the activity task was scheduled but has + * not been assigned to a worker, then it will be canceled. If the + * activity task was already assigned to a worker, then the worker will + * be informed that cancellation has been requested in the response to + * RecordActivityTaskHeartbeat.
  • + *
  • RecordMarker records a MarkerRecorded event + * in the history. Markers can be used for adding custom information in + * the history for instance to let deciders know that they do not need to + * look at the history beyond the marker event.
  • + *
  • CompleteWorkflowExecution closes the workflow execution + * and records a WorkflowExecutionCompleted event in the + * history .
  • + *
  • FailWorkflowExecution closes the workflow execution and + * records a WorkflowExecutionFailed event in the + * history.
  • + *
  • CancelWorkflowExecution closes the workflow execution and + * records a WorkflowExecutionCanceled event in the + * history.
  • + *
  • ContinueAsNewWorkflowExecution closes the workflow + * execution and starts a new workflow execution of the same type using + * the same workflow id and a unique run Id. A + * WorkflowExecutionContinuedAsNew event is recorded in the + * history.
  • + *
  • StartTimer starts a timer for this workflow execution and + * records a TimerStarted event in the history. This timer + * will fire after the specified delay and record a + * TimerFired event.
  • + *
  • CancelTimer cancels a previously started timer and + * records a TimerCanceled event in the history.
  • + *
  • SignalExternalWorkflowExecution requests a signal to be + * delivered to the specified external workflow execution and records a + * SignalExternalWorkflowExecutionInitiated event in the + * history.
  • + *
  • RequestCancelExternalWorkflowExecution requests that a + * request be made to cancel the specified external workflow execution + * and records a + * RequestCancelExternalWorkflowExecutionInitiated event in + * the history.
  • + *
  • StartChildWorkflowExecution requests that a child + * workflow execution be started and records a + * StartChildWorkflowExecutionInitiated event in the + * history. The child workflow execution is a separate workflow execution + * with its own history.
  • + * + *
+ *

+ * The ordering of decisions should follow a logical flow. Some + * decisions might not make sense in the current context of the workflow + * execution and will therefore fail. A decision might also fail due to a + * limit being reached on your account. One of the following events might + * be added to the history to indicate an error: + *

+ * + *
    + *
  • ScheduleActivityTaskFailed a ScheduleActivityTask + * decision failed. This could happen if the activity type specified in + * the decision is not registered, is in a deprecated state, or the + * decision is not properly configured.
  • + *
  • RequestCancelActivityTaskFailed a + * RequestCancelActivityTask decision failed. This could happen if there + * is no open activity task with the specified activityId.
  • + *
  • StartTimerFailed a StartTimer decision failed. This could + * happen if there is another open timer with the same timerId.
  • + *
  • CancelTimerFailed a CancelTimer decision failed. This + * could happen if there is no open timer with the specified + * timerId.
  • + *
  • StartChildWorkflowExecutionFailed a + * StartChildWorkflowExecution decision failed. This could happen if the + * workflow type specified is not registered, is deprecated, or the + * decision is not properly configured.
  • + *
  • SignalExternalWorkflowExecutionFailed a + * SignalExternalWorkflowExecution decision failed. This could happen if + * the workflowID specified in the decision was incorrect. + *
  • + *
  • RequestCancelExternalWorkflowExecutionFailed a + * RequestCancelExternalWorkflowExecution decision failed. This could + * happen if the workflowID specified in the decision was + * incorrect.
  • + *
  • CancelWorkflowExecutionFailed a CancelWorkflowExecution + * decision failed. This could happen if there is an unhandled decision + * task pending in the workflow execution.
  • + *
  • CompleteWorkflowExecutionFailed a + * CompleteWorkflowExecution decision failed. This could happen if there + * is an unhandled decision task pending in the workflow execution.
  • + *
  • ContinueAsNewWorkflowExecutionFailed a + * ContinueAsNewWorkflowExecution decision failed. This could happen if + * there is an unhandled decision task pending in the workflow execution + * or the ContinueAsNewWorkflowExecution decision was not configured + * correctly.
  • + *
  • FailWorkflowExecutionFailed a FailWorkflowExecution + * decision failed. This could happen if there is an unhandled decision + * task pending in the workflow execution.
  • + * + *
+ *

+ * The preceding error events might occur due to an error in the decider + * logic, which might put the workflow execution in an unstable state The + * cause field in the event structure for the error event indicates the + * cause of the error. + *

+ *

+ * NOTE: A workflow execution may be closed by the decider by + * returning one of the following decisions when completing a decision + * task: CompleteWorkflowExecution, FailWorkflowExecution, + * CancelWorkflowExecution and ContinueAsNewWorkflowExecution. An + * UnhandledDecision fault will be returned if a workflow closing + * decision is specified and a signal or activity event had been added to + * the history while the decision task was being performed by the + * decider. Unlike the above situations which are logic issues, this + * fault is always possible because of race conditions in a distributed + * system. The right action here is to call RespondDecisionTaskCompleted + * without any decisions. This would result in another decision task with + * these new events included in the history. The decider should handle + * the new events and may decide to close the workflow execution. + *

+ *

+ * You must code a decision by first setting the decision type field to + * one of the above decision values, and then set the corresponding + * attributes field shown below: + *

+ * + *
    + *
  • ScheduleActivityTaskDecisionAttributes
  • + *
  • RequestCancelActivityTaskDecisionAttributes
  • + *
  • CompleteWorkflowExecutionDecisionAttributes
  • + *
  • FailWorkflowExecutionDecisionAttributes
  • + *
  • CancelWorkflowExecutionDecisionAttributes
  • + *
  • ContinueAsNewWorkflowExecutionDecisionAttributes
  • + *
  • RecordMarkerDecisionAttributes
  • + *
  • StartTimerDecisionAttributes
  • + *
  • CancelTimerDecisionAttributes
  • + *
  • SignalExternalWorkflowExecutionDecisionAttributes
  • + *
  • RequestCancelExternalWorkflowExecutionDecisionAttributes
  • + *
  • StartChildWorkflowExecutionDecisionAttributes
  • + * + *
+ */ +public class Decision { + + /** + * Specifies the type of the decision. + *

+ * Constraints:
+ * Allowed Values: ScheduleActivityTask, RequestCancelActivityTask, CompleteWorkflowExecution, FailWorkflowExecution, CancelWorkflowExecution, ContinueAsNewWorkflowExecution, RecordMarker, StartTimer, CancelTimer, SignalExternalWorkflowExecution, RequestCancelExternalWorkflowExecution, StartChildWorkflowExecution + */ + private String decisionType; + + /** + * Provides details of the ScheduleActivityTask decision. It + * is not set for other decision types. + */ + private ScheduleActivityTaskDecisionAttributes scheduleActivityTaskDecisionAttributes; + + /** + * Provides details of the RequestCancelActivityTask + * decision. It is not set for other decision types. + */ + private RequestCancelActivityTaskDecisionAttributes requestCancelActivityTaskDecisionAttributes; + + /** + * Provides details of the CompleteWorkflowExecution + * decision. It is not set for other decision types. + */ + private CompleteWorkflowExecutionDecisionAttributes completeWorkflowExecutionDecisionAttributes; + + /** + * Provides details of the FailWorkflowExecution decision. + * It is not set for other decision types. + */ + private FailWorkflowExecutionDecisionAttributes failWorkflowExecutionDecisionAttributes; + + /** + * Provides details of the CancelWorkflowExecution decision. + * It is not set for other decision types. + */ + private CancelWorkflowExecutionDecisionAttributes cancelWorkflowExecutionDecisionAttributes; + + /** + * Provides details of the ContinueAsNewWorkflowExecution + * decision. It is not set for other decision types. + */ + private ContinueAsNewWorkflowExecutionDecisionAttributes continueAsNewWorkflowExecutionDecisionAttributes; + + /** + * Provides details of the RecordMarker decision. It is not + * set for other decision types. + */ + private RecordMarkerDecisionAttributes recordMarkerDecisionAttributes; + + /** + * Provides details of the StartTimer decision. It is not + * set for other decision types. + */ + private StartTimerDecisionAttributes startTimerDecisionAttributes; + + /** + * Provides details of the CancelTimer decision. It is not + * set for other decision types. + */ + private CancelTimerDecisionAttributes cancelTimerDecisionAttributes; + + /** + * Provides details of the SignalExternalWorkflowExecution + * decision. It is not set for other decision types. + */ + private SignalExternalWorkflowExecutionDecisionAttributes signalExternalWorkflowExecutionDecisionAttributes; + + /** + * Provides details of the + * RequestCancelExternalWorkflowExecution decision. It is + * not set for other decision types. + */ + private RequestCancelExternalWorkflowExecutionDecisionAttributes requestCancelExternalWorkflowExecutionDecisionAttributes; + + /** + * Provides details of the StartChildWorkflowExecution + * decision. It is not set for other decision types. + */ + private StartChildWorkflowExecutionDecisionAttributes startChildWorkflowExecutionDecisionAttributes; + + /** + * Specifies the type of the decision. + *

+ * Constraints:
+ * Allowed Values: ScheduleActivityTask, RequestCancelActivityTask, CompleteWorkflowExecution, FailWorkflowExecution, CancelWorkflowExecution, ContinueAsNewWorkflowExecution, RecordMarker, StartTimer, CancelTimer, SignalExternalWorkflowExecution, RequestCancelExternalWorkflowExecution, StartChildWorkflowExecution + * + * @return Specifies the type of the decision. + * + * @see DecisionType + */ + public String getDecisionType() { + return decisionType; + } + + /** + * Specifies the type of the decision. + *

+ * Constraints:
+ * Allowed Values: ScheduleActivityTask, RequestCancelActivityTask, CompleteWorkflowExecution, FailWorkflowExecution, CancelWorkflowExecution, ContinueAsNewWorkflowExecution, RecordMarker, StartTimer, CancelTimer, SignalExternalWorkflowExecution, RequestCancelExternalWorkflowExecution, StartChildWorkflowExecution + * + * @param decisionType Specifies the type of the decision. + * + * @see DecisionType + */ + public void setDecisionType(String decisionType) { + this.decisionType = decisionType; + } + + /** + * Specifies the type of the decision. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: ScheduleActivityTask, RequestCancelActivityTask, CompleteWorkflowExecution, FailWorkflowExecution, CancelWorkflowExecution, ContinueAsNewWorkflowExecution, RecordMarker, StartTimer, CancelTimer, SignalExternalWorkflowExecution, RequestCancelExternalWorkflowExecution, StartChildWorkflowExecution + * + * @param decisionType Specifies the type of the decision. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see DecisionType + */ + public Decision withDecisionType(String decisionType) { + this.decisionType = decisionType; + return this; + } + + + /** + * Specifies the type of the decision. + *

+ * Constraints:
+ * Allowed Values: ScheduleActivityTask, RequestCancelActivityTask, CompleteWorkflowExecution, FailWorkflowExecution, CancelWorkflowExecution, ContinueAsNewWorkflowExecution, RecordMarker, StartTimer, CancelTimer, SignalExternalWorkflowExecution, RequestCancelExternalWorkflowExecution, StartChildWorkflowExecution + * + * @param decisionType Specifies the type of the decision. + * + * @see DecisionType + */ + public void setDecisionType(DecisionType decisionType) { + this.decisionType = decisionType.toString(); + } + + /** + * Specifies the type of the decision. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: ScheduleActivityTask, RequestCancelActivityTask, CompleteWorkflowExecution, FailWorkflowExecution, CancelWorkflowExecution, ContinueAsNewWorkflowExecution, RecordMarker, StartTimer, CancelTimer, SignalExternalWorkflowExecution, RequestCancelExternalWorkflowExecution, StartChildWorkflowExecution + * + * @param decisionType Specifies the type of the decision. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see DecisionType + */ + public Decision withDecisionType(DecisionType decisionType) { + this.decisionType = decisionType.toString(); + return this; + } + + /** + * Provides details of the ScheduleActivityTask decision. It + * is not set for other decision types. + * + * @return Provides details of the ScheduleActivityTask decision. It + * is not set for other decision types. + */ + public ScheduleActivityTaskDecisionAttributes getScheduleActivityTaskDecisionAttributes() { + return scheduleActivityTaskDecisionAttributes; + } + + /** + * Provides details of the ScheduleActivityTask decision. It + * is not set for other decision types. + * + * @param scheduleActivityTaskDecisionAttributes Provides details of the ScheduleActivityTask decision. It + * is not set for other decision types. + */ + public void setScheduleActivityTaskDecisionAttributes(ScheduleActivityTaskDecisionAttributes scheduleActivityTaskDecisionAttributes) { + this.scheduleActivityTaskDecisionAttributes = scheduleActivityTaskDecisionAttributes; + } + + /** + * Provides details of the ScheduleActivityTask decision. It + * is not set for other decision types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param scheduleActivityTaskDecisionAttributes Provides details of the ScheduleActivityTask decision. It + * is not set for other decision types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public Decision withScheduleActivityTaskDecisionAttributes(ScheduleActivityTaskDecisionAttributes scheduleActivityTaskDecisionAttributes) { + this.scheduleActivityTaskDecisionAttributes = scheduleActivityTaskDecisionAttributes; + return this; + } + + + /** + * Provides details of the RequestCancelActivityTask + * decision. It is not set for other decision types. + * + * @return Provides details of the RequestCancelActivityTask + * decision. It is not set for other decision types. + */ + public RequestCancelActivityTaskDecisionAttributes getRequestCancelActivityTaskDecisionAttributes() { + return requestCancelActivityTaskDecisionAttributes; + } + + /** + * Provides details of the RequestCancelActivityTask + * decision. It is not set for other decision types. + * + * @param requestCancelActivityTaskDecisionAttributes Provides details of the RequestCancelActivityTask + * decision. It is not set for other decision types. + */ + public void setRequestCancelActivityTaskDecisionAttributes(RequestCancelActivityTaskDecisionAttributes requestCancelActivityTaskDecisionAttributes) { + this.requestCancelActivityTaskDecisionAttributes = requestCancelActivityTaskDecisionAttributes; + } + + /** + * Provides details of the RequestCancelActivityTask + * decision. It is not set for other decision types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param requestCancelActivityTaskDecisionAttributes Provides details of the RequestCancelActivityTask + * decision. It is not set for other decision types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public Decision withRequestCancelActivityTaskDecisionAttributes(RequestCancelActivityTaskDecisionAttributes requestCancelActivityTaskDecisionAttributes) { + this.requestCancelActivityTaskDecisionAttributes = requestCancelActivityTaskDecisionAttributes; + return this; + } + + + /** + * Provides details of the CompleteWorkflowExecution + * decision. It is not set for other decision types. + * + * @return Provides details of the CompleteWorkflowExecution + * decision. It is not set for other decision types. + */ + public CompleteWorkflowExecutionDecisionAttributes getCompleteWorkflowExecutionDecisionAttributes() { + return completeWorkflowExecutionDecisionAttributes; + } + + /** + * Provides details of the CompleteWorkflowExecution + * decision. It is not set for other decision types. + * + * @param completeWorkflowExecutionDecisionAttributes Provides details of the CompleteWorkflowExecution + * decision. It is not set for other decision types. + */ + public void setCompleteWorkflowExecutionDecisionAttributes(CompleteWorkflowExecutionDecisionAttributes completeWorkflowExecutionDecisionAttributes) { + this.completeWorkflowExecutionDecisionAttributes = completeWorkflowExecutionDecisionAttributes; + } + + /** + * Provides details of the CompleteWorkflowExecution + * decision. It is not set for other decision types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param completeWorkflowExecutionDecisionAttributes Provides details of the CompleteWorkflowExecution + * decision. It is not set for other decision types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public Decision withCompleteWorkflowExecutionDecisionAttributes(CompleteWorkflowExecutionDecisionAttributes completeWorkflowExecutionDecisionAttributes) { + this.completeWorkflowExecutionDecisionAttributes = completeWorkflowExecutionDecisionAttributes; + return this; + } + + + /** + * Provides details of the FailWorkflowExecution decision. + * It is not set for other decision types. + * + * @return Provides details of the FailWorkflowExecution decision. + * It is not set for other decision types. + */ + public FailWorkflowExecutionDecisionAttributes getFailWorkflowExecutionDecisionAttributes() { + return failWorkflowExecutionDecisionAttributes; + } + + /** + * Provides details of the FailWorkflowExecution decision. + * It is not set for other decision types. + * + * @param failWorkflowExecutionDecisionAttributes Provides details of the FailWorkflowExecution decision. + * It is not set for other decision types. + */ + public void setFailWorkflowExecutionDecisionAttributes(FailWorkflowExecutionDecisionAttributes failWorkflowExecutionDecisionAttributes) { + this.failWorkflowExecutionDecisionAttributes = failWorkflowExecutionDecisionAttributes; + } + + /** + * Provides details of the FailWorkflowExecution decision. + * It is not set for other decision types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param failWorkflowExecutionDecisionAttributes Provides details of the FailWorkflowExecution decision. + * It is not set for other decision types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public Decision withFailWorkflowExecutionDecisionAttributes(FailWorkflowExecutionDecisionAttributes failWorkflowExecutionDecisionAttributes) { + this.failWorkflowExecutionDecisionAttributes = failWorkflowExecutionDecisionAttributes; + return this; + } + + + /** + * Provides details of the CancelWorkflowExecution decision. + * It is not set for other decision types. + * + * @return Provides details of the CancelWorkflowExecution decision. + * It is not set for other decision types. + */ + public CancelWorkflowExecutionDecisionAttributes getCancelWorkflowExecutionDecisionAttributes() { + return cancelWorkflowExecutionDecisionAttributes; + } + + /** + * Provides details of the CancelWorkflowExecution decision. + * It is not set for other decision types. + * + * @param cancelWorkflowExecutionDecisionAttributes Provides details of the CancelWorkflowExecution decision. + * It is not set for other decision types. + */ + public void setCancelWorkflowExecutionDecisionAttributes(CancelWorkflowExecutionDecisionAttributes cancelWorkflowExecutionDecisionAttributes) { + this.cancelWorkflowExecutionDecisionAttributes = cancelWorkflowExecutionDecisionAttributes; + } + + /** + * Provides details of the CancelWorkflowExecution decision. + * It is not set for other decision types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param cancelWorkflowExecutionDecisionAttributes Provides details of the CancelWorkflowExecution decision. + * It is not set for other decision types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public Decision withCancelWorkflowExecutionDecisionAttributes(CancelWorkflowExecutionDecisionAttributes cancelWorkflowExecutionDecisionAttributes) { + this.cancelWorkflowExecutionDecisionAttributes = cancelWorkflowExecutionDecisionAttributes; + return this; + } + + + /** + * Provides details of the ContinueAsNewWorkflowExecution + * decision. It is not set for other decision types. + * + * @return Provides details of the ContinueAsNewWorkflowExecution + * decision. It is not set for other decision types. + */ + public ContinueAsNewWorkflowExecutionDecisionAttributes getContinueAsNewWorkflowExecutionDecisionAttributes() { + return continueAsNewWorkflowExecutionDecisionAttributes; + } + + /** + * Provides details of the ContinueAsNewWorkflowExecution + * decision. It is not set for other decision types. + * + * @param continueAsNewWorkflowExecutionDecisionAttributes Provides details of the ContinueAsNewWorkflowExecution + * decision. It is not set for other decision types. + */ + public void setContinueAsNewWorkflowExecutionDecisionAttributes(ContinueAsNewWorkflowExecutionDecisionAttributes continueAsNewWorkflowExecutionDecisionAttributes) { + this.continueAsNewWorkflowExecutionDecisionAttributes = continueAsNewWorkflowExecutionDecisionAttributes; + } + + /** + * Provides details of the ContinueAsNewWorkflowExecution + * decision. It is not set for other decision types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param continueAsNewWorkflowExecutionDecisionAttributes Provides details of the ContinueAsNewWorkflowExecution + * decision. It is not set for other decision types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public Decision withContinueAsNewWorkflowExecutionDecisionAttributes(ContinueAsNewWorkflowExecutionDecisionAttributes continueAsNewWorkflowExecutionDecisionAttributes) { + this.continueAsNewWorkflowExecutionDecisionAttributes = continueAsNewWorkflowExecutionDecisionAttributes; + return this; + } + + + /** + * Provides details of the RecordMarker decision. It is not + * set for other decision types. + * + * @return Provides details of the RecordMarker decision. It is not + * set for other decision types. + */ + public RecordMarkerDecisionAttributes getRecordMarkerDecisionAttributes() { + return recordMarkerDecisionAttributes; + } + + /** + * Provides details of the RecordMarker decision. It is not + * set for other decision types. + * + * @param recordMarkerDecisionAttributes Provides details of the RecordMarker decision. It is not + * set for other decision types. + */ + public void setRecordMarkerDecisionAttributes(RecordMarkerDecisionAttributes recordMarkerDecisionAttributes) { + this.recordMarkerDecisionAttributes = recordMarkerDecisionAttributes; + } + + /** + * Provides details of the RecordMarker decision. It is not + * set for other decision types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param recordMarkerDecisionAttributes Provides details of the RecordMarker decision. It is not + * set for other decision types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public Decision withRecordMarkerDecisionAttributes(RecordMarkerDecisionAttributes recordMarkerDecisionAttributes) { + this.recordMarkerDecisionAttributes = recordMarkerDecisionAttributes; + return this; + } + + + /** + * Provides details of the StartTimer decision. It is not + * set for other decision types. + * + * @return Provides details of the StartTimer decision. It is not + * set for other decision types. + */ + public StartTimerDecisionAttributes getStartTimerDecisionAttributes() { + return startTimerDecisionAttributes; + } + + /** + * Provides details of the StartTimer decision. It is not + * set for other decision types. + * + * @param startTimerDecisionAttributes Provides details of the StartTimer decision. It is not + * set for other decision types. + */ + public void setStartTimerDecisionAttributes(StartTimerDecisionAttributes startTimerDecisionAttributes) { + this.startTimerDecisionAttributes = startTimerDecisionAttributes; + } + + /** + * Provides details of the StartTimer decision. It is not + * set for other decision types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startTimerDecisionAttributes Provides details of the StartTimer decision. It is not + * set for other decision types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public Decision withStartTimerDecisionAttributes(StartTimerDecisionAttributes startTimerDecisionAttributes) { + this.startTimerDecisionAttributes = startTimerDecisionAttributes; + return this; + } + + + /** + * Provides details of the CancelTimer decision. It is not + * set for other decision types. + * + * @return Provides details of the CancelTimer decision. It is not + * set for other decision types. + */ + public CancelTimerDecisionAttributes getCancelTimerDecisionAttributes() { + return cancelTimerDecisionAttributes; + } + + /** + * Provides details of the CancelTimer decision. It is not + * set for other decision types. + * + * @param cancelTimerDecisionAttributes Provides details of the CancelTimer decision. It is not + * set for other decision types. + */ + public void setCancelTimerDecisionAttributes(CancelTimerDecisionAttributes cancelTimerDecisionAttributes) { + this.cancelTimerDecisionAttributes = cancelTimerDecisionAttributes; + } + + /** + * Provides details of the CancelTimer decision. It is not + * set for other decision types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param cancelTimerDecisionAttributes Provides details of the CancelTimer decision. It is not + * set for other decision types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public Decision withCancelTimerDecisionAttributes(CancelTimerDecisionAttributes cancelTimerDecisionAttributes) { + this.cancelTimerDecisionAttributes = cancelTimerDecisionAttributes; + return this; + } + + + /** + * Provides details of the SignalExternalWorkflowExecution + * decision. It is not set for other decision types. + * + * @return Provides details of the SignalExternalWorkflowExecution + * decision. It is not set for other decision types. + */ + public SignalExternalWorkflowExecutionDecisionAttributes getSignalExternalWorkflowExecutionDecisionAttributes() { + return signalExternalWorkflowExecutionDecisionAttributes; + } + + /** + * Provides details of the SignalExternalWorkflowExecution + * decision. It is not set for other decision types. + * + * @param signalExternalWorkflowExecutionDecisionAttributes Provides details of the SignalExternalWorkflowExecution + * decision. It is not set for other decision types. + */ + public void setSignalExternalWorkflowExecutionDecisionAttributes(SignalExternalWorkflowExecutionDecisionAttributes signalExternalWorkflowExecutionDecisionAttributes) { + this.signalExternalWorkflowExecutionDecisionAttributes = signalExternalWorkflowExecutionDecisionAttributes; + } + + /** + * Provides details of the SignalExternalWorkflowExecution + * decision. It is not set for other decision types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param signalExternalWorkflowExecutionDecisionAttributes Provides details of the SignalExternalWorkflowExecution + * decision. It is not set for other decision types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public Decision withSignalExternalWorkflowExecutionDecisionAttributes(SignalExternalWorkflowExecutionDecisionAttributes signalExternalWorkflowExecutionDecisionAttributes) { + this.signalExternalWorkflowExecutionDecisionAttributes = signalExternalWorkflowExecutionDecisionAttributes; + return this; + } + + + /** + * Provides details of the + * RequestCancelExternalWorkflowExecution decision. It is + * not set for other decision types. + * + * @return Provides details of the + * RequestCancelExternalWorkflowExecution decision. It is + * not set for other decision types. + */ + public RequestCancelExternalWorkflowExecutionDecisionAttributes getRequestCancelExternalWorkflowExecutionDecisionAttributes() { + return requestCancelExternalWorkflowExecutionDecisionAttributes; + } + + /** + * Provides details of the + * RequestCancelExternalWorkflowExecution decision. It is + * not set for other decision types. + * + * @param requestCancelExternalWorkflowExecutionDecisionAttributes Provides details of the + * RequestCancelExternalWorkflowExecution decision. It is + * not set for other decision types. + */ + public void setRequestCancelExternalWorkflowExecutionDecisionAttributes(RequestCancelExternalWorkflowExecutionDecisionAttributes requestCancelExternalWorkflowExecutionDecisionAttributes) { + this.requestCancelExternalWorkflowExecutionDecisionAttributes = requestCancelExternalWorkflowExecutionDecisionAttributes; + } + + /** + * Provides details of the + * RequestCancelExternalWorkflowExecution decision. It is + * not set for other decision types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param requestCancelExternalWorkflowExecutionDecisionAttributes Provides details of the + * RequestCancelExternalWorkflowExecution decision. It is + * not set for other decision types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public Decision withRequestCancelExternalWorkflowExecutionDecisionAttributes(RequestCancelExternalWorkflowExecutionDecisionAttributes requestCancelExternalWorkflowExecutionDecisionAttributes) { + this.requestCancelExternalWorkflowExecutionDecisionAttributes = requestCancelExternalWorkflowExecutionDecisionAttributes; + return this; + } + + + /** + * Provides details of the StartChildWorkflowExecution + * decision. It is not set for other decision types. + * + * @return Provides details of the StartChildWorkflowExecution + * decision. It is not set for other decision types. + */ + public StartChildWorkflowExecutionDecisionAttributes getStartChildWorkflowExecutionDecisionAttributes() { + return startChildWorkflowExecutionDecisionAttributes; + } + + /** + * Provides details of the StartChildWorkflowExecution + * decision. It is not set for other decision types. + * + * @param startChildWorkflowExecutionDecisionAttributes Provides details of the StartChildWorkflowExecution + * decision. It is not set for other decision types. + */ + public void setStartChildWorkflowExecutionDecisionAttributes(StartChildWorkflowExecutionDecisionAttributes startChildWorkflowExecutionDecisionAttributes) { + this.startChildWorkflowExecutionDecisionAttributes = startChildWorkflowExecutionDecisionAttributes; + } + + /** + * Provides details of the StartChildWorkflowExecution + * decision. It is not set for other decision types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startChildWorkflowExecutionDecisionAttributes Provides details of the StartChildWorkflowExecution + * decision. It is not set for other decision types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public Decision withStartChildWorkflowExecutionDecisionAttributes(StartChildWorkflowExecutionDecisionAttributes startChildWorkflowExecutionDecisionAttributes) { + this.startChildWorkflowExecutionDecisionAttributes = startChildWorkflowExecutionDecisionAttributes; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (decisionType != null) sb.append("DecisionType: " + decisionType + ", "); + if (scheduleActivityTaskDecisionAttributes != null) sb.append("ScheduleActivityTaskDecisionAttributes: " + scheduleActivityTaskDecisionAttributes + ", "); + if (requestCancelActivityTaskDecisionAttributes != null) sb.append("RequestCancelActivityTaskDecisionAttributes: " + requestCancelActivityTaskDecisionAttributes + ", "); + if (completeWorkflowExecutionDecisionAttributes != null) sb.append("CompleteWorkflowExecutionDecisionAttributes: " + completeWorkflowExecutionDecisionAttributes + ", "); + if (failWorkflowExecutionDecisionAttributes != null) sb.append("FailWorkflowExecutionDecisionAttributes: " + failWorkflowExecutionDecisionAttributes + ", "); + if (cancelWorkflowExecutionDecisionAttributes != null) sb.append("CancelWorkflowExecutionDecisionAttributes: " + cancelWorkflowExecutionDecisionAttributes + ", "); + if (continueAsNewWorkflowExecutionDecisionAttributes != null) sb.append("ContinueAsNewWorkflowExecutionDecisionAttributes: " + continueAsNewWorkflowExecutionDecisionAttributes + ", "); + if (recordMarkerDecisionAttributes != null) sb.append("RecordMarkerDecisionAttributes: " + recordMarkerDecisionAttributes + ", "); + if (startTimerDecisionAttributes != null) sb.append("StartTimerDecisionAttributes: " + startTimerDecisionAttributes + ", "); + if (cancelTimerDecisionAttributes != null) sb.append("CancelTimerDecisionAttributes: " + cancelTimerDecisionAttributes + ", "); + if (signalExternalWorkflowExecutionDecisionAttributes != null) sb.append("SignalExternalWorkflowExecutionDecisionAttributes: " + signalExternalWorkflowExecutionDecisionAttributes + ", "); + if (requestCancelExternalWorkflowExecutionDecisionAttributes != null) sb.append("RequestCancelExternalWorkflowExecutionDecisionAttributes: " + requestCancelExternalWorkflowExecutionDecisionAttributes + ", "); + if (startChildWorkflowExecutionDecisionAttributes != null) sb.append("StartChildWorkflowExecutionDecisionAttributes: " + startChildWorkflowExecutionDecisionAttributes + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDecisionType() == null) ? 0 : getDecisionType().hashCode()); + hashCode = prime * hashCode + ((getScheduleActivityTaskDecisionAttributes() == null) ? 0 : getScheduleActivityTaskDecisionAttributes().hashCode()); + hashCode = prime * hashCode + ((getRequestCancelActivityTaskDecisionAttributes() == null) ? 0 : getRequestCancelActivityTaskDecisionAttributes().hashCode()); + hashCode = prime * hashCode + ((getCompleteWorkflowExecutionDecisionAttributes() == null) ? 0 : getCompleteWorkflowExecutionDecisionAttributes().hashCode()); + hashCode = prime * hashCode + ((getFailWorkflowExecutionDecisionAttributes() == null) ? 0 : getFailWorkflowExecutionDecisionAttributes().hashCode()); + hashCode = prime * hashCode + ((getCancelWorkflowExecutionDecisionAttributes() == null) ? 0 : getCancelWorkflowExecutionDecisionAttributes().hashCode()); + hashCode = prime * hashCode + ((getContinueAsNewWorkflowExecutionDecisionAttributes() == null) ? 0 : getContinueAsNewWorkflowExecutionDecisionAttributes().hashCode()); + hashCode = prime * hashCode + ((getRecordMarkerDecisionAttributes() == null) ? 0 : getRecordMarkerDecisionAttributes().hashCode()); + hashCode = prime * hashCode + ((getStartTimerDecisionAttributes() == null) ? 0 : getStartTimerDecisionAttributes().hashCode()); + hashCode = prime * hashCode + ((getCancelTimerDecisionAttributes() == null) ? 0 : getCancelTimerDecisionAttributes().hashCode()); + hashCode = prime * hashCode + ((getSignalExternalWorkflowExecutionDecisionAttributes() == null) ? 0 : getSignalExternalWorkflowExecutionDecisionAttributes().hashCode()); + hashCode = prime * hashCode + ((getRequestCancelExternalWorkflowExecutionDecisionAttributes() == null) ? 0 : getRequestCancelExternalWorkflowExecutionDecisionAttributes().hashCode()); + hashCode = prime * hashCode + ((getStartChildWorkflowExecutionDecisionAttributes() == null) ? 0 : getStartChildWorkflowExecutionDecisionAttributes().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof Decision == false) return false; + Decision other = (Decision)obj; + + if (other.getDecisionType() == null ^ this.getDecisionType() == null) return false; + if (other.getDecisionType() != null && other.getDecisionType().equals(this.getDecisionType()) == false) return false; + if (other.getScheduleActivityTaskDecisionAttributes() == null ^ this.getScheduleActivityTaskDecisionAttributes() == null) return false; + if (other.getScheduleActivityTaskDecisionAttributes() != null && other.getScheduleActivityTaskDecisionAttributes().equals(this.getScheduleActivityTaskDecisionAttributes()) == false) return false; + if (other.getRequestCancelActivityTaskDecisionAttributes() == null ^ this.getRequestCancelActivityTaskDecisionAttributes() == null) return false; + if (other.getRequestCancelActivityTaskDecisionAttributes() != null && other.getRequestCancelActivityTaskDecisionAttributes().equals(this.getRequestCancelActivityTaskDecisionAttributes()) == false) return false; + if (other.getCompleteWorkflowExecutionDecisionAttributes() == null ^ this.getCompleteWorkflowExecutionDecisionAttributes() == null) return false; + if (other.getCompleteWorkflowExecutionDecisionAttributes() != null && other.getCompleteWorkflowExecutionDecisionAttributes().equals(this.getCompleteWorkflowExecutionDecisionAttributes()) == false) return false; + if (other.getFailWorkflowExecutionDecisionAttributes() == null ^ this.getFailWorkflowExecutionDecisionAttributes() == null) return false; + if (other.getFailWorkflowExecutionDecisionAttributes() != null && other.getFailWorkflowExecutionDecisionAttributes().equals(this.getFailWorkflowExecutionDecisionAttributes()) == false) return false; + if (other.getCancelWorkflowExecutionDecisionAttributes() == null ^ this.getCancelWorkflowExecutionDecisionAttributes() == null) return false; + if (other.getCancelWorkflowExecutionDecisionAttributes() != null && other.getCancelWorkflowExecutionDecisionAttributes().equals(this.getCancelWorkflowExecutionDecisionAttributes()) == false) return false; + if (other.getContinueAsNewWorkflowExecutionDecisionAttributes() == null ^ this.getContinueAsNewWorkflowExecutionDecisionAttributes() == null) return false; + if (other.getContinueAsNewWorkflowExecutionDecisionAttributes() != null && other.getContinueAsNewWorkflowExecutionDecisionAttributes().equals(this.getContinueAsNewWorkflowExecutionDecisionAttributes()) == false) return false; + if (other.getRecordMarkerDecisionAttributes() == null ^ this.getRecordMarkerDecisionAttributes() == null) return false; + if (other.getRecordMarkerDecisionAttributes() != null && other.getRecordMarkerDecisionAttributes().equals(this.getRecordMarkerDecisionAttributes()) == false) return false; + if (other.getStartTimerDecisionAttributes() == null ^ this.getStartTimerDecisionAttributes() == null) return false; + if (other.getStartTimerDecisionAttributes() != null && other.getStartTimerDecisionAttributes().equals(this.getStartTimerDecisionAttributes()) == false) return false; + if (other.getCancelTimerDecisionAttributes() == null ^ this.getCancelTimerDecisionAttributes() == null) return false; + if (other.getCancelTimerDecisionAttributes() != null && other.getCancelTimerDecisionAttributes().equals(this.getCancelTimerDecisionAttributes()) == false) return false; + if (other.getSignalExternalWorkflowExecutionDecisionAttributes() == null ^ this.getSignalExternalWorkflowExecutionDecisionAttributes() == null) return false; + if (other.getSignalExternalWorkflowExecutionDecisionAttributes() != null && other.getSignalExternalWorkflowExecutionDecisionAttributes().equals(this.getSignalExternalWorkflowExecutionDecisionAttributes()) == false) return false; + if (other.getRequestCancelExternalWorkflowExecutionDecisionAttributes() == null ^ this.getRequestCancelExternalWorkflowExecutionDecisionAttributes() == null) return false; + if (other.getRequestCancelExternalWorkflowExecutionDecisionAttributes() != null && other.getRequestCancelExternalWorkflowExecutionDecisionAttributes().equals(this.getRequestCancelExternalWorkflowExecutionDecisionAttributes()) == false) return false; + if (other.getStartChildWorkflowExecutionDecisionAttributes() == null ^ this.getStartChildWorkflowExecutionDecisionAttributes() == null) return false; + if (other.getStartChildWorkflowExecutionDecisionAttributes() != null && other.getStartChildWorkflowExecutionDecisionAttributes().equals(this.getStartChildWorkflowExecutionDecisionAttributes()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTask.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTask.java new file mode 100644 index 000000000000..180e86d9f70a --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTask.java @@ -0,0 +1,493 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * A structure that represents a decision task. Decision tasks are sent + * to deciders in order for them to make decisions. + *

+ */ +public class DecisionTask { + + /** + * The opaque string used as a handle on the task. This token is used by + * workers to communicate progress and response information back to the + * system about the task. + *

+ * Constraints:
+ * Length: 1 - 1024
+ */ + private String taskToken; + + /** + * The id of the DecisionTaskStarted event recorded in the + * history. + */ + private Long startedEventId; + + /** + * The workflow execution for which this decision task was created. + */ + private WorkflowExecution workflowExecution; + + /** + * The type of the workflow execution for which this decision task was + * created. + */ + private WorkflowType workflowType; + + /** + * A paginated list of history events of the workflow execution. The + * decider uses this during the processing of the decision task. + */ + private java.util.List events; + + /** + * Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ */ + private String nextPageToken; + + /** + * The id of the DecisionTaskStarted event of the previous decision task + * of this workflow execution that was processed by the decider. This can + * be used to determine the events in the history new since the last + * decision task received by the decider. + */ + private Long previousStartedEventId; + + /** + * The opaque string used as a handle on the task. This token is used by + * workers to communicate progress and response information back to the + * system about the task. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @return The opaque string used as a handle on the task. This token is used by + * workers to communicate progress and response information back to the + * system about the task. + */ + public String getTaskToken() { + return taskToken; + } + + /** + * The opaque string used as a handle on the task. This token is used by + * workers to communicate progress and response information back to the + * system about the task. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @param taskToken The opaque string used as a handle on the task. This token is used by + * workers to communicate progress and response information back to the + * system about the task. + */ + public void setTaskToken(String taskToken) { + this.taskToken = taskToken; + } + + /** + * The opaque string used as a handle on the task. This token is used by + * workers to communicate progress and response information back to the + * system about the task. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @param taskToken The opaque string used as a handle on the task. This token is used by + * workers to communicate progress and response information back to the + * system about the task. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DecisionTask withTaskToken(String taskToken) { + this.taskToken = taskToken; + return this; + } + + + /** + * The id of the DecisionTaskStarted event recorded in the + * history. + * + * @return The id of the DecisionTaskStarted event recorded in the + * history. + */ + public Long getStartedEventId() { + return startedEventId; + } + + /** + * The id of the DecisionTaskStarted event recorded in the + * history. + * + * @param startedEventId The id of the DecisionTaskStarted event recorded in the + * history. + */ + public void setStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + } + + /** + * The id of the DecisionTaskStarted event recorded in the + * history. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startedEventId The id of the DecisionTaskStarted event recorded in the + * history. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DecisionTask withStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + return this; + } + + + /** + * The workflow execution for which this decision task was created. + * + * @return The workflow execution for which this decision task was created. + */ + public WorkflowExecution getWorkflowExecution() { + return workflowExecution; + } + + /** + * The workflow execution for which this decision task was created. + * + * @param workflowExecution The workflow execution for which this decision task was created. + */ + public void setWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + } + + /** + * The workflow execution for which this decision task was created. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowExecution The workflow execution for which this decision task was created. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DecisionTask withWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + return this; + } + + + /** + * The type of the workflow execution for which this decision task was + * created. + * + * @return The type of the workflow execution for which this decision task was + * created. + */ + public WorkflowType getWorkflowType() { + return workflowType; + } + + /** + * The type of the workflow execution for which this decision task was + * created. + * + * @param workflowType The type of the workflow execution for which this decision task was + * created. + */ + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + /** + * The type of the workflow execution for which this decision task was + * created. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowType The type of the workflow execution for which this decision task was + * created. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DecisionTask withWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + return this; + } + + + /** + * A paginated list of history events of the workflow execution. The + * decider uses this during the processing of the decision task. + * + * @return A paginated list of history events of the workflow execution. The + * decider uses this during the processing of the decision task. + */ + public java.util.List getEvents() { + + if (events == null) { + events = new java.util.ArrayList(); + } + return events; + } + + /** + * A paginated list of history events of the workflow execution. The + * decider uses this during the processing of the decision task. + * + * @param events A paginated list of history events of the workflow execution. The + * decider uses this during the processing of the decision task. + */ + public void setEvents(java.util.Collection events) { + if (events == null) { + this.events = null; + return; + } + + java.util.List eventsCopy = new java.util.ArrayList(events.size()); + eventsCopy.addAll(events); + this.events = eventsCopy; + } + + /** + * A paginated list of history events of the workflow execution. The + * decider uses this during the processing of the decision task. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param events A paginated list of history events of the workflow execution. The + * decider uses this during the processing of the decision task. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DecisionTask withEvents(HistoryEvent... events) { + if (getEvents() == null) setEvents(new java.util.ArrayList(events.length)); + for (HistoryEvent value : events) { + getEvents().add(value); + } + return this; + } + + /** + * A paginated list of history events of the workflow execution. The + * decider uses this during the processing of the decision task. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param events A paginated list of history events of the workflow execution. The + * decider uses this during the processing of the decision task. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DecisionTask withEvents(java.util.Collection events) { + if (events == null) { + this.events = null; + } else { + java.util.List eventsCopy = new java.util.ArrayList(events.size()); + eventsCopy.addAll(events); + this.events = eventsCopy; + } + + return this; + } + + /** + * Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @return Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + */ + public String getNextPageToken() { + return nextPageToken; + } + + /** + * Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + */ + public void setNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + } + + /** + * Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DecisionTask withNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + + /** + * The id of the DecisionTaskStarted event of the previous decision task + * of this workflow execution that was processed by the decider. This can + * be used to determine the events in the history new since the last + * decision task received by the decider. + * + * @return The id of the DecisionTaskStarted event of the previous decision task + * of this workflow execution that was processed by the decider. This can + * be used to determine the events in the history new since the last + * decision task received by the decider. + */ + public Long getPreviousStartedEventId() { + return previousStartedEventId; + } + + /** + * The id of the DecisionTaskStarted event of the previous decision task + * of this workflow execution that was processed by the decider. This can + * be used to determine the events in the history new since the last + * decision task received by the decider. + * + * @param previousStartedEventId The id of the DecisionTaskStarted event of the previous decision task + * of this workflow execution that was processed by the decider. This can + * be used to determine the events in the history new since the last + * decision task received by the decider. + */ + public void setPreviousStartedEventId(Long previousStartedEventId) { + this.previousStartedEventId = previousStartedEventId; + } + + /** + * The id of the DecisionTaskStarted event of the previous decision task + * of this workflow execution that was processed by the decider. This can + * be used to determine the events in the history new since the last + * decision task received by the decider. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param previousStartedEventId The id of the DecisionTaskStarted event of the previous decision task + * of this workflow execution that was processed by the decider. This can + * be used to determine the events in the history new since the last + * decision task received by the decider. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DecisionTask withPreviousStartedEventId(Long previousStartedEventId) { + this.previousStartedEventId = previousStartedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (taskToken != null) sb.append("TaskToken: " + taskToken + ", "); + if (startedEventId != null) sb.append("StartedEventId: " + startedEventId + ", "); + if (workflowExecution != null) sb.append("WorkflowExecution: " + workflowExecution + ", "); + if (workflowType != null) sb.append("WorkflowType: " + workflowType + ", "); + if (events != null) sb.append("Events: " + events + ", "); + if (nextPageToken != null) sb.append("NextPageToken: " + nextPageToken + ", "); + if (previousStartedEventId != null) sb.append("PreviousStartedEventId: " + previousStartedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTaskToken() == null) ? 0 : getTaskToken().hashCode()); + hashCode = prime * hashCode + ((getStartedEventId() == null) ? 0 : getStartedEventId().hashCode()); + hashCode = prime * hashCode + ((getWorkflowExecution() == null) ? 0 : getWorkflowExecution().hashCode()); + hashCode = prime * hashCode + ((getWorkflowType() == null) ? 0 : getWorkflowType().hashCode()); + hashCode = prime * hashCode + ((getEvents() == null) ? 0 : getEvents().hashCode()); + hashCode = prime * hashCode + ((getNextPageToken() == null) ? 0 : getNextPageToken().hashCode()); + hashCode = prime * hashCode + ((getPreviousStartedEventId() == null) ? 0 : getPreviousStartedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof DecisionTask == false) return false; + DecisionTask other = (DecisionTask)obj; + + if (other.getTaskToken() == null ^ this.getTaskToken() == null) return false; + if (other.getTaskToken() != null && other.getTaskToken().equals(this.getTaskToken()) == false) return false; + if (other.getStartedEventId() == null ^ this.getStartedEventId() == null) return false; + if (other.getStartedEventId() != null && other.getStartedEventId().equals(this.getStartedEventId()) == false) return false; + if (other.getWorkflowExecution() == null ^ this.getWorkflowExecution() == null) return false; + if (other.getWorkflowExecution() != null && other.getWorkflowExecution().equals(this.getWorkflowExecution()) == false) return false; + if (other.getWorkflowType() == null ^ this.getWorkflowType() == null) return false; + if (other.getWorkflowType() != null && other.getWorkflowType().equals(this.getWorkflowType()) == false) return false; + if (other.getEvents() == null ^ this.getEvents() == null) return false; + if (other.getEvents() != null && other.getEvents().equals(this.getEvents()) == false) return false; + if (other.getNextPageToken() == null ^ this.getNextPageToken() == null) return false; + if (other.getNextPageToken() != null && other.getNextPageToken().equals(this.getNextPageToken()) == false) return false; + if (other.getPreviousStartedEventId() == null ^ this.getPreviousStartedEventId() == null) return false; + if (other.getPreviousStartedEventId() != null && other.getPreviousStartedEventId().equals(this.getPreviousStartedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTaskCompletedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTaskCompletedEventAttributes.java new file mode 100644 index 000000000000..5fa7468b8923 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTaskCompletedEventAttributes.java @@ -0,0 +1,243 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the DecisionTaskCompleted event. + *

+ */ +public class DecisionTaskCompletedEventAttributes { + + /** + * User defined context for the workflow execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String executionContext; + + /** + * The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + private Long scheduledEventId; + + /** + * The Id of the DecisionTaskStarted event recorded when + * this decision task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + private Long startedEventId; + + /** + * User defined context for the workflow execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return User defined context for the workflow execution. + */ + public String getExecutionContext() { + return executionContext; + } + + /** + * User defined context for the workflow execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param executionContext User defined context for the workflow execution. + */ + public void setExecutionContext(String executionContext) { + this.executionContext = executionContext; + } + + /** + * User defined context for the workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param executionContext User defined context for the workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DecisionTaskCompletedEventAttributes withExecutionContext(String executionContext) { + this.executionContext = executionContext; + return this; + } + + + /** + * The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @return The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + public Long getScheduledEventId() { + return scheduledEventId; + } + + /** + * The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @param scheduledEventId The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + public void setScheduledEventId(Long scheduledEventId) { + this.scheduledEventId = scheduledEventId; + } + + /** + * The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param scheduledEventId The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DecisionTaskCompletedEventAttributes withScheduledEventId(Long scheduledEventId) { + this.scheduledEventId = scheduledEventId; + return this; + } + + + /** + * The Id of the DecisionTaskStarted event recorded when + * this decision task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @return The Id of the DecisionTaskStarted event recorded when + * this decision task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + public Long getStartedEventId() { + return startedEventId; + } + + /** + * The Id of the DecisionTaskStarted event recorded when + * this decision task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @param startedEventId The Id of the DecisionTaskStarted event recorded when + * this decision task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + public void setStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + } + + /** + * The Id of the DecisionTaskStarted event recorded when + * this decision task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startedEventId The Id of the DecisionTaskStarted event recorded when + * this decision task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DecisionTaskCompletedEventAttributes withStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (executionContext != null) sb.append("ExecutionContext: " + executionContext + ", "); + if (scheduledEventId != null) sb.append("ScheduledEventId: " + scheduledEventId + ", "); + if (startedEventId != null) sb.append("StartedEventId: " + startedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getExecutionContext() == null) ? 0 : getExecutionContext().hashCode()); + hashCode = prime * hashCode + ((getScheduledEventId() == null) ? 0 : getScheduledEventId().hashCode()); + hashCode = prime * hashCode + ((getStartedEventId() == null) ? 0 : getStartedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof DecisionTaskCompletedEventAttributes == false) return false; + DecisionTaskCompletedEventAttributes other = (DecisionTaskCompletedEventAttributes)obj; + + if (other.getExecutionContext() == null ^ this.getExecutionContext() == null) return false; + if (other.getExecutionContext() != null && other.getExecutionContext().equals(this.getExecutionContext()) == false) return false; + if (other.getScheduledEventId() == null ^ this.getScheduledEventId() == null) return false; + if (other.getScheduledEventId() != null && other.getScheduledEventId().equals(this.getScheduledEventId()) == false) return false; + if (other.getStartedEventId() == null ^ this.getStartedEventId() == null) return false; + if (other.getStartedEventId() != null && other.getStartedEventId().equals(this.getStartedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTaskScheduledEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTaskScheduledEventAttributes.java new file mode 100644 index 000000000000..fe5ea3986b7e --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTaskScheduledEventAttributes.java @@ -0,0 +1,186 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the DecisionTaskScheduled event. + *

+ */ +public class DecisionTaskScheduledEventAttributes { + + /** + * The name of the task list in which the decision task was scheduled. + */ + private TaskList taskList; + + /** + * The maximum duration for this decision task. The task is considered + * timed out if it does not completed within this duration.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String startToCloseTimeout; + + /** + * The name of the task list in which the decision task was scheduled. + * + * @return The name of the task list in which the decision task was scheduled. + */ + public TaskList getTaskList() { + return taskList; + } + + /** + * The name of the task list in which the decision task was scheduled. + * + * @param taskList The name of the task list in which the decision task was scheduled. + */ + public void setTaskList(TaskList taskList) { + this.taskList = taskList; + } + + /** + * The name of the task list in which the decision task was scheduled. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param taskList The name of the task list in which the decision task was scheduled. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DecisionTaskScheduledEventAttributes withTaskList(TaskList taskList) { + this.taskList = taskList; + return this; + } + + + /** + * The maximum duration for this decision task. The task is considered + * timed out if it does not completed within this duration.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return The maximum duration for this decision task. The task is considered + * timed out if it does not completed within this duration.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + */ + public String getStartToCloseTimeout() { + return startToCloseTimeout; + } + + /** + * The maximum duration for this decision task. The task is considered + * timed out if it does not completed within this duration.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param startToCloseTimeout The maximum duration for this decision task. The task is considered + * timed out if it does not completed within this duration.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + */ + public void setStartToCloseTimeout(String startToCloseTimeout) { + this.startToCloseTimeout = startToCloseTimeout; + } + + /** + * The maximum duration for this decision task. The task is considered + * timed out if it does not completed within this duration.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param startToCloseTimeout The maximum duration for this decision task. The task is considered + * timed out if it does not completed within this duration.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DecisionTaskScheduledEventAttributes withStartToCloseTimeout(String startToCloseTimeout) { + this.startToCloseTimeout = startToCloseTimeout; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (taskList != null) sb.append("TaskList: " + taskList + ", "); + if (startToCloseTimeout != null) sb.append("StartToCloseTimeout: " + startToCloseTimeout + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTaskList() == null) ? 0 : getTaskList().hashCode()); + hashCode = prime * hashCode + ((getStartToCloseTimeout() == null) ? 0 : getStartToCloseTimeout().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof DecisionTaskScheduledEventAttributes == false) return false; + DecisionTaskScheduledEventAttributes other = (DecisionTaskScheduledEventAttributes)obj; + + if (other.getTaskList() == null ^ this.getTaskList() == null) return false; + if (other.getTaskList() != null && other.getTaskList().equals(this.getTaskList()) == false) return false; + if (other.getStartToCloseTimeout() == null ^ this.getStartToCloseTimeout() == null) return false; + if (other.getStartToCloseTimeout() != null && other.getStartToCloseTimeout().equals(this.getStartToCloseTimeout()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTaskStartedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTaskStartedEventAttributes.java new file mode 100644 index 000000000000..618e7bcae8e1 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTaskStartedEventAttributes.java @@ -0,0 +1,193 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the DecisionTaskStarted event. + *

+ */ +public class DecisionTaskStartedEventAttributes { + + /** + * Identity of the decider making the request. This enables diagnostic + * tracing when problems arise. The form of this identity is user + * defined. + *

+ * Constraints:
+ * Length: 0 - 256
+ */ + private String identity; + + /** + * The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + private Long scheduledEventId; + + /** + * Identity of the decider making the request. This enables diagnostic + * tracing when problems arise. The form of this identity is user + * defined. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @return Identity of the decider making the request. This enables diagnostic + * tracing when problems arise. The form of this identity is user + * defined. + */ + public String getIdentity() { + return identity; + } + + /** + * Identity of the decider making the request. This enables diagnostic + * tracing when problems arise. The form of this identity is user + * defined. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param identity Identity of the decider making the request. This enables diagnostic + * tracing when problems arise. The form of this identity is user + * defined. + */ + public void setIdentity(String identity) { + this.identity = identity; + } + + /** + * Identity of the decider making the request. This enables diagnostic + * tracing when problems arise. The form of this identity is user + * defined. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param identity Identity of the decider making the request. This enables diagnostic + * tracing when problems arise. The form of this identity is user + * defined. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DecisionTaskStartedEventAttributes withIdentity(String identity) { + this.identity = identity; + return this; + } + + + /** + * The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @return The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + public Long getScheduledEventId() { + return scheduledEventId; + } + + /** + * The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @param scheduledEventId The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + public void setScheduledEventId(Long scheduledEventId) { + this.scheduledEventId = scheduledEventId; + } + + /** + * The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param scheduledEventId The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DecisionTaskStartedEventAttributes withScheduledEventId(Long scheduledEventId) { + this.scheduledEventId = scheduledEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (identity != null) sb.append("Identity: " + identity + ", "); + if (scheduledEventId != null) sb.append("ScheduledEventId: " + scheduledEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getIdentity() == null) ? 0 : getIdentity().hashCode()); + hashCode = prime * hashCode + ((getScheduledEventId() == null) ? 0 : getScheduledEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof DecisionTaskStartedEventAttributes == false) return false; + DecisionTaskStartedEventAttributes other = (DecisionTaskStartedEventAttributes)obj; + + if (other.getIdentity() == null ^ this.getIdentity() == null) return false; + if (other.getIdentity() != null && other.getIdentity().equals(this.getIdentity()) == false) return false; + if (other.getScheduledEventId() == null ^ this.getScheduledEventId() == null) return false; + if (other.getScheduledEventId() != null && other.getScheduledEventId().equals(this.getScheduledEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTaskTimedOutEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTaskTimedOutEventAttributes.java new file mode 100644 index 000000000000..b7aafcadd3c2 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTaskTimedOutEventAttributes.java @@ -0,0 +1,294 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the DecisionTaskTimedOut event. + *

+ */ +public class DecisionTaskTimedOutEventAttributes { + + /** + * The type of timeout that expired before the decision task could be + * completed. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE + */ + private String timeoutType; + + /** + * The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + private Long scheduledEventId; + + /** + * The Id of the DecisionTaskStarted event recorded when + * this decision task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + private Long startedEventId; + + /** + * The type of timeout that expired before the decision task could be + * completed. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE + * + * @return The type of timeout that expired before the decision task could be + * completed. + * + * @see DecisionTaskTimeoutType + */ + public String getTimeoutType() { + return timeoutType; + } + + /** + * The type of timeout that expired before the decision task could be + * completed. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE + * + * @param timeoutType The type of timeout that expired before the decision task could be + * completed. + * + * @see DecisionTaskTimeoutType + */ + public void setTimeoutType(String timeoutType) { + this.timeoutType = timeoutType; + } + + /** + * The type of timeout that expired before the decision task could be + * completed. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE + * + * @param timeoutType The type of timeout that expired before the decision task could be + * completed. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see DecisionTaskTimeoutType + */ + public DecisionTaskTimedOutEventAttributes withTimeoutType(String timeoutType) { + this.timeoutType = timeoutType; + return this; + } + + + /** + * The type of timeout that expired before the decision task could be + * completed. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE + * + * @param timeoutType The type of timeout that expired before the decision task could be + * completed. + * + * @see DecisionTaskTimeoutType + */ + public void setTimeoutType(DecisionTaskTimeoutType timeoutType) { + this.timeoutType = timeoutType.toString(); + } + + /** + * The type of timeout that expired before the decision task could be + * completed. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE + * + * @param timeoutType The type of timeout that expired before the decision task could be + * completed. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see DecisionTaskTimeoutType + */ + public DecisionTaskTimedOutEventAttributes withTimeoutType(DecisionTaskTimeoutType timeoutType) { + this.timeoutType = timeoutType.toString(); + return this; + } + + /** + * The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @return The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + public Long getScheduledEventId() { + return scheduledEventId; + } + + /** + * The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @param scheduledEventId The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + public void setScheduledEventId(Long scheduledEventId) { + this.scheduledEventId = scheduledEventId; + } + + /** + * The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param scheduledEventId The id of the DecisionTaskScheduled event that was + * recorded when this decision task was scheduled. This information can + * be useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DecisionTaskTimedOutEventAttributes withScheduledEventId(Long scheduledEventId) { + this.scheduledEventId = scheduledEventId; + return this; + } + + + /** + * The Id of the DecisionTaskStarted event recorded when + * this decision task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @return The Id of the DecisionTaskStarted event recorded when + * this decision task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + public Long getStartedEventId() { + return startedEventId; + } + + /** + * The Id of the DecisionTaskStarted event recorded when + * this decision task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @param startedEventId The Id of the DecisionTaskStarted event recorded when + * this decision task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + public void setStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + } + + /** + * The Id of the DecisionTaskStarted event recorded when + * this decision task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startedEventId The Id of the DecisionTaskStarted event recorded when + * this decision task was started. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DecisionTaskTimedOutEventAttributes withStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (timeoutType != null) sb.append("TimeoutType: " + timeoutType + ", "); + if (scheduledEventId != null) sb.append("ScheduledEventId: " + scheduledEventId + ", "); + if (startedEventId != null) sb.append("StartedEventId: " + startedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTimeoutType() == null) ? 0 : getTimeoutType().hashCode()); + hashCode = prime * hashCode + ((getScheduledEventId() == null) ? 0 : getScheduledEventId().hashCode()); + hashCode = prime * hashCode + ((getStartedEventId() == null) ? 0 : getStartedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof DecisionTaskTimedOutEventAttributes == false) return false; + DecisionTaskTimedOutEventAttributes other = (DecisionTaskTimedOutEventAttributes)obj; + + if (other.getTimeoutType() == null ^ this.getTimeoutType() == null) return false; + if (other.getTimeoutType() != null && other.getTimeoutType().equals(this.getTimeoutType()) == false) return false; + if (other.getScheduledEventId() == null ^ this.getScheduledEventId() == null) return false; + if (other.getScheduledEventId() != null && other.getScheduledEventId().equals(this.getScheduledEventId()) == false) return false; + if (other.getStartedEventId() == null ^ this.getStartedEventId() == null) return false; + if (other.getStartedEventId() != null && other.getStartedEventId().equals(this.getStartedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTaskTimeoutType.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTaskTimeoutType.java new file mode 100644 index 000000000000..3a7449f3de78 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionTaskTimeoutType.java @@ -0,0 +1,53 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Decision Task Timeout Type + */ +public enum DecisionTaskTimeoutType { + + START_TO_CLOSE("START_TO_CLOSE"); + + private String value; + + private DecisionTaskTimeoutType(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return DecisionTaskTimeoutType corresponding to the value + */ + public static DecisionTaskTimeoutType fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("START_TO_CLOSE".equals(value)) { + return DecisionTaskTimeoutType.START_TO_CLOSE; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionType.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionType.java new file mode 100644 index 000000000000..0fadeabf98d2 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DecisionType.java @@ -0,0 +1,86 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Decision Type + */ +public enum DecisionType { + + ScheduleActivityTask("ScheduleActivityTask"), + RequestCancelActivityTask("RequestCancelActivityTask"), + CompleteWorkflowExecution("CompleteWorkflowExecution"), + FailWorkflowExecution("FailWorkflowExecution"), + CancelWorkflowExecution("CancelWorkflowExecution"), + ContinueAsNewWorkflowExecution("ContinueAsNewWorkflowExecution"), + RecordMarker("RecordMarker"), + StartTimer("StartTimer"), + CancelTimer("CancelTimer"), + SignalExternalWorkflowExecution("SignalExternalWorkflowExecution"), + RequestCancelExternalWorkflowExecution("RequestCancelExternalWorkflowExecution"), + StartChildWorkflowExecution("StartChildWorkflowExecution"); + + private String value; + + private DecisionType(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return DecisionType corresponding to the value + */ + public static DecisionType fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("ScheduleActivityTask".equals(value)) { + return DecisionType.ScheduleActivityTask; + } else if ("RequestCancelActivityTask".equals(value)) { + return DecisionType.RequestCancelActivityTask; + } else if ("CompleteWorkflowExecution".equals(value)) { + return DecisionType.CompleteWorkflowExecution; + } else if ("FailWorkflowExecution".equals(value)) { + return DecisionType.FailWorkflowExecution; + } else if ("CancelWorkflowExecution".equals(value)) { + return DecisionType.CancelWorkflowExecution; + } else if ("ContinueAsNewWorkflowExecution".equals(value)) { + return DecisionType.ContinueAsNewWorkflowExecution; + } else if ("RecordMarker".equals(value)) { + return DecisionType.RecordMarker; + } else if ("StartTimer".equals(value)) { + return DecisionType.StartTimer; + } else if ("CancelTimer".equals(value)) { + return DecisionType.CancelTimer; + } else if ("SignalExternalWorkflowExecution".equals(value)) { + return DecisionType.SignalExternalWorkflowExecution; + } else if ("RequestCancelExternalWorkflowExecution".equals(value)) { + return DecisionType.RequestCancelExternalWorkflowExecution; + } else if ("StartChildWorkflowExecution".equals(value)) { + return DecisionType.StartChildWorkflowExecution; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DefaultUndefinedException.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DefaultUndefinedException.java new file mode 100644 index 000000000000..4ba9ecabdbd7 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DefaultUndefinedException.java @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +import com.amazonaws.AmazonServiceException; + +/** + * AmazonSimpleWorkflow exception + */ +public class DefaultUndefinedException extends AmazonServiceException { + private static final long serialVersionUID = 1L; + + /** + * Constructs a new DefaultUndefinedException with the specified error + * message. + * + * @param message Describes the error encountered. + */ + public DefaultUndefinedException(String message) { + super(message); + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DeprecateActivityTypeRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DeprecateActivityTypeRequest.java new file mode 100644 index 000000000000..d61bfbc58f08 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DeprecateActivityTypeRequest.java @@ -0,0 +1,169 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#deprecateActivityType(DeprecateActivityTypeRequest) DeprecateActivityType operation}. + *

+ * Deprecates the specified activity type . + * After an activity type has been deprecated, you cannot create new + * tasks of that activity type. Tasks of this type that were scheduled + * before the type was deprecated will continue to run. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#deprecateActivityType(DeprecateActivityTypeRequest) + */ +public class DeprecateActivityTypeRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain in which the activity type is registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * The activity type to deprecate. + */ + private ActivityType activityType; + + /** + * The name of the domain in which the activity type is registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain in which the activity type is registered. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain in which the activity type is registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain in which the activity type is registered. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain in which the activity type is registered. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain in which the activity type is registered. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DeprecateActivityTypeRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * The activity type to deprecate. + * + * @return The activity type to deprecate. + */ + public ActivityType getActivityType() { + return activityType; + } + + /** + * The activity type to deprecate. + * + * @param activityType The activity type to deprecate. + */ + public void setActivityType(ActivityType activityType) { + this.activityType = activityType; + } + + /** + * The activity type to deprecate. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param activityType The activity type to deprecate. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DeprecateActivityTypeRequest withActivityType(ActivityType activityType) { + this.activityType = activityType; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (activityType != null) sb.append("ActivityType: " + activityType + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getActivityType() == null) ? 0 : getActivityType().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof DeprecateActivityTypeRequest == false) return false; + DeprecateActivityTypeRequest other = (DeprecateActivityTypeRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getActivityType() == null ^ this.getActivityType() == null) return false; + if (other.getActivityType() != null && other.getActivityType().equals(this.getActivityType()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DeprecateDomainRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DeprecateDomainRequest.java new file mode 100644 index 000000000000..6c1736f118b3 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DeprecateDomainRequest.java @@ -0,0 +1,128 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#deprecateDomain(DeprecateDomainRequest) DeprecateDomain operation}. + *

+ * Deprecates the specified domain. After a domain has been deprecated + * it cannot be used to create new workflow executions or register new + * types. However, you can still use visibility actions on this domain. + * Deprecating a domain also deprecates all activity and workflow types + * registered in the domain. Executions that were started before the + * domain was deprecated will continue to run. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#deprecateDomain(DeprecateDomainRequest) + */ +public class DeprecateDomainRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain to deprecate. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String name; + + /** + * The name of the domain to deprecate. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain to deprecate. + */ + public String getName() { + return name; + } + + /** + * The name of the domain to deprecate. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name The name of the domain to deprecate. + */ + public void setName(String name) { + this.name = name; + } + + /** + * The name of the domain to deprecate. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name The name of the domain to deprecate. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DeprecateDomainRequest withName(String name) { + this.name = name; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (name != null) sb.append("Name: " + name + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof DeprecateDomainRequest == false) return false; + DeprecateDomainRequest other = (DeprecateDomainRequest)obj; + + if (other.getName() == null ^ this.getName() == null) return false; + if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DeprecateWorkflowTypeRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DeprecateWorkflowTypeRequest.java new file mode 100644 index 000000000000..20201b703995 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DeprecateWorkflowTypeRequest.java @@ -0,0 +1,170 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#deprecateWorkflowType(DeprecateWorkflowTypeRequest) DeprecateWorkflowType operation}. + *

+ * Deprecates the specified workflow type . After a workflow type + * has been deprecated, you cannot create new executions of that type. + * Executions that were started before the type was deprecated will + * continue to run. A deprecated workflow type may still be used when + * calling visibility actions. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#deprecateWorkflowType(DeprecateWorkflowTypeRequest) + */ +public class DeprecateWorkflowTypeRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain in which the workflow type is registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * The workflow type to deprecate. + */ + private WorkflowType workflowType; + + /** + * The name of the domain in which the workflow type is registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain in which the workflow type is registered. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain in which the workflow type is registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain in which the workflow type is registered. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain in which the workflow type is registered. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain in which the workflow type is registered. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DeprecateWorkflowTypeRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * The workflow type to deprecate. + * + * @return The workflow type to deprecate. + */ + public WorkflowType getWorkflowType() { + return workflowType; + } + + /** + * The workflow type to deprecate. + * + * @param workflowType The workflow type to deprecate. + */ + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + /** + * The workflow type to deprecate. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowType The workflow type to deprecate. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DeprecateWorkflowTypeRequest withWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (workflowType != null) sb.append("WorkflowType: " + workflowType + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getWorkflowType() == null) ? 0 : getWorkflowType().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof DeprecateWorkflowTypeRequest == false) return false; + DeprecateWorkflowTypeRequest other = (DeprecateWorkflowTypeRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getWorkflowType() == null ^ this.getWorkflowType() == null) return false; + if (other.getWorkflowType() != null && other.getWorkflowType().equals(this.getWorkflowType()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DescribeActivityTypeRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DescribeActivityTypeRequest.java new file mode 100644 index 000000000000..ee1e33b14aec --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DescribeActivityTypeRequest.java @@ -0,0 +1,164 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#describeActivityType(DescribeActivityTypeRequest) DescribeActivityType operation}. + *

+ * Returns information about the specified activity type. This includes + * configuration settings provided at registration time as well as other + * general information about the type. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#describeActivityType(DescribeActivityTypeRequest) + */ +public class DescribeActivityTypeRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain in which the activity type is registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * The activity type to describe. + */ + private ActivityType activityType; + + /** + * The name of the domain in which the activity type is registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain in which the activity type is registered. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain in which the activity type is registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain in which the activity type is registered. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain in which the activity type is registered. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain in which the activity type is registered. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DescribeActivityTypeRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * The activity type to describe. + * + * @return The activity type to describe. + */ + public ActivityType getActivityType() { + return activityType; + } + + /** + * The activity type to describe. + * + * @param activityType The activity type to describe. + */ + public void setActivityType(ActivityType activityType) { + this.activityType = activityType; + } + + /** + * The activity type to describe. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param activityType The activity type to describe. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DescribeActivityTypeRequest withActivityType(ActivityType activityType) { + this.activityType = activityType; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (activityType != null) sb.append("ActivityType: " + activityType + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getActivityType() == null) ? 0 : getActivityType().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof DescribeActivityTypeRequest == false) return false; + DescribeActivityTypeRequest other = (DescribeActivityTypeRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getActivityType() == null ^ this.getActivityType() == null) return false; + if (other.getActivityType() != null && other.getActivityType().equals(this.getActivityType()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DescribeDomainRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DescribeDomainRequest.java new file mode 100644 index 000000000000..d5c841e6977b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DescribeDomainRequest.java @@ -0,0 +1,120 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#describeDomain(DescribeDomainRequest) DescribeDomain operation}. + *

+ * Returns information about the specified domain including description + * and status. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#describeDomain(DescribeDomainRequest) + */ +public class DescribeDomainRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain to describe. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String name; + + /** + * The name of the domain to describe. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain to describe. + */ + public String getName() { + return name; + } + + /** + * The name of the domain to describe. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name The name of the domain to describe. + */ + public void setName(String name) { + this.name = name; + } + + /** + * The name of the domain to describe. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name The name of the domain to describe. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DescribeDomainRequest withName(String name) { + this.name = name; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (name != null) sb.append("Name: " + name + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof DescribeDomainRequest == false) return false; + DescribeDomainRequest other = (DescribeDomainRequest)obj; + + if (other.getName() == null ^ this.getName() == null) return false; + if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DescribeWorkflowExecutionRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DescribeWorkflowExecutionRequest.java new file mode 100644 index 000000000000..c51993874108 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DescribeWorkflowExecutionRequest.java @@ -0,0 +1,167 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#describeWorkflowExecution(DescribeWorkflowExecutionRequest) DescribeWorkflowExecution operation}. + *

+ * Returns information about the specified workflow execution including + * its type and some statistics. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#describeWorkflowExecution(DescribeWorkflowExecutionRequest) + */ +public class DescribeWorkflowExecutionRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain containing the workflow execution. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * The workflow execution to describe. + */ + private WorkflowExecution execution; + + /** + * The name of the domain containing the workflow execution. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain containing the workflow execution. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain containing the workflow execution. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain containing the workflow execution. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain containing the workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain containing the workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DescribeWorkflowExecutionRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * The workflow execution to describe. + * + * @return The workflow execution to describe. + */ + public WorkflowExecution getExecution() { + return execution; + } + + /** + * The workflow execution to describe. + * + * @param execution The workflow execution to describe. + */ + public void setExecution(WorkflowExecution execution) { + this.execution = execution; + } + + /** + * The workflow execution to describe. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param execution The workflow execution to describe. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DescribeWorkflowExecutionRequest withExecution(WorkflowExecution execution) { + this.execution = execution; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (execution != null) sb.append("Execution: " + execution + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getExecution() == null) ? 0 : getExecution().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof DescribeWorkflowExecutionRequest == false) return false; + DescribeWorkflowExecutionRequest other = (DescribeWorkflowExecutionRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getExecution() == null ^ this.getExecution() == null) return false; + if (other.getExecution() != null && other.getExecution().equals(this.getExecution()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DescribeWorkflowTypeRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DescribeWorkflowTypeRequest.java new file mode 100644 index 000000000000..59b8ee43790a --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DescribeWorkflowTypeRequest.java @@ -0,0 +1,164 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#describeWorkflowType(DescribeWorkflowTypeRequest) DescribeWorkflowType operation}. + *

+ * Returns information about the specified workflow type . This + * includes configuration settings specified when the type was registered + * and other information such as creation date, current status, etc. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#describeWorkflowType(DescribeWorkflowTypeRequest) + */ +public class DescribeWorkflowTypeRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain in which this workflow type is registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * The workflow type to describe. + */ + private WorkflowType workflowType; + + /** + * The name of the domain in which this workflow type is registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain in which this workflow type is registered. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain in which this workflow type is registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain in which this workflow type is registered. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain in which this workflow type is registered. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain in which this workflow type is registered. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DescribeWorkflowTypeRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * The workflow type to describe. + * + * @return The workflow type to describe. + */ + public WorkflowType getWorkflowType() { + return workflowType; + } + + /** + * The workflow type to describe. + * + * @param workflowType The workflow type to describe. + */ + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + /** + * The workflow type to describe. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowType The workflow type to describe. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DescribeWorkflowTypeRequest withWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (workflowType != null) sb.append("WorkflowType: " + workflowType + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getWorkflowType() == null) ? 0 : getWorkflowType().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof DescribeWorkflowTypeRequest == false) return false; + DescribeWorkflowTypeRequest other = (DescribeWorkflowTypeRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getWorkflowType() == null ^ this.getWorkflowType() == null) return false; + if (other.getWorkflowType() != null && other.getWorkflowType().equals(this.getWorkflowType()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DomainAlreadyExistsException.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DomainAlreadyExistsException.java new file mode 100644 index 000000000000..0b40644f98a1 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DomainAlreadyExistsException.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +import com.amazonaws.AmazonServiceException; + +/** + *

+ * Returned if the specified domain already exists. You will get this + * fault even if the existing domain is in deprecated status. + *

+ */ +public class DomainAlreadyExistsException extends AmazonServiceException { + private static final long serialVersionUID = 1L; + + /** + * Constructs a new DomainAlreadyExistsException with the specified error + * message. + * + * @param message Describes the error encountered. + */ + public DomainAlreadyExistsException(String message) { + super(message); + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DomainConfiguration.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DomainConfiguration.java new file mode 100644 index 000000000000..079bfb003a33 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DomainConfiguration.java @@ -0,0 +1,115 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Contains the configuration settings of a domain. + *

+ */ +public class DomainConfiguration { + + /** + * The retention period for workflow executions in this domain. + *

+ * Constraints:
+ * Length: 1 - 8
+ */ + private String workflowExecutionRetentionPeriodInDays; + + /** + * The retention period for workflow executions in this domain. + *

+ * Constraints:
+ * Length: 1 - 8
+ * + * @return The retention period for workflow executions in this domain. + */ + public String getWorkflowExecutionRetentionPeriodInDays() { + return workflowExecutionRetentionPeriodInDays; + } + + /** + * The retention period for workflow executions in this domain. + *

+ * Constraints:
+ * Length: 1 - 8
+ * + * @param workflowExecutionRetentionPeriodInDays The retention period for workflow executions in this domain. + */ + public void setWorkflowExecutionRetentionPeriodInDays(String workflowExecutionRetentionPeriodInDays) { + this.workflowExecutionRetentionPeriodInDays = workflowExecutionRetentionPeriodInDays; + } + + /** + * The retention period for workflow executions in this domain. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 8
+ * + * @param workflowExecutionRetentionPeriodInDays The retention period for workflow executions in this domain. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DomainConfiguration withWorkflowExecutionRetentionPeriodInDays(String workflowExecutionRetentionPeriodInDays) { + this.workflowExecutionRetentionPeriodInDays = workflowExecutionRetentionPeriodInDays; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowExecutionRetentionPeriodInDays != null) sb.append("WorkflowExecutionRetentionPeriodInDays: " + workflowExecutionRetentionPeriodInDays + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowExecutionRetentionPeriodInDays() == null) ? 0 : getWorkflowExecutionRetentionPeriodInDays().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof DomainConfiguration == false) return false; + DomainConfiguration other = (DomainConfiguration)obj; + + if (other.getWorkflowExecutionRetentionPeriodInDays() == null ^ this.getWorkflowExecutionRetentionPeriodInDays() == null) return false; + if (other.getWorkflowExecutionRetentionPeriodInDays() != null && other.getWorkflowExecutionRetentionPeriodInDays().equals(this.getWorkflowExecutionRetentionPeriodInDays()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DomainDeprecatedException.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DomainDeprecatedException.java new file mode 100644 index 000000000000..5f6fa426d296 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DomainDeprecatedException.java @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +import com.amazonaws.AmazonServiceException; + +/** + *

+ * Returned when the specified domain has been deprecated. + *

+ */ +public class DomainDeprecatedException extends AmazonServiceException { + private static final long serialVersionUID = 1L; + + /** + * Constructs a new DomainDeprecatedException with the specified error + * message. + * + * @param message Describes the error encountered. + */ + public DomainDeprecatedException(String message) { + super(message); + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DomainDetail.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DomainDetail.java new file mode 100644 index 000000000000..0c7bd04fe984 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DomainDetail.java @@ -0,0 +1,146 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Contains details of a domain. + *

+ */ +public class DomainDetail { + + /** + * Contains general information about a domain. + */ + private DomainInfo domainInfo; + + /** + * Contains the configuration settings of a domain. + */ + private DomainConfiguration configuration; + + /** + * Contains general information about a domain. + * + * @return Contains general information about a domain. + */ + public DomainInfo getDomainInfo() { + return domainInfo; + } + + /** + * Contains general information about a domain. + * + * @param domainInfo Contains general information about a domain. + */ + public void setDomainInfo(DomainInfo domainInfo) { + this.domainInfo = domainInfo; + } + + /** + * Contains general information about a domain. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param domainInfo Contains general information about a domain. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DomainDetail withDomainInfo(DomainInfo domainInfo) { + this.domainInfo = domainInfo; + return this; + } + + + /** + * Contains the configuration settings of a domain. + * + * @return Contains the configuration settings of a domain. + */ + public DomainConfiguration getConfiguration() { + return configuration; + } + + /** + * Contains the configuration settings of a domain. + * + * @param configuration Contains the configuration settings of a domain. + */ + public void setConfiguration(DomainConfiguration configuration) { + this.configuration = configuration; + } + + /** + * Contains the configuration settings of a domain. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param configuration Contains the configuration settings of a domain. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DomainDetail withConfiguration(DomainConfiguration configuration) { + this.configuration = configuration; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domainInfo != null) sb.append("DomainInfo: " + domainInfo + ", "); + if (configuration != null) sb.append("Configuration: " + configuration + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomainInfo() == null) ? 0 : getDomainInfo().hashCode()); + hashCode = prime * hashCode + ((getConfiguration() == null) ? 0 : getConfiguration().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof DomainDetail == false) return false; + DomainDetail other = (DomainDetail)obj; + + if (other.getDomainInfo() == null ^ this.getDomainInfo() == null) return false; + if (other.getDomainInfo() != null && other.getDomainInfo().equals(this.getDomainInfo()) == false) return false; + if (other.getConfiguration() == null ^ this.getConfiguration() == null) return false; + if (other.getConfiguration() != null && other.getConfiguration().equals(this.getConfiguration()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DomainInfo.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DomainInfo.java new file mode 100644 index 000000000000..e43d28f95a10 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DomainInfo.java @@ -0,0 +1,320 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Contains general information about a domain. + *

+ */ +public class DomainInfo { + + /** + * The name of the domain. This name is unique within the account. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String name; + + /** + * The status of the domain:

  • REGISTERED: The domain is + * properly registered and available. You can use this domain for + * registering types and creating new workflow executions.
  • + * DEPRECATED: The domain was deprecated using + * DeprecateDomain, but is still in use. You should not create new + * workflow executions in this domain.
+ *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + */ + private String status; + + /** + * The description of the domain provided through RegisterDomain. + *

+ * Constraints:
+ * Length: 0 - 1024
+ */ + private String description; + + /** + * The name of the domain. This name is unique within the account. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain. This name is unique within the account. + */ + public String getName() { + return name; + } + + /** + * The name of the domain. This name is unique within the account. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name The name of the domain. This name is unique within the account. + */ + public void setName(String name) { + this.name = name; + } + + /** + * The name of the domain. This name is unique within the account. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name The name of the domain. This name is unique within the account. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DomainInfo withName(String name) { + this.name = name; + return this; + } + + + /** + * The status of the domain:

  • REGISTERED: The domain is + * properly registered and available. You can use this domain for + * registering types and creating new workflow executions.
  • + * DEPRECATED: The domain was deprecated using + * DeprecateDomain, but is still in use. You should not create new + * workflow executions in this domain.
+ *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @return The status of the domain:

  • REGISTERED: The domain is + * properly registered and available. You can use this domain for + * registering types and creating new workflow executions.
  • + * DEPRECATED: The domain was deprecated using + * DeprecateDomain, but is still in use. You should not create new + * workflow executions in this domain.
+ * + * @see RegistrationStatus + */ + public String getStatus() { + return status; + } + + /** + * The status of the domain:
  • REGISTERED: The domain is + * properly registered and available. You can use this domain for + * registering types and creating new workflow executions.
  • + * DEPRECATED: The domain was deprecated using + * DeprecateDomain, but is still in use. You should not create new + * workflow executions in this domain.
+ *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param status The status of the domain:

  • REGISTERED: The domain is + * properly registered and available. You can use this domain for + * registering types and creating new workflow executions.
  • + * DEPRECATED: The domain was deprecated using + * DeprecateDomain, but is still in use. You should not create new + * workflow executions in this domain.
+ * + * @see RegistrationStatus + */ + public void setStatus(String status) { + this.status = status; + } + + /** + * The status of the domain:
  • REGISTERED: The domain is + * properly registered and available. You can use this domain for + * registering types and creating new workflow executions.
  • + * DEPRECATED: The domain was deprecated using + * DeprecateDomain, but is still in use. You should not create new + * workflow executions in this domain.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param status The status of the domain:

  • REGISTERED: The domain is + * properly registered and available. You can use this domain for + * registering types and creating new workflow executions.
  • + * DEPRECATED: The domain was deprecated using + * DeprecateDomain, but is still in use. You should not create new + * workflow executions in this domain.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see RegistrationStatus + */ + public DomainInfo withStatus(String status) { + this.status = status; + return this; + } + + + /** + * The status of the domain:
  • REGISTERED: The domain is + * properly registered and available. You can use this domain for + * registering types and creating new workflow executions.
  • + * DEPRECATED: The domain was deprecated using + * DeprecateDomain, but is still in use. You should not create new + * workflow executions in this domain.
+ *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param status The status of the domain:

  • REGISTERED: The domain is + * properly registered and available. You can use this domain for + * registering types and creating new workflow executions.
  • + * DEPRECATED: The domain was deprecated using + * DeprecateDomain, but is still in use. You should not create new + * workflow executions in this domain.
+ * + * @see RegistrationStatus + */ + public void setStatus(RegistrationStatus status) { + this.status = status.toString(); + } + + /** + * The status of the domain:
  • REGISTERED: The domain is + * properly registered and available. You can use this domain for + * registering types and creating new workflow executions.
  • + * DEPRECATED: The domain was deprecated using + * DeprecateDomain, but is still in use. You should not create new + * workflow executions in this domain.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param status The status of the domain:

  • REGISTERED: The domain is + * properly registered and available. You can use this domain for + * registering types and creating new workflow executions.
  • + * DEPRECATED: The domain was deprecated using + * DeprecateDomain, but is still in use. You should not create new + * workflow executions in this domain.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see RegistrationStatus + */ + public DomainInfo withStatus(RegistrationStatus status) { + this.status = status.toString(); + return this; + } + + /** + * The description of the domain provided through RegisterDomain. + *

+ * Constraints:
+ * Length: 0 - 1024
+ * + * @return The description of the domain provided through RegisterDomain. + */ + public String getDescription() { + return description; + } + + /** + * The description of the domain provided through RegisterDomain. + *

+ * Constraints:
+ * Length: 0 - 1024
+ * + * @param description The description of the domain provided through RegisterDomain. + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * The description of the domain provided through RegisterDomain. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 1024
+ * + * @param description The description of the domain provided through RegisterDomain. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DomainInfo withDescription(String description) { + this.description = description; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (name != null) sb.append("Name: " + name + ", "); + if (status != null) sb.append("Status: " + status + ", "); + if (description != null) sb.append("Description: " + description + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); + hashCode = prime * hashCode + ((getStatus() == null) ? 0 : getStatus().hashCode()); + hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof DomainInfo == false) return false; + DomainInfo other = (DomainInfo)obj; + + if (other.getName() == null ^ this.getName() == null) return false; + if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; + if (other.getStatus() == null ^ this.getStatus() == null) return false; + if (other.getStatus() != null && other.getStatus().equals(this.getStatus()) == false) return false; + if (other.getDescription() == null ^ this.getDescription() == null) return false; + if (other.getDescription() != null && other.getDescription().equals(this.getDescription()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/DomainInfos.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/DomainInfos.java new file mode 100644 index 000000000000..bbfb4d4d2be2 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/DomainInfos.java @@ -0,0 +1,207 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Contains a paginated collection of DomainInfo structures. + *

+ */ +public class DomainInfos { + + /** + * A list of DomainInfo structures. + */ + private java.util.List domainInfos; + + /** + * Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ */ + private String nextPageToken; + + /** + * A list of DomainInfo structures. + * + * @return A list of DomainInfo structures. + */ + public java.util.List getDomainInfos() { + + if (domainInfos == null) { + domainInfos = new java.util.ArrayList(); + } + return domainInfos; + } + + /** + * A list of DomainInfo structures. + * + * @param domainInfos A list of DomainInfo structures. + */ + public void setDomainInfos(java.util.Collection domainInfos) { + if (domainInfos == null) { + this.domainInfos = null; + return; + } + + java.util.List domainInfosCopy = new java.util.ArrayList(domainInfos.size()); + domainInfosCopy.addAll(domainInfos); + this.domainInfos = domainInfosCopy; + } + + /** + * A list of DomainInfo structures. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param domainInfos A list of DomainInfo structures. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DomainInfos withDomainInfos(DomainInfo... domainInfos) { + if (getDomainInfos() == null) setDomainInfos(new java.util.ArrayList(domainInfos.length)); + for (DomainInfo value : domainInfos) { + getDomainInfos().add(value); + } + return this; + } + + /** + * A list of DomainInfo structures. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param domainInfos A list of DomainInfo structures. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DomainInfos withDomainInfos(java.util.Collection domainInfos) { + if (domainInfos == null) { + this.domainInfos = null; + } else { + java.util.List domainInfosCopy = new java.util.ArrayList(domainInfos.size()); + domainInfosCopy.addAll(domainInfos); + this.domainInfos = domainInfosCopy; + } + + return this; + } + + /** + * Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @return Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + */ + public String getNextPageToken() { + return nextPageToken; + } + + /** + * Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + */ + public void setNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + } + + /** + * Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken Returns a value if the results are paginated. To get the next page of + * results, repeat the request specifying this token and all other + * arguments unchanged. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public DomainInfos withNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domainInfos != null) sb.append("DomainInfos: " + domainInfos + ", "); + if (nextPageToken != null) sb.append("NextPageToken: " + nextPageToken + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomainInfos() == null) ? 0 : getDomainInfos().hashCode()); + hashCode = prime * hashCode + ((getNextPageToken() == null) ? 0 : getNextPageToken().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof DomainInfos == false) return false; + DomainInfos other = (DomainInfos)obj; + + if (other.getDomainInfos() == null ^ this.getDomainInfos() == null) return false; + if (other.getDomainInfos() != null && other.getDomainInfos().equals(this.getDomainInfos()) == false) return false; + if (other.getNextPageToken() == null ^ this.getNextPageToken() == null) return false; + if (other.getNextPageToken() != null && other.getNextPageToken().equals(this.getNextPageToken()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/EventType.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/EventType.java new file mode 100644 index 000000000000..e5ebf807d452 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/EventType.java @@ -0,0 +1,188 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Event Type + */ +public enum EventType { + + WorkflowExecutionStarted("WorkflowExecutionStarted"), + WorkflowExecutionCancelRequested("WorkflowExecutionCancelRequested"), + WorkflowExecutionCompleted("WorkflowExecutionCompleted"), + CompleteWorkflowExecutionFailed("CompleteWorkflowExecutionFailed"), + WorkflowExecutionFailed("WorkflowExecutionFailed"), + FailWorkflowExecutionFailed("FailWorkflowExecutionFailed"), + WorkflowExecutionTimedOut("WorkflowExecutionTimedOut"), + WorkflowExecutionCanceled("WorkflowExecutionCanceled"), + CancelWorkflowExecutionFailed("CancelWorkflowExecutionFailed"), + WorkflowExecutionContinuedAsNew("WorkflowExecutionContinuedAsNew"), + ContinueAsNewWorkflowExecutionFailed("ContinueAsNewWorkflowExecutionFailed"), + WorkflowExecutionTerminated("WorkflowExecutionTerminated"), + DecisionTaskScheduled("DecisionTaskScheduled"), + DecisionTaskStarted("DecisionTaskStarted"), + DecisionTaskCompleted("DecisionTaskCompleted"), + DecisionTaskTimedOut("DecisionTaskTimedOut"), + ActivityTaskScheduled("ActivityTaskScheduled"), + ScheduleActivityTaskFailed("ScheduleActivityTaskFailed"), + ActivityTaskStarted("ActivityTaskStarted"), + ActivityTaskCompleted("ActivityTaskCompleted"), + ActivityTaskFailed("ActivityTaskFailed"), + ActivityTaskTimedOut("ActivityTaskTimedOut"), + ActivityTaskCanceled("ActivityTaskCanceled"), + ActivityTaskCancelRequested("ActivityTaskCancelRequested"), + RequestCancelActivityTaskFailed("RequestCancelActivityTaskFailed"), + WorkflowExecutionSignaled("WorkflowExecutionSignaled"), + MarkerRecorded("MarkerRecorded"), + TimerStarted("TimerStarted"), + StartTimerFailed("StartTimerFailed"), + TimerFired("TimerFired"), + TimerCanceled("TimerCanceled"), + CancelTimerFailed("CancelTimerFailed"), + StartChildWorkflowExecutionInitiated("StartChildWorkflowExecutionInitiated"), + StartChildWorkflowExecutionFailed("StartChildWorkflowExecutionFailed"), + ChildWorkflowExecutionStarted("ChildWorkflowExecutionStarted"), + ChildWorkflowExecutionCompleted("ChildWorkflowExecutionCompleted"), + ChildWorkflowExecutionFailed("ChildWorkflowExecutionFailed"), + ChildWorkflowExecutionTimedOut("ChildWorkflowExecutionTimedOut"), + ChildWorkflowExecutionCanceled("ChildWorkflowExecutionCanceled"), + ChildWorkflowExecutionTerminated("ChildWorkflowExecutionTerminated"), + SignalExternalWorkflowExecutionInitiated("SignalExternalWorkflowExecutionInitiated"), + SignalExternalWorkflowExecutionFailed("SignalExternalWorkflowExecutionFailed"), + ExternalWorkflowExecutionSignaled("ExternalWorkflowExecutionSignaled"), + RequestCancelExternalWorkflowExecutionInitiated("RequestCancelExternalWorkflowExecutionInitiated"), + RequestCancelExternalWorkflowExecutionFailed("RequestCancelExternalWorkflowExecutionFailed"), + ExternalWorkflowExecutionCancelRequested("ExternalWorkflowExecutionCancelRequested"); + + private String value; + + private EventType(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return EventType corresponding to the value + */ + public static EventType fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("WorkflowExecutionStarted".equals(value)) { + return EventType.WorkflowExecutionStarted; + } else if ("WorkflowExecutionCancelRequested".equals(value)) { + return EventType.WorkflowExecutionCancelRequested; + } else if ("WorkflowExecutionCompleted".equals(value)) { + return EventType.WorkflowExecutionCompleted; + } else if ("CompleteWorkflowExecutionFailed".equals(value)) { + return EventType.CompleteWorkflowExecutionFailed; + } else if ("WorkflowExecutionFailed".equals(value)) { + return EventType.WorkflowExecutionFailed; + } else if ("FailWorkflowExecutionFailed".equals(value)) { + return EventType.FailWorkflowExecutionFailed; + } else if ("WorkflowExecutionTimedOut".equals(value)) { + return EventType.WorkflowExecutionTimedOut; + } else if ("WorkflowExecutionCanceled".equals(value)) { + return EventType.WorkflowExecutionCanceled; + } else if ("CancelWorkflowExecutionFailed".equals(value)) { + return EventType.CancelWorkflowExecutionFailed; + } else if ("WorkflowExecutionContinuedAsNew".equals(value)) { + return EventType.WorkflowExecutionContinuedAsNew; + } else if ("ContinueAsNewWorkflowExecutionFailed".equals(value)) { + return EventType.ContinueAsNewWorkflowExecutionFailed; + } else if ("WorkflowExecutionTerminated".equals(value)) { + return EventType.WorkflowExecutionTerminated; + } else if ("DecisionTaskScheduled".equals(value)) { + return EventType.DecisionTaskScheduled; + } else if ("DecisionTaskStarted".equals(value)) { + return EventType.DecisionTaskStarted; + } else if ("DecisionTaskCompleted".equals(value)) { + return EventType.DecisionTaskCompleted; + } else if ("DecisionTaskTimedOut".equals(value)) { + return EventType.DecisionTaskTimedOut; + } else if ("ActivityTaskScheduled".equals(value)) { + return EventType.ActivityTaskScheduled; + } else if ("ScheduleActivityTaskFailed".equals(value)) { + return EventType.ScheduleActivityTaskFailed; + } else if ("ActivityTaskStarted".equals(value)) { + return EventType.ActivityTaskStarted; + } else if ("ActivityTaskCompleted".equals(value)) { + return EventType.ActivityTaskCompleted; + } else if ("ActivityTaskFailed".equals(value)) { + return EventType.ActivityTaskFailed; + } else if ("ActivityTaskTimedOut".equals(value)) { + return EventType.ActivityTaskTimedOut; + } else if ("ActivityTaskCanceled".equals(value)) { + return EventType.ActivityTaskCanceled; + } else if ("ActivityTaskCancelRequested".equals(value)) { + return EventType.ActivityTaskCancelRequested; + } else if ("RequestCancelActivityTaskFailed".equals(value)) { + return EventType.RequestCancelActivityTaskFailed; + } else if ("WorkflowExecutionSignaled".equals(value)) { + return EventType.WorkflowExecutionSignaled; + } else if ("MarkerRecorded".equals(value)) { + return EventType.MarkerRecorded; + } else if ("TimerStarted".equals(value)) { + return EventType.TimerStarted; + } else if ("StartTimerFailed".equals(value)) { + return EventType.StartTimerFailed; + } else if ("TimerFired".equals(value)) { + return EventType.TimerFired; + } else if ("TimerCanceled".equals(value)) { + return EventType.TimerCanceled; + } else if ("CancelTimerFailed".equals(value)) { + return EventType.CancelTimerFailed; + } else if ("StartChildWorkflowExecutionInitiated".equals(value)) { + return EventType.StartChildWorkflowExecutionInitiated; + } else if ("StartChildWorkflowExecutionFailed".equals(value)) { + return EventType.StartChildWorkflowExecutionFailed; + } else if ("ChildWorkflowExecutionStarted".equals(value)) { + return EventType.ChildWorkflowExecutionStarted; + } else if ("ChildWorkflowExecutionCompleted".equals(value)) { + return EventType.ChildWorkflowExecutionCompleted; + } else if ("ChildWorkflowExecutionFailed".equals(value)) { + return EventType.ChildWorkflowExecutionFailed; + } else if ("ChildWorkflowExecutionTimedOut".equals(value)) { + return EventType.ChildWorkflowExecutionTimedOut; + } else if ("ChildWorkflowExecutionCanceled".equals(value)) { + return EventType.ChildWorkflowExecutionCanceled; + } else if ("ChildWorkflowExecutionTerminated".equals(value)) { + return EventType.ChildWorkflowExecutionTerminated; + } else if ("SignalExternalWorkflowExecutionInitiated".equals(value)) { + return EventType.SignalExternalWorkflowExecutionInitiated; + } else if ("SignalExternalWorkflowExecutionFailed".equals(value)) { + return EventType.SignalExternalWorkflowExecutionFailed; + } else if ("ExternalWorkflowExecutionSignaled".equals(value)) { + return EventType.ExternalWorkflowExecutionSignaled; + } else if ("RequestCancelExternalWorkflowExecutionInitiated".equals(value)) { + return EventType.RequestCancelExternalWorkflowExecutionInitiated; + } else if ("RequestCancelExternalWorkflowExecutionFailed".equals(value)) { + return EventType.RequestCancelExternalWorkflowExecutionFailed; + } else if ("ExternalWorkflowExecutionCancelRequested".equals(value)) { + return EventType.ExternalWorkflowExecutionCancelRequested; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ExecutionStatus.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ExecutionStatus.java new file mode 100644 index 000000000000..f2c3b252f47d --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ExecutionStatus.java @@ -0,0 +1,56 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Execution Status + */ +public enum ExecutionStatus { + + OPEN("OPEN"), + CLOSED("CLOSED"); + + private String value; + + private ExecutionStatus(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return ExecutionStatus corresponding to the value + */ + public static ExecutionStatus fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("OPEN".equals(value)) { + return ExecutionStatus.OPEN; + } else if ("CLOSED".equals(value)) { + return ExecutionStatus.CLOSED; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ExecutionTimeFilter.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ExecutionTimeFilter.java new file mode 100644 index 000000000000..bcd98f021e71 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ExecutionTimeFilter.java @@ -0,0 +1,148 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Used to filter the workflow executions in visibility APIs by various + * time-based rules. Each parameter, if specified, defines a rule that + * must be satisfied by each returned query result. + *

+ */ +public class ExecutionTimeFilter { + + /** + * Specifies the oldest start or close date and time to return. + */ + private java.util.Date oldestDate; + + /** + * Specifies the latest start or close date and time to return. + */ + private java.util.Date latestDate; + + /** + * Specifies the oldest start or close date and time to return. + * + * @return Specifies the oldest start or close date and time to return. + */ + public java.util.Date getOldestDate() { + return oldestDate; + } + + /** + * Specifies the oldest start or close date and time to return. + * + * @param oldestDate Specifies the oldest start or close date and time to return. + */ + public void setOldestDate(java.util.Date oldestDate) { + this.oldestDate = oldestDate; + } + + /** + * Specifies the oldest start or close date and time to return. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param oldestDate Specifies the oldest start or close date and time to return. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ExecutionTimeFilter withOldestDate(java.util.Date oldestDate) { + this.oldestDate = oldestDate; + return this; + } + + + /** + * Specifies the latest start or close date and time to return. + * + * @return Specifies the latest start or close date and time to return. + */ + public java.util.Date getLatestDate() { + return latestDate; + } + + /** + * Specifies the latest start or close date and time to return. + * + * @param latestDate Specifies the latest start or close date and time to return. + */ + public void setLatestDate(java.util.Date latestDate) { + this.latestDate = latestDate; + } + + /** + * Specifies the latest start or close date and time to return. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param latestDate Specifies the latest start or close date and time to return. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ExecutionTimeFilter withLatestDate(java.util.Date latestDate) { + this.latestDate = latestDate; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (oldestDate != null) sb.append("OldestDate: " + oldestDate + ", "); + if (latestDate != null) sb.append("LatestDate: " + latestDate + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getOldestDate() == null) ? 0 : getOldestDate().hashCode()); + hashCode = prime * hashCode + ((getLatestDate() == null) ? 0 : getLatestDate().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ExecutionTimeFilter == false) return false; + ExecutionTimeFilter other = (ExecutionTimeFilter)obj; + + if (other.getOldestDate() == null ^ this.getOldestDate() == null) return false; + if (other.getOldestDate() != null && other.getOldestDate().equals(this.getOldestDate()) == false) return false; + if (other.getLatestDate() == null ^ this.getLatestDate() == null) return false; + if (other.getLatestDate() != null && other.getLatestDate().equals(this.getLatestDate()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ExternalWorkflowExecutionCancelRequestedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ExternalWorkflowExecutionCancelRequestedEventAttributes.java new file mode 100644 index 000000000000..c859c91da08a --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ExternalWorkflowExecutionCancelRequestedEventAttributes.java @@ -0,0 +1,196 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the + * ExternalWorkflowExecutionCancelRequested event. + *

+ */ +public class ExternalWorkflowExecutionCancelRequestedEventAttributes { + + /** + * The external workflow execution to which the cancellation request was + * delivered. + */ + private WorkflowExecution workflowExecution; + + /** + * The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this external workflow execution. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + private Long initiatedEventId; + + /** + * The external workflow execution to which the cancellation request was + * delivered. + * + * @return The external workflow execution to which the cancellation request was + * delivered. + */ + public WorkflowExecution getWorkflowExecution() { + return workflowExecution; + } + + /** + * The external workflow execution to which the cancellation request was + * delivered. + * + * @param workflowExecution The external workflow execution to which the cancellation request was + * delivered. + */ + public void setWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + } + + /** + * The external workflow execution to which the cancellation request was + * delivered. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowExecution The external workflow execution to which the cancellation request was + * delivered. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ExternalWorkflowExecutionCancelRequestedEventAttributes withWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + return this; + } + + + /** + * The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this external workflow execution. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @return The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this external workflow execution. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + public Long getInitiatedEventId() { + return initiatedEventId; + } + + /** + * The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this external workflow execution. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @param initiatedEventId The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this external workflow execution. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + public void setInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + } + + /** + * The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this external workflow execution. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param initiatedEventId The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this external workflow execution. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ExternalWorkflowExecutionCancelRequestedEventAttributes withInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowExecution != null) sb.append("WorkflowExecution: " + workflowExecution + ", "); + if (initiatedEventId != null) sb.append("InitiatedEventId: " + initiatedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowExecution() == null) ? 0 : getWorkflowExecution().hashCode()); + hashCode = prime * hashCode + ((getInitiatedEventId() == null) ? 0 : getInitiatedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ExternalWorkflowExecutionCancelRequestedEventAttributes == false) return false; + ExternalWorkflowExecutionCancelRequestedEventAttributes other = (ExternalWorkflowExecutionCancelRequestedEventAttributes)obj; + + if (other.getWorkflowExecution() == null ^ this.getWorkflowExecution() == null) return false; + if (other.getWorkflowExecution() != null && other.getWorkflowExecution().equals(this.getWorkflowExecution()) == false) return false; + if (other.getInitiatedEventId() == null ^ this.getInitiatedEventId() == null) return false; + if (other.getInitiatedEventId() != null && other.getInitiatedEventId().equals(this.getInitiatedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ExternalWorkflowExecutionSignaledEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ExternalWorkflowExecutionSignaledEventAttributes.java new file mode 100644 index 000000000000..8a999bbf5002 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ExternalWorkflowExecutionSignaledEventAttributes.java @@ -0,0 +1,175 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the + * ExternalWorkflowExecutionSignaled event. + *

+ */ +public class ExternalWorkflowExecutionSignaledEventAttributes { + + /** + * The external workflow execution that the signal was delivered to. + */ + private WorkflowExecution workflowExecution; + + /** + * The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the + * SignalExternalWorkflowExecution decision to request this + * signal. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + */ + private Long initiatedEventId; + + /** + * The external workflow execution that the signal was delivered to. + * + * @return The external workflow execution that the signal was delivered to. + */ + public WorkflowExecution getWorkflowExecution() { + return workflowExecution; + } + + /** + * The external workflow execution that the signal was delivered to. + * + * @param workflowExecution The external workflow execution that the signal was delivered to. + */ + public void setWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + } + + /** + * The external workflow execution that the signal was delivered to. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowExecution The external workflow execution that the signal was delivered to. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ExternalWorkflowExecutionSignaledEventAttributes withWorkflowExecution(WorkflowExecution workflowExecution) { + this.workflowExecution = workflowExecution; + return this; + } + + + /** + * The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the + * SignalExternalWorkflowExecution decision to request this + * signal. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + * + * @return The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the + * SignalExternalWorkflowExecution decision to request this + * signal. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + */ + public Long getInitiatedEventId() { + return initiatedEventId; + } + + /** + * The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the + * SignalExternalWorkflowExecution decision to request this + * signal. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + * + * @param initiatedEventId The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the + * SignalExternalWorkflowExecution decision to request this + * signal. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + */ + public void setInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + } + + /** + * The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the + * SignalExternalWorkflowExecution decision to request this + * signal. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param initiatedEventId The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the + * SignalExternalWorkflowExecution decision to request this + * signal. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ExternalWorkflowExecutionSignaledEventAttributes withInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowExecution != null) sb.append("WorkflowExecution: " + workflowExecution + ", "); + if (initiatedEventId != null) sb.append("InitiatedEventId: " + initiatedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowExecution() == null) ? 0 : getWorkflowExecution().hashCode()); + hashCode = prime * hashCode + ((getInitiatedEventId() == null) ? 0 : getInitiatedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ExternalWorkflowExecutionSignaledEventAttributes == false) return false; + ExternalWorkflowExecutionSignaledEventAttributes other = (ExternalWorkflowExecutionSignaledEventAttributes)obj; + + if (other.getWorkflowExecution() == null ^ this.getWorkflowExecution() == null) return false; + if (other.getWorkflowExecution() != null && other.getWorkflowExecution().equals(this.getWorkflowExecution()) == false) return false; + if (other.getInitiatedEventId() == null ^ this.getInitiatedEventId() == null) return false; + if (other.getInitiatedEventId() != null && other.getInitiatedEventId().equals(this.getInitiatedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/FailWorkflowExecutionDecisionAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/FailWorkflowExecutionDecisionAttributes.java new file mode 100644 index 000000000000..a8a542007477 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/FailWorkflowExecutionDecisionAttributes.java @@ -0,0 +1,170 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the FailWorkflowExecution decision. + *

+ */ +public class FailWorkflowExecutionDecisionAttributes { + + /** + * A descriptive reason for the failure that may help in diagnostics. + *

+ * Constraints:
+ * Length: 0 - 256
+ */ + private String reason; + + /** + * Optional details of the failure. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String details; + + /** + * A descriptive reason for the failure that may help in diagnostics. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @return A descriptive reason for the failure that may help in diagnostics. + */ + public String getReason() { + return reason; + } + + /** + * A descriptive reason for the failure that may help in diagnostics. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param reason A descriptive reason for the failure that may help in diagnostics. + */ + public void setReason(String reason) { + this.reason = reason; + } + + /** + * A descriptive reason for the failure that may help in diagnostics. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param reason A descriptive reason for the failure that may help in diagnostics. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public FailWorkflowExecutionDecisionAttributes withReason(String reason) { + this.reason = reason; + return this; + } + + + /** + * Optional details of the failure. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Optional details of the failure. + */ + public String getDetails() { + return details; + } + + /** + * Optional details of the failure. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details Optional details of the failure. + */ + public void setDetails(String details) { + this.details = details; + } + + /** + * Optional details of the failure. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details Optional details of the failure. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public FailWorkflowExecutionDecisionAttributes withDetails(String details) { + this.details = details; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (reason != null) sb.append("Reason: " + reason + ", "); + if (details != null) sb.append("Details: " + details + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getReason() == null) ? 0 : getReason().hashCode()); + hashCode = prime * hashCode + ((getDetails() == null) ? 0 : getDetails().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof FailWorkflowExecutionDecisionAttributes == false) return false; + FailWorkflowExecutionDecisionAttributes other = (FailWorkflowExecutionDecisionAttributes)obj; + + if (other.getReason() == null ^ this.getReason() == null) return false; + if (other.getReason() != null && other.getReason().equals(this.getReason()) == false) return false; + if (other.getDetails() == null ^ this.getDetails() == null) return false; + if (other.getDetails() != null && other.getDetails().equals(this.getDetails()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/FailWorkflowExecutionFailedCause.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/FailWorkflowExecutionFailedCause.java new file mode 100644 index 000000000000..f8f754e4ecce --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/FailWorkflowExecutionFailedCause.java @@ -0,0 +1,53 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Fail Workflow Execution Failed Cause + */ +public enum FailWorkflowExecutionFailedCause { + + UNHANDLED_DECISION("UNHANDLED_DECISION"); + + private String value; + + private FailWorkflowExecutionFailedCause(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return FailWorkflowExecutionFailedCause corresponding to the value + */ + public static FailWorkflowExecutionFailedCause fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("UNHANDLED_DECISION".equals(value)) { + return FailWorkflowExecutionFailedCause.UNHANDLED_DECISION; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/FailWorkflowExecutionFailedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/FailWorkflowExecutionFailedEventAttributes.java new file mode 100644 index 000000000000..4c444e26f13a --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/FailWorkflowExecutionFailedEventAttributes.java @@ -0,0 +1,238 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the FailWorkflowExecutionFailed + * event. + *

+ */ +public class FailWorkflowExecutionFailedEventAttributes { + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION + */ + private String cause; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * FailWorkflowExecution decision to fail this execution. + * This information can be useful for diagnosing problems by tracing back + * the cause of events. + */ + private Long decisionTaskCompletedEventId; + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION + * + * @return The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + * + * @see FailWorkflowExecutionFailedCause + */ + public String getCause() { + return cause; + } + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION + * + * @param cause The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + * + * @see FailWorkflowExecutionFailedCause + */ + public void setCause(String cause) { + this.cause = cause; + } + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION + * + * @param cause The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see FailWorkflowExecutionFailedCause + */ + public FailWorkflowExecutionFailedEventAttributes withCause(String cause) { + this.cause = cause; + return this; + } + + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION + * + * @param cause The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + * + * @see FailWorkflowExecutionFailedCause + */ + public void setCause(FailWorkflowExecutionFailedCause cause) { + this.cause = cause.toString(); + } + + /** + * The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: UNHANDLED_DECISION + * + * @param cause The cause of the failure. This information is generated by the system + * and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see FailWorkflowExecutionFailedCause + */ + public FailWorkflowExecutionFailedEventAttributes withCause(FailWorkflowExecutionFailedCause cause) { + this.cause = cause.toString(); + return this; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * FailWorkflowExecution decision to fail this execution. + * This information can be useful for diagnosing problems by tracing back + * the cause of events. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * FailWorkflowExecution decision to fail this execution. + * This information can be useful for diagnosing problems by tracing back + * the cause of events. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * FailWorkflowExecution decision to fail this execution. + * This information can be useful for diagnosing problems by tracing back + * the cause of events. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * FailWorkflowExecution decision to fail this execution. + * This information can be useful for diagnosing problems by tracing back + * the cause of events. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * FailWorkflowExecution decision to fail this execution. + * This information can be useful for diagnosing problems by tracing back + * the cause of events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * FailWorkflowExecution decision to fail this execution. + * This information can be useful for diagnosing problems by tracing back + * the cause of events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public FailWorkflowExecutionFailedEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (cause != null) sb.append("Cause: " + cause + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getCause() == null) ? 0 : getCause().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof FailWorkflowExecutionFailedEventAttributes == false) return false; + FailWorkflowExecutionFailedEventAttributes other = (FailWorkflowExecutionFailedEventAttributes)obj; + + if (other.getCause() == null ^ this.getCause() == null) return false; + if (other.getCause() != null && other.getCause().equals(this.getCause()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/GetWorkflowExecutionHistoryRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/GetWorkflowExecutionHistoryRequest.java new file mode 100644 index 000000000000..67e36c17f37c --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/GetWorkflowExecutionHistoryRequest.java @@ -0,0 +1,398 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#getWorkflowExecutionHistory(GetWorkflowExecutionHistoryRequest) GetWorkflowExecutionHistory operation}. + *

+ * Returns the history of the specified workflow execution. The results + * may be split into multiple pages. To retrieve subsequent pages, make + * the call again using the nextPageToken returned by the + * initial call. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#getWorkflowExecutionHistory(GetWorkflowExecutionHistoryRequest) + */ +public class GetWorkflowExecutionHistoryRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain containing the workflow execution. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * Specifies the workflow execution for which to return the history. + */ + private WorkflowExecution execution; + + /** + * If a NextPageToken is returned, the result has more than + * one pages. To get the next page, repeat the call and specify the + * nextPageToken with all other arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ */ + private String nextPageToken; + + /** + * Specifies the maximum number of history events returned in one page. + * The next page in the result is identified by the + * NextPageToken returned. By default 100 history events are + * returned in a page but the caller can override this value to a page + * size smaller than the default. You cannot specify a page size + * larger than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ */ + private Integer maximumPageSize; + + /** + * When set to true, returns the events in reverse order. By + * default the results are returned in ascending order of the + * eventTimeStamp of the events. + */ + private Boolean reverseOrder; + + /** + * The name of the domain containing the workflow execution. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain containing the workflow execution. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain containing the workflow execution. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain containing the workflow execution. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain containing the workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain containing the workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public GetWorkflowExecutionHistoryRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * Specifies the workflow execution for which to return the history. + * + * @return Specifies the workflow execution for which to return the history. + */ + public WorkflowExecution getExecution() { + return execution; + } + + /** + * Specifies the workflow execution for which to return the history. + * + * @param execution Specifies the workflow execution for which to return the history. + */ + public void setExecution(WorkflowExecution execution) { + this.execution = execution; + } + + /** + * Specifies the workflow execution for which to return the history. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param execution Specifies the workflow execution for which to return the history. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public GetWorkflowExecutionHistoryRequest withExecution(WorkflowExecution execution) { + this.execution = execution; + return this; + } + + + /** + * If a NextPageToken is returned, the result has more than + * one pages. To get the next page, repeat the call and specify the + * nextPageToken with all other arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @return If a NextPageToken is returned, the result has more than + * one pages. To get the next page, repeat the call and specify the + * nextPageToken with all other arguments unchanged. + */ + public String getNextPageToken() { + return nextPageToken; + } + + /** + * If a NextPageToken is returned, the result has more than + * one pages. To get the next page, repeat the call and specify the + * nextPageToken with all other arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken If a NextPageToken is returned, the result has more than + * one pages. To get the next page, repeat the call and specify the + * nextPageToken with all other arguments unchanged. + */ + public void setNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + } + + /** + * If a NextPageToken is returned, the result has more than + * one pages. To get the next page, repeat the call and specify the + * nextPageToken with all other arguments unchanged. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken If a NextPageToken is returned, the result has more than + * one pages. To get the next page, repeat the call and specify the + * nextPageToken with all other arguments unchanged. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public GetWorkflowExecutionHistoryRequest withNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + + /** + * Specifies the maximum number of history events returned in one page. + * The next page in the result is identified by the + * NextPageToken returned. By default 100 history events are + * returned in a page but the caller can override this value to a page + * size smaller than the default. You cannot specify a page size + * larger than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @return Specifies the maximum number of history events returned in one page. + * The next page in the result is identified by the + * NextPageToken returned. By default 100 history events are + * returned in a page but the caller can override this value to a page + * size smaller than the default. You cannot specify a page size + * larger than 100. + */ + public Integer getMaximumPageSize() { + return maximumPageSize; + } + + /** + * Specifies the maximum number of history events returned in one page. + * The next page in the result is identified by the + * NextPageToken returned. By default 100 history events are + * returned in a page but the caller can override this value to a page + * size smaller than the default. You cannot specify a page size + * larger than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @param maximumPageSize Specifies the maximum number of history events returned in one page. + * The next page in the result is identified by the + * NextPageToken returned. By default 100 history events are + * returned in a page but the caller can override this value to a page + * size smaller than the default. You cannot specify a page size + * larger than 100. + */ + public void setMaximumPageSize(Integer maximumPageSize) { + this.maximumPageSize = maximumPageSize; + } + + /** + * Specifies the maximum number of history events returned in one page. + * The next page in the result is identified by the + * NextPageToken returned. By default 100 history events are + * returned in a page but the caller can override this value to a page + * size smaller than the default. You cannot specify a page size + * larger than 100. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @param maximumPageSize Specifies the maximum number of history events returned in one page. + * The next page in the result is identified by the + * NextPageToken returned. By default 100 history events are + * returned in a page but the caller can override this value to a page + * size smaller than the default. You cannot specify a page size + * larger than 100. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public GetWorkflowExecutionHistoryRequest withMaximumPageSize(Integer maximumPageSize) { + this.maximumPageSize = maximumPageSize; + return this; + } + + + /** + * When set to true, returns the events in reverse order. By + * default the results are returned in ascending order of the + * eventTimeStamp of the events. + * + * @return When set to true, returns the events in reverse order. By + * default the results are returned in ascending order of the + * eventTimeStamp of the events. + */ + public Boolean isReverseOrder() { + return reverseOrder; + } + + /** + * When set to true, returns the events in reverse order. By + * default the results are returned in ascending order of the + * eventTimeStamp of the events. + * + * @param reverseOrder When set to true, returns the events in reverse order. By + * default the results are returned in ascending order of the + * eventTimeStamp of the events. + */ + public void setReverseOrder(Boolean reverseOrder) { + this.reverseOrder = reverseOrder; + } + + /** + * When set to true, returns the events in reverse order. By + * default the results are returned in ascending order of the + * eventTimeStamp of the events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param reverseOrder When set to true, returns the events in reverse order. By + * default the results are returned in ascending order of the + * eventTimeStamp of the events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public GetWorkflowExecutionHistoryRequest withReverseOrder(Boolean reverseOrder) { + this.reverseOrder = reverseOrder; + return this; + } + + + /** + * When set to true, returns the events in reverse order. By + * default the results are returned in ascending order of the + * eventTimeStamp of the events. + * + * @return When set to true, returns the events in reverse order. By + * default the results are returned in ascending order of the + * eventTimeStamp of the events. + */ + public Boolean getReverseOrder() { + return reverseOrder; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (execution != null) sb.append("Execution: " + execution + ", "); + if (nextPageToken != null) sb.append("NextPageToken: " + nextPageToken + ", "); + if (maximumPageSize != null) sb.append("MaximumPageSize: " + maximumPageSize + ", "); + if (reverseOrder != null) sb.append("ReverseOrder: " + reverseOrder + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getExecution() == null) ? 0 : getExecution().hashCode()); + hashCode = prime * hashCode + ((getNextPageToken() == null) ? 0 : getNextPageToken().hashCode()); + hashCode = prime * hashCode + ((getMaximumPageSize() == null) ? 0 : getMaximumPageSize().hashCode()); + hashCode = prime * hashCode + ((isReverseOrder() == null) ? 0 : isReverseOrder().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof GetWorkflowExecutionHistoryRequest == false) return false; + GetWorkflowExecutionHistoryRequest other = (GetWorkflowExecutionHistoryRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getExecution() == null ^ this.getExecution() == null) return false; + if (other.getExecution() != null && other.getExecution().equals(this.getExecution()) == false) return false; + if (other.getNextPageToken() == null ^ this.getNextPageToken() == null) return false; + if (other.getNextPageToken() != null && other.getNextPageToken().equals(this.getNextPageToken()) == false) return false; + if (other.getMaximumPageSize() == null ^ this.getMaximumPageSize() == null) return false; + if (other.getMaximumPageSize() != null && other.getMaximumPageSize().equals(this.getMaximumPageSize()) == false) return false; + if (other.isReverseOrder() == null ^ this.isReverseOrder() == null) return false; + if (other.isReverseOrder() != null && other.isReverseOrder().equals(this.isReverseOrder()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/History.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/History.java new file mode 100644 index 000000000000..e28520590a5e --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/History.java @@ -0,0 +1,210 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Paginated representation of a workflow history for a workflow + * execution. This is the up to date, complete and authoritative record + * of the events related to all tasks and events in the life of the + * workflow execution. + *

+ */ +public class History { + + /** + * The list of history events. + */ + private java.util.List events; + + /** + * The token for the next page. If set, the history consists of more than + * one page and the next page can be retrieved by repeating the request + * with this token and all other arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ */ + private String nextPageToken; + + /** + * The list of history events. + * + * @return The list of history events. + */ + public java.util.List getEvents() { + + if (events == null) { + events = new java.util.ArrayList(); + } + return events; + } + + /** + * The list of history events. + * + * @param events The list of history events. + */ + public void setEvents(java.util.Collection events) { + if (events == null) { + this.events = null; + return; + } + + java.util.List eventsCopy = new java.util.ArrayList(events.size()); + eventsCopy.addAll(events); + this.events = eventsCopy; + } + + /** + * The list of history events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param events The list of history events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public History withEvents(HistoryEvent... events) { + if (getEvents() == null) setEvents(new java.util.ArrayList(events.length)); + for (HistoryEvent value : events) { + getEvents().add(value); + } + return this; + } + + /** + * The list of history events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param events The list of history events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public History withEvents(java.util.Collection events) { + if (events == null) { + this.events = null; + } else { + java.util.List eventsCopy = new java.util.ArrayList(events.size()); + eventsCopy.addAll(events); + this.events = eventsCopy; + } + + return this; + } + + /** + * The token for the next page. If set, the history consists of more than + * one page and the next page can be retrieved by repeating the request + * with this token and all other arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @return The token for the next page. If set, the history consists of more than + * one page and the next page can be retrieved by repeating the request + * with this token and all other arguments unchanged. + */ + public String getNextPageToken() { + return nextPageToken; + } + + /** + * The token for the next page. If set, the history consists of more than + * one page and the next page can be retrieved by repeating the request + * with this token and all other arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken The token for the next page. If set, the history consists of more than + * one page and the next page can be retrieved by repeating the request + * with this token and all other arguments unchanged. + */ + public void setNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + } + + /** + * The token for the next page. If set, the history consists of more than + * one page and the next page can be retrieved by repeating the request + * with this token and all other arguments unchanged. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken The token for the next page. If set, the history consists of more than + * one page and the next page can be retrieved by repeating the request + * with this token and all other arguments unchanged. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public History withNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (events != null) sb.append("Events: " + events + ", "); + if (nextPageToken != null) sb.append("NextPageToken: " + nextPageToken + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getEvents() == null) ? 0 : getEvents().hashCode()); + hashCode = prime * hashCode + ((getNextPageToken() == null) ? 0 : getNextPageToken().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof History == false) return false; + History other = (History)obj; + + if (other.getEvents() == null ^ this.getEvents() == null) return false; + if (other.getEvents() != null && other.getEvents().equals(this.getEvents()) == false) return false; + if (other.getNextPageToken() == null ^ this.getNextPageToken() == null) return false; + if (other.getNextPageToken() != null && other.getNextPageToken().equals(this.getNextPageToken()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/HistoryEvent.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/HistoryEvent.java new file mode 100644 index 000000000000..005d06309e87 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/HistoryEvent.java @@ -0,0 +1,3024 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Event within a workflow execution. A history event can be one of + * these types: + *

+ * + *
    + *
  • WorkflowExecutionStarted : The workflow execution was + * started.
  • + *
  • WorkflowExecutionCompleted : The workflow execution was + * closed due to successful completion.
  • + *
  • WorkflowExecutionFailed : The workflow execution closed + * due to a failure.
  • + *
  • WorkflowExecutionTimedOut : The workflow execution was + * closed because a time out was exceeded.
  • + *
  • WorkflowExecutionCanceled : The workflow execution was + * successfully canceled and closed.
  • + *
  • WorkflowExecutionTerminated : The workflow execution was + * terminated.
  • + *
  • WorkflowExecutionContinuedAsNew : The workflow execution + * was closed and a new execution of the same type was created with the + * same workflowId.
  • + *
  • WorkflowExecutionCancelRequested : A request to cancel + * this workflow execution was made.
  • + *
  • DecisionTaskScheduled : A decision task was scheduled for + * the workflow execution.
  • + *
  • DecisionTaskStarted : The decision task was dispatched to + * a decider.
  • + *
  • DecisionTaskCompleted : The decider successfully + * completed a decision task by calling RespondDecisionTaskCompleted. + *
  • + *
  • DecisionTaskTimedOut : The decision task timed out.
  • + *
  • ActivityTaskScheduled : An activity task was scheduled + * for execution.
  • + *
  • ScheduleActivityTaskFailed : Failed to process + * ScheduleActivityTask decision. This happens when the decision is not + * configured properly, for example the activity type specified is not + * registered.
  • + *
  • ActivityTaskStarted : The scheduled activity task was + * dispatched to a worker.
  • + *
  • ActivityTaskCompleted : An activity worker successfully + * completed an activity task by calling RespondActivityTaskCompleted. + *
  • + *
  • ActivityTaskFailed : An activity worker failed an + * activity task by calling RespondActivityTaskFailed.
  • + *
  • ActivityTaskTimedOut : The activity task timed out.
  • + *
  • ActivityTaskCanceled : The activity task was successfully + * canceled.
  • + *
  • ActivityTaskCancelRequested : A + * RequestCancelActivityTask decision was received by the + * system.
  • + *
  • RequestCancelActivityTaskFailed : Failed to process + * RequestCancelActivityTask decision. This happens when the decision is + * not configured properly.
  • + *
  • WorkflowExecutionSignaled : An external signal was + * received for the workflow execution.
  • + *
  • MarkerRecorded : A marker was recorded in the workflow + * history as the result of a RecordMarker decision.
  • + *
  • TimerStarted : A timer was started for the workflow + * execution due to a StartTimer decision.
  • + *
  • StartTimerFailed : Failed to process StartTimer decision. + * This happens when the decision is not configured properly, for example + * a timer already exists with the specified timer Id.
  • + *
  • TimerFired : A timer, previously started for this + * workflow execution, fired.
  • + *
  • TimerCanceled : A timer, previously started for this + * workflow execution, was successfully canceled.
  • + *
  • CancelTimerFailed : Failed to process CancelTimer + * decision. This happens when the decision is not configured properly, + * for example no timer exists with the specified timer Id.
  • + *
  • StartChildWorkflowExecutionInitiated : A request was made + * to start a child workflow execution.
  • + *
  • StartChildWorkflowExecutionFailed : Failed to process + * StartChildWorkflowExecution decision. This happens when the decision + * is not configured properly, for example the workflow type specified is + * not registered.
  • + *
  • ChildWorkflowExecutionStarted : A child workflow + * execution was successfully started.
  • + *
  • ChildWorkflowExecutionCompleted : A child workflow + * execution, started by this workflow execution, completed successfully + * and was closed.
  • + *
  • ChildWorkflowExecutionFailed : A child workflow + * execution, started by this workflow execution, failed to complete + * successfully and was closed.
  • + *
  • ChildWorkflowExecutionTimedOut : A child workflow + * execution, started by this workflow execution, timed out and was + * closed.
  • + *
  • ChildWorkflowExecutionCanceled : A child workflow + * execution, started by this workflow execution, was canceled and + * closed.
  • + *
  • ChildWorkflowExecutionTerminated : A child workflow + * execution, started by this workflow execution, was terminated.
  • + *
  • SignalExternalWorkflowExecutionInitiated : A request to + * signal an external workflow was made.
  • + *
  • ExternalWorkflowExecutionSignaled : A signal, requested + * by this workflow execution, was successfully delivered to the target + * external workflow execution.
  • + *
  • SignalExternalWorkflowExecutionFailed : The request to + * signal an external workflow execution failed.
  • + *
  • RequestCancelExternalWorkflowExecutionInitiated : A + * request was made to request the cancellation of an external workflow + * execution.
  • + *
  • ExternalWorkflowExecutionCancelRequested : Request to + * cancel an external workflow execution was successfully delivered to + * the target execution.
  • + *
  • RequestCancelExternalWorkflowExecutionFailed : Request to + * cancel an external workflow execution failed.
  • + * + *
+ */ +public class HistoryEvent { + + /** + * The date and time when the event occurred. + */ + private java.util.Date eventTimestamp; + + /** + * The type of the history event. + *

+ * Constraints:
+ * Allowed Values: WorkflowExecutionStarted, WorkflowExecutionCancelRequested, WorkflowExecutionCompleted, CompleteWorkflowExecutionFailed, WorkflowExecutionFailed, FailWorkflowExecutionFailed, WorkflowExecutionTimedOut, WorkflowExecutionCanceled, CancelWorkflowExecutionFailed, WorkflowExecutionContinuedAsNew, ContinueAsNewWorkflowExecutionFailed, WorkflowExecutionTerminated, DecisionTaskScheduled, DecisionTaskStarted, DecisionTaskCompleted, DecisionTaskTimedOut, ActivityTaskScheduled, ScheduleActivityTaskFailed, ActivityTaskStarted, ActivityTaskCompleted, ActivityTaskFailed, ActivityTaskTimedOut, ActivityTaskCanceled, ActivityTaskCancelRequested, RequestCancelActivityTaskFailed, WorkflowExecutionSignaled, MarkerRecorded, TimerStarted, StartTimerFailed, TimerFired, TimerCanceled, CancelTimerFailed, StartChildWorkflowExecutionInitiated, StartChildWorkflowExecutionFailed, ChildWorkflowExecutionStarted, ChildWorkflowExecutionCompleted, ChildWorkflowExecutionFailed, ChildWorkflowExecutionTimedOut, ChildWorkflowExecutionCanceled, ChildWorkflowExecutionTerminated, SignalExternalWorkflowExecutionInitiated, SignalExternalWorkflowExecutionFailed, ExternalWorkflowExecutionSignaled, RequestCancelExternalWorkflowExecutionInitiated, RequestCancelExternalWorkflowExecutionFailed, ExternalWorkflowExecutionCancelRequested + */ + private String eventType; + + /** + * The system generated id of the event. This id uniquely identifies the + * event with in the workflow execution history. + */ + private Long eventId; + + /** + * If the event is of type WorkflowExecutionStarted then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + private WorkflowExecutionStartedEventAttributes workflowExecutionStartedEventAttributes; + + /** + * If the event is of type WorkflowExecutionCompleted then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + private WorkflowExecutionCompletedEventAttributes workflowExecutionCompletedEventAttributes; + + /** + * If the event is of type CompleteWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + private CompleteWorkflowExecutionFailedEventAttributes completeWorkflowExecutionFailedEventAttributes; + + /** + * If the event is of type WorkflowExecutionFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + private WorkflowExecutionFailedEventAttributes workflowExecutionFailedEventAttributes; + + /** + * If the event is of type FailWorkflowExecutionFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + private FailWorkflowExecutionFailedEventAttributes failWorkflowExecutionFailedEventAttributes; + + /** + * If the event is of type WorkflowExecutionTimedOut then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + private WorkflowExecutionTimedOutEventAttributes workflowExecutionTimedOutEventAttributes; + + /** + * If the event is of type WorkflowExecutionCanceled then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + private WorkflowExecutionCanceledEventAttributes workflowExecutionCanceledEventAttributes; + + /** + * If the event is of type CancelWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + private CancelWorkflowExecutionFailedEventAttributes cancelWorkflowExecutionFailedEventAttributes; + + /** + * If the event is of type WorkflowExecutionContinuedAsNew + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + private WorkflowExecutionContinuedAsNewEventAttributes workflowExecutionContinuedAsNewEventAttributes; + + /** + * If the event is of type + * ContinueAsNewWorkflowExecutionFailed then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + */ + private ContinueAsNewWorkflowExecutionFailedEventAttributes continueAsNewWorkflowExecutionFailedEventAttributes; + + /** + * If the event is of type WorkflowExecutionTerminated then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + private WorkflowExecutionTerminatedEventAttributes workflowExecutionTerminatedEventAttributes; + + /** + * If the event is of type WorkflowExecutionCancelRequested + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + private WorkflowExecutionCancelRequestedEventAttributes workflowExecutionCancelRequestedEventAttributes; + + /** + * If the event is of type DecisionTaskScheduled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + private DecisionTaskScheduledEventAttributes decisionTaskScheduledEventAttributes; + + /** + * If the event is of type DecisionTaskStarted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + private DecisionTaskStartedEventAttributes decisionTaskStartedEventAttributes; + + /** + * If the event is of type DecisionTaskCompleted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + private DecisionTaskCompletedEventAttributes decisionTaskCompletedEventAttributes; + + /** + * If the event is of type DecisionTaskTimedOut then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + private DecisionTaskTimedOutEventAttributes decisionTaskTimedOutEventAttributes; + + /** + * If the event is of type ActivityTaskScheduled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + private ActivityTaskScheduledEventAttributes activityTaskScheduledEventAttributes; + + /** + * If the event is of type ActivityTaskStarted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + private ActivityTaskStartedEventAttributes activityTaskStartedEventAttributes; + + /** + * If the event is of type ActivityTaskCompleted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + private ActivityTaskCompletedEventAttributes activityTaskCompletedEventAttributes; + + /** + * If the event is of type ActivityTaskFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + private ActivityTaskFailedEventAttributes activityTaskFailedEventAttributes; + + /** + * If the event is of type ActivityTaskTimedOut then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + private ActivityTaskTimedOutEventAttributes activityTaskTimedOutEventAttributes; + + /** + * If the event is of type ActivityTaskCanceled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + private ActivityTaskCanceledEventAttributes activityTaskCanceledEventAttributes; + + /** + * If the event is of type ActivityTaskcancelRequested then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + private ActivityTaskCancelRequestedEventAttributes activityTaskCancelRequestedEventAttributes; + + /** + * If the event is of type WorkflowExecutionSignaled then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + private WorkflowExecutionSignaledEventAttributes workflowExecutionSignaledEventAttributes; + + /** + * If the event is of type MarkerRecorded then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + */ + private MarkerRecordedEventAttributes markerRecordedEventAttributes; + + /** + * If the event is of type TimerStarted then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + */ + private TimerStartedEventAttributes timerStartedEventAttributes; + + /** + * If the event is of type TimerFired then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + */ + private TimerFiredEventAttributes timerFiredEventAttributes; + + /** + * If the event is of type TimerCanceled then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + */ + private TimerCanceledEventAttributes timerCanceledEventAttributes; + + /** + * If the event is of type + * StartChildWorkflowExecutionInitiated then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + */ + private StartChildWorkflowExecutionInitiatedEventAttributes startChildWorkflowExecutionInitiatedEventAttributes; + + /** + * If the event is of type ChildWorkflowExecutionStarted + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + private ChildWorkflowExecutionStartedEventAttributes childWorkflowExecutionStartedEventAttributes; + + /** + * If the event is of type ChildWorkflowExecutionCompleted + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + private ChildWorkflowExecutionCompletedEventAttributes childWorkflowExecutionCompletedEventAttributes; + + /** + * If the event is of type ChildWorkflowExecutionFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + private ChildWorkflowExecutionFailedEventAttributes childWorkflowExecutionFailedEventAttributes; + + /** + * If the event is of type ChildWorkflowExecutionTimedOut + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + private ChildWorkflowExecutionTimedOutEventAttributes childWorkflowExecutionTimedOutEventAttributes; + + /** + * If the event is of type ChildWorkflowExecutionCanceled + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + private ChildWorkflowExecutionCanceledEventAttributes childWorkflowExecutionCanceledEventAttributes; + + /** + * If the event is of type ChildWorkflowExecutionTerminated + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + private ChildWorkflowExecutionTerminatedEventAttributes childWorkflowExecutionTerminatedEventAttributes; + + /** + * If the event is of type + * SignalExternalWorkflowExecutionInitiated then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + */ + private SignalExternalWorkflowExecutionInitiatedEventAttributes signalExternalWorkflowExecutionInitiatedEventAttributes; + + /** + * If the event is of type ExternalWorkflowExecutionSignaled + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + private ExternalWorkflowExecutionSignaledEventAttributes externalWorkflowExecutionSignaledEventAttributes; + + /** + * If the event is of type + * SignalExternalWorkflowExecutionFailed then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + */ + private SignalExternalWorkflowExecutionFailedEventAttributes signalExternalWorkflowExecutionFailedEventAttributes; + + /** + * If the event is of type + * ExternalWorkflowExecutionCancelRequested then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + */ + private ExternalWorkflowExecutionCancelRequestedEventAttributes externalWorkflowExecutionCancelRequestedEventAttributes; + + /** + * If the event is of type + * RequestCancelExternalWorkflowExecutionInitiated then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + private RequestCancelExternalWorkflowExecutionInitiatedEventAttributes requestCancelExternalWorkflowExecutionInitiatedEventAttributes; + + /** + * If the event is of type + * RequestCancelExternalWorkflowExecutionFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + private RequestCancelExternalWorkflowExecutionFailedEventAttributes requestCancelExternalWorkflowExecutionFailedEventAttributes; + + /** + * If the event is of type ScheduleActivityTaskFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + private ScheduleActivityTaskFailedEventAttributes scheduleActivityTaskFailedEventAttributes; + + /** + * If the event is of type RequestCancelActivityTaskFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + private RequestCancelActivityTaskFailedEventAttributes requestCancelActivityTaskFailedEventAttributes; + + /** + * If the event is of type StartTimerFailed then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + */ + private StartTimerFailedEventAttributes startTimerFailedEventAttributes; + + /** + * If the event is of type CancelTimerFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + private CancelTimerFailedEventAttributes cancelTimerFailedEventAttributes; + + /** + * If the event is of type StartChildWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + private StartChildWorkflowExecutionFailedEventAttributes startChildWorkflowExecutionFailedEventAttributes; + + /** + * The date and time when the event occurred. + * + * @return The date and time when the event occurred. + */ + public java.util.Date getEventTimestamp() { + return eventTimestamp; + } + + /** + * The date and time when the event occurred. + * + * @param eventTimestamp The date and time when the event occurred. + */ + public void setEventTimestamp(java.util.Date eventTimestamp) { + this.eventTimestamp = eventTimestamp; + } + + /** + * The date and time when the event occurred. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param eventTimestamp The date and time when the event occurred. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withEventTimestamp(java.util.Date eventTimestamp) { + this.eventTimestamp = eventTimestamp; + return this; + } + + + /** + * The type of the history event. + *

+ * Constraints:
+ * Allowed Values: WorkflowExecutionStarted, WorkflowExecutionCancelRequested, WorkflowExecutionCompleted, CompleteWorkflowExecutionFailed, WorkflowExecutionFailed, FailWorkflowExecutionFailed, WorkflowExecutionTimedOut, WorkflowExecutionCanceled, CancelWorkflowExecutionFailed, WorkflowExecutionContinuedAsNew, ContinueAsNewWorkflowExecutionFailed, WorkflowExecutionTerminated, DecisionTaskScheduled, DecisionTaskStarted, DecisionTaskCompleted, DecisionTaskTimedOut, ActivityTaskScheduled, ScheduleActivityTaskFailed, ActivityTaskStarted, ActivityTaskCompleted, ActivityTaskFailed, ActivityTaskTimedOut, ActivityTaskCanceled, ActivityTaskCancelRequested, RequestCancelActivityTaskFailed, WorkflowExecutionSignaled, MarkerRecorded, TimerStarted, StartTimerFailed, TimerFired, TimerCanceled, CancelTimerFailed, StartChildWorkflowExecutionInitiated, StartChildWorkflowExecutionFailed, ChildWorkflowExecutionStarted, ChildWorkflowExecutionCompleted, ChildWorkflowExecutionFailed, ChildWorkflowExecutionTimedOut, ChildWorkflowExecutionCanceled, ChildWorkflowExecutionTerminated, SignalExternalWorkflowExecutionInitiated, SignalExternalWorkflowExecutionFailed, ExternalWorkflowExecutionSignaled, RequestCancelExternalWorkflowExecutionInitiated, RequestCancelExternalWorkflowExecutionFailed, ExternalWorkflowExecutionCancelRequested + * + * @return The type of the history event. + * + * @see EventType + */ + public String getEventType() { + return eventType; + } + + /** + * The type of the history event. + *

+ * Constraints:
+ * Allowed Values: WorkflowExecutionStarted, WorkflowExecutionCancelRequested, WorkflowExecutionCompleted, CompleteWorkflowExecutionFailed, WorkflowExecutionFailed, FailWorkflowExecutionFailed, WorkflowExecutionTimedOut, WorkflowExecutionCanceled, CancelWorkflowExecutionFailed, WorkflowExecutionContinuedAsNew, ContinueAsNewWorkflowExecutionFailed, WorkflowExecutionTerminated, DecisionTaskScheduled, DecisionTaskStarted, DecisionTaskCompleted, DecisionTaskTimedOut, ActivityTaskScheduled, ScheduleActivityTaskFailed, ActivityTaskStarted, ActivityTaskCompleted, ActivityTaskFailed, ActivityTaskTimedOut, ActivityTaskCanceled, ActivityTaskCancelRequested, RequestCancelActivityTaskFailed, WorkflowExecutionSignaled, MarkerRecorded, TimerStarted, StartTimerFailed, TimerFired, TimerCanceled, CancelTimerFailed, StartChildWorkflowExecutionInitiated, StartChildWorkflowExecutionFailed, ChildWorkflowExecutionStarted, ChildWorkflowExecutionCompleted, ChildWorkflowExecutionFailed, ChildWorkflowExecutionTimedOut, ChildWorkflowExecutionCanceled, ChildWorkflowExecutionTerminated, SignalExternalWorkflowExecutionInitiated, SignalExternalWorkflowExecutionFailed, ExternalWorkflowExecutionSignaled, RequestCancelExternalWorkflowExecutionInitiated, RequestCancelExternalWorkflowExecutionFailed, ExternalWorkflowExecutionCancelRequested + * + * @param eventType The type of the history event. + * + * @see EventType + */ + public void setEventType(String eventType) { + this.eventType = eventType; + } + + /** + * The type of the history event. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: WorkflowExecutionStarted, WorkflowExecutionCancelRequested, WorkflowExecutionCompleted, CompleteWorkflowExecutionFailed, WorkflowExecutionFailed, FailWorkflowExecutionFailed, WorkflowExecutionTimedOut, WorkflowExecutionCanceled, CancelWorkflowExecutionFailed, WorkflowExecutionContinuedAsNew, ContinueAsNewWorkflowExecutionFailed, WorkflowExecutionTerminated, DecisionTaskScheduled, DecisionTaskStarted, DecisionTaskCompleted, DecisionTaskTimedOut, ActivityTaskScheduled, ScheduleActivityTaskFailed, ActivityTaskStarted, ActivityTaskCompleted, ActivityTaskFailed, ActivityTaskTimedOut, ActivityTaskCanceled, ActivityTaskCancelRequested, RequestCancelActivityTaskFailed, WorkflowExecutionSignaled, MarkerRecorded, TimerStarted, StartTimerFailed, TimerFired, TimerCanceled, CancelTimerFailed, StartChildWorkflowExecutionInitiated, StartChildWorkflowExecutionFailed, ChildWorkflowExecutionStarted, ChildWorkflowExecutionCompleted, ChildWorkflowExecutionFailed, ChildWorkflowExecutionTimedOut, ChildWorkflowExecutionCanceled, ChildWorkflowExecutionTerminated, SignalExternalWorkflowExecutionInitiated, SignalExternalWorkflowExecutionFailed, ExternalWorkflowExecutionSignaled, RequestCancelExternalWorkflowExecutionInitiated, RequestCancelExternalWorkflowExecutionFailed, ExternalWorkflowExecutionCancelRequested + * + * @param eventType The type of the history event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see EventType + */ + public HistoryEvent withEventType(String eventType) { + this.eventType = eventType; + return this; + } + + + /** + * The type of the history event. + *

+ * Constraints:
+ * Allowed Values: WorkflowExecutionStarted, WorkflowExecutionCancelRequested, WorkflowExecutionCompleted, CompleteWorkflowExecutionFailed, WorkflowExecutionFailed, FailWorkflowExecutionFailed, WorkflowExecutionTimedOut, WorkflowExecutionCanceled, CancelWorkflowExecutionFailed, WorkflowExecutionContinuedAsNew, ContinueAsNewWorkflowExecutionFailed, WorkflowExecutionTerminated, DecisionTaskScheduled, DecisionTaskStarted, DecisionTaskCompleted, DecisionTaskTimedOut, ActivityTaskScheduled, ScheduleActivityTaskFailed, ActivityTaskStarted, ActivityTaskCompleted, ActivityTaskFailed, ActivityTaskTimedOut, ActivityTaskCanceled, ActivityTaskCancelRequested, RequestCancelActivityTaskFailed, WorkflowExecutionSignaled, MarkerRecorded, TimerStarted, StartTimerFailed, TimerFired, TimerCanceled, CancelTimerFailed, StartChildWorkflowExecutionInitiated, StartChildWorkflowExecutionFailed, ChildWorkflowExecutionStarted, ChildWorkflowExecutionCompleted, ChildWorkflowExecutionFailed, ChildWorkflowExecutionTimedOut, ChildWorkflowExecutionCanceled, ChildWorkflowExecutionTerminated, SignalExternalWorkflowExecutionInitiated, SignalExternalWorkflowExecutionFailed, ExternalWorkflowExecutionSignaled, RequestCancelExternalWorkflowExecutionInitiated, RequestCancelExternalWorkflowExecutionFailed, ExternalWorkflowExecutionCancelRequested + * + * @param eventType The type of the history event. + * + * @see EventType + */ + public void setEventType(EventType eventType) { + this.eventType = eventType.toString(); + } + + /** + * The type of the history event. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: WorkflowExecutionStarted, WorkflowExecutionCancelRequested, WorkflowExecutionCompleted, CompleteWorkflowExecutionFailed, WorkflowExecutionFailed, FailWorkflowExecutionFailed, WorkflowExecutionTimedOut, WorkflowExecutionCanceled, CancelWorkflowExecutionFailed, WorkflowExecutionContinuedAsNew, ContinueAsNewWorkflowExecutionFailed, WorkflowExecutionTerminated, DecisionTaskScheduled, DecisionTaskStarted, DecisionTaskCompleted, DecisionTaskTimedOut, ActivityTaskScheduled, ScheduleActivityTaskFailed, ActivityTaskStarted, ActivityTaskCompleted, ActivityTaskFailed, ActivityTaskTimedOut, ActivityTaskCanceled, ActivityTaskCancelRequested, RequestCancelActivityTaskFailed, WorkflowExecutionSignaled, MarkerRecorded, TimerStarted, StartTimerFailed, TimerFired, TimerCanceled, CancelTimerFailed, StartChildWorkflowExecutionInitiated, StartChildWorkflowExecutionFailed, ChildWorkflowExecutionStarted, ChildWorkflowExecutionCompleted, ChildWorkflowExecutionFailed, ChildWorkflowExecutionTimedOut, ChildWorkflowExecutionCanceled, ChildWorkflowExecutionTerminated, SignalExternalWorkflowExecutionInitiated, SignalExternalWorkflowExecutionFailed, ExternalWorkflowExecutionSignaled, RequestCancelExternalWorkflowExecutionInitiated, RequestCancelExternalWorkflowExecutionFailed, ExternalWorkflowExecutionCancelRequested + * + * @param eventType The type of the history event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see EventType + */ + public HistoryEvent withEventType(EventType eventType) { + this.eventType = eventType.toString(); + return this; + } + + /** + * The system generated id of the event. This id uniquely identifies the + * event with in the workflow execution history. + * + * @return The system generated id of the event. This id uniquely identifies the + * event with in the workflow execution history. + */ + public Long getEventId() { + return eventId; + } + + /** + * The system generated id of the event. This id uniquely identifies the + * event with in the workflow execution history. + * + * @param eventId The system generated id of the event. This id uniquely identifies the + * event with in the workflow execution history. + */ + public void setEventId(Long eventId) { + this.eventId = eventId; + } + + /** + * The system generated id of the event. This id uniquely identifies the + * event with in the workflow execution history. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param eventId The system generated id of the event. This id uniquely identifies the + * event with in the workflow execution history. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withEventId(Long eventId) { + this.eventId = eventId; + return this; + } + + + /** + * If the event is of type WorkflowExecutionStarted then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @return If the event is of type WorkflowExecutionStarted then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + public WorkflowExecutionStartedEventAttributes getWorkflowExecutionStartedEventAttributes() { + return workflowExecutionStartedEventAttributes; + } + + /** + * If the event is of type WorkflowExecutionStarted then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @param workflowExecutionStartedEventAttributes If the event is of type WorkflowExecutionStarted then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + public void setWorkflowExecutionStartedEventAttributes(WorkflowExecutionStartedEventAttributes workflowExecutionStartedEventAttributes) { + this.workflowExecutionStartedEventAttributes = workflowExecutionStartedEventAttributes; + } + + /** + * If the event is of type WorkflowExecutionStarted then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowExecutionStartedEventAttributes If the event is of type WorkflowExecutionStarted then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withWorkflowExecutionStartedEventAttributes(WorkflowExecutionStartedEventAttributes workflowExecutionStartedEventAttributes) { + this.workflowExecutionStartedEventAttributes = workflowExecutionStartedEventAttributes; + return this; + } + + + /** + * If the event is of type WorkflowExecutionCompleted then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @return If the event is of type WorkflowExecutionCompleted then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + public WorkflowExecutionCompletedEventAttributes getWorkflowExecutionCompletedEventAttributes() { + return workflowExecutionCompletedEventAttributes; + } + + /** + * If the event is of type WorkflowExecutionCompleted then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @param workflowExecutionCompletedEventAttributes If the event is of type WorkflowExecutionCompleted then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + public void setWorkflowExecutionCompletedEventAttributes(WorkflowExecutionCompletedEventAttributes workflowExecutionCompletedEventAttributes) { + this.workflowExecutionCompletedEventAttributes = workflowExecutionCompletedEventAttributes; + } + + /** + * If the event is of type WorkflowExecutionCompleted then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowExecutionCompletedEventAttributes If the event is of type WorkflowExecutionCompleted then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withWorkflowExecutionCompletedEventAttributes(WorkflowExecutionCompletedEventAttributes workflowExecutionCompletedEventAttributes) { + this.workflowExecutionCompletedEventAttributes = workflowExecutionCompletedEventAttributes; + return this; + } + + + /** + * If the event is of type CompleteWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return If the event is of type CompleteWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public CompleteWorkflowExecutionFailedEventAttributes getCompleteWorkflowExecutionFailedEventAttributes() { + return completeWorkflowExecutionFailedEventAttributes; + } + + /** + * If the event is of type CompleteWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @param completeWorkflowExecutionFailedEventAttributes If the event is of type CompleteWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public void setCompleteWorkflowExecutionFailedEventAttributes(CompleteWorkflowExecutionFailedEventAttributes completeWorkflowExecutionFailedEventAttributes) { + this.completeWorkflowExecutionFailedEventAttributes = completeWorkflowExecutionFailedEventAttributes; + } + + /** + * If the event is of type CompleteWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param completeWorkflowExecutionFailedEventAttributes If the event is of type CompleteWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withCompleteWorkflowExecutionFailedEventAttributes(CompleteWorkflowExecutionFailedEventAttributes completeWorkflowExecutionFailedEventAttributes) { + this.completeWorkflowExecutionFailedEventAttributes = completeWorkflowExecutionFailedEventAttributes; + return this; + } + + + /** + * If the event is of type WorkflowExecutionFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return If the event is of type WorkflowExecutionFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public WorkflowExecutionFailedEventAttributes getWorkflowExecutionFailedEventAttributes() { + return workflowExecutionFailedEventAttributes; + } + + /** + * If the event is of type WorkflowExecutionFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @param workflowExecutionFailedEventAttributes If the event is of type WorkflowExecutionFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public void setWorkflowExecutionFailedEventAttributes(WorkflowExecutionFailedEventAttributes workflowExecutionFailedEventAttributes) { + this.workflowExecutionFailedEventAttributes = workflowExecutionFailedEventAttributes; + } + + /** + * If the event is of type WorkflowExecutionFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowExecutionFailedEventAttributes If the event is of type WorkflowExecutionFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withWorkflowExecutionFailedEventAttributes(WorkflowExecutionFailedEventAttributes workflowExecutionFailedEventAttributes) { + this.workflowExecutionFailedEventAttributes = workflowExecutionFailedEventAttributes; + return this; + } + + + /** + * If the event is of type FailWorkflowExecutionFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @return If the event is of type FailWorkflowExecutionFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + public FailWorkflowExecutionFailedEventAttributes getFailWorkflowExecutionFailedEventAttributes() { + return failWorkflowExecutionFailedEventAttributes; + } + + /** + * If the event is of type FailWorkflowExecutionFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @param failWorkflowExecutionFailedEventAttributes If the event is of type FailWorkflowExecutionFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + public void setFailWorkflowExecutionFailedEventAttributes(FailWorkflowExecutionFailedEventAttributes failWorkflowExecutionFailedEventAttributes) { + this.failWorkflowExecutionFailedEventAttributes = failWorkflowExecutionFailedEventAttributes; + } + + /** + * If the event is of type FailWorkflowExecutionFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param failWorkflowExecutionFailedEventAttributes If the event is of type FailWorkflowExecutionFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withFailWorkflowExecutionFailedEventAttributes(FailWorkflowExecutionFailedEventAttributes failWorkflowExecutionFailedEventAttributes) { + this.failWorkflowExecutionFailedEventAttributes = failWorkflowExecutionFailedEventAttributes; + return this; + } + + + /** + * If the event is of type WorkflowExecutionTimedOut then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @return If the event is of type WorkflowExecutionTimedOut then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + public WorkflowExecutionTimedOutEventAttributes getWorkflowExecutionTimedOutEventAttributes() { + return workflowExecutionTimedOutEventAttributes; + } + + /** + * If the event is of type WorkflowExecutionTimedOut then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @param workflowExecutionTimedOutEventAttributes If the event is of type WorkflowExecutionTimedOut then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + public void setWorkflowExecutionTimedOutEventAttributes(WorkflowExecutionTimedOutEventAttributes workflowExecutionTimedOutEventAttributes) { + this.workflowExecutionTimedOutEventAttributes = workflowExecutionTimedOutEventAttributes; + } + + /** + * If the event is of type WorkflowExecutionTimedOut then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowExecutionTimedOutEventAttributes If the event is of type WorkflowExecutionTimedOut then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withWorkflowExecutionTimedOutEventAttributes(WorkflowExecutionTimedOutEventAttributes workflowExecutionTimedOutEventAttributes) { + this.workflowExecutionTimedOutEventAttributes = workflowExecutionTimedOutEventAttributes; + return this; + } + + + /** + * If the event is of type WorkflowExecutionCanceled then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @return If the event is of type WorkflowExecutionCanceled then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + public WorkflowExecutionCanceledEventAttributes getWorkflowExecutionCanceledEventAttributes() { + return workflowExecutionCanceledEventAttributes; + } + + /** + * If the event is of type WorkflowExecutionCanceled then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @param workflowExecutionCanceledEventAttributes If the event is of type WorkflowExecutionCanceled then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + public void setWorkflowExecutionCanceledEventAttributes(WorkflowExecutionCanceledEventAttributes workflowExecutionCanceledEventAttributes) { + this.workflowExecutionCanceledEventAttributes = workflowExecutionCanceledEventAttributes; + } + + /** + * If the event is of type WorkflowExecutionCanceled then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowExecutionCanceledEventAttributes If the event is of type WorkflowExecutionCanceled then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withWorkflowExecutionCanceledEventAttributes(WorkflowExecutionCanceledEventAttributes workflowExecutionCanceledEventAttributes) { + this.workflowExecutionCanceledEventAttributes = workflowExecutionCanceledEventAttributes; + return this; + } + + + /** + * If the event is of type CancelWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return If the event is of type CancelWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public CancelWorkflowExecutionFailedEventAttributes getCancelWorkflowExecutionFailedEventAttributes() { + return cancelWorkflowExecutionFailedEventAttributes; + } + + /** + * If the event is of type CancelWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @param cancelWorkflowExecutionFailedEventAttributes If the event is of type CancelWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public void setCancelWorkflowExecutionFailedEventAttributes(CancelWorkflowExecutionFailedEventAttributes cancelWorkflowExecutionFailedEventAttributes) { + this.cancelWorkflowExecutionFailedEventAttributes = cancelWorkflowExecutionFailedEventAttributes; + } + + /** + * If the event is of type CancelWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param cancelWorkflowExecutionFailedEventAttributes If the event is of type CancelWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withCancelWorkflowExecutionFailedEventAttributes(CancelWorkflowExecutionFailedEventAttributes cancelWorkflowExecutionFailedEventAttributes) { + this.cancelWorkflowExecutionFailedEventAttributes = cancelWorkflowExecutionFailedEventAttributes; + return this; + } + + + /** + * If the event is of type WorkflowExecutionContinuedAsNew + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return If the event is of type WorkflowExecutionContinuedAsNew + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public WorkflowExecutionContinuedAsNewEventAttributes getWorkflowExecutionContinuedAsNewEventAttributes() { + return workflowExecutionContinuedAsNewEventAttributes; + } + + /** + * If the event is of type WorkflowExecutionContinuedAsNew + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @param workflowExecutionContinuedAsNewEventAttributes If the event is of type WorkflowExecutionContinuedAsNew + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public void setWorkflowExecutionContinuedAsNewEventAttributes(WorkflowExecutionContinuedAsNewEventAttributes workflowExecutionContinuedAsNewEventAttributes) { + this.workflowExecutionContinuedAsNewEventAttributes = workflowExecutionContinuedAsNewEventAttributes; + } + + /** + * If the event is of type WorkflowExecutionContinuedAsNew + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowExecutionContinuedAsNewEventAttributes If the event is of type WorkflowExecutionContinuedAsNew + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withWorkflowExecutionContinuedAsNewEventAttributes(WorkflowExecutionContinuedAsNewEventAttributes workflowExecutionContinuedAsNewEventAttributes) { + this.workflowExecutionContinuedAsNewEventAttributes = workflowExecutionContinuedAsNewEventAttributes; + return this; + } + + + /** + * If the event is of type + * ContinueAsNewWorkflowExecutionFailed then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + * + * @return If the event is of type + * ContinueAsNewWorkflowExecutionFailed then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + */ + public ContinueAsNewWorkflowExecutionFailedEventAttributes getContinueAsNewWorkflowExecutionFailedEventAttributes() { + return continueAsNewWorkflowExecutionFailedEventAttributes; + } + + /** + * If the event is of type + * ContinueAsNewWorkflowExecutionFailed then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + * + * @param continueAsNewWorkflowExecutionFailedEventAttributes If the event is of type + * ContinueAsNewWorkflowExecutionFailed then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + */ + public void setContinueAsNewWorkflowExecutionFailedEventAttributes(ContinueAsNewWorkflowExecutionFailedEventAttributes continueAsNewWorkflowExecutionFailedEventAttributes) { + this.continueAsNewWorkflowExecutionFailedEventAttributes = continueAsNewWorkflowExecutionFailedEventAttributes; + } + + /** + * If the event is of type + * ContinueAsNewWorkflowExecutionFailed then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param continueAsNewWorkflowExecutionFailedEventAttributes If the event is of type + * ContinueAsNewWorkflowExecutionFailed then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withContinueAsNewWorkflowExecutionFailedEventAttributes(ContinueAsNewWorkflowExecutionFailedEventAttributes continueAsNewWorkflowExecutionFailedEventAttributes) { + this.continueAsNewWorkflowExecutionFailedEventAttributes = continueAsNewWorkflowExecutionFailedEventAttributes; + return this; + } + + + /** + * If the event is of type WorkflowExecutionTerminated then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @return If the event is of type WorkflowExecutionTerminated then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + public WorkflowExecutionTerminatedEventAttributes getWorkflowExecutionTerminatedEventAttributes() { + return workflowExecutionTerminatedEventAttributes; + } + + /** + * If the event is of type WorkflowExecutionTerminated then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @param workflowExecutionTerminatedEventAttributes If the event is of type WorkflowExecutionTerminated then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + public void setWorkflowExecutionTerminatedEventAttributes(WorkflowExecutionTerminatedEventAttributes workflowExecutionTerminatedEventAttributes) { + this.workflowExecutionTerminatedEventAttributes = workflowExecutionTerminatedEventAttributes; + } + + /** + * If the event is of type WorkflowExecutionTerminated then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowExecutionTerminatedEventAttributes If the event is of type WorkflowExecutionTerminated then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withWorkflowExecutionTerminatedEventAttributes(WorkflowExecutionTerminatedEventAttributes workflowExecutionTerminatedEventAttributes) { + this.workflowExecutionTerminatedEventAttributes = workflowExecutionTerminatedEventAttributes; + return this; + } + + + /** + * If the event is of type WorkflowExecutionCancelRequested + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return If the event is of type WorkflowExecutionCancelRequested + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public WorkflowExecutionCancelRequestedEventAttributes getWorkflowExecutionCancelRequestedEventAttributes() { + return workflowExecutionCancelRequestedEventAttributes; + } + + /** + * If the event is of type WorkflowExecutionCancelRequested + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @param workflowExecutionCancelRequestedEventAttributes If the event is of type WorkflowExecutionCancelRequested + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public void setWorkflowExecutionCancelRequestedEventAttributes(WorkflowExecutionCancelRequestedEventAttributes workflowExecutionCancelRequestedEventAttributes) { + this.workflowExecutionCancelRequestedEventAttributes = workflowExecutionCancelRequestedEventAttributes; + } + + /** + * If the event is of type WorkflowExecutionCancelRequested + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowExecutionCancelRequestedEventAttributes If the event is of type WorkflowExecutionCancelRequested + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withWorkflowExecutionCancelRequestedEventAttributes(WorkflowExecutionCancelRequestedEventAttributes workflowExecutionCancelRequestedEventAttributes) { + this.workflowExecutionCancelRequestedEventAttributes = workflowExecutionCancelRequestedEventAttributes; + return this; + } + + + /** + * If the event is of type DecisionTaskScheduled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return If the event is of type DecisionTaskScheduled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public DecisionTaskScheduledEventAttributes getDecisionTaskScheduledEventAttributes() { + return decisionTaskScheduledEventAttributes; + } + + /** + * If the event is of type DecisionTaskScheduled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @param decisionTaskScheduledEventAttributes If the event is of type DecisionTaskScheduled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public void setDecisionTaskScheduledEventAttributes(DecisionTaskScheduledEventAttributes decisionTaskScheduledEventAttributes) { + this.decisionTaskScheduledEventAttributes = decisionTaskScheduledEventAttributes; + } + + /** + * If the event is of type DecisionTaskScheduled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskScheduledEventAttributes If the event is of type DecisionTaskScheduled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withDecisionTaskScheduledEventAttributes(DecisionTaskScheduledEventAttributes decisionTaskScheduledEventAttributes) { + this.decisionTaskScheduledEventAttributes = decisionTaskScheduledEventAttributes; + return this; + } + + + /** + * If the event is of type DecisionTaskStarted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return If the event is of type DecisionTaskStarted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public DecisionTaskStartedEventAttributes getDecisionTaskStartedEventAttributes() { + return decisionTaskStartedEventAttributes; + } + + /** + * If the event is of type DecisionTaskStarted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @param decisionTaskStartedEventAttributes If the event is of type DecisionTaskStarted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public void setDecisionTaskStartedEventAttributes(DecisionTaskStartedEventAttributes decisionTaskStartedEventAttributes) { + this.decisionTaskStartedEventAttributes = decisionTaskStartedEventAttributes; + } + + /** + * If the event is of type DecisionTaskStarted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskStartedEventAttributes If the event is of type DecisionTaskStarted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withDecisionTaskStartedEventAttributes(DecisionTaskStartedEventAttributes decisionTaskStartedEventAttributes) { + this.decisionTaskStartedEventAttributes = decisionTaskStartedEventAttributes; + return this; + } + + + /** + * If the event is of type DecisionTaskCompleted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return If the event is of type DecisionTaskCompleted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public DecisionTaskCompletedEventAttributes getDecisionTaskCompletedEventAttributes() { + return decisionTaskCompletedEventAttributes; + } + + /** + * If the event is of type DecisionTaskCompleted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @param decisionTaskCompletedEventAttributes If the event is of type DecisionTaskCompleted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public void setDecisionTaskCompletedEventAttributes(DecisionTaskCompletedEventAttributes decisionTaskCompletedEventAttributes) { + this.decisionTaskCompletedEventAttributes = decisionTaskCompletedEventAttributes; + } + + /** + * If the event is of type DecisionTaskCompleted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventAttributes If the event is of type DecisionTaskCompleted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withDecisionTaskCompletedEventAttributes(DecisionTaskCompletedEventAttributes decisionTaskCompletedEventAttributes) { + this.decisionTaskCompletedEventAttributes = decisionTaskCompletedEventAttributes; + return this; + } + + + /** + * If the event is of type DecisionTaskTimedOut then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return If the event is of type DecisionTaskTimedOut then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public DecisionTaskTimedOutEventAttributes getDecisionTaskTimedOutEventAttributes() { + return decisionTaskTimedOutEventAttributes; + } + + /** + * If the event is of type DecisionTaskTimedOut then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @param decisionTaskTimedOutEventAttributes If the event is of type DecisionTaskTimedOut then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public void setDecisionTaskTimedOutEventAttributes(DecisionTaskTimedOutEventAttributes decisionTaskTimedOutEventAttributes) { + this.decisionTaskTimedOutEventAttributes = decisionTaskTimedOutEventAttributes; + } + + /** + * If the event is of type DecisionTaskTimedOut then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskTimedOutEventAttributes If the event is of type DecisionTaskTimedOut then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withDecisionTaskTimedOutEventAttributes(DecisionTaskTimedOutEventAttributes decisionTaskTimedOutEventAttributes) { + this.decisionTaskTimedOutEventAttributes = decisionTaskTimedOutEventAttributes; + return this; + } + + + /** + * If the event is of type ActivityTaskScheduled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return If the event is of type ActivityTaskScheduled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public ActivityTaskScheduledEventAttributes getActivityTaskScheduledEventAttributes() { + return activityTaskScheduledEventAttributes; + } + + /** + * If the event is of type ActivityTaskScheduled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @param activityTaskScheduledEventAttributes If the event is of type ActivityTaskScheduled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public void setActivityTaskScheduledEventAttributes(ActivityTaskScheduledEventAttributes activityTaskScheduledEventAttributes) { + this.activityTaskScheduledEventAttributes = activityTaskScheduledEventAttributes; + } + + /** + * If the event is of type ActivityTaskScheduled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param activityTaskScheduledEventAttributes If the event is of type ActivityTaskScheduled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withActivityTaskScheduledEventAttributes(ActivityTaskScheduledEventAttributes activityTaskScheduledEventAttributes) { + this.activityTaskScheduledEventAttributes = activityTaskScheduledEventAttributes; + return this; + } + + + /** + * If the event is of type ActivityTaskStarted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return If the event is of type ActivityTaskStarted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public ActivityTaskStartedEventAttributes getActivityTaskStartedEventAttributes() { + return activityTaskStartedEventAttributes; + } + + /** + * If the event is of type ActivityTaskStarted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @param activityTaskStartedEventAttributes If the event is of type ActivityTaskStarted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public void setActivityTaskStartedEventAttributes(ActivityTaskStartedEventAttributes activityTaskStartedEventAttributes) { + this.activityTaskStartedEventAttributes = activityTaskStartedEventAttributes; + } + + /** + * If the event is of type ActivityTaskStarted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param activityTaskStartedEventAttributes If the event is of type ActivityTaskStarted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withActivityTaskStartedEventAttributes(ActivityTaskStartedEventAttributes activityTaskStartedEventAttributes) { + this.activityTaskStartedEventAttributes = activityTaskStartedEventAttributes; + return this; + } + + + /** + * If the event is of type ActivityTaskCompleted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return If the event is of type ActivityTaskCompleted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public ActivityTaskCompletedEventAttributes getActivityTaskCompletedEventAttributes() { + return activityTaskCompletedEventAttributes; + } + + /** + * If the event is of type ActivityTaskCompleted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @param activityTaskCompletedEventAttributes If the event is of type ActivityTaskCompleted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public void setActivityTaskCompletedEventAttributes(ActivityTaskCompletedEventAttributes activityTaskCompletedEventAttributes) { + this.activityTaskCompletedEventAttributes = activityTaskCompletedEventAttributes; + } + + /** + * If the event is of type ActivityTaskCompleted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param activityTaskCompletedEventAttributes If the event is of type ActivityTaskCompleted then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withActivityTaskCompletedEventAttributes(ActivityTaskCompletedEventAttributes activityTaskCompletedEventAttributes) { + this.activityTaskCompletedEventAttributes = activityTaskCompletedEventAttributes; + return this; + } + + + /** + * If the event is of type ActivityTaskFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return If the event is of type ActivityTaskFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public ActivityTaskFailedEventAttributes getActivityTaskFailedEventAttributes() { + return activityTaskFailedEventAttributes; + } + + /** + * If the event is of type ActivityTaskFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @param activityTaskFailedEventAttributes If the event is of type ActivityTaskFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public void setActivityTaskFailedEventAttributes(ActivityTaskFailedEventAttributes activityTaskFailedEventAttributes) { + this.activityTaskFailedEventAttributes = activityTaskFailedEventAttributes; + } + + /** + * If the event is of type ActivityTaskFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param activityTaskFailedEventAttributes If the event is of type ActivityTaskFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withActivityTaskFailedEventAttributes(ActivityTaskFailedEventAttributes activityTaskFailedEventAttributes) { + this.activityTaskFailedEventAttributes = activityTaskFailedEventAttributes; + return this; + } + + + /** + * If the event is of type ActivityTaskTimedOut then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return If the event is of type ActivityTaskTimedOut then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public ActivityTaskTimedOutEventAttributes getActivityTaskTimedOutEventAttributes() { + return activityTaskTimedOutEventAttributes; + } + + /** + * If the event is of type ActivityTaskTimedOut then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @param activityTaskTimedOutEventAttributes If the event is of type ActivityTaskTimedOut then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public void setActivityTaskTimedOutEventAttributes(ActivityTaskTimedOutEventAttributes activityTaskTimedOutEventAttributes) { + this.activityTaskTimedOutEventAttributes = activityTaskTimedOutEventAttributes; + } + + /** + * If the event is of type ActivityTaskTimedOut then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param activityTaskTimedOutEventAttributes If the event is of type ActivityTaskTimedOut then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withActivityTaskTimedOutEventAttributes(ActivityTaskTimedOutEventAttributes activityTaskTimedOutEventAttributes) { + this.activityTaskTimedOutEventAttributes = activityTaskTimedOutEventAttributes; + return this; + } + + + /** + * If the event is of type ActivityTaskCanceled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return If the event is of type ActivityTaskCanceled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public ActivityTaskCanceledEventAttributes getActivityTaskCanceledEventAttributes() { + return activityTaskCanceledEventAttributes; + } + + /** + * If the event is of type ActivityTaskCanceled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @param activityTaskCanceledEventAttributes If the event is of type ActivityTaskCanceled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public void setActivityTaskCanceledEventAttributes(ActivityTaskCanceledEventAttributes activityTaskCanceledEventAttributes) { + this.activityTaskCanceledEventAttributes = activityTaskCanceledEventAttributes; + } + + /** + * If the event is of type ActivityTaskCanceled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param activityTaskCanceledEventAttributes If the event is of type ActivityTaskCanceled then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withActivityTaskCanceledEventAttributes(ActivityTaskCanceledEventAttributes activityTaskCanceledEventAttributes) { + this.activityTaskCanceledEventAttributes = activityTaskCanceledEventAttributes; + return this; + } + + + /** + * If the event is of type ActivityTaskcancelRequested then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @return If the event is of type ActivityTaskcancelRequested then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + public ActivityTaskCancelRequestedEventAttributes getActivityTaskCancelRequestedEventAttributes() { + return activityTaskCancelRequestedEventAttributes; + } + + /** + * If the event is of type ActivityTaskcancelRequested then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @param activityTaskCancelRequestedEventAttributes If the event is of type ActivityTaskcancelRequested then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + public void setActivityTaskCancelRequestedEventAttributes(ActivityTaskCancelRequestedEventAttributes activityTaskCancelRequestedEventAttributes) { + this.activityTaskCancelRequestedEventAttributes = activityTaskCancelRequestedEventAttributes; + } + + /** + * If the event is of type ActivityTaskcancelRequested then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param activityTaskCancelRequestedEventAttributes If the event is of type ActivityTaskcancelRequested then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withActivityTaskCancelRequestedEventAttributes(ActivityTaskCancelRequestedEventAttributes activityTaskCancelRequestedEventAttributes) { + this.activityTaskCancelRequestedEventAttributes = activityTaskCancelRequestedEventAttributes; + return this; + } + + + /** + * If the event is of type WorkflowExecutionSignaled then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @return If the event is of type WorkflowExecutionSignaled then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + public WorkflowExecutionSignaledEventAttributes getWorkflowExecutionSignaledEventAttributes() { + return workflowExecutionSignaledEventAttributes; + } + + /** + * If the event is of type WorkflowExecutionSignaled then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @param workflowExecutionSignaledEventAttributes If the event is of type WorkflowExecutionSignaled then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + public void setWorkflowExecutionSignaledEventAttributes(WorkflowExecutionSignaledEventAttributes workflowExecutionSignaledEventAttributes) { + this.workflowExecutionSignaledEventAttributes = workflowExecutionSignaledEventAttributes; + } + + /** + * If the event is of type WorkflowExecutionSignaled then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowExecutionSignaledEventAttributes If the event is of type WorkflowExecutionSignaled then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withWorkflowExecutionSignaledEventAttributes(WorkflowExecutionSignaledEventAttributes workflowExecutionSignaledEventAttributes) { + this.workflowExecutionSignaledEventAttributes = workflowExecutionSignaledEventAttributes; + return this; + } + + + /** + * If the event is of type MarkerRecorded then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + * + * @return If the event is of type MarkerRecorded then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + */ + public MarkerRecordedEventAttributes getMarkerRecordedEventAttributes() { + return markerRecordedEventAttributes; + } + + /** + * If the event is of type MarkerRecorded then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + * + * @param markerRecordedEventAttributes If the event is of type MarkerRecorded then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + */ + public void setMarkerRecordedEventAttributes(MarkerRecordedEventAttributes markerRecordedEventAttributes) { + this.markerRecordedEventAttributes = markerRecordedEventAttributes; + } + + /** + * If the event is of type MarkerRecorded then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param markerRecordedEventAttributes If the event is of type MarkerRecorded then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withMarkerRecordedEventAttributes(MarkerRecordedEventAttributes markerRecordedEventAttributes) { + this.markerRecordedEventAttributes = markerRecordedEventAttributes; + return this; + } + + + /** + * If the event is of type TimerStarted then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + * + * @return If the event is of type TimerStarted then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + */ + public TimerStartedEventAttributes getTimerStartedEventAttributes() { + return timerStartedEventAttributes; + } + + /** + * If the event is of type TimerStarted then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + * + * @param timerStartedEventAttributes If the event is of type TimerStarted then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + */ + public void setTimerStartedEventAttributes(TimerStartedEventAttributes timerStartedEventAttributes) { + this.timerStartedEventAttributes = timerStartedEventAttributes; + } + + /** + * If the event is of type TimerStarted then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param timerStartedEventAttributes If the event is of type TimerStarted then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withTimerStartedEventAttributes(TimerStartedEventAttributes timerStartedEventAttributes) { + this.timerStartedEventAttributes = timerStartedEventAttributes; + return this; + } + + + /** + * If the event is of type TimerFired then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + * + * @return If the event is of type TimerFired then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + */ + public TimerFiredEventAttributes getTimerFiredEventAttributes() { + return timerFiredEventAttributes; + } + + /** + * If the event is of type TimerFired then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + * + * @param timerFiredEventAttributes If the event is of type TimerFired then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + */ + public void setTimerFiredEventAttributes(TimerFiredEventAttributes timerFiredEventAttributes) { + this.timerFiredEventAttributes = timerFiredEventAttributes; + } + + /** + * If the event is of type TimerFired then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param timerFiredEventAttributes If the event is of type TimerFired then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withTimerFiredEventAttributes(TimerFiredEventAttributes timerFiredEventAttributes) { + this.timerFiredEventAttributes = timerFiredEventAttributes; + return this; + } + + + /** + * If the event is of type TimerCanceled then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + * + * @return If the event is of type TimerCanceled then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + */ + public TimerCanceledEventAttributes getTimerCanceledEventAttributes() { + return timerCanceledEventAttributes; + } + + /** + * If the event is of type TimerCanceled then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + * + * @param timerCanceledEventAttributes If the event is of type TimerCanceled then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + */ + public void setTimerCanceledEventAttributes(TimerCanceledEventAttributes timerCanceledEventAttributes) { + this.timerCanceledEventAttributes = timerCanceledEventAttributes; + } + + /** + * If the event is of type TimerCanceled then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param timerCanceledEventAttributes If the event is of type TimerCanceled then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withTimerCanceledEventAttributes(TimerCanceledEventAttributes timerCanceledEventAttributes) { + this.timerCanceledEventAttributes = timerCanceledEventAttributes; + return this; + } + + + /** + * If the event is of type + * StartChildWorkflowExecutionInitiated then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + * + * @return If the event is of type + * StartChildWorkflowExecutionInitiated then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + */ + public StartChildWorkflowExecutionInitiatedEventAttributes getStartChildWorkflowExecutionInitiatedEventAttributes() { + return startChildWorkflowExecutionInitiatedEventAttributes; + } + + /** + * If the event is of type + * StartChildWorkflowExecutionInitiated then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + * + * @param startChildWorkflowExecutionInitiatedEventAttributes If the event is of type + * StartChildWorkflowExecutionInitiated then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + */ + public void setStartChildWorkflowExecutionInitiatedEventAttributes(StartChildWorkflowExecutionInitiatedEventAttributes startChildWorkflowExecutionInitiatedEventAttributes) { + this.startChildWorkflowExecutionInitiatedEventAttributes = startChildWorkflowExecutionInitiatedEventAttributes; + } + + /** + * If the event is of type + * StartChildWorkflowExecutionInitiated then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startChildWorkflowExecutionInitiatedEventAttributes If the event is of type + * StartChildWorkflowExecutionInitiated then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withStartChildWorkflowExecutionInitiatedEventAttributes(StartChildWorkflowExecutionInitiatedEventAttributes startChildWorkflowExecutionInitiatedEventAttributes) { + this.startChildWorkflowExecutionInitiatedEventAttributes = startChildWorkflowExecutionInitiatedEventAttributes; + return this; + } + + + /** + * If the event is of type ChildWorkflowExecutionStarted + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return If the event is of type ChildWorkflowExecutionStarted + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public ChildWorkflowExecutionStartedEventAttributes getChildWorkflowExecutionStartedEventAttributes() { + return childWorkflowExecutionStartedEventAttributes; + } + + /** + * If the event is of type ChildWorkflowExecutionStarted + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @param childWorkflowExecutionStartedEventAttributes If the event is of type ChildWorkflowExecutionStarted + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public void setChildWorkflowExecutionStartedEventAttributes(ChildWorkflowExecutionStartedEventAttributes childWorkflowExecutionStartedEventAttributes) { + this.childWorkflowExecutionStartedEventAttributes = childWorkflowExecutionStartedEventAttributes; + } + + /** + * If the event is of type ChildWorkflowExecutionStarted + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param childWorkflowExecutionStartedEventAttributes If the event is of type ChildWorkflowExecutionStarted + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withChildWorkflowExecutionStartedEventAttributes(ChildWorkflowExecutionStartedEventAttributes childWorkflowExecutionStartedEventAttributes) { + this.childWorkflowExecutionStartedEventAttributes = childWorkflowExecutionStartedEventAttributes; + return this; + } + + + /** + * If the event is of type ChildWorkflowExecutionCompleted + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return If the event is of type ChildWorkflowExecutionCompleted + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public ChildWorkflowExecutionCompletedEventAttributes getChildWorkflowExecutionCompletedEventAttributes() { + return childWorkflowExecutionCompletedEventAttributes; + } + + /** + * If the event is of type ChildWorkflowExecutionCompleted + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @param childWorkflowExecutionCompletedEventAttributes If the event is of type ChildWorkflowExecutionCompleted + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public void setChildWorkflowExecutionCompletedEventAttributes(ChildWorkflowExecutionCompletedEventAttributes childWorkflowExecutionCompletedEventAttributes) { + this.childWorkflowExecutionCompletedEventAttributes = childWorkflowExecutionCompletedEventAttributes; + } + + /** + * If the event is of type ChildWorkflowExecutionCompleted + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param childWorkflowExecutionCompletedEventAttributes If the event is of type ChildWorkflowExecutionCompleted + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withChildWorkflowExecutionCompletedEventAttributes(ChildWorkflowExecutionCompletedEventAttributes childWorkflowExecutionCompletedEventAttributes) { + this.childWorkflowExecutionCompletedEventAttributes = childWorkflowExecutionCompletedEventAttributes; + return this; + } + + + /** + * If the event is of type ChildWorkflowExecutionFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @return If the event is of type ChildWorkflowExecutionFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + public ChildWorkflowExecutionFailedEventAttributes getChildWorkflowExecutionFailedEventAttributes() { + return childWorkflowExecutionFailedEventAttributes; + } + + /** + * If the event is of type ChildWorkflowExecutionFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @param childWorkflowExecutionFailedEventAttributes If the event is of type ChildWorkflowExecutionFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + public void setChildWorkflowExecutionFailedEventAttributes(ChildWorkflowExecutionFailedEventAttributes childWorkflowExecutionFailedEventAttributes) { + this.childWorkflowExecutionFailedEventAttributes = childWorkflowExecutionFailedEventAttributes; + } + + /** + * If the event is of type ChildWorkflowExecutionFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param childWorkflowExecutionFailedEventAttributes If the event is of type ChildWorkflowExecutionFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withChildWorkflowExecutionFailedEventAttributes(ChildWorkflowExecutionFailedEventAttributes childWorkflowExecutionFailedEventAttributes) { + this.childWorkflowExecutionFailedEventAttributes = childWorkflowExecutionFailedEventAttributes; + return this; + } + + + /** + * If the event is of type ChildWorkflowExecutionTimedOut + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return If the event is of type ChildWorkflowExecutionTimedOut + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public ChildWorkflowExecutionTimedOutEventAttributes getChildWorkflowExecutionTimedOutEventAttributes() { + return childWorkflowExecutionTimedOutEventAttributes; + } + + /** + * If the event is of type ChildWorkflowExecutionTimedOut + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @param childWorkflowExecutionTimedOutEventAttributes If the event is of type ChildWorkflowExecutionTimedOut + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public void setChildWorkflowExecutionTimedOutEventAttributes(ChildWorkflowExecutionTimedOutEventAttributes childWorkflowExecutionTimedOutEventAttributes) { + this.childWorkflowExecutionTimedOutEventAttributes = childWorkflowExecutionTimedOutEventAttributes; + } + + /** + * If the event is of type ChildWorkflowExecutionTimedOut + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param childWorkflowExecutionTimedOutEventAttributes If the event is of type ChildWorkflowExecutionTimedOut + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withChildWorkflowExecutionTimedOutEventAttributes(ChildWorkflowExecutionTimedOutEventAttributes childWorkflowExecutionTimedOutEventAttributes) { + this.childWorkflowExecutionTimedOutEventAttributes = childWorkflowExecutionTimedOutEventAttributes; + return this; + } + + + /** + * If the event is of type ChildWorkflowExecutionCanceled + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return If the event is of type ChildWorkflowExecutionCanceled + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public ChildWorkflowExecutionCanceledEventAttributes getChildWorkflowExecutionCanceledEventAttributes() { + return childWorkflowExecutionCanceledEventAttributes; + } + + /** + * If the event is of type ChildWorkflowExecutionCanceled + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @param childWorkflowExecutionCanceledEventAttributes If the event is of type ChildWorkflowExecutionCanceled + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public void setChildWorkflowExecutionCanceledEventAttributes(ChildWorkflowExecutionCanceledEventAttributes childWorkflowExecutionCanceledEventAttributes) { + this.childWorkflowExecutionCanceledEventAttributes = childWorkflowExecutionCanceledEventAttributes; + } + + /** + * If the event is of type ChildWorkflowExecutionCanceled + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param childWorkflowExecutionCanceledEventAttributes If the event is of type ChildWorkflowExecutionCanceled + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withChildWorkflowExecutionCanceledEventAttributes(ChildWorkflowExecutionCanceledEventAttributes childWorkflowExecutionCanceledEventAttributes) { + this.childWorkflowExecutionCanceledEventAttributes = childWorkflowExecutionCanceledEventAttributes; + return this; + } + + + /** + * If the event is of type ChildWorkflowExecutionTerminated + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return If the event is of type ChildWorkflowExecutionTerminated + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public ChildWorkflowExecutionTerminatedEventAttributes getChildWorkflowExecutionTerminatedEventAttributes() { + return childWorkflowExecutionTerminatedEventAttributes; + } + + /** + * If the event is of type ChildWorkflowExecutionTerminated + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @param childWorkflowExecutionTerminatedEventAttributes If the event is of type ChildWorkflowExecutionTerminated + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public void setChildWorkflowExecutionTerminatedEventAttributes(ChildWorkflowExecutionTerminatedEventAttributes childWorkflowExecutionTerminatedEventAttributes) { + this.childWorkflowExecutionTerminatedEventAttributes = childWorkflowExecutionTerminatedEventAttributes; + } + + /** + * If the event is of type ChildWorkflowExecutionTerminated + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param childWorkflowExecutionTerminatedEventAttributes If the event is of type ChildWorkflowExecutionTerminated + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withChildWorkflowExecutionTerminatedEventAttributes(ChildWorkflowExecutionTerminatedEventAttributes childWorkflowExecutionTerminatedEventAttributes) { + this.childWorkflowExecutionTerminatedEventAttributes = childWorkflowExecutionTerminatedEventAttributes; + return this; + } + + + /** + * If the event is of type + * SignalExternalWorkflowExecutionInitiated then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + * + * @return If the event is of type + * SignalExternalWorkflowExecutionInitiated then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + */ + public SignalExternalWorkflowExecutionInitiatedEventAttributes getSignalExternalWorkflowExecutionInitiatedEventAttributes() { + return signalExternalWorkflowExecutionInitiatedEventAttributes; + } + + /** + * If the event is of type + * SignalExternalWorkflowExecutionInitiated then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + * + * @param signalExternalWorkflowExecutionInitiatedEventAttributes If the event is of type + * SignalExternalWorkflowExecutionInitiated then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + */ + public void setSignalExternalWorkflowExecutionInitiatedEventAttributes(SignalExternalWorkflowExecutionInitiatedEventAttributes signalExternalWorkflowExecutionInitiatedEventAttributes) { + this.signalExternalWorkflowExecutionInitiatedEventAttributes = signalExternalWorkflowExecutionInitiatedEventAttributes; + } + + /** + * If the event is of type + * SignalExternalWorkflowExecutionInitiated then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param signalExternalWorkflowExecutionInitiatedEventAttributes If the event is of type + * SignalExternalWorkflowExecutionInitiated then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withSignalExternalWorkflowExecutionInitiatedEventAttributes(SignalExternalWorkflowExecutionInitiatedEventAttributes signalExternalWorkflowExecutionInitiatedEventAttributes) { + this.signalExternalWorkflowExecutionInitiatedEventAttributes = signalExternalWorkflowExecutionInitiatedEventAttributes; + return this; + } + + + /** + * If the event is of type ExternalWorkflowExecutionSignaled + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return If the event is of type ExternalWorkflowExecutionSignaled + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public ExternalWorkflowExecutionSignaledEventAttributes getExternalWorkflowExecutionSignaledEventAttributes() { + return externalWorkflowExecutionSignaledEventAttributes; + } + + /** + * If the event is of type ExternalWorkflowExecutionSignaled + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @param externalWorkflowExecutionSignaledEventAttributes If the event is of type ExternalWorkflowExecutionSignaled + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public void setExternalWorkflowExecutionSignaledEventAttributes(ExternalWorkflowExecutionSignaledEventAttributes externalWorkflowExecutionSignaledEventAttributes) { + this.externalWorkflowExecutionSignaledEventAttributes = externalWorkflowExecutionSignaledEventAttributes; + } + + /** + * If the event is of type ExternalWorkflowExecutionSignaled + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param externalWorkflowExecutionSignaledEventAttributes If the event is of type ExternalWorkflowExecutionSignaled + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withExternalWorkflowExecutionSignaledEventAttributes(ExternalWorkflowExecutionSignaledEventAttributes externalWorkflowExecutionSignaledEventAttributes) { + this.externalWorkflowExecutionSignaledEventAttributes = externalWorkflowExecutionSignaledEventAttributes; + return this; + } + + + /** + * If the event is of type + * SignalExternalWorkflowExecutionFailed then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + * + * @return If the event is of type + * SignalExternalWorkflowExecutionFailed then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + */ + public SignalExternalWorkflowExecutionFailedEventAttributes getSignalExternalWorkflowExecutionFailedEventAttributes() { + return signalExternalWorkflowExecutionFailedEventAttributes; + } + + /** + * If the event is of type + * SignalExternalWorkflowExecutionFailed then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + * + * @param signalExternalWorkflowExecutionFailedEventAttributes If the event is of type + * SignalExternalWorkflowExecutionFailed then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + */ + public void setSignalExternalWorkflowExecutionFailedEventAttributes(SignalExternalWorkflowExecutionFailedEventAttributes signalExternalWorkflowExecutionFailedEventAttributes) { + this.signalExternalWorkflowExecutionFailedEventAttributes = signalExternalWorkflowExecutionFailedEventAttributes; + } + + /** + * If the event is of type + * SignalExternalWorkflowExecutionFailed then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param signalExternalWorkflowExecutionFailedEventAttributes If the event is of type + * SignalExternalWorkflowExecutionFailed then this member is + * set and provides detailed information about the event. It is not set + * for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withSignalExternalWorkflowExecutionFailedEventAttributes(SignalExternalWorkflowExecutionFailedEventAttributes signalExternalWorkflowExecutionFailedEventAttributes) { + this.signalExternalWorkflowExecutionFailedEventAttributes = signalExternalWorkflowExecutionFailedEventAttributes; + return this; + } + + + /** + * If the event is of type + * ExternalWorkflowExecutionCancelRequested then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + * + * @return If the event is of type + * ExternalWorkflowExecutionCancelRequested then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + */ + public ExternalWorkflowExecutionCancelRequestedEventAttributes getExternalWorkflowExecutionCancelRequestedEventAttributes() { + return externalWorkflowExecutionCancelRequestedEventAttributes; + } + + /** + * If the event is of type + * ExternalWorkflowExecutionCancelRequested then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + * + * @param externalWorkflowExecutionCancelRequestedEventAttributes If the event is of type + * ExternalWorkflowExecutionCancelRequested then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + */ + public void setExternalWorkflowExecutionCancelRequestedEventAttributes(ExternalWorkflowExecutionCancelRequestedEventAttributes externalWorkflowExecutionCancelRequestedEventAttributes) { + this.externalWorkflowExecutionCancelRequestedEventAttributes = externalWorkflowExecutionCancelRequestedEventAttributes; + } + + /** + * If the event is of type + * ExternalWorkflowExecutionCancelRequested then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param externalWorkflowExecutionCancelRequestedEventAttributes If the event is of type + * ExternalWorkflowExecutionCancelRequested then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withExternalWorkflowExecutionCancelRequestedEventAttributes(ExternalWorkflowExecutionCancelRequestedEventAttributes externalWorkflowExecutionCancelRequestedEventAttributes) { + this.externalWorkflowExecutionCancelRequestedEventAttributes = externalWorkflowExecutionCancelRequestedEventAttributes; + return this; + } + + + /** + * If the event is of type + * RequestCancelExternalWorkflowExecutionInitiated then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return If the event is of type + * RequestCancelExternalWorkflowExecutionInitiated then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public RequestCancelExternalWorkflowExecutionInitiatedEventAttributes getRequestCancelExternalWorkflowExecutionInitiatedEventAttributes() { + return requestCancelExternalWorkflowExecutionInitiatedEventAttributes; + } + + /** + * If the event is of type + * RequestCancelExternalWorkflowExecutionInitiated then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @param requestCancelExternalWorkflowExecutionInitiatedEventAttributes If the event is of type + * RequestCancelExternalWorkflowExecutionInitiated then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public void setRequestCancelExternalWorkflowExecutionInitiatedEventAttributes(RequestCancelExternalWorkflowExecutionInitiatedEventAttributes requestCancelExternalWorkflowExecutionInitiatedEventAttributes) { + this.requestCancelExternalWorkflowExecutionInitiatedEventAttributes = requestCancelExternalWorkflowExecutionInitiatedEventAttributes; + } + + /** + * If the event is of type + * RequestCancelExternalWorkflowExecutionInitiated then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param requestCancelExternalWorkflowExecutionInitiatedEventAttributes If the event is of type + * RequestCancelExternalWorkflowExecutionInitiated then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withRequestCancelExternalWorkflowExecutionInitiatedEventAttributes(RequestCancelExternalWorkflowExecutionInitiatedEventAttributes requestCancelExternalWorkflowExecutionInitiatedEventAttributes) { + this.requestCancelExternalWorkflowExecutionInitiatedEventAttributes = requestCancelExternalWorkflowExecutionInitiatedEventAttributes; + return this; + } + + + /** + * If the event is of type + * RequestCancelExternalWorkflowExecutionFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return If the event is of type + * RequestCancelExternalWorkflowExecutionFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public RequestCancelExternalWorkflowExecutionFailedEventAttributes getRequestCancelExternalWorkflowExecutionFailedEventAttributes() { + return requestCancelExternalWorkflowExecutionFailedEventAttributes; + } + + /** + * If the event is of type + * RequestCancelExternalWorkflowExecutionFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @param requestCancelExternalWorkflowExecutionFailedEventAttributes If the event is of type + * RequestCancelExternalWorkflowExecutionFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public void setRequestCancelExternalWorkflowExecutionFailedEventAttributes(RequestCancelExternalWorkflowExecutionFailedEventAttributes requestCancelExternalWorkflowExecutionFailedEventAttributes) { + this.requestCancelExternalWorkflowExecutionFailedEventAttributes = requestCancelExternalWorkflowExecutionFailedEventAttributes; + } + + /** + * If the event is of type + * RequestCancelExternalWorkflowExecutionFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param requestCancelExternalWorkflowExecutionFailedEventAttributes If the event is of type + * RequestCancelExternalWorkflowExecutionFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withRequestCancelExternalWorkflowExecutionFailedEventAttributes(RequestCancelExternalWorkflowExecutionFailedEventAttributes requestCancelExternalWorkflowExecutionFailedEventAttributes) { + this.requestCancelExternalWorkflowExecutionFailedEventAttributes = requestCancelExternalWorkflowExecutionFailedEventAttributes; + return this; + } + + + /** + * If the event is of type ScheduleActivityTaskFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @return If the event is of type ScheduleActivityTaskFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + public ScheduleActivityTaskFailedEventAttributes getScheduleActivityTaskFailedEventAttributes() { + return scheduleActivityTaskFailedEventAttributes; + } + + /** + * If the event is of type ScheduleActivityTaskFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @param scheduleActivityTaskFailedEventAttributes If the event is of type ScheduleActivityTaskFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + */ + public void setScheduleActivityTaskFailedEventAttributes(ScheduleActivityTaskFailedEventAttributes scheduleActivityTaskFailedEventAttributes) { + this.scheduleActivityTaskFailedEventAttributes = scheduleActivityTaskFailedEventAttributes; + } + + /** + * If the event is of type ScheduleActivityTaskFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param scheduleActivityTaskFailedEventAttributes If the event is of type ScheduleActivityTaskFailed then + * this member is set and provides detailed information about the event. + * It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withScheduleActivityTaskFailedEventAttributes(ScheduleActivityTaskFailedEventAttributes scheduleActivityTaskFailedEventAttributes) { + this.scheduleActivityTaskFailedEventAttributes = scheduleActivityTaskFailedEventAttributes; + return this; + } + + + /** + * If the event is of type RequestCancelActivityTaskFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return If the event is of type RequestCancelActivityTaskFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public RequestCancelActivityTaskFailedEventAttributes getRequestCancelActivityTaskFailedEventAttributes() { + return requestCancelActivityTaskFailedEventAttributes; + } + + /** + * If the event is of type RequestCancelActivityTaskFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @param requestCancelActivityTaskFailedEventAttributes If the event is of type RequestCancelActivityTaskFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public void setRequestCancelActivityTaskFailedEventAttributes(RequestCancelActivityTaskFailedEventAttributes requestCancelActivityTaskFailedEventAttributes) { + this.requestCancelActivityTaskFailedEventAttributes = requestCancelActivityTaskFailedEventAttributes; + } + + /** + * If the event is of type RequestCancelActivityTaskFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param requestCancelActivityTaskFailedEventAttributes If the event is of type RequestCancelActivityTaskFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withRequestCancelActivityTaskFailedEventAttributes(RequestCancelActivityTaskFailedEventAttributes requestCancelActivityTaskFailedEventAttributes) { + this.requestCancelActivityTaskFailedEventAttributes = requestCancelActivityTaskFailedEventAttributes; + return this; + } + + + /** + * If the event is of type StartTimerFailed then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + * + * @return If the event is of type StartTimerFailed then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + */ + public StartTimerFailedEventAttributes getStartTimerFailedEventAttributes() { + return startTimerFailedEventAttributes; + } + + /** + * If the event is of type StartTimerFailed then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + * + * @param startTimerFailedEventAttributes If the event is of type StartTimerFailed then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + */ + public void setStartTimerFailedEventAttributes(StartTimerFailedEventAttributes startTimerFailedEventAttributes) { + this.startTimerFailedEventAttributes = startTimerFailedEventAttributes; + } + + /** + * If the event is of type StartTimerFailed then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startTimerFailedEventAttributes If the event is of type StartTimerFailed then this member + * is set and provides detailed information about the event. It is not + * set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withStartTimerFailedEventAttributes(StartTimerFailedEventAttributes startTimerFailedEventAttributes) { + this.startTimerFailedEventAttributes = startTimerFailedEventAttributes; + return this; + } + + + /** + * If the event is of type CancelTimerFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return If the event is of type CancelTimerFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public CancelTimerFailedEventAttributes getCancelTimerFailedEventAttributes() { + return cancelTimerFailedEventAttributes; + } + + /** + * If the event is of type CancelTimerFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @param cancelTimerFailedEventAttributes If the event is of type CancelTimerFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + */ + public void setCancelTimerFailedEventAttributes(CancelTimerFailedEventAttributes cancelTimerFailedEventAttributes) { + this.cancelTimerFailedEventAttributes = cancelTimerFailedEventAttributes; + } + + /** + * If the event is of type CancelTimerFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param cancelTimerFailedEventAttributes If the event is of type CancelTimerFailed then this + * member is set and provides detailed information about the event. It is + * not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withCancelTimerFailedEventAttributes(CancelTimerFailedEventAttributes cancelTimerFailedEventAttributes) { + this.cancelTimerFailedEventAttributes = cancelTimerFailedEventAttributes; + return this; + } + + + /** + * If the event is of type StartChildWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return If the event is of type StartChildWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public StartChildWorkflowExecutionFailedEventAttributes getStartChildWorkflowExecutionFailedEventAttributes() { + return startChildWorkflowExecutionFailedEventAttributes; + } + + /** + * If the event is of type StartChildWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @param startChildWorkflowExecutionFailedEventAttributes If the event is of type StartChildWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + */ + public void setStartChildWorkflowExecutionFailedEventAttributes(StartChildWorkflowExecutionFailedEventAttributes startChildWorkflowExecutionFailedEventAttributes) { + this.startChildWorkflowExecutionFailedEventAttributes = startChildWorkflowExecutionFailedEventAttributes; + } + + /** + * If the event is of type StartChildWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startChildWorkflowExecutionFailedEventAttributes If the event is of type StartChildWorkflowExecutionFailed + * then this member is set and provides detailed information about the + * event. It is not set for other event types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public HistoryEvent withStartChildWorkflowExecutionFailedEventAttributes(StartChildWorkflowExecutionFailedEventAttributes startChildWorkflowExecutionFailedEventAttributes) { + this.startChildWorkflowExecutionFailedEventAttributes = startChildWorkflowExecutionFailedEventAttributes; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (eventTimestamp != null) sb.append("EventTimestamp: " + eventTimestamp + ", "); + if (eventType != null) sb.append("EventType: " + eventType + ", "); + if (eventId != null) sb.append("EventId: " + eventId + ", "); + if (workflowExecutionStartedEventAttributes != null) sb.append("WorkflowExecutionStartedEventAttributes: " + workflowExecutionStartedEventAttributes + ", "); + if (workflowExecutionCompletedEventAttributes != null) sb.append("WorkflowExecutionCompletedEventAttributes: " + workflowExecutionCompletedEventAttributes + ", "); + if (completeWorkflowExecutionFailedEventAttributes != null) sb.append("CompleteWorkflowExecutionFailedEventAttributes: " + completeWorkflowExecutionFailedEventAttributes + ", "); + if (workflowExecutionFailedEventAttributes != null) sb.append("WorkflowExecutionFailedEventAttributes: " + workflowExecutionFailedEventAttributes + ", "); + if (failWorkflowExecutionFailedEventAttributes != null) sb.append("FailWorkflowExecutionFailedEventAttributes: " + failWorkflowExecutionFailedEventAttributes + ", "); + if (workflowExecutionTimedOutEventAttributes != null) sb.append("WorkflowExecutionTimedOutEventAttributes: " + workflowExecutionTimedOutEventAttributes + ", "); + if (workflowExecutionCanceledEventAttributes != null) sb.append("WorkflowExecutionCanceledEventAttributes: " + workflowExecutionCanceledEventAttributes + ", "); + if (cancelWorkflowExecutionFailedEventAttributes != null) sb.append("CancelWorkflowExecutionFailedEventAttributes: " + cancelWorkflowExecutionFailedEventAttributes + ", "); + if (workflowExecutionContinuedAsNewEventAttributes != null) sb.append("WorkflowExecutionContinuedAsNewEventAttributes: " + workflowExecutionContinuedAsNewEventAttributes + ", "); + if (continueAsNewWorkflowExecutionFailedEventAttributes != null) sb.append("ContinueAsNewWorkflowExecutionFailedEventAttributes: " + continueAsNewWorkflowExecutionFailedEventAttributes + ", "); + if (workflowExecutionTerminatedEventAttributes != null) sb.append("WorkflowExecutionTerminatedEventAttributes: " + workflowExecutionTerminatedEventAttributes + ", "); + if (workflowExecutionCancelRequestedEventAttributes != null) sb.append("WorkflowExecutionCancelRequestedEventAttributes: " + workflowExecutionCancelRequestedEventAttributes + ", "); + if (decisionTaskScheduledEventAttributes != null) sb.append("DecisionTaskScheduledEventAttributes: " + decisionTaskScheduledEventAttributes + ", "); + if (decisionTaskStartedEventAttributes != null) sb.append("DecisionTaskStartedEventAttributes: " + decisionTaskStartedEventAttributes + ", "); + if (decisionTaskCompletedEventAttributes != null) sb.append("DecisionTaskCompletedEventAttributes: " + decisionTaskCompletedEventAttributes + ", "); + if (decisionTaskTimedOutEventAttributes != null) sb.append("DecisionTaskTimedOutEventAttributes: " + decisionTaskTimedOutEventAttributes + ", "); + if (activityTaskScheduledEventAttributes != null) sb.append("ActivityTaskScheduledEventAttributes: " + activityTaskScheduledEventAttributes + ", "); + if (activityTaskStartedEventAttributes != null) sb.append("ActivityTaskStartedEventAttributes: " + activityTaskStartedEventAttributes + ", "); + if (activityTaskCompletedEventAttributes != null) sb.append("ActivityTaskCompletedEventAttributes: " + activityTaskCompletedEventAttributes + ", "); + if (activityTaskFailedEventAttributes != null) sb.append("ActivityTaskFailedEventAttributes: " + activityTaskFailedEventAttributes + ", "); + if (activityTaskTimedOutEventAttributes != null) sb.append("ActivityTaskTimedOutEventAttributes: " + activityTaskTimedOutEventAttributes + ", "); + if (activityTaskCanceledEventAttributes != null) sb.append("ActivityTaskCanceledEventAttributes: " + activityTaskCanceledEventAttributes + ", "); + if (activityTaskCancelRequestedEventAttributes != null) sb.append("ActivityTaskCancelRequestedEventAttributes: " + activityTaskCancelRequestedEventAttributes + ", "); + if (workflowExecutionSignaledEventAttributes != null) sb.append("WorkflowExecutionSignaledEventAttributes: " + workflowExecutionSignaledEventAttributes + ", "); + if (markerRecordedEventAttributes != null) sb.append("MarkerRecordedEventAttributes: " + markerRecordedEventAttributes + ", "); + if (timerStartedEventAttributes != null) sb.append("TimerStartedEventAttributes: " + timerStartedEventAttributes + ", "); + if (timerFiredEventAttributes != null) sb.append("TimerFiredEventAttributes: " + timerFiredEventAttributes + ", "); + if (timerCanceledEventAttributes != null) sb.append("TimerCanceledEventAttributes: " + timerCanceledEventAttributes + ", "); + if (startChildWorkflowExecutionInitiatedEventAttributes != null) sb.append("StartChildWorkflowExecutionInitiatedEventAttributes: " + startChildWorkflowExecutionInitiatedEventAttributes + ", "); + if (childWorkflowExecutionStartedEventAttributes != null) sb.append("ChildWorkflowExecutionStartedEventAttributes: " + childWorkflowExecutionStartedEventAttributes + ", "); + if (childWorkflowExecutionCompletedEventAttributes != null) sb.append("ChildWorkflowExecutionCompletedEventAttributes: " + childWorkflowExecutionCompletedEventAttributes + ", "); + if (childWorkflowExecutionFailedEventAttributes != null) sb.append("ChildWorkflowExecutionFailedEventAttributes: " + childWorkflowExecutionFailedEventAttributes + ", "); + if (childWorkflowExecutionTimedOutEventAttributes != null) sb.append("ChildWorkflowExecutionTimedOutEventAttributes: " + childWorkflowExecutionTimedOutEventAttributes + ", "); + if (childWorkflowExecutionCanceledEventAttributes != null) sb.append("ChildWorkflowExecutionCanceledEventAttributes: " + childWorkflowExecutionCanceledEventAttributes + ", "); + if (childWorkflowExecutionTerminatedEventAttributes != null) sb.append("ChildWorkflowExecutionTerminatedEventAttributes: " + childWorkflowExecutionTerminatedEventAttributes + ", "); + if (signalExternalWorkflowExecutionInitiatedEventAttributes != null) sb.append("SignalExternalWorkflowExecutionInitiatedEventAttributes: " + signalExternalWorkflowExecutionInitiatedEventAttributes + ", "); + if (externalWorkflowExecutionSignaledEventAttributes != null) sb.append("ExternalWorkflowExecutionSignaledEventAttributes: " + externalWorkflowExecutionSignaledEventAttributes + ", "); + if (signalExternalWorkflowExecutionFailedEventAttributes != null) sb.append("SignalExternalWorkflowExecutionFailedEventAttributes: " + signalExternalWorkflowExecutionFailedEventAttributes + ", "); + if (externalWorkflowExecutionCancelRequestedEventAttributes != null) sb.append("ExternalWorkflowExecutionCancelRequestedEventAttributes: " + externalWorkflowExecutionCancelRequestedEventAttributes + ", "); + if (requestCancelExternalWorkflowExecutionInitiatedEventAttributes != null) sb.append("RequestCancelExternalWorkflowExecutionInitiatedEventAttributes: " + requestCancelExternalWorkflowExecutionInitiatedEventAttributes + ", "); + if (requestCancelExternalWorkflowExecutionFailedEventAttributes != null) sb.append("RequestCancelExternalWorkflowExecutionFailedEventAttributes: " + requestCancelExternalWorkflowExecutionFailedEventAttributes + ", "); + if (scheduleActivityTaskFailedEventAttributes != null) sb.append("ScheduleActivityTaskFailedEventAttributes: " + scheduleActivityTaskFailedEventAttributes + ", "); + if (requestCancelActivityTaskFailedEventAttributes != null) sb.append("RequestCancelActivityTaskFailedEventAttributes: " + requestCancelActivityTaskFailedEventAttributes + ", "); + if (startTimerFailedEventAttributes != null) sb.append("StartTimerFailedEventAttributes: " + startTimerFailedEventAttributes + ", "); + if (cancelTimerFailedEventAttributes != null) sb.append("CancelTimerFailedEventAttributes: " + cancelTimerFailedEventAttributes + ", "); + if (startChildWorkflowExecutionFailedEventAttributes != null) sb.append("StartChildWorkflowExecutionFailedEventAttributes: " + startChildWorkflowExecutionFailedEventAttributes + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getEventTimestamp() == null) ? 0 : getEventTimestamp().hashCode()); + hashCode = prime * hashCode + ((getEventType() == null) ? 0 : getEventType().hashCode()); + hashCode = prime * hashCode + ((getEventId() == null) ? 0 : getEventId().hashCode()); + hashCode = prime * hashCode + ((getWorkflowExecutionStartedEventAttributes() == null) ? 0 : getWorkflowExecutionStartedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getWorkflowExecutionCompletedEventAttributes() == null) ? 0 : getWorkflowExecutionCompletedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getCompleteWorkflowExecutionFailedEventAttributes() == null) ? 0 : getCompleteWorkflowExecutionFailedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getWorkflowExecutionFailedEventAttributes() == null) ? 0 : getWorkflowExecutionFailedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getFailWorkflowExecutionFailedEventAttributes() == null) ? 0 : getFailWorkflowExecutionFailedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getWorkflowExecutionTimedOutEventAttributes() == null) ? 0 : getWorkflowExecutionTimedOutEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getWorkflowExecutionCanceledEventAttributes() == null) ? 0 : getWorkflowExecutionCanceledEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getCancelWorkflowExecutionFailedEventAttributes() == null) ? 0 : getCancelWorkflowExecutionFailedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getWorkflowExecutionContinuedAsNewEventAttributes() == null) ? 0 : getWorkflowExecutionContinuedAsNewEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getContinueAsNewWorkflowExecutionFailedEventAttributes() == null) ? 0 : getContinueAsNewWorkflowExecutionFailedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getWorkflowExecutionTerminatedEventAttributes() == null) ? 0 : getWorkflowExecutionTerminatedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getWorkflowExecutionCancelRequestedEventAttributes() == null) ? 0 : getWorkflowExecutionCancelRequestedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskScheduledEventAttributes() == null) ? 0 : getDecisionTaskScheduledEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskStartedEventAttributes() == null) ? 0 : getDecisionTaskStartedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventAttributes() == null) ? 0 : getDecisionTaskCompletedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskTimedOutEventAttributes() == null) ? 0 : getDecisionTaskTimedOutEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getActivityTaskScheduledEventAttributes() == null) ? 0 : getActivityTaskScheduledEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getActivityTaskStartedEventAttributes() == null) ? 0 : getActivityTaskStartedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getActivityTaskCompletedEventAttributes() == null) ? 0 : getActivityTaskCompletedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getActivityTaskFailedEventAttributes() == null) ? 0 : getActivityTaskFailedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getActivityTaskTimedOutEventAttributes() == null) ? 0 : getActivityTaskTimedOutEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getActivityTaskCanceledEventAttributes() == null) ? 0 : getActivityTaskCanceledEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getActivityTaskCancelRequestedEventAttributes() == null) ? 0 : getActivityTaskCancelRequestedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getWorkflowExecutionSignaledEventAttributes() == null) ? 0 : getWorkflowExecutionSignaledEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getMarkerRecordedEventAttributes() == null) ? 0 : getMarkerRecordedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getTimerStartedEventAttributes() == null) ? 0 : getTimerStartedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getTimerFiredEventAttributes() == null) ? 0 : getTimerFiredEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getTimerCanceledEventAttributes() == null) ? 0 : getTimerCanceledEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getStartChildWorkflowExecutionInitiatedEventAttributes() == null) ? 0 : getStartChildWorkflowExecutionInitiatedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getChildWorkflowExecutionStartedEventAttributes() == null) ? 0 : getChildWorkflowExecutionStartedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getChildWorkflowExecutionCompletedEventAttributes() == null) ? 0 : getChildWorkflowExecutionCompletedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getChildWorkflowExecutionFailedEventAttributes() == null) ? 0 : getChildWorkflowExecutionFailedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getChildWorkflowExecutionTimedOutEventAttributes() == null) ? 0 : getChildWorkflowExecutionTimedOutEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getChildWorkflowExecutionCanceledEventAttributes() == null) ? 0 : getChildWorkflowExecutionCanceledEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getChildWorkflowExecutionTerminatedEventAttributes() == null) ? 0 : getChildWorkflowExecutionTerminatedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getSignalExternalWorkflowExecutionInitiatedEventAttributes() == null) ? 0 : getSignalExternalWorkflowExecutionInitiatedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getExternalWorkflowExecutionSignaledEventAttributes() == null) ? 0 : getExternalWorkflowExecutionSignaledEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getSignalExternalWorkflowExecutionFailedEventAttributes() == null) ? 0 : getSignalExternalWorkflowExecutionFailedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getExternalWorkflowExecutionCancelRequestedEventAttributes() == null) ? 0 : getExternalWorkflowExecutionCancelRequestedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getRequestCancelExternalWorkflowExecutionInitiatedEventAttributes() == null) ? 0 : getRequestCancelExternalWorkflowExecutionInitiatedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getRequestCancelExternalWorkflowExecutionFailedEventAttributes() == null) ? 0 : getRequestCancelExternalWorkflowExecutionFailedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getScheduleActivityTaskFailedEventAttributes() == null) ? 0 : getScheduleActivityTaskFailedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getRequestCancelActivityTaskFailedEventAttributes() == null) ? 0 : getRequestCancelActivityTaskFailedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getStartTimerFailedEventAttributes() == null) ? 0 : getStartTimerFailedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getCancelTimerFailedEventAttributes() == null) ? 0 : getCancelTimerFailedEventAttributes().hashCode()); + hashCode = prime * hashCode + ((getStartChildWorkflowExecutionFailedEventAttributes() == null) ? 0 : getStartChildWorkflowExecutionFailedEventAttributes().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof HistoryEvent == false) return false; + HistoryEvent other = (HistoryEvent)obj; + + if (other.getEventTimestamp() == null ^ this.getEventTimestamp() == null) return false; + if (other.getEventTimestamp() != null && other.getEventTimestamp().equals(this.getEventTimestamp()) == false) return false; + if (other.getEventType() == null ^ this.getEventType() == null) return false; + if (other.getEventType() != null && other.getEventType().equals(this.getEventType()) == false) return false; + if (other.getEventId() == null ^ this.getEventId() == null) return false; + if (other.getEventId() != null && other.getEventId().equals(this.getEventId()) == false) return false; + if (other.getWorkflowExecutionStartedEventAttributes() == null ^ this.getWorkflowExecutionStartedEventAttributes() == null) return false; + if (other.getWorkflowExecutionStartedEventAttributes() != null && other.getWorkflowExecutionStartedEventAttributes().equals(this.getWorkflowExecutionStartedEventAttributes()) == false) return false; + if (other.getWorkflowExecutionCompletedEventAttributes() == null ^ this.getWorkflowExecutionCompletedEventAttributes() == null) return false; + if (other.getWorkflowExecutionCompletedEventAttributes() != null && other.getWorkflowExecutionCompletedEventAttributes().equals(this.getWorkflowExecutionCompletedEventAttributes()) == false) return false; + if (other.getCompleteWorkflowExecutionFailedEventAttributes() == null ^ this.getCompleteWorkflowExecutionFailedEventAttributes() == null) return false; + if (other.getCompleteWorkflowExecutionFailedEventAttributes() != null && other.getCompleteWorkflowExecutionFailedEventAttributes().equals(this.getCompleteWorkflowExecutionFailedEventAttributes()) == false) return false; + if (other.getWorkflowExecutionFailedEventAttributes() == null ^ this.getWorkflowExecutionFailedEventAttributes() == null) return false; + if (other.getWorkflowExecutionFailedEventAttributes() != null && other.getWorkflowExecutionFailedEventAttributes().equals(this.getWorkflowExecutionFailedEventAttributes()) == false) return false; + if (other.getFailWorkflowExecutionFailedEventAttributes() == null ^ this.getFailWorkflowExecutionFailedEventAttributes() == null) return false; + if (other.getFailWorkflowExecutionFailedEventAttributes() != null && other.getFailWorkflowExecutionFailedEventAttributes().equals(this.getFailWorkflowExecutionFailedEventAttributes()) == false) return false; + if (other.getWorkflowExecutionTimedOutEventAttributes() == null ^ this.getWorkflowExecutionTimedOutEventAttributes() == null) return false; + if (other.getWorkflowExecutionTimedOutEventAttributes() != null && other.getWorkflowExecutionTimedOutEventAttributes().equals(this.getWorkflowExecutionTimedOutEventAttributes()) == false) return false; + if (other.getWorkflowExecutionCanceledEventAttributes() == null ^ this.getWorkflowExecutionCanceledEventAttributes() == null) return false; + if (other.getWorkflowExecutionCanceledEventAttributes() != null && other.getWorkflowExecutionCanceledEventAttributes().equals(this.getWorkflowExecutionCanceledEventAttributes()) == false) return false; + if (other.getCancelWorkflowExecutionFailedEventAttributes() == null ^ this.getCancelWorkflowExecutionFailedEventAttributes() == null) return false; + if (other.getCancelWorkflowExecutionFailedEventAttributes() != null && other.getCancelWorkflowExecutionFailedEventAttributes().equals(this.getCancelWorkflowExecutionFailedEventAttributes()) == false) return false; + if (other.getWorkflowExecutionContinuedAsNewEventAttributes() == null ^ this.getWorkflowExecutionContinuedAsNewEventAttributes() == null) return false; + if (other.getWorkflowExecutionContinuedAsNewEventAttributes() != null && other.getWorkflowExecutionContinuedAsNewEventAttributes().equals(this.getWorkflowExecutionContinuedAsNewEventAttributes()) == false) return false; + if (other.getContinueAsNewWorkflowExecutionFailedEventAttributes() == null ^ this.getContinueAsNewWorkflowExecutionFailedEventAttributes() == null) return false; + if (other.getContinueAsNewWorkflowExecutionFailedEventAttributes() != null && other.getContinueAsNewWorkflowExecutionFailedEventAttributes().equals(this.getContinueAsNewWorkflowExecutionFailedEventAttributes()) == false) return false; + if (other.getWorkflowExecutionTerminatedEventAttributes() == null ^ this.getWorkflowExecutionTerminatedEventAttributes() == null) return false; + if (other.getWorkflowExecutionTerminatedEventAttributes() != null && other.getWorkflowExecutionTerminatedEventAttributes().equals(this.getWorkflowExecutionTerminatedEventAttributes()) == false) return false; + if (other.getWorkflowExecutionCancelRequestedEventAttributes() == null ^ this.getWorkflowExecutionCancelRequestedEventAttributes() == null) return false; + if (other.getWorkflowExecutionCancelRequestedEventAttributes() != null && other.getWorkflowExecutionCancelRequestedEventAttributes().equals(this.getWorkflowExecutionCancelRequestedEventAttributes()) == false) return false; + if (other.getDecisionTaskScheduledEventAttributes() == null ^ this.getDecisionTaskScheduledEventAttributes() == null) return false; + if (other.getDecisionTaskScheduledEventAttributes() != null && other.getDecisionTaskScheduledEventAttributes().equals(this.getDecisionTaskScheduledEventAttributes()) == false) return false; + if (other.getDecisionTaskStartedEventAttributes() == null ^ this.getDecisionTaskStartedEventAttributes() == null) return false; + if (other.getDecisionTaskStartedEventAttributes() != null && other.getDecisionTaskStartedEventAttributes().equals(this.getDecisionTaskStartedEventAttributes()) == false) return false; + if (other.getDecisionTaskCompletedEventAttributes() == null ^ this.getDecisionTaskCompletedEventAttributes() == null) return false; + if (other.getDecisionTaskCompletedEventAttributes() != null && other.getDecisionTaskCompletedEventAttributes().equals(this.getDecisionTaskCompletedEventAttributes()) == false) return false; + if (other.getDecisionTaskTimedOutEventAttributes() == null ^ this.getDecisionTaskTimedOutEventAttributes() == null) return false; + if (other.getDecisionTaskTimedOutEventAttributes() != null && other.getDecisionTaskTimedOutEventAttributes().equals(this.getDecisionTaskTimedOutEventAttributes()) == false) return false; + if (other.getActivityTaskScheduledEventAttributes() == null ^ this.getActivityTaskScheduledEventAttributes() == null) return false; + if (other.getActivityTaskScheduledEventAttributes() != null && other.getActivityTaskScheduledEventAttributes().equals(this.getActivityTaskScheduledEventAttributes()) == false) return false; + if (other.getActivityTaskStartedEventAttributes() == null ^ this.getActivityTaskStartedEventAttributes() == null) return false; + if (other.getActivityTaskStartedEventAttributes() != null && other.getActivityTaskStartedEventAttributes().equals(this.getActivityTaskStartedEventAttributes()) == false) return false; + if (other.getActivityTaskCompletedEventAttributes() == null ^ this.getActivityTaskCompletedEventAttributes() == null) return false; + if (other.getActivityTaskCompletedEventAttributes() != null && other.getActivityTaskCompletedEventAttributes().equals(this.getActivityTaskCompletedEventAttributes()) == false) return false; + if (other.getActivityTaskFailedEventAttributes() == null ^ this.getActivityTaskFailedEventAttributes() == null) return false; + if (other.getActivityTaskFailedEventAttributes() != null && other.getActivityTaskFailedEventAttributes().equals(this.getActivityTaskFailedEventAttributes()) == false) return false; + if (other.getActivityTaskTimedOutEventAttributes() == null ^ this.getActivityTaskTimedOutEventAttributes() == null) return false; + if (other.getActivityTaskTimedOutEventAttributes() != null && other.getActivityTaskTimedOutEventAttributes().equals(this.getActivityTaskTimedOutEventAttributes()) == false) return false; + if (other.getActivityTaskCanceledEventAttributes() == null ^ this.getActivityTaskCanceledEventAttributes() == null) return false; + if (other.getActivityTaskCanceledEventAttributes() != null && other.getActivityTaskCanceledEventAttributes().equals(this.getActivityTaskCanceledEventAttributes()) == false) return false; + if (other.getActivityTaskCancelRequestedEventAttributes() == null ^ this.getActivityTaskCancelRequestedEventAttributes() == null) return false; + if (other.getActivityTaskCancelRequestedEventAttributes() != null && other.getActivityTaskCancelRequestedEventAttributes().equals(this.getActivityTaskCancelRequestedEventAttributes()) == false) return false; + if (other.getWorkflowExecutionSignaledEventAttributes() == null ^ this.getWorkflowExecutionSignaledEventAttributes() == null) return false; + if (other.getWorkflowExecutionSignaledEventAttributes() != null && other.getWorkflowExecutionSignaledEventAttributes().equals(this.getWorkflowExecutionSignaledEventAttributes()) == false) return false; + if (other.getMarkerRecordedEventAttributes() == null ^ this.getMarkerRecordedEventAttributes() == null) return false; + if (other.getMarkerRecordedEventAttributes() != null && other.getMarkerRecordedEventAttributes().equals(this.getMarkerRecordedEventAttributes()) == false) return false; + if (other.getTimerStartedEventAttributes() == null ^ this.getTimerStartedEventAttributes() == null) return false; + if (other.getTimerStartedEventAttributes() != null && other.getTimerStartedEventAttributes().equals(this.getTimerStartedEventAttributes()) == false) return false; + if (other.getTimerFiredEventAttributes() == null ^ this.getTimerFiredEventAttributes() == null) return false; + if (other.getTimerFiredEventAttributes() != null && other.getTimerFiredEventAttributes().equals(this.getTimerFiredEventAttributes()) == false) return false; + if (other.getTimerCanceledEventAttributes() == null ^ this.getTimerCanceledEventAttributes() == null) return false; + if (other.getTimerCanceledEventAttributes() != null && other.getTimerCanceledEventAttributes().equals(this.getTimerCanceledEventAttributes()) == false) return false; + if (other.getStartChildWorkflowExecutionInitiatedEventAttributes() == null ^ this.getStartChildWorkflowExecutionInitiatedEventAttributes() == null) return false; + if (other.getStartChildWorkflowExecutionInitiatedEventAttributes() != null && other.getStartChildWorkflowExecutionInitiatedEventAttributes().equals(this.getStartChildWorkflowExecutionInitiatedEventAttributes()) == false) return false; + if (other.getChildWorkflowExecutionStartedEventAttributes() == null ^ this.getChildWorkflowExecutionStartedEventAttributes() == null) return false; + if (other.getChildWorkflowExecutionStartedEventAttributes() != null && other.getChildWorkflowExecutionStartedEventAttributes().equals(this.getChildWorkflowExecutionStartedEventAttributes()) == false) return false; + if (other.getChildWorkflowExecutionCompletedEventAttributes() == null ^ this.getChildWorkflowExecutionCompletedEventAttributes() == null) return false; + if (other.getChildWorkflowExecutionCompletedEventAttributes() != null && other.getChildWorkflowExecutionCompletedEventAttributes().equals(this.getChildWorkflowExecutionCompletedEventAttributes()) == false) return false; + if (other.getChildWorkflowExecutionFailedEventAttributes() == null ^ this.getChildWorkflowExecutionFailedEventAttributes() == null) return false; + if (other.getChildWorkflowExecutionFailedEventAttributes() != null && other.getChildWorkflowExecutionFailedEventAttributes().equals(this.getChildWorkflowExecutionFailedEventAttributes()) == false) return false; + if (other.getChildWorkflowExecutionTimedOutEventAttributes() == null ^ this.getChildWorkflowExecutionTimedOutEventAttributes() == null) return false; + if (other.getChildWorkflowExecutionTimedOutEventAttributes() != null && other.getChildWorkflowExecutionTimedOutEventAttributes().equals(this.getChildWorkflowExecutionTimedOutEventAttributes()) == false) return false; + if (other.getChildWorkflowExecutionCanceledEventAttributes() == null ^ this.getChildWorkflowExecutionCanceledEventAttributes() == null) return false; + if (other.getChildWorkflowExecutionCanceledEventAttributes() != null && other.getChildWorkflowExecutionCanceledEventAttributes().equals(this.getChildWorkflowExecutionCanceledEventAttributes()) == false) return false; + if (other.getChildWorkflowExecutionTerminatedEventAttributes() == null ^ this.getChildWorkflowExecutionTerminatedEventAttributes() == null) return false; + if (other.getChildWorkflowExecutionTerminatedEventAttributes() != null && other.getChildWorkflowExecutionTerminatedEventAttributes().equals(this.getChildWorkflowExecutionTerminatedEventAttributes()) == false) return false; + if (other.getSignalExternalWorkflowExecutionInitiatedEventAttributes() == null ^ this.getSignalExternalWorkflowExecutionInitiatedEventAttributes() == null) return false; + if (other.getSignalExternalWorkflowExecutionInitiatedEventAttributes() != null && other.getSignalExternalWorkflowExecutionInitiatedEventAttributes().equals(this.getSignalExternalWorkflowExecutionInitiatedEventAttributes()) == false) return false; + if (other.getExternalWorkflowExecutionSignaledEventAttributes() == null ^ this.getExternalWorkflowExecutionSignaledEventAttributes() == null) return false; + if (other.getExternalWorkflowExecutionSignaledEventAttributes() != null && other.getExternalWorkflowExecutionSignaledEventAttributes().equals(this.getExternalWorkflowExecutionSignaledEventAttributes()) == false) return false; + if (other.getSignalExternalWorkflowExecutionFailedEventAttributes() == null ^ this.getSignalExternalWorkflowExecutionFailedEventAttributes() == null) return false; + if (other.getSignalExternalWorkflowExecutionFailedEventAttributes() != null && other.getSignalExternalWorkflowExecutionFailedEventAttributes().equals(this.getSignalExternalWorkflowExecutionFailedEventAttributes()) == false) return false; + if (other.getExternalWorkflowExecutionCancelRequestedEventAttributes() == null ^ this.getExternalWorkflowExecutionCancelRequestedEventAttributes() == null) return false; + if (other.getExternalWorkflowExecutionCancelRequestedEventAttributes() != null && other.getExternalWorkflowExecutionCancelRequestedEventAttributes().equals(this.getExternalWorkflowExecutionCancelRequestedEventAttributes()) == false) return false; + if (other.getRequestCancelExternalWorkflowExecutionInitiatedEventAttributes() == null ^ this.getRequestCancelExternalWorkflowExecutionInitiatedEventAttributes() == null) return false; + if (other.getRequestCancelExternalWorkflowExecutionInitiatedEventAttributes() != null && other.getRequestCancelExternalWorkflowExecutionInitiatedEventAttributes().equals(this.getRequestCancelExternalWorkflowExecutionInitiatedEventAttributes()) == false) return false; + if (other.getRequestCancelExternalWorkflowExecutionFailedEventAttributes() == null ^ this.getRequestCancelExternalWorkflowExecutionFailedEventAttributes() == null) return false; + if (other.getRequestCancelExternalWorkflowExecutionFailedEventAttributes() != null && other.getRequestCancelExternalWorkflowExecutionFailedEventAttributes().equals(this.getRequestCancelExternalWorkflowExecutionFailedEventAttributes()) == false) return false; + if (other.getScheduleActivityTaskFailedEventAttributes() == null ^ this.getScheduleActivityTaskFailedEventAttributes() == null) return false; + if (other.getScheduleActivityTaskFailedEventAttributes() != null && other.getScheduleActivityTaskFailedEventAttributes().equals(this.getScheduleActivityTaskFailedEventAttributes()) == false) return false; + if (other.getRequestCancelActivityTaskFailedEventAttributes() == null ^ this.getRequestCancelActivityTaskFailedEventAttributes() == null) return false; + if (other.getRequestCancelActivityTaskFailedEventAttributes() != null && other.getRequestCancelActivityTaskFailedEventAttributes().equals(this.getRequestCancelActivityTaskFailedEventAttributes()) == false) return false; + if (other.getStartTimerFailedEventAttributes() == null ^ this.getStartTimerFailedEventAttributes() == null) return false; + if (other.getStartTimerFailedEventAttributes() != null && other.getStartTimerFailedEventAttributes().equals(this.getStartTimerFailedEventAttributes()) == false) return false; + if (other.getCancelTimerFailedEventAttributes() == null ^ this.getCancelTimerFailedEventAttributes() == null) return false; + if (other.getCancelTimerFailedEventAttributes() != null && other.getCancelTimerFailedEventAttributes().equals(this.getCancelTimerFailedEventAttributes()) == false) return false; + if (other.getStartChildWorkflowExecutionFailedEventAttributes() == null ^ this.getStartChildWorkflowExecutionFailedEventAttributes() == null) return false; + if (other.getStartChildWorkflowExecutionFailedEventAttributes() != null && other.getStartChildWorkflowExecutionFailedEventAttributes().equals(this.getStartChildWorkflowExecutionFailedEventAttributes()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/LimitExceededException.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/LimitExceededException.java new file mode 100644 index 000000000000..435115781233 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/LimitExceededException.java @@ -0,0 +1,40 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +import com.amazonaws.AmazonServiceException; + +/** + *

+ * Returned by any operation if a system imposed limitation has been + * reached. To address this fault you should either clean up unused + * resources or increase the limit by contacting AWS. + *

+ */ +public class LimitExceededException extends AmazonServiceException { + private static final long serialVersionUID = 1L; + + /** + * Constructs a new LimitExceededException with the specified error + * message. + * + * @param message Describes the error encountered. + */ + public LimitExceededException(String message) { + super(message); + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ListActivityTypesRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ListActivityTypesRequest.java new file mode 100644 index 000000000000..cd448fa52e92 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ListActivityTypesRequest.java @@ -0,0 +1,503 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#listActivityTypes(ListActivityTypesRequest) ListActivityTypes operation}. + *

+ * Returns information about all activities registered in the specified + * domain that match the specified name and registration status. The + * result includes information like creation date, current status of the + * activity, etc. The results may be split into multiple pages. To + * retrieve subsequent pages, make the call again using the + * nextPageToken returned by the initial call. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#listActivityTypes(ListActivityTypesRequest) + */ +public class ListActivityTypesRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain in which the activity types have been + * registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * If specified, only lists the activity types that have this name. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String name; + + /** + * Specifies the registration status of the activity types to list. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + */ + private String registrationStatus; + + /** + * If on a previous call to this method a NextResultToken + * was returned, the results have more than one page. To get the next + * page of results, repeat the call with the nextPageToken + * and keep all other arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ */ + private String nextPageToken; + + /** + * The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ */ + private Integer maximumPageSize; + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the activity types. + */ + private Boolean reverseOrder; + + /** + * The name of the domain in which the activity types have been + * registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain in which the activity types have been + * registered. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain in which the activity types have been + * registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain in which the activity types have been + * registered. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain in which the activity types have been + * registered. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain in which the activity types have been + * registered. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListActivityTypesRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * If specified, only lists the activity types that have this name. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return If specified, only lists the activity types that have this name. + */ + public String getName() { + return name; + } + + /** + * If specified, only lists the activity types that have this name. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name If specified, only lists the activity types that have this name. + */ + public void setName(String name) { + this.name = name; + } + + /** + * If specified, only lists the activity types that have this name. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name If specified, only lists the activity types that have this name. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListActivityTypesRequest withName(String name) { + this.name = name; + return this; + } + + + /** + * Specifies the registration status of the activity types to list. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @return Specifies the registration status of the activity types to list. + * + * @see RegistrationStatus + */ + public String getRegistrationStatus() { + return registrationStatus; + } + + /** + * Specifies the registration status of the activity types to list. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param registrationStatus Specifies the registration status of the activity types to list. + * + * @see RegistrationStatus + */ + public void setRegistrationStatus(String registrationStatus) { + this.registrationStatus = registrationStatus; + } + + /** + * Specifies the registration status of the activity types to list. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param registrationStatus Specifies the registration status of the activity types to list. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see RegistrationStatus + */ + public ListActivityTypesRequest withRegistrationStatus(String registrationStatus) { + this.registrationStatus = registrationStatus; + return this; + } + + + /** + * Specifies the registration status of the activity types to list. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param registrationStatus Specifies the registration status of the activity types to list. + * + * @see RegistrationStatus + */ + public void setRegistrationStatus(RegistrationStatus registrationStatus) { + this.registrationStatus = registrationStatus.toString(); + } + + /** + * Specifies the registration status of the activity types to list. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param registrationStatus Specifies the registration status of the activity types to list. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see RegistrationStatus + */ + public ListActivityTypesRequest withRegistrationStatus(RegistrationStatus registrationStatus) { + this.registrationStatus = registrationStatus.toString(); + return this; + } + + /** + * If on a previous call to this method a NextResultToken + * was returned, the results have more than one page. To get the next + * page of results, repeat the call with the nextPageToken + * and keep all other arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @return If on a previous call to this method a NextResultToken + * was returned, the results have more than one page. To get the next + * page of results, repeat the call with the nextPageToken + * and keep all other arguments unchanged. + */ + public String getNextPageToken() { + return nextPageToken; + } + + /** + * If on a previous call to this method a NextResultToken + * was returned, the results have more than one page. To get the next + * page of results, repeat the call with the nextPageToken + * and keep all other arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken If on a previous call to this method a NextResultToken + * was returned, the results have more than one page. To get the next + * page of results, repeat the call with the nextPageToken + * and keep all other arguments unchanged. + */ + public void setNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + } + + /** + * If on a previous call to this method a NextResultToken + * was returned, the results have more than one page. To get the next + * page of results, repeat the call with the nextPageToken + * and keep all other arguments unchanged. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken If on a previous call to this method a NextResultToken + * was returned, the results have more than one page. To get the next + * page of results, repeat the call with the nextPageToken + * and keep all other arguments unchanged. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListActivityTypesRequest withNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + + /** + * The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @return The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + */ + public Integer getMaximumPageSize() { + return maximumPageSize; + } + + /** + * The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @param maximumPageSize The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + */ + public void setMaximumPageSize(Integer maximumPageSize) { + this.maximumPageSize = maximumPageSize; + } + + /** + * The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @param maximumPageSize The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListActivityTypesRequest withMaximumPageSize(Integer maximumPageSize) { + this.maximumPageSize = maximumPageSize; + return this; + } + + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the activity types. + * + * @return When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the activity types. + */ + public Boolean isReverseOrder() { + return reverseOrder; + } + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the activity types. + * + * @param reverseOrder When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the activity types. + */ + public void setReverseOrder(Boolean reverseOrder) { + this.reverseOrder = reverseOrder; + } + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the activity types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param reverseOrder When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the activity types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListActivityTypesRequest withReverseOrder(Boolean reverseOrder) { + this.reverseOrder = reverseOrder; + return this; + } + + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the activity types. + * + * @return When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the activity types. + */ + public Boolean getReverseOrder() { + return reverseOrder; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (name != null) sb.append("Name: " + name + ", "); + if (registrationStatus != null) sb.append("RegistrationStatus: " + registrationStatus + ", "); + if (nextPageToken != null) sb.append("NextPageToken: " + nextPageToken + ", "); + if (maximumPageSize != null) sb.append("MaximumPageSize: " + maximumPageSize + ", "); + if (reverseOrder != null) sb.append("ReverseOrder: " + reverseOrder + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); + hashCode = prime * hashCode + ((getRegistrationStatus() == null) ? 0 : getRegistrationStatus().hashCode()); + hashCode = prime * hashCode + ((getNextPageToken() == null) ? 0 : getNextPageToken().hashCode()); + hashCode = prime * hashCode + ((getMaximumPageSize() == null) ? 0 : getMaximumPageSize().hashCode()); + hashCode = prime * hashCode + ((isReverseOrder() == null) ? 0 : isReverseOrder().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ListActivityTypesRequest == false) return false; + ListActivityTypesRequest other = (ListActivityTypesRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getName() == null ^ this.getName() == null) return false; + if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; + if (other.getRegistrationStatus() == null ^ this.getRegistrationStatus() == null) return false; + if (other.getRegistrationStatus() != null && other.getRegistrationStatus().equals(this.getRegistrationStatus()) == false) return false; + if (other.getNextPageToken() == null ^ this.getNextPageToken() == null) return false; + if (other.getNextPageToken() != null && other.getNextPageToken().equals(this.getNextPageToken()) == false) return false; + if (other.getMaximumPageSize() == null ^ this.getMaximumPageSize() == null) return false; + if (other.getMaximumPageSize() != null && other.getMaximumPageSize().equals(this.getMaximumPageSize()) == false) return false; + if (other.isReverseOrder() == null ^ this.isReverseOrder() == null) return false; + if (other.isReverseOrder() != null && other.isReverseOrder().equals(this.isReverseOrder()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ListClosedWorkflowExecutionsRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ListClosedWorkflowExecutionsRequest.java new file mode 100644 index 000000000000..251b6ddea066 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ListClosedWorkflowExecutionsRequest.java @@ -0,0 +1,802 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#listClosedWorkflowExecutions(ListClosedWorkflowExecutionsRequest) ListClosedWorkflowExecutions operation}. + *

+ * Returns a list of closed workflow executions in the specified domain + * that meet the filtering criteria. The results may be split into + * multiple pages. To retrieve subsequent pages, make the call again + * using the nextPageToken returned by the initial call. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#listClosedWorkflowExecutions(ListClosedWorkflowExecutionsRequest) + */ +public class ListClosedWorkflowExecutionsRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain that contains the workflow executions to list. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * If specified, the workflow executions are included in the returned + * results based on whether their start times are within the range + * specified by this filter. Also, if this parameter is specified, the + * returned results are ordered by their start times. + * startTimeFilter and closeTimeFilter + * are mutually exclusive. You must specify one of these in a request but + * not both. + */ + private ExecutionTimeFilter startTimeFilter; + + /** + * If specified, the workflow executions are included in the returned + * results based on whether their close times are within the range + * specified by this filter. Also, if this parameter is specified, the + * returned results are ordered by their close times. + * startTimeFilter and closeTimeFilter + * are mutually exclusive. You must specify one of these in a request but + * not both. + */ + private ExecutionTimeFilter closeTimeFilter; + + /** + * If specified, only workflow executions matching the workflow id + * specified in the filter are returned. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + */ + private WorkflowExecutionFilter executionFilter; + + /** + * If specified, only workflow executions that match this close + * status are listed. For example, if TERMINATED is specified, then + * only TERMINATED workflow executions are listed. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + */ + private CloseStatusFilter closeStatusFilter; + + /** + * If specified, only executions of the type specified in the filter are + * returned. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + private WorkflowTypeFilter typeFilter; + + /** + * If specified, only executions that have the matching tag are listed. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + */ + private TagFilter tagFilter; + + /** + * If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ */ + private String nextPageToken; + + /** + * The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ */ + private Integer maximumPageSize; + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in descending order of the start + * or the close time of the executions. + */ + private Boolean reverseOrder; + + /** + * The name of the domain that contains the workflow executions to list. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain that contains the workflow executions to list. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain that contains the workflow executions to list. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain that contains the workflow executions to list. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain that contains the workflow executions to list. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain that contains the workflow executions to list. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListClosedWorkflowExecutionsRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * If specified, the workflow executions are included in the returned + * results based on whether their start times are within the range + * specified by this filter. Also, if this parameter is specified, the + * returned results are ordered by their start times. + * startTimeFilter and closeTimeFilter + * are mutually exclusive. You must specify one of these in a request but + * not both. + * + * @return If specified, the workflow executions are included in the returned + * results based on whether their start times are within the range + * specified by this filter. Also, if this parameter is specified, the + * returned results are ordered by their start times. + * startTimeFilter and closeTimeFilter + * are mutually exclusive. You must specify one of these in a request but + * not both. + */ + public ExecutionTimeFilter getStartTimeFilter() { + return startTimeFilter; + } + + /** + * If specified, the workflow executions are included in the returned + * results based on whether their start times are within the range + * specified by this filter. Also, if this parameter is specified, the + * returned results are ordered by their start times. + * startTimeFilter and closeTimeFilter + * are mutually exclusive. You must specify one of these in a request but + * not both. + * + * @param startTimeFilter If specified, the workflow executions are included in the returned + * results based on whether their start times are within the range + * specified by this filter. Also, if this parameter is specified, the + * returned results are ordered by their start times. + * startTimeFilter and closeTimeFilter + * are mutually exclusive. You must specify one of these in a request but + * not both. + */ + public void setStartTimeFilter(ExecutionTimeFilter startTimeFilter) { + this.startTimeFilter = startTimeFilter; + } + + /** + * If specified, the workflow executions are included in the returned + * results based on whether their start times are within the range + * specified by this filter. Also, if this parameter is specified, the + * returned results are ordered by their start times. + * startTimeFilter and closeTimeFilter + * are mutually exclusive. You must specify one of these in a request but + * not both. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startTimeFilter If specified, the workflow executions are included in the returned + * results based on whether their start times are within the range + * specified by this filter. Also, if this parameter is specified, the + * returned results are ordered by their start times. + * startTimeFilter and closeTimeFilter + * are mutually exclusive. You must specify one of these in a request but + * not both. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListClosedWorkflowExecutionsRequest withStartTimeFilter(ExecutionTimeFilter startTimeFilter) { + this.startTimeFilter = startTimeFilter; + return this; + } + + + /** + * If specified, the workflow executions are included in the returned + * results based on whether their close times are within the range + * specified by this filter. Also, if this parameter is specified, the + * returned results are ordered by their close times. + * startTimeFilter and closeTimeFilter + * are mutually exclusive. You must specify one of these in a request but + * not both. + * + * @return If specified, the workflow executions are included in the returned + * results based on whether their close times are within the range + * specified by this filter. Also, if this parameter is specified, the + * returned results are ordered by their close times. + * startTimeFilter and closeTimeFilter + * are mutually exclusive. You must specify one of these in a request but + * not both. + */ + public ExecutionTimeFilter getCloseTimeFilter() { + return closeTimeFilter; + } + + /** + * If specified, the workflow executions are included in the returned + * results based on whether their close times are within the range + * specified by this filter. Also, if this parameter is specified, the + * returned results are ordered by their close times. + * startTimeFilter and closeTimeFilter + * are mutually exclusive. You must specify one of these in a request but + * not both. + * + * @param closeTimeFilter If specified, the workflow executions are included in the returned + * results based on whether their close times are within the range + * specified by this filter. Also, if this parameter is specified, the + * returned results are ordered by their close times. + * startTimeFilter and closeTimeFilter + * are mutually exclusive. You must specify one of these in a request but + * not both. + */ + public void setCloseTimeFilter(ExecutionTimeFilter closeTimeFilter) { + this.closeTimeFilter = closeTimeFilter; + } + + /** + * If specified, the workflow executions are included in the returned + * results based on whether their close times are within the range + * specified by this filter. Also, if this parameter is specified, the + * returned results are ordered by their close times. + * startTimeFilter and closeTimeFilter + * are mutually exclusive. You must specify one of these in a request but + * not both. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param closeTimeFilter If specified, the workflow executions are included in the returned + * results based on whether their close times are within the range + * specified by this filter. Also, if this parameter is specified, the + * returned results are ordered by their close times. + * startTimeFilter and closeTimeFilter + * are mutually exclusive. You must specify one of these in a request but + * not both. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListClosedWorkflowExecutionsRequest withCloseTimeFilter(ExecutionTimeFilter closeTimeFilter) { + this.closeTimeFilter = closeTimeFilter; + return this; + } + + + /** + * If specified, only workflow executions matching the workflow id + * specified in the filter are returned. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + * + * @return If specified, only workflow executions matching the workflow id + * specified in the filter are returned. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + */ + public WorkflowExecutionFilter getExecutionFilter() { + return executionFilter; + } + + /** + * If specified, only workflow executions matching the workflow id + * specified in the filter are returned. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + * + * @param executionFilter If specified, only workflow executions matching the workflow id + * specified in the filter are returned. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + */ + public void setExecutionFilter(WorkflowExecutionFilter executionFilter) { + this.executionFilter = executionFilter; + } + + /** + * If specified, only workflow executions matching the workflow id + * specified in the filter are returned. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param executionFilter If specified, only workflow executions matching the workflow id + * specified in the filter are returned. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListClosedWorkflowExecutionsRequest withExecutionFilter(WorkflowExecutionFilter executionFilter) { + this.executionFilter = executionFilter; + return this; + } + + + /** + * If specified, only workflow executions that match this close + * status are listed. For example, if TERMINATED is specified, then + * only TERMINATED workflow executions are listed. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + * + * @return If specified, only workflow executions that match this close + * status are listed. For example, if TERMINATED is specified, then + * only TERMINATED workflow executions are listed. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + */ + public CloseStatusFilter getCloseStatusFilter() { + return closeStatusFilter; + } + + /** + * If specified, only workflow executions that match this close + * status are listed. For example, if TERMINATED is specified, then + * only TERMINATED workflow executions are listed. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + * + * @param closeStatusFilter If specified, only workflow executions that match this close + * status are listed. For example, if TERMINATED is specified, then + * only TERMINATED workflow executions are listed. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + */ + public void setCloseStatusFilter(CloseStatusFilter closeStatusFilter) { + this.closeStatusFilter = closeStatusFilter; + } + + /** + * If specified, only workflow executions that match this close + * status are listed. For example, if TERMINATED is specified, then + * only TERMINATED workflow executions are listed. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param closeStatusFilter If specified, only workflow executions that match this close + * status are listed. For example, if TERMINATED is specified, then + * only TERMINATED workflow executions are listed. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListClosedWorkflowExecutionsRequest withCloseStatusFilter(CloseStatusFilter closeStatusFilter) { + this.closeStatusFilter = closeStatusFilter; + return this; + } + + + /** + * If specified, only executions of the type specified in the filter are + * returned. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @return If specified, only executions of the type specified in the filter are + * returned. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + public WorkflowTypeFilter getTypeFilter() { + return typeFilter; + } + + /** + * If specified, only executions of the type specified in the filter are + * returned. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @param typeFilter If specified, only executions of the type specified in the filter are + * returned. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + public void setTypeFilter(WorkflowTypeFilter typeFilter) { + this.typeFilter = typeFilter; + } + + /** + * If specified, only executions of the type specified in the filter are + * returned. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param typeFilter If specified, only executions of the type specified in the filter are + * returned. closeStatusFilter, + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListClosedWorkflowExecutionsRequest withTypeFilter(WorkflowTypeFilter typeFilter) { + this.typeFilter = typeFilter; + return this; + } + + + /** + * If specified, only executions that have the matching tag are listed. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + * + * @return If specified, only executions that have the matching tag are listed. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + */ + public TagFilter getTagFilter() { + return tagFilter; + } + + /** + * If specified, only executions that have the matching tag are listed. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + * + * @param tagFilter If specified, only executions that have the matching tag are listed. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + */ + public void setTagFilter(TagFilter tagFilter) { + this.tagFilter = tagFilter; + } + + /** + * If specified, only executions that have the matching tag are listed. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param tagFilter If specified, only executions that have the matching tag are listed. + * closeStatusFilter, executionFilter, + * typeFilter and tagFilter are mutually + * exclusive. You can specify at most one of these in a request. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListClosedWorkflowExecutionsRequest withTagFilter(TagFilter tagFilter) { + this.tagFilter = tagFilter; + return this; + } + + + /** + * If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @return If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + */ + public String getNextPageToken() { + return nextPageToken; + } + + /** + * If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + */ + public void setNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + } + + /** + * If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListClosedWorkflowExecutionsRequest withNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + + /** + * The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @return The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + */ + public Integer getMaximumPageSize() { + return maximumPageSize; + } + + /** + * The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @param maximumPageSize The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + */ + public void setMaximumPageSize(Integer maximumPageSize) { + this.maximumPageSize = maximumPageSize; + } + + /** + * The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @param maximumPageSize The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListClosedWorkflowExecutionsRequest withMaximumPageSize(Integer maximumPageSize) { + this.maximumPageSize = maximumPageSize; + return this; + } + + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in descending order of the start + * or the close time of the executions. + * + * @return When set to true, returns the results in reverse order. + * By default the results are returned in descending order of the start + * or the close time of the executions. + */ + public Boolean isReverseOrder() { + return reverseOrder; + } + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in descending order of the start + * or the close time of the executions. + * + * @param reverseOrder When set to true, returns the results in reverse order. + * By default the results are returned in descending order of the start + * or the close time of the executions. + */ + public void setReverseOrder(Boolean reverseOrder) { + this.reverseOrder = reverseOrder; + } + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in descending order of the start + * or the close time of the executions. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param reverseOrder When set to true, returns the results in reverse order. + * By default the results are returned in descending order of the start + * or the close time of the executions. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListClosedWorkflowExecutionsRequest withReverseOrder(Boolean reverseOrder) { + this.reverseOrder = reverseOrder; + return this; + } + + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in descending order of the start + * or the close time of the executions. + * + * @return When set to true, returns the results in reverse order. + * By default the results are returned in descending order of the start + * or the close time of the executions. + */ + public Boolean getReverseOrder() { + return reverseOrder; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (startTimeFilter != null) sb.append("StartTimeFilter: " + startTimeFilter + ", "); + if (closeTimeFilter != null) sb.append("CloseTimeFilter: " + closeTimeFilter + ", "); + if (executionFilter != null) sb.append("ExecutionFilter: " + executionFilter + ", "); + if (closeStatusFilter != null) sb.append("CloseStatusFilter: " + closeStatusFilter + ", "); + if (typeFilter != null) sb.append("TypeFilter: " + typeFilter + ", "); + if (tagFilter != null) sb.append("TagFilter: " + tagFilter + ", "); + if (nextPageToken != null) sb.append("NextPageToken: " + nextPageToken + ", "); + if (maximumPageSize != null) sb.append("MaximumPageSize: " + maximumPageSize + ", "); + if (reverseOrder != null) sb.append("ReverseOrder: " + reverseOrder + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getStartTimeFilter() == null) ? 0 : getStartTimeFilter().hashCode()); + hashCode = prime * hashCode + ((getCloseTimeFilter() == null) ? 0 : getCloseTimeFilter().hashCode()); + hashCode = prime * hashCode + ((getExecutionFilter() == null) ? 0 : getExecutionFilter().hashCode()); + hashCode = prime * hashCode + ((getCloseStatusFilter() == null) ? 0 : getCloseStatusFilter().hashCode()); + hashCode = prime * hashCode + ((getTypeFilter() == null) ? 0 : getTypeFilter().hashCode()); + hashCode = prime * hashCode + ((getTagFilter() == null) ? 0 : getTagFilter().hashCode()); + hashCode = prime * hashCode + ((getNextPageToken() == null) ? 0 : getNextPageToken().hashCode()); + hashCode = prime * hashCode + ((getMaximumPageSize() == null) ? 0 : getMaximumPageSize().hashCode()); + hashCode = prime * hashCode + ((isReverseOrder() == null) ? 0 : isReverseOrder().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ListClosedWorkflowExecutionsRequest == false) return false; + ListClosedWorkflowExecutionsRequest other = (ListClosedWorkflowExecutionsRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getStartTimeFilter() == null ^ this.getStartTimeFilter() == null) return false; + if (other.getStartTimeFilter() != null && other.getStartTimeFilter().equals(this.getStartTimeFilter()) == false) return false; + if (other.getCloseTimeFilter() == null ^ this.getCloseTimeFilter() == null) return false; + if (other.getCloseTimeFilter() != null && other.getCloseTimeFilter().equals(this.getCloseTimeFilter()) == false) return false; + if (other.getExecutionFilter() == null ^ this.getExecutionFilter() == null) return false; + if (other.getExecutionFilter() != null && other.getExecutionFilter().equals(this.getExecutionFilter()) == false) return false; + if (other.getCloseStatusFilter() == null ^ this.getCloseStatusFilter() == null) return false; + if (other.getCloseStatusFilter() != null && other.getCloseStatusFilter().equals(this.getCloseStatusFilter()) == false) return false; + if (other.getTypeFilter() == null ^ this.getTypeFilter() == null) return false; + if (other.getTypeFilter() != null && other.getTypeFilter().equals(this.getTypeFilter()) == false) return false; + if (other.getTagFilter() == null ^ this.getTagFilter() == null) return false; + if (other.getTagFilter() != null && other.getTagFilter().equals(this.getTagFilter()) == false) return false; + if (other.getNextPageToken() == null ^ this.getNextPageToken() == null) return false; + if (other.getNextPageToken() != null && other.getNextPageToken().equals(this.getNextPageToken()) == false) return false; + if (other.getMaximumPageSize() == null ^ this.getMaximumPageSize() == null) return false; + if (other.getMaximumPageSize() != null && other.getMaximumPageSize().equals(this.getMaximumPageSize()) == false) return false; + if (other.isReverseOrder() == null ^ this.isReverseOrder() == null) return false; + if (other.isReverseOrder() != null && other.isReverseOrder().equals(this.isReverseOrder()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ListDomainsRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ListDomainsRequest.java new file mode 100644 index 000000000000..07f1e13e1e35 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ListDomainsRequest.java @@ -0,0 +1,387 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#listDomains(ListDomainsRequest) ListDomains operation}. + *

+ * Returns the list of domains registered in the account. The results + * may be split into multiple pages. To retrieve subsequent pages, make + * the call again using the nextPageToken returned by the initial call. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#listDomains(ListDomainsRequest) + */ +public class ListDomainsRequest extends AmazonWebServiceRequest { + + /** + * If on a previous call to this method a NextPageToken was + * returned, the result has more than one page. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ */ + private String nextPageToken; + + /** + * Specifies the registration status of the domains to list. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + */ + private String registrationStatus; + + /** + * The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ */ + private Integer maximumPageSize; + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the domains. + */ + private Boolean reverseOrder; + + /** + * If on a previous call to this method a NextPageToken was + * returned, the result has more than one page. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @return If on a previous call to this method a NextPageToken was + * returned, the result has more than one page. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + */ + public String getNextPageToken() { + return nextPageToken; + } + + /** + * If on a previous call to this method a NextPageToken was + * returned, the result has more than one page. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken If on a previous call to this method a NextPageToken was + * returned, the result has more than one page. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + */ + public void setNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + } + + /** + * If on a previous call to this method a NextPageToken was + * returned, the result has more than one page. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken If on a previous call to this method a NextPageToken was + * returned, the result has more than one page. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListDomainsRequest withNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + + /** + * Specifies the registration status of the domains to list. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @return Specifies the registration status of the domains to list. + * + * @see RegistrationStatus + */ + public String getRegistrationStatus() { + return registrationStatus; + } + + /** + * Specifies the registration status of the domains to list. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param registrationStatus Specifies the registration status of the domains to list. + * + * @see RegistrationStatus + */ + public void setRegistrationStatus(String registrationStatus) { + this.registrationStatus = registrationStatus; + } + + /** + * Specifies the registration status of the domains to list. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param registrationStatus Specifies the registration status of the domains to list. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see RegistrationStatus + */ + public ListDomainsRequest withRegistrationStatus(String registrationStatus) { + this.registrationStatus = registrationStatus; + return this; + } + + + /** + * Specifies the registration status of the domains to list. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param registrationStatus Specifies the registration status of the domains to list. + * + * @see RegistrationStatus + */ + public void setRegistrationStatus(RegistrationStatus registrationStatus) { + this.registrationStatus = registrationStatus.toString(); + } + + /** + * Specifies the registration status of the domains to list. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param registrationStatus Specifies the registration status of the domains to list. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see RegistrationStatus + */ + public ListDomainsRequest withRegistrationStatus(RegistrationStatus registrationStatus) { + this.registrationStatus = registrationStatus.toString(); + return this; + } + + /** + * The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @return The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + */ + public Integer getMaximumPageSize() { + return maximumPageSize; + } + + /** + * The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @param maximumPageSize The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + */ + public void setMaximumPageSize(Integer maximumPageSize) { + this.maximumPageSize = maximumPageSize; + } + + /** + * The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @param maximumPageSize The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListDomainsRequest withMaximumPageSize(Integer maximumPageSize) { + this.maximumPageSize = maximumPageSize; + return this; + } + + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the domains. + * + * @return When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the domains. + */ + public Boolean isReverseOrder() { + return reverseOrder; + } + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the domains. + * + * @param reverseOrder When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the domains. + */ + public void setReverseOrder(Boolean reverseOrder) { + this.reverseOrder = reverseOrder; + } + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the domains. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param reverseOrder When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the domains. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListDomainsRequest withReverseOrder(Boolean reverseOrder) { + this.reverseOrder = reverseOrder; + return this; + } + + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the domains. + * + * @return When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the domains. + */ + public Boolean getReverseOrder() { + return reverseOrder; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (nextPageToken != null) sb.append("NextPageToken: " + nextPageToken + ", "); + if (registrationStatus != null) sb.append("RegistrationStatus: " + registrationStatus + ", "); + if (maximumPageSize != null) sb.append("MaximumPageSize: " + maximumPageSize + ", "); + if (reverseOrder != null) sb.append("ReverseOrder: " + reverseOrder + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getNextPageToken() == null) ? 0 : getNextPageToken().hashCode()); + hashCode = prime * hashCode + ((getRegistrationStatus() == null) ? 0 : getRegistrationStatus().hashCode()); + hashCode = prime * hashCode + ((getMaximumPageSize() == null) ? 0 : getMaximumPageSize().hashCode()); + hashCode = prime * hashCode + ((isReverseOrder() == null) ? 0 : isReverseOrder().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ListDomainsRequest == false) return false; + ListDomainsRequest other = (ListDomainsRequest)obj; + + if (other.getNextPageToken() == null ^ this.getNextPageToken() == null) return false; + if (other.getNextPageToken() != null && other.getNextPageToken().equals(this.getNextPageToken()) == false) return false; + if (other.getRegistrationStatus() == null ^ this.getRegistrationStatus() == null) return false; + if (other.getRegistrationStatus() != null && other.getRegistrationStatus().equals(this.getRegistrationStatus()) == false) return false; + if (other.getMaximumPageSize() == null ^ this.getMaximumPageSize() == null) return false; + if (other.getMaximumPageSize() != null && other.getMaximumPageSize().equals(this.getMaximumPageSize()) == false) return false; + if (other.isReverseOrder() == null ^ this.isReverseOrder() == null) return false; + if (other.isReverseOrder() != null && other.isReverseOrder().equals(this.isReverseOrder()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ListOpenWorkflowExecutionsRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ListOpenWorkflowExecutionsRequest.java new file mode 100644 index 000000000000..86d301c47863 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ListOpenWorkflowExecutionsRequest.java @@ -0,0 +1,604 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#listOpenWorkflowExecutions(ListOpenWorkflowExecutionsRequest) ListOpenWorkflowExecutions operation}. + *

+ * Returns a list of open workflow executions in the specified domain + * that meet the filtering criteria. The results may be split into + * multiple pages. To retrieve subsequent pages, make the call again + * using the nextPageToken returned by the initial call. + *

+ *

+ * NOTE: This operation is eventually consistent. The results are + * best effort and may not exactly reflect recent updates and changes. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#listOpenWorkflowExecutions(ListOpenWorkflowExecutionsRequest) + */ +public class ListOpenWorkflowExecutionsRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain that contains the workflow executions to list. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * Workflow executions are included in the returned results based on + * whether their start times are within the range specified by this + * filter. + */ + private ExecutionTimeFilter startTimeFilter; + + /** + * If specified, only executions of the type specified in the filter are + * returned. executionFilter, typeFilter + * and tagFilter are mutually exclusive. You can specify at + * most one of these in a request. + */ + private WorkflowTypeFilter typeFilter; + + /** + * If specified, only executions that have the matching tag are listed. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + private TagFilter tagFilter; + + /** + * If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ */ + private String nextPageToken; + + /** + * The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ */ + private Integer maximumPageSize; + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in descending order of the start + * time of the executions. + */ + private Boolean reverseOrder; + + /** + * If specified, only workflow executions matching the workflow id + * specified in the filter are returned. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + private WorkflowExecutionFilter executionFilter; + + /** + * The name of the domain that contains the workflow executions to list. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain that contains the workflow executions to list. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain that contains the workflow executions to list. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain that contains the workflow executions to list. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain that contains the workflow executions to list. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain that contains the workflow executions to list. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListOpenWorkflowExecutionsRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * Workflow executions are included in the returned results based on + * whether their start times are within the range specified by this + * filter. + * + * @return Workflow executions are included in the returned results based on + * whether their start times are within the range specified by this + * filter. + */ + public ExecutionTimeFilter getStartTimeFilter() { + return startTimeFilter; + } + + /** + * Workflow executions are included in the returned results based on + * whether their start times are within the range specified by this + * filter. + * + * @param startTimeFilter Workflow executions are included in the returned results based on + * whether their start times are within the range specified by this + * filter. + */ + public void setStartTimeFilter(ExecutionTimeFilter startTimeFilter) { + this.startTimeFilter = startTimeFilter; + } + + /** + * Workflow executions are included in the returned results based on + * whether their start times are within the range specified by this + * filter. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startTimeFilter Workflow executions are included in the returned results based on + * whether their start times are within the range specified by this + * filter. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListOpenWorkflowExecutionsRequest withStartTimeFilter(ExecutionTimeFilter startTimeFilter) { + this.startTimeFilter = startTimeFilter; + return this; + } + + + /** + * If specified, only executions of the type specified in the filter are + * returned. executionFilter, typeFilter + * and tagFilter are mutually exclusive. You can specify at + * most one of these in a request. + * + * @return If specified, only executions of the type specified in the filter are + * returned. executionFilter, typeFilter + * and tagFilter are mutually exclusive. You can specify at + * most one of these in a request. + */ + public WorkflowTypeFilter getTypeFilter() { + return typeFilter; + } + + /** + * If specified, only executions of the type specified in the filter are + * returned. executionFilter, typeFilter + * and tagFilter are mutually exclusive. You can specify at + * most one of these in a request. + * + * @param typeFilter If specified, only executions of the type specified in the filter are + * returned. executionFilter, typeFilter + * and tagFilter are mutually exclusive. You can specify at + * most one of these in a request. + */ + public void setTypeFilter(WorkflowTypeFilter typeFilter) { + this.typeFilter = typeFilter; + } + + /** + * If specified, only executions of the type specified in the filter are + * returned. executionFilter, typeFilter + * and tagFilter are mutually exclusive. You can specify at + * most one of these in a request. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param typeFilter If specified, only executions of the type specified in the filter are + * returned. executionFilter, typeFilter + * and tagFilter are mutually exclusive. You can specify at + * most one of these in a request. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListOpenWorkflowExecutionsRequest withTypeFilter(WorkflowTypeFilter typeFilter) { + this.typeFilter = typeFilter; + return this; + } + + + /** + * If specified, only executions that have the matching tag are listed. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @return If specified, only executions that have the matching tag are listed. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + public TagFilter getTagFilter() { + return tagFilter; + } + + /** + * If specified, only executions that have the matching tag are listed. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @param tagFilter If specified, only executions that have the matching tag are listed. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + public void setTagFilter(TagFilter tagFilter) { + this.tagFilter = tagFilter; + } + + /** + * If specified, only executions that have the matching tag are listed. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param tagFilter If specified, only executions that have the matching tag are listed. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListOpenWorkflowExecutionsRequest withTagFilter(TagFilter tagFilter) { + this.tagFilter = tagFilter; + return this; + } + + + /** + * If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @return If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + */ + public String getNextPageToken() { + return nextPageToken; + } + + /** + * If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + */ + public void setNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + } + + /** + * If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListOpenWorkflowExecutionsRequest withNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + + /** + * The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @return The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + */ + public Integer getMaximumPageSize() { + return maximumPageSize; + } + + /** + * The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @param maximumPageSize The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + */ + public void setMaximumPageSize(Integer maximumPageSize) { + this.maximumPageSize = maximumPageSize; + } + + /** + * The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @param maximumPageSize The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListOpenWorkflowExecutionsRequest withMaximumPageSize(Integer maximumPageSize) { + this.maximumPageSize = maximumPageSize; + return this; + } + + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in descending order of the start + * time of the executions. + * + * @return When set to true, returns the results in reverse order. + * By default the results are returned in descending order of the start + * time of the executions. + */ + public Boolean isReverseOrder() { + return reverseOrder; + } + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in descending order of the start + * time of the executions. + * + * @param reverseOrder When set to true, returns the results in reverse order. + * By default the results are returned in descending order of the start + * time of the executions. + */ + public void setReverseOrder(Boolean reverseOrder) { + this.reverseOrder = reverseOrder; + } + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in descending order of the start + * time of the executions. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param reverseOrder When set to true, returns the results in reverse order. + * By default the results are returned in descending order of the start + * time of the executions. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListOpenWorkflowExecutionsRequest withReverseOrder(Boolean reverseOrder) { + this.reverseOrder = reverseOrder; + return this; + } + + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in descending order of the start + * time of the executions. + * + * @return When set to true, returns the results in reverse order. + * By default the results are returned in descending order of the start + * time of the executions. + */ + public Boolean getReverseOrder() { + return reverseOrder; + } + + /** + * If specified, only workflow executions matching the workflow id + * specified in the filter are returned. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @return If specified, only workflow executions matching the workflow id + * specified in the filter are returned. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + public WorkflowExecutionFilter getExecutionFilter() { + return executionFilter; + } + + /** + * If specified, only workflow executions matching the workflow id + * specified in the filter are returned. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @param executionFilter If specified, only workflow executions matching the workflow id + * specified in the filter are returned. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + */ + public void setExecutionFilter(WorkflowExecutionFilter executionFilter) { + this.executionFilter = executionFilter; + } + + /** + * If specified, only workflow executions matching the workflow id + * specified in the filter are returned. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param executionFilter If specified, only workflow executions matching the workflow id + * specified in the filter are returned. + * executionFilter, typeFilter and + * tagFilter are mutually exclusive. You can specify at most + * one of these in a request. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListOpenWorkflowExecutionsRequest withExecutionFilter(WorkflowExecutionFilter executionFilter) { + this.executionFilter = executionFilter; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (startTimeFilter != null) sb.append("StartTimeFilter: " + startTimeFilter + ", "); + if (typeFilter != null) sb.append("TypeFilter: " + typeFilter + ", "); + if (tagFilter != null) sb.append("TagFilter: " + tagFilter + ", "); + if (nextPageToken != null) sb.append("NextPageToken: " + nextPageToken + ", "); + if (maximumPageSize != null) sb.append("MaximumPageSize: " + maximumPageSize + ", "); + if (reverseOrder != null) sb.append("ReverseOrder: " + reverseOrder + ", "); + if (executionFilter != null) sb.append("ExecutionFilter: " + executionFilter + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getStartTimeFilter() == null) ? 0 : getStartTimeFilter().hashCode()); + hashCode = prime * hashCode + ((getTypeFilter() == null) ? 0 : getTypeFilter().hashCode()); + hashCode = prime * hashCode + ((getTagFilter() == null) ? 0 : getTagFilter().hashCode()); + hashCode = prime * hashCode + ((getNextPageToken() == null) ? 0 : getNextPageToken().hashCode()); + hashCode = prime * hashCode + ((getMaximumPageSize() == null) ? 0 : getMaximumPageSize().hashCode()); + hashCode = prime * hashCode + ((isReverseOrder() == null) ? 0 : isReverseOrder().hashCode()); + hashCode = prime * hashCode + ((getExecutionFilter() == null) ? 0 : getExecutionFilter().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ListOpenWorkflowExecutionsRequest == false) return false; + ListOpenWorkflowExecutionsRequest other = (ListOpenWorkflowExecutionsRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getStartTimeFilter() == null ^ this.getStartTimeFilter() == null) return false; + if (other.getStartTimeFilter() != null && other.getStartTimeFilter().equals(this.getStartTimeFilter()) == false) return false; + if (other.getTypeFilter() == null ^ this.getTypeFilter() == null) return false; + if (other.getTypeFilter() != null && other.getTypeFilter().equals(this.getTypeFilter()) == false) return false; + if (other.getTagFilter() == null ^ this.getTagFilter() == null) return false; + if (other.getTagFilter() != null && other.getTagFilter().equals(this.getTagFilter()) == false) return false; + if (other.getNextPageToken() == null ^ this.getNextPageToken() == null) return false; + if (other.getNextPageToken() != null && other.getNextPageToken().equals(this.getNextPageToken()) == false) return false; + if (other.getMaximumPageSize() == null ^ this.getMaximumPageSize() == null) return false; + if (other.getMaximumPageSize() != null && other.getMaximumPageSize().equals(this.getMaximumPageSize()) == false) return false; + if (other.isReverseOrder() == null ^ this.isReverseOrder() == null) return false; + if (other.isReverseOrder() != null && other.isReverseOrder().equals(this.isReverseOrder()) == false) return false; + if (other.getExecutionFilter() == null ^ this.getExecutionFilter() == null) return false; + if (other.getExecutionFilter() != null && other.getExecutionFilter().equals(this.getExecutionFilter()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ListWorkflowTypesRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ListWorkflowTypesRequest.java new file mode 100644 index 000000000000..beac8e66bddf --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ListWorkflowTypesRequest.java @@ -0,0 +1,500 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#listWorkflowTypes(ListWorkflowTypesRequest) ListWorkflowTypes operation}. + *

+ * Returns information about workflow types in the specified domain. The + * results may be split into multiple pages that can be retrieved by + * making the call repeatedly. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#listWorkflowTypes(ListWorkflowTypesRequest) + */ +public class ListWorkflowTypesRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain in which the workflow types have been + * registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * If specified, lists the workflow type with this name. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String name; + + /** + * Specifies the registration status of the workflow types to list. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + */ + private String registrationStatus; + + /** + * If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ */ + private String nextPageToken; + + /** + * The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ */ + private Integer maximumPageSize; + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the workflow types. + */ + private Boolean reverseOrder; + + /** + * The name of the domain in which the workflow types have been + * registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain in which the workflow types have been + * registered. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain in which the workflow types have been + * registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain in which the workflow types have been + * registered. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain in which the workflow types have been + * registered. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain in which the workflow types have been + * registered. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListWorkflowTypesRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * If specified, lists the workflow type with this name. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return If specified, lists the workflow type with this name. + */ + public String getName() { + return name; + } + + /** + * If specified, lists the workflow type with this name. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name If specified, lists the workflow type with this name. + */ + public void setName(String name) { + this.name = name; + } + + /** + * If specified, lists the workflow type with this name. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name If specified, lists the workflow type with this name. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListWorkflowTypesRequest withName(String name) { + this.name = name; + return this; + } + + + /** + * Specifies the registration status of the workflow types to list. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @return Specifies the registration status of the workflow types to list. + * + * @see RegistrationStatus + */ + public String getRegistrationStatus() { + return registrationStatus; + } + + /** + * Specifies the registration status of the workflow types to list. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param registrationStatus Specifies the registration status of the workflow types to list. + * + * @see RegistrationStatus + */ + public void setRegistrationStatus(String registrationStatus) { + this.registrationStatus = registrationStatus; + } + + /** + * Specifies the registration status of the workflow types to list. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param registrationStatus Specifies the registration status of the workflow types to list. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see RegistrationStatus + */ + public ListWorkflowTypesRequest withRegistrationStatus(String registrationStatus) { + this.registrationStatus = registrationStatus; + return this; + } + + + /** + * Specifies the registration status of the workflow types to list. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param registrationStatus Specifies the registration status of the workflow types to list. + * + * @see RegistrationStatus + */ + public void setRegistrationStatus(RegistrationStatus registrationStatus) { + this.registrationStatus = registrationStatus.toString(); + } + + /** + * Specifies the registration status of the workflow types to list. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param registrationStatus Specifies the registration status of the workflow types to list. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see RegistrationStatus + */ + public ListWorkflowTypesRequest withRegistrationStatus(RegistrationStatus registrationStatus) { + this.registrationStatus = registrationStatus.toString(); + return this; + } + + /** + * If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @return If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + */ + public String getNextPageToken() { + return nextPageToken; + } + + /** + * If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + */ + public void setNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + } + + /** + * If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListWorkflowTypesRequest withNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + + /** + * The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @return The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + */ + public Integer getMaximumPageSize() { + return maximumPageSize; + } + + /** + * The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @param maximumPageSize The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + */ + public void setMaximumPageSize(Integer maximumPageSize) { + this.maximumPageSize = maximumPageSize; + } + + /** + * The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @param maximumPageSize The maximum number of results returned in each page. The default is + * 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListWorkflowTypesRequest withMaximumPageSize(Integer maximumPageSize) { + this.maximumPageSize = maximumPageSize; + return this; + } + + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the workflow types. + * + * @return When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the workflow types. + */ + public Boolean isReverseOrder() { + return reverseOrder; + } + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the workflow types. + * + * @param reverseOrder When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the workflow types. + */ + public void setReverseOrder(Boolean reverseOrder) { + this.reverseOrder = reverseOrder; + } + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the workflow types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param reverseOrder When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the workflow types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ListWorkflowTypesRequest withReverseOrder(Boolean reverseOrder) { + this.reverseOrder = reverseOrder; + return this; + } + + + /** + * When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the workflow types. + * + * @return When set to true, returns the results in reverse order. + * By default the results are returned in ascending alphabetical order of + * the name of the workflow types. + */ + public Boolean getReverseOrder() { + return reverseOrder; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (name != null) sb.append("Name: " + name + ", "); + if (registrationStatus != null) sb.append("RegistrationStatus: " + registrationStatus + ", "); + if (nextPageToken != null) sb.append("NextPageToken: " + nextPageToken + ", "); + if (maximumPageSize != null) sb.append("MaximumPageSize: " + maximumPageSize + ", "); + if (reverseOrder != null) sb.append("ReverseOrder: " + reverseOrder + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); + hashCode = prime * hashCode + ((getRegistrationStatus() == null) ? 0 : getRegistrationStatus().hashCode()); + hashCode = prime * hashCode + ((getNextPageToken() == null) ? 0 : getNextPageToken().hashCode()); + hashCode = prime * hashCode + ((getMaximumPageSize() == null) ? 0 : getMaximumPageSize().hashCode()); + hashCode = prime * hashCode + ((isReverseOrder() == null) ? 0 : isReverseOrder().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ListWorkflowTypesRequest == false) return false; + ListWorkflowTypesRequest other = (ListWorkflowTypesRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getName() == null ^ this.getName() == null) return false; + if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; + if (other.getRegistrationStatus() == null ^ this.getRegistrationStatus() == null) return false; + if (other.getRegistrationStatus() != null && other.getRegistrationStatus().equals(this.getRegistrationStatus()) == false) return false; + if (other.getNextPageToken() == null ^ this.getNextPageToken() == null) return false; + if (other.getNextPageToken() != null && other.getNextPageToken().equals(this.getNextPageToken()) == false) return false; + if (other.getMaximumPageSize() == null ^ this.getMaximumPageSize() == null) return false; + if (other.getMaximumPageSize() != null && other.getMaximumPageSize().equals(this.getMaximumPageSize()) == false) return false; + if (other.isReverseOrder() == null ^ this.isReverseOrder() == null) return false; + if (other.isReverseOrder() != null && other.isReverseOrder().equals(this.isReverseOrder()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/MarkerRecordedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/MarkerRecordedEventAttributes.java new file mode 100644 index 000000000000..5201ba8ad422 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/MarkerRecordedEventAttributes.java @@ -0,0 +1,234 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the MarkerRecorded event. + *

+ */ +public class MarkerRecordedEventAttributes { + + /** + * The name of the marker. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String markerName; + + /** + * Details of the marker (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String details; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the RecordMarker + * decision that requested this marker. This information can be useful + * for diagnosing problems by tracing back the cause of events. + */ + private Long decisionTaskCompletedEventId; + + /** + * The name of the marker. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the marker. + */ + public String getMarkerName() { + return markerName; + } + + /** + * The name of the marker. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param markerName The name of the marker. + */ + public void setMarkerName(String markerName) { + this.markerName = markerName; + } + + /** + * The name of the marker. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param markerName The name of the marker. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public MarkerRecordedEventAttributes withMarkerName(String markerName) { + this.markerName = markerName; + return this; + } + + + /** + * Details of the marker (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Details of the marker (if any). + */ + public String getDetails() { + return details; + } + + /** + * Details of the marker (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details Details of the marker (if any). + */ + public void setDetails(String details) { + this.details = details; + } + + /** + * Details of the marker (if any). + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details Details of the marker (if any). + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public MarkerRecordedEventAttributes withDetails(String details) { + this.details = details; + return this; + } + + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the RecordMarker + * decision that requested this marker. This information can be useful + * for diagnosing problems by tracing back the cause of events. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the RecordMarker + * decision that requested this marker. This information can be useful + * for diagnosing problems by tracing back the cause of events. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the RecordMarker + * decision that requested this marker. This information can be useful + * for diagnosing problems by tracing back the cause of events. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the RecordMarker + * decision that requested this marker. This information can be useful + * for diagnosing problems by tracing back the cause of events. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the RecordMarker + * decision that requested this marker. This information can be useful + * for diagnosing problems by tracing back the cause of events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the RecordMarker + * decision that requested this marker. This information can be useful + * for diagnosing problems by tracing back the cause of events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public MarkerRecordedEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (markerName != null) sb.append("MarkerName: " + markerName + ", "); + if (details != null) sb.append("Details: " + details + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getMarkerName() == null) ? 0 : getMarkerName().hashCode()); + hashCode = prime * hashCode + ((getDetails() == null) ? 0 : getDetails().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof MarkerRecordedEventAttributes == false) return false; + MarkerRecordedEventAttributes other = (MarkerRecordedEventAttributes)obj; + + if (other.getMarkerName() == null ^ this.getMarkerName() == null) return false; + if (other.getMarkerName() != null && other.getMarkerName().equals(this.getMarkerName()) == false) return false; + if (other.getDetails() == null ^ this.getDetails() == null) return false; + if (other.getDetails() != null && other.getDetails().equals(this.getDetails()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/OperationNotPermittedException.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/OperationNotPermittedException.java new file mode 100644 index 000000000000..3682ea851d6c --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/OperationNotPermittedException.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +import com.amazonaws.AmazonServiceException; + +/** + *

+ * Returned when the requester does not have the required permissions to + * perform the requested operation. + *

+ */ +public class OperationNotPermittedException extends AmazonServiceException { + private static final long serialVersionUID = 1L; + + /** + * Constructs a new OperationNotPermittedException with the specified error + * message. + * + * @param message Describes the error encountered. + */ + public OperationNotPermittedException(String message) { + super(message); + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/PendingTaskCount.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/PendingTaskCount.java new file mode 100644 index 000000000000..b8abff1abbd3 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/PendingTaskCount.java @@ -0,0 +1,185 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Contains the count of tasks in a task list. + *

+ */ +public class PendingTaskCount { + + /** + * The number of tasks in the task list. + *

+ * Constraints:
+ * Range: 0 -
+ */ + private Integer count; + + /** + * If set to true, indicates that the actual count was more than the + * maximum supported by this API and the count returned is the truncated + * value. + */ + private Boolean truncated; + + /** + * The number of tasks in the task list. + *

+ * Constraints:
+ * Range: 0 -
+ * + * @return The number of tasks in the task list. + */ + public Integer getCount() { + return count; + } + + /** + * The number of tasks in the task list. + *

+ * Constraints:
+ * Range: 0 -
+ * + * @param count The number of tasks in the task list. + */ + public void setCount(Integer count) { + this.count = count; + } + + /** + * The number of tasks in the task list. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Range: 0 -
+ * + * @param count The number of tasks in the task list. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public PendingTaskCount withCount(Integer count) { + this.count = count; + return this; + } + + + /** + * If set to true, indicates that the actual count was more than the + * maximum supported by this API and the count returned is the truncated + * value. + * + * @return If set to true, indicates that the actual count was more than the + * maximum supported by this API and the count returned is the truncated + * value. + */ + public Boolean isTruncated() { + return truncated; + } + + /** + * If set to true, indicates that the actual count was more than the + * maximum supported by this API and the count returned is the truncated + * value. + * + * @param truncated If set to true, indicates that the actual count was more than the + * maximum supported by this API and the count returned is the truncated + * value. + */ + public void setTruncated(Boolean truncated) { + this.truncated = truncated; + } + + /** + * If set to true, indicates that the actual count was more than the + * maximum supported by this API and the count returned is the truncated + * value. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param truncated If set to true, indicates that the actual count was more than the + * maximum supported by this API and the count returned is the truncated + * value. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public PendingTaskCount withTruncated(Boolean truncated) { + this.truncated = truncated; + return this; + } + + + /** + * If set to true, indicates that the actual count was more than the + * maximum supported by this API and the count returned is the truncated + * value. + * + * @return If set to true, indicates that the actual count was more than the + * maximum supported by this API and the count returned is the truncated + * value. + */ + public Boolean getTruncated() { + return truncated; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (count != null) sb.append("Count: " + count + ", "); + if (truncated != null) sb.append("Truncated: " + truncated + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getCount() == null) ? 0 : getCount().hashCode()); + hashCode = prime * hashCode + ((isTruncated() == null) ? 0 : isTruncated().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof PendingTaskCount == false) return false; + PendingTaskCount other = (PendingTaskCount)obj; + + if (other.getCount() == null ^ this.getCount() == null) return false; + if (other.getCount() != null && other.getCount().equals(this.getCount()) == false) return false; + if (other.isTruncated() == null ^ this.isTruncated() == null) return false; + if (other.isTruncated() != null && other.isTruncated().equals(this.isTruncated()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/PollForActivityTaskRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/PollForActivityTaskRequest.java new file mode 100644 index 000000000000..fa52406a1267 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/PollForActivityTaskRequest.java @@ -0,0 +1,280 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#pollForActivityTask(PollForActivityTaskRequest) PollForActivityTask operation}. + *

+ * Used by workers to get an ActivityTask from the specified activity + * taskList . + * This initiates a long poll, where the service holds the HTTP + * connection open and responds as soon as a task becomes available. The + * maximum time the service holds on to the request before responding is + * 60 seconds. If no task is available within 60 seconds, the poll will + * return an empty result. An empty result, in this context, means that + * an ActivityTask is returned, but that the value of taskToken is an + * empty string. If a task is returned, the worker should use its type to + * identify and process it correctly. + *

+ *

+ * IMPORTANT: Workers should set their client side socket timeout + * to at least 70 seconds (10 seconds higher than the maximum time + * service may hold the poll request). + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#pollForActivityTask(PollForActivityTaskRequest) + */ +public class PollForActivityTaskRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain that contains the task lists being polled. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * Specifies the task list to poll for activity tasks.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + */ + private TaskList taskList; + + /** + * Identity of the worker making the request, which is recorded in the + * ActivityTaskStarted event in the workflow history. This + * enables diagnostic tracing when problems arise. The form of this + * identity is user defined. + *

+ * Constraints:
+ * Length: 0 - 256
+ */ + private String identity; + + /** + * The name of the domain that contains the task lists being polled. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain that contains the task lists being polled. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain that contains the task lists being polled. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain that contains the task lists being polled. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain that contains the task lists being polled. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain that contains the task lists being polled. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public PollForActivityTaskRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * Specifies the task list to poll for activity tasks.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + * + * @return Specifies the task list to poll for activity tasks.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + */ + public TaskList getTaskList() { + return taskList; + } + + /** + * Specifies the task list to poll for activity tasks.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + * + * @param taskList Specifies the task list to poll for activity tasks.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + */ + public void setTaskList(TaskList taskList) { + this.taskList = taskList; + } + + /** + * Specifies the task list to poll for activity tasks.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param taskList Specifies the task list to poll for activity tasks.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public PollForActivityTaskRequest withTaskList(TaskList taskList) { + this.taskList = taskList; + return this; + } + + + /** + * Identity of the worker making the request, which is recorded in the + * ActivityTaskStarted event in the workflow history. This + * enables diagnostic tracing when problems arise. The form of this + * identity is user defined. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @return Identity of the worker making the request, which is recorded in the + * ActivityTaskStarted event in the workflow history. This + * enables diagnostic tracing when problems arise. The form of this + * identity is user defined. + */ + public String getIdentity() { + return identity; + } + + /** + * Identity of the worker making the request, which is recorded in the + * ActivityTaskStarted event in the workflow history. This + * enables diagnostic tracing when problems arise. The form of this + * identity is user defined. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param identity Identity of the worker making the request, which is recorded in the + * ActivityTaskStarted event in the workflow history. This + * enables diagnostic tracing when problems arise. The form of this + * identity is user defined. + */ + public void setIdentity(String identity) { + this.identity = identity; + } + + /** + * Identity of the worker making the request, which is recorded in the + * ActivityTaskStarted event in the workflow history. This + * enables diagnostic tracing when problems arise. The form of this + * identity is user defined. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param identity Identity of the worker making the request, which is recorded in the + * ActivityTaskStarted event in the workflow history. This + * enables diagnostic tracing when problems arise. The form of this + * identity is user defined. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public PollForActivityTaskRequest withIdentity(String identity) { + this.identity = identity; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (taskList != null) sb.append("TaskList: " + taskList + ", "); + if (identity != null) sb.append("Identity: " + identity + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getTaskList() == null) ? 0 : getTaskList().hashCode()); + hashCode = prime * hashCode + ((getIdentity() == null) ? 0 : getIdentity().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof PollForActivityTaskRequest == false) return false; + PollForActivityTaskRequest other = (PollForActivityTaskRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getTaskList() == null ^ this.getTaskList() == null) return false; + if (other.getTaskList() != null && other.getTaskList().equals(this.getTaskList()) == false) return false; + if (other.getIdentity() == null ^ this.getIdentity() == null) return false; + if (other.getIdentity() != null && other.getIdentity().equals(this.getIdentity()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/PollForDecisionTaskRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/PollForDecisionTaskRequest.java new file mode 100644 index 000000000000..21f8c386bb4e --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/PollForDecisionTaskRequest.java @@ -0,0 +1,557 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#pollForDecisionTask(PollForDecisionTaskRequest) PollForDecisionTask operation}. + *

+ * Used by deciders to get a DecisionTask from the specified decision + * taskList . + * A decision task may be returned for any open workflow + * execution that is using the specified task list. The task includes a + * paginated view of the history of the workflow execution. The decider + * should use the workflow type and the history to determine how to + * properly handle the task. + *

+ *

+ * This action initiates a long poll, where the service holds the HTTP + * connection open and responds as soon a task becomes available. If no + * decision task is available in the specified task list before the + * timeout of 60 seconds expires, an empty result is returned. An empty + * result, in this context, means that a DecisionTask is returned, but + * that the value of taskToken is an empty string. + *

+ *

+ * IMPORTANT: Deciders should set their client side socket timeout + * to at least 70 seconds (10 seconds higher than the timeout). + *

+ *

+ * IMPORTANT: Because the number of workflow history events for a + * single workflow execution might be very large, the result returned + * might be split up across a number of pages. To retrieve subsequent + * pages, make additional calls to PollForDecisionTask using the + * nextPageToken returned by the initial call. Note that you do not call + * GetWorkflowExecutionHistory with this nextPageToken. Instead, call + * PollForDecisionTask again. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#pollForDecisionTask(PollForDecisionTaskRequest) + */ +public class PollForDecisionTaskRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain containing the task lists to poll. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * Specifies the task list to poll for decision tasks.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + */ + private TaskList taskList; + + /** + * Identity of the decider making the request, which is recorded in the + * DecisionTaskStarted event in the workflow history. This enables + * diagnostic tracing when problems arise. The form of this identity is + * user defined. + *

+ * Constraints:
+ * Length: 0 - 256
+ */ + private String identity; + + /** + * If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. The nextPageToken returned by + * this action cannot be used with GetWorkflowExecutionHistory to + * get the next page. You must call PollForDecisionTask again + * (with the nextPageToken) to retrieve the next page of + * history records. Calling PollForDecisionTask with a + * nextPageToken will not return a new decision + * task.. + *

+ * Constraints:
+ * Length: 0 - 2048
+ */ + private String nextPageToken; + + /** + * The maximum number of history events returned in each page. The + * default is 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ */ + private Integer maximumPageSize; + + /** + * When set to true, returns the events in reverse order. By + * default the results are returned in ascending order of the + * eventTimestamp of the events. + */ + private Boolean reverseOrder; + + /** + * The name of the domain containing the task lists to poll. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain containing the task lists to poll. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain containing the task lists to poll. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain containing the task lists to poll. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain containing the task lists to poll. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain containing the task lists to poll. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public PollForDecisionTaskRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * Specifies the task list to poll for decision tasks.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + * + * @return Specifies the task list to poll for decision tasks.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + */ + public TaskList getTaskList() { + return taskList; + } + + /** + * Specifies the task list to poll for decision tasks.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + * + * @param taskList Specifies the task list to poll for decision tasks.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + */ + public void setTaskList(TaskList taskList) { + this.taskList = taskList; + } + + /** + * Specifies the task list to poll for decision tasks.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param taskList Specifies the task list to poll for decision tasks.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public PollForDecisionTaskRequest withTaskList(TaskList taskList) { + this.taskList = taskList; + return this; + } + + + /** + * Identity of the decider making the request, which is recorded in the + * DecisionTaskStarted event in the workflow history. This enables + * diagnostic tracing when problems arise. The form of this identity is + * user defined. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @return Identity of the decider making the request, which is recorded in the + * DecisionTaskStarted event in the workflow history. This enables + * diagnostic tracing when problems arise. The form of this identity is + * user defined. + */ + public String getIdentity() { + return identity; + } + + /** + * Identity of the decider making the request, which is recorded in the + * DecisionTaskStarted event in the workflow history. This enables + * diagnostic tracing when problems arise. The form of this identity is + * user defined. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param identity Identity of the decider making the request, which is recorded in the + * DecisionTaskStarted event in the workflow history. This enables + * diagnostic tracing when problems arise. The form of this identity is + * user defined. + */ + public void setIdentity(String identity) { + this.identity = identity; + } + + /** + * Identity of the decider making the request, which is recorded in the + * DecisionTaskStarted event in the workflow history. This enables + * diagnostic tracing when problems arise. The form of this identity is + * user defined. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param identity Identity of the decider making the request, which is recorded in the + * DecisionTaskStarted event in the workflow history. This enables + * diagnostic tracing when problems arise. The form of this identity is + * user defined. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public PollForDecisionTaskRequest withIdentity(String identity) { + this.identity = identity; + return this; + } + + + /** + * If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. The nextPageToken returned by + * this action cannot be used with GetWorkflowExecutionHistory to + * get the next page. You must call PollForDecisionTask again + * (with the nextPageToken) to retrieve the next page of + * history records. Calling PollForDecisionTask with a + * nextPageToken will not return a new decision + * task.. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @return If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. The nextPageToken returned by + * this action cannot be used with GetWorkflowExecutionHistory to + * get the next page. You must call PollForDecisionTask again + * (with the nextPageToken) to retrieve the next page of + * history records. Calling PollForDecisionTask with a + * nextPageToken will not return a new decision + * task.. + */ + public String getNextPageToken() { + return nextPageToken; + } + + /** + * If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. The nextPageToken returned by + * this action cannot be used with GetWorkflowExecutionHistory to + * get the next page. You must call PollForDecisionTask again + * (with the nextPageToken) to retrieve the next page of + * history records. Calling PollForDecisionTask with a + * nextPageToken will not return a new decision + * task.. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. The nextPageToken returned by + * this action cannot be used with GetWorkflowExecutionHistory to + * get the next page. You must call PollForDecisionTask again + * (with the nextPageToken) to retrieve the next page of + * history records. Calling PollForDecisionTask with a + * nextPageToken will not return a new decision + * task.. + */ + public void setNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + } + + /** + * If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. The nextPageToken returned by + * this action cannot be used with GetWorkflowExecutionHistory to + * get the next page. You must call PollForDecisionTask again + * (with the nextPageToken) to retrieve the next page of + * history records. Calling PollForDecisionTask with a + * nextPageToken will not return a new decision + * task.. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken If on a previous call to this method a NextPageToken was + * returned, the results are being paginated. To get the next page of + * results, repeat the call with the returned token and all other + * arguments unchanged. The nextPageToken returned by + * this action cannot be used with GetWorkflowExecutionHistory to + * get the next page. You must call PollForDecisionTask again + * (with the nextPageToken) to retrieve the next page of + * history records. Calling PollForDecisionTask with a + * nextPageToken will not return a new decision + * task.. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public PollForDecisionTaskRequest withNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + + /** + * The maximum number of history events returned in each page. The + * default is 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @return The maximum number of history events returned in each page. The + * default is 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + */ + public Integer getMaximumPageSize() { + return maximumPageSize; + } + + /** + * The maximum number of history events returned in each page. The + * default is 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @param maximumPageSize The maximum number of history events returned in each page. The + * default is 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + */ + public void setMaximumPageSize(Integer maximumPageSize) { + this.maximumPageSize = maximumPageSize; + } + + /** + * The maximum number of history events returned in each page. The + * default is 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Range: 0 - 1000
+ * + * @param maximumPageSize The maximum number of history events returned in each page. The + * default is 100, but the caller can override this value to a page size + * smaller than the default. You cannot specify a page size + * greater than 100. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public PollForDecisionTaskRequest withMaximumPageSize(Integer maximumPageSize) { + this.maximumPageSize = maximumPageSize; + return this; + } + + + /** + * When set to true, returns the events in reverse order. By + * default the results are returned in ascending order of the + * eventTimestamp of the events. + * + * @return When set to true, returns the events in reverse order. By + * default the results are returned in ascending order of the + * eventTimestamp of the events. + */ + public Boolean isReverseOrder() { + return reverseOrder; + } + + /** + * When set to true, returns the events in reverse order. By + * default the results are returned in ascending order of the + * eventTimestamp of the events. + * + * @param reverseOrder When set to true, returns the events in reverse order. By + * default the results are returned in ascending order of the + * eventTimestamp of the events. + */ + public void setReverseOrder(Boolean reverseOrder) { + this.reverseOrder = reverseOrder; + } + + /** + * When set to true, returns the events in reverse order. By + * default the results are returned in ascending order of the + * eventTimestamp of the events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param reverseOrder When set to true, returns the events in reverse order. By + * default the results are returned in ascending order of the + * eventTimestamp of the events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public PollForDecisionTaskRequest withReverseOrder(Boolean reverseOrder) { + this.reverseOrder = reverseOrder; + return this; + } + + + /** + * When set to true, returns the events in reverse order. By + * default the results are returned in ascending order of the + * eventTimestamp of the events. + * + * @return When set to true, returns the events in reverse order. By + * default the results are returned in ascending order of the + * eventTimestamp of the events. + */ + public Boolean getReverseOrder() { + return reverseOrder; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (taskList != null) sb.append("TaskList: " + taskList + ", "); + if (identity != null) sb.append("Identity: " + identity + ", "); + if (nextPageToken != null) sb.append("NextPageToken: " + nextPageToken + ", "); + if (maximumPageSize != null) sb.append("MaximumPageSize: " + maximumPageSize + ", "); + if (reverseOrder != null) sb.append("ReverseOrder: " + reverseOrder + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getTaskList() == null) ? 0 : getTaskList().hashCode()); + hashCode = prime * hashCode + ((getIdentity() == null) ? 0 : getIdentity().hashCode()); + hashCode = prime * hashCode + ((getNextPageToken() == null) ? 0 : getNextPageToken().hashCode()); + hashCode = prime * hashCode + ((getMaximumPageSize() == null) ? 0 : getMaximumPageSize().hashCode()); + hashCode = prime * hashCode + ((isReverseOrder() == null) ? 0 : isReverseOrder().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof PollForDecisionTaskRequest == false) return false; + PollForDecisionTaskRequest other = (PollForDecisionTaskRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getTaskList() == null ^ this.getTaskList() == null) return false; + if (other.getTaskList() != null && other.getTaskList().equals(this.getTaskList()) == false) return false; + if (other.getIdentity() == null ^ this.getIdentity() == null) return false; + if (other.getIdentity() != null && other.getIdentity().equals(this.getIdentity()) == false) return false; + if (other.getNextPageToken() == null ^ this.getNextPageToken() == null) return false; + if (other.getNextPageToken() != null && other.getNextPageToken().equals(this.getNextPageToken()) == false) return false; + if (other.getMaximumPageSize() == null ^ this.getMaximumPageSize() == null) return false; + if (other.getMaximumPageSize() != null && other.getMaximumPageSize().equals(this.getMaximumPageSize()) == false) return false; + if (other.isReverseOrder() == null ^ this.isReverseOrder() == null) return false; + if (other.isReverseOrder() != null && other.isReverseOrder().equals(this.isReverseOrder()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/PredefinedDuration.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/PredefinedDuration.java new file mode 100644 index 000000000000..2321fa9a6aa5 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/PredefinedDuration.java @@ -0,0 +1,8 @@ +package com.amazonaws.services.simpleworkflow.model; + + +public enum PredefinedDuration { + + NONE + +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/RecordActivityTaskHeartbeatRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/RecordActivityTaskHeartbeatRequest.java new file mode 100644 index 000000000000..0898d96cba9b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/RecordActivityTaskHeartbeatRequest.java @@ -0,0 +1,240 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#recordActivityTaskHeartbeat(RecordActivityTaskHeartbeatRequest) RecordActivityTaskHeartbeat operation}. + *

+ * Used by activity workers to report to the service that the + * ActivityTask represented by the specified taskToken is + * still making progress. The worker can also (optionally) specify + * details of the progress, for example percent complete, using the + * details parameter. This action can also be used by the + * worker as a mechanism to check if cancellation is being requested for + * the activity task. If a cancellation is being attempted for the + * specified task, then the boolean cancelRequested flag + * returned by the service is set to true . + * + *

+ *

+ * This action resets the taskHeartbeatTimeout clock. The + * taskHeartbeatTimeout is specified in + * RegisterActivityType. + *

+ *

+ * This action does not in itself create an event in the workflow + * execution history. However, if the task times out, the workflow + * execution history will contain a ActivityTaskTimedOut + * event that contains the information from the last heartbeat generated + * by the activity worker. + *

+ *

+ * NOTE: The taskStartToCloseTimeout of an activity type is the + * maximum duration of an activity task, regardless of the number of + * RecordActivityTaskHeartbeat requests received. The + * taskStartToCloseTimeout is also specified in RegisterActivityType. + *

+ *

+ * NOTE: This operation is only useful for long-lived activities + * to report liveliness of the task and to determine if a cancellation is + * being attempted. + *

+ *

+ * IMPORTANT: If the cancelRequested flag returns true, a + * cancellation is being attempted. If the worker can cancel the + * activity, it should respond with RespondActivityTaskCanceled. + * Otherwise, it should ignore the cancellation request. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#recordActivityTaskHeartbeat(RecordActivityTaskHeartbeatRequest) + */ +public class RecordActivityTaskHeartbeatRequest extends AmazonWebServiceRequest { + + /** + * The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + *

+ * Constraints:
+ * Length: 1 - 1024
+ */ + private String taskToken; + + /** + * If specified, contains details about the progress of the task. + *

+ * Constraints:
+ * Length: 0 - 2048
+ */ + private String details; + + /** + * The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @return The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + */ + public String getTaskToken() { + return taskToken; + } + + /** + * The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @param taskToken The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + */ + public void setTaskToken(String taskToken) { + this.taskToken = taskToken; + } + + /** + * The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @param taskToken The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RecordActivityTaskHeartbeatRequest withTaskToken(String taskToken) { + this.taskToken = taskToken; + return this; + } + + + /** + * If specified, contains details about the progress of the task. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @return If specified, contains details about the progress of the task. + */ + public String getDetails() { + return details; + } + + /** + * If specified, contains details about the progress of the task. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param details If specified, contains details about the progress of the task. + */ + public void setDetails(String details) { + this.details = details; + } + + /** + * If specified, contains details about the progress of the task. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param details If specified, contains details about the progress of the task. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RecordActivityTaskHeartbeatRequest withDetails(String details) { + this.details = details; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (taskToken != null) sb.append("TaskToken: " + taskToken + ", "); + if (details != null) sb.append("Details: " + details + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTaskToken() == null) ? 0 : getTaskToken().hashCode()); + hashCode = prime * hashCode + ((getDetails() == null) ? 0 : getDetails().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof RecordActivityTaskHeartbeatRequest == false) return false; + RecordActivityTaskHeartbeatRequest other = (RecordActivityTaskHeartbeatRequest)obj; + + if (other.getTaskToken() == null ^ this.getTaskToken() == null) return false; + if (other.getTaskToken() != null && other.getTaskToken().equals(this.getTaskToken()) == false) return false; + if (other.getDetails() == null ^ this.getDetails() == null) return false; + if (other.getDetails() != null && other.getDetails().equals(this.getDetails()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/RecordMarkerDecisionAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/RecordMarkerDecisionAttributes.java new file mode 100644 index 000000000000..eee278c76b1c --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/RecordMarkerDecisionAttributes.java @@ -0,0 +1,170 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the RecordMarker decision. + *

+ */ +public class RecordMarkerDecisionAttributes { + + /** + * The name of the marker. This filed is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String markerName; + + /** + * Optional details of the marker. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String details; + + /** + * The name of the marker. This filed is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the marker. This filed is required. + */ + public String getMarkerName() { + return markerName; + } + + /** + * The name of the marker. This filed is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param markerName The name of the marker. This filed is required. + */ + public void setMarkerName(String markerName) { + this.markerName = markerName; + } + + /** + * The name of the marker. This filed is required. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param markerName The name of the marker. This filed is required. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RecordMarkerDecisionAttributes withMarkerName(String markerName) { + this.markerName = markerName; + return this; + } + + + /** + * Optional details of the marker. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Optional details of the marker. + */ + public String getDetails() { + return details; + } + + /** + * Optional details of the marker. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details Optional details of the marker. + */ + public void setDetails(String details) { + this.details = details; + } + + /** + * Optional details of the marker. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details Optional details of the marker. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RecordMarkerDecisionAttributes withDetails(String details) { + this.details = details; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (markerName != null) sb.append("MarkerName: " + markerName + ", "); + if (details != null) sb.append("Details: " + details + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getMarkerName() == null) ? 0 : getMarkerName().hashCode()); + hashCode = prime * hashCode + ((getDetails() == null) ? 0 : getDetails().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof RecordMarkerDecisionAttributes == false) return false; + RecordMarkerDecisionAttributes other = (RecordMarkerDecisionAttributes)obj; + + if (other.getMarkerName() == null ^ this.getMarkerName() == null) return false; + if (other.getMarkerName() != null && other.getMarkerName().equals(this.getMarkerName()) == false) return false; + if (other.getDetails() == null ^ this.getDetails() == null) return false; + if (other.getDetails() != null && other.getDetails().equals(this.getDetails()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/RegisterActivityTypeRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/RegisterActivityTypeRequest.java new file mode 100644 index 000000000000..453ed10cac77 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/RegisterActivityTypeRequest.java @@ -0,0 +1,862 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#registerActivityType(RegisterActivityTypeRequest) RegisterActivityType operation}. + *

+ * Registers a new activity type along with its configuration + * settings in the specified domain. + *

+ *

+ * IMPORTANT: A TypeAlreadyExists fault is returned if the type + * already exists in the domain. You cannot change any configuration + * settings of the type after its registration, and it must be registered + * as a new version. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#registerActivityType(RegisterActivityTypeRequest) + */ +public class RegisterActivityTypeRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain in which this activity is to be registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * The name of the activity type within the domain.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String name; + + /** + * The version of the activity type. The activity type consists of + * the name and version, the combination of which must be unique within + * the domain.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 64
+ */ + private String version; + + /** + * A textual description of the activity type. + *

+ * Constraints:
+ * Length: 0 - 1024
+ */ + private String description; + + /** + * If set, specifies the default maximum duration that a worker can take + * to process tasks of this activity type. This default can be overridden + * when scheduling an activity task using the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String defaultTaskStartToCloseTimeout; + + /** + * If set, specifies the default maximum time before which a worker + * processing a task of this type must report progress by calling + * RecordActivityTaskHeartbeat. If the timeout is exceeded, the + * activity task is automatically timed out. This default can be + * overridden when scheduling an activity task using the + * ScheduleActivityTask Decision. If the activity + * worker subsequently attempts to record a heartbeat or returns a + * result, the activity worker receives an UnknownResource + * fault. In this case, Amazon SWF no longer considers the activity task + * to be valid; the activity worker should clean up the activity task. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String defaultTaskHeartbeatTimeout; + + /** + * If set, specifies the default task list to use for scheduling tasks of + * this activity type. This default task list is used if a task list is + * not provided when a task is scheduled through the + * ScheduleActivityTask Decision. + */ + private TaskList defaultTaskList; + + /** + * If set, specifies the default maximum duration that a task of this + * activity type can wait before being assigned to a worker. This default + * can be overridden when scheduling an activity task using the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String defaultTaskScheduleToStartTimeout; + + /** + * If set, specifies the default maximum duration for a task of this + * activity type. This default can be overridden when scheduling an + * activity task using the ScheduleActivityTask + * Decision.

The valid values are integers greater than or + * equal to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String defaultTaskScheduleToCloseTimeout; + + /** + * The name of the domain in which this activity is to be registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain in which this activity is to be registered. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain in which this activity is to be registered. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain in which this activity is to be registered. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain in which this activity is to be registered. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain in which this activity is to be registered. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RegisterActivityTypeRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * The name of the activity type within the domain.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the activity type within the domain.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + */ + public String getName() { + return name; + } + + /** + * The name of the activity type within the domain.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name The name of the activity type within the domain.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + */ + public void setName(String name) { + this.name = name; + } + + /** + * The name of the activity type within the domain.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name The name of the activity type within the domain.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RegisterActivityTypeRequest withName(String name) { + this.name = name; + return this; + } + + + /** + * The version of the activity type. The activity type consists of + * the name and version, the combination of which must be unique within + * the domain.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @return The version of the activity type. The activity type consists of + * the name and version, the combination of which must be unique within + * the domain.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + */ + public String getVersion() { + return version; + } + + /** + * The version of the activity type. The activity type consists of + * the name and version, the combination of which must be unique within + * the domain.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param version The version of the activity type. The activity type consists of + * the name and version, the combination of which must be unique within + * the domain.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + */ + public void setVersion(String version) { + this.version = version; + } + + /** + * The version of the activity type. The activity type consists of + * the name and version, the combination of which must be unique within + * the domain.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param version The version of the activity type. The activity type consists of + * the name and version, the combination of which must be unique within + * the domain.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RegisterActivityTypeRequest withVersion(String version) { + this.version = version; + return this; + } + + + /** + * A textual description of the activity type. + *

+ * Constraints:
+ * Length: 0 - 1024
+ * + * @return A textual description of the activity type. + */ + public String getDescription() { + return description; + } + + /** + * A textual description of the activity type. + *

+ * Constraints:
+ * Length: 0 - 1024
+ * + * @param description A textual description of the activity type. + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * A textual description of the activity type. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 1024
+ * + * @param description A textual description of the activity type. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RegisterActivityTypeRequest withDescription(String description) { + this.description = description; + return this; + } + + + /** + * If set, specifies the default maximum duration that a worker can take + * to process tasks of this activity type. This default can be overridden + * when scheduling an activity task using the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return If set, specifies the default maximum duration that a worker can take + * to process tasks of this activity type. This default can be overridden + * when scheduling an activity task using the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + */ + public String getDefaultTaskStartToCloseTimeout() { + return defaultTaskStartToCloseTimeout; + } + + /** + * If set, specifies the default maximum duration that a worker can take + * to process tasks of this activity type. This default can be overridden + * when scheduling an activity task using the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultTaskStartToCloseTimeout If set, specifies the default maximum duration that a worker can take + * to process tasks of this activity type. This default can be overridden + * when scheduling an activity task using the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + */ + public void setDefaultTaskStartToCloseTimeout(String defaultTaskStartToCloseTimeout) { + this.defaultTaskStartToCloseTimeout = defaultTaskStartToCloseTimeout; + } + + /** + * If set, specifies the default maximum duration that a worker can take + * to process tasks of this activity type. This default can be overridden + * when scheduling an activity task using the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultTaskStartToCloseTimeout If set, specifies the default maximum duration that a worker can take + * to process tasks of this activity type. This default can be overridden + * when scheduling an activity task using the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RegisterActivityTypeRequest withDefaultTaskStartToCloseTimeout(String defaultTaskStartToCloseTimeout) { + this.defaultTaskStartToCloseTimeout = defaultTaskStartToCloseTimeout; + return this; + } + + + /** + * If set, specifies the default maximum time before which a worker + * processing a task of this type must report progress by calling + * RecordActivityTaskHeartbeat. If the timeout is exceeded, the + * activity task is automatically timed out. This default can be + * overridden when scheduling an activity task using the + * ScheduleActivityTask Decision. If the activity + * worker subsequently attempts to record a heartbeat or returns a + * result, the activity worker receives an UnknownResource + * fault. In this case, Amazon SWF no longer considers the activity task + * to be valid; the activity worker should clean up the activity task. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return If set, specifies the default maximum time before which a worker + * processing a task of this type must report progress by calling + * RecordActivityTaskHeartbeat. If the timeout is exceeded, the + * activity task is automatically timed out. This default can be + * overridden when scheduling an activity task using the + * ScheduleActivityTask Decision. If the activity + * worker subsequently attempts to record a heartbeat or returns a + * result, the activity worker receives an UnknownResource + * fault. In this case, Amazon SWF no longer considers the activity task + * to be valid; the activity worker should clean up the activity task. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + */ + public String getDefaultTaskHeartbeatTimeout() { + return defaultTaskHeartbeatTimeout; + } + + /** + * If set, specifies the default maximum time before which a worker + * processing a task of this type must report progress by calling + * RecordActivityTaskHeartbeat. If the timeout is exceeded, the + * activity task is automatically timed out. This default can be + * overridden when scheduling an activity task using the + * ScheduleActivityTask Decision. If the activity + * worker subsequently attempts to record a heartbeat or returns a + * result, the activity worker receives an UnknownResource + * fault. In this case, Amazon SWF no longer considers the activity task + * to be valid; the activity worker should clean up the activity task. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultTaskHeartbeatTimeout If set, specifies the default maximum time before which a worker + * processing a task of this type must report progress by calling + * RecordActivityTaskHeartbeat. If the timeout is exceeded, the + * activity task is automatically timed out. This default can be + * overridden when scheduling an activity task using the + * ScheduleActivityTask Decision. If the activity + * worker subsequently attempts to record a heartbeat or returns a + * result, the activity worker receives an UnknownResource + * fault. In this case, Amazon SWF no longer considers the activity task + * to be valid; the activity worker should clean up the activity task. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + */ + public void setDefaultTaskHeartbeatTimeout(String defaultTaskHeartbeatTimeout) { + this.defaultTaskHeartbeatTimeout = defaultTaskHeartbeatTimeout; + } + + /** + * If set, specifies the default maximum time before which a worker + * processing a task of this type must report progress by calling + * RecordActivityTaskHeartbeat. If the timeout is exceeded, the + * activity task is automatically timed out. This default can be + * overridden when scheduling an activity task using the + * ScheduleActivityTask Decision. If the activity + * worker subsequently attempts to record a heartbeat or returns a + * result, the activity worker receives an UnknownResource + * fault. In this case, Amazon SWF no longer considers the activity task + * to be valid; the activity worker should clean up the activity task. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultTaskHeartbeatTimeout If set, specifies the default maximum time before which a worker + * processing a task of this type must report progress by calling + * RecordActivityTaskHeartbeat. If the timeout is exceeded, the + * activity task is automatically timed out. This default can be + * overridden when scheduling an activity task using the + * ScheduleActivityTask Decision. If the activity + * worker subsequently attempts to record a heartbeat or returns a + * result, the activity worker receives an UnknownResource + * fault. In this case, Amazon SWF no longer considers the activity task + * to be valid; the activity worker should clean up the activity task. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RegisterActivityTypeRequest withDefaultTaskHeartbeatTimeout(String defaultTaskHeartbeatTimeout) { + this.defaultTaskHeartbeatTimeout = defaultTaskHeartbeatTimeout; + return this; + } + + + /** + * If set, specifies the default task list to use for scheduling tasks of + * this activity type. This default task list is used if a task list is + * not provided when a task is scheduled through the + * ScheduleActivityTask Decision. + * + * @return If set, specifies the default task list to use for scheduling tasks of + * this activity type. This default task list is used if a task list is + * not provided when a task is scheduled through the + * ScheduleActivityTask Decision. + */ + public TaskList getDefaultTaskList() { + return defaultTaskList; + } + + /** + * If set, specifies the default task list to use for scheduling tasks of + * this activity type. This default task list is used if a task list is + * not provided when a task is scheduled through the + * ScheduleActivityTask Decision. + * + * @param defaultTaskList If set, specifies the default task list to use for scheduling tasks of + * this activity type. This default task list is used if a task list is + * not provided when a task is scheduled through the + * ScheduleActivityTask Decision. + */ + public void setDefaultTaskList(TaskList defaultTaskList) { + this.defaultTaskList = defaultTaskList; + } + + /** + * If set, specifies the default task list to use for scheduling tasks of + * this activity type. This default task list is used if a task list is + * not provided when a task is scheduled through the + * ScheduleActivityTask Decision. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param defaultTaskList If set, specifies the default task list to use for scheduling tasks of + * this activity type. This default task list is used if a task list is + * not provided when a task is scheduled through the + * ScheduleActivityTask Decision. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RegisterActivityTypeRequest withDefaultTaskList(TaskList defaultTaskList) { + this.defaultTaskList = defaultTaskList; + return this; + } + + + /** + * If set, specifies the default maximum duration that a task of this + * activity type can wait before being assigned to a worker. This default + * can be overridden when scheduling an activity task using the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return If set, specifies the default maximum duration that a task of this + * activity type can wait before being assigned to a worker. This default + * can be overridden when scheduling an activity task using the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + */ + public String getDefaultTaskScheduleToStartTimeout() { + return defaultTaskScheduleToStartTimeout; + } + + /** + * If set, specifies the default maximum duration that a task of this + * activity type can wait before being assigned to a worker. This default + * can be overridden when scheduling an activity task using the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultTaskScheduleToStartTimeout If set, specifies the default maximum duration that a task of this + * activity type can wait before being assigned to a worker. This default + * can be overridden when scheduling an activity task using the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + */ + public void setDefaultTaskScheduleToStartTimeout(String defaultTaskScheduleToStartTimeout) { + this.defaultTaskScheduleToStartTimeout = defaultTaskScheduleToStartTimeout; + } + + /** + * If set, specifies the default maximum duration that a task of this + * activity type can wait before being assigned to a worker. This default + * can be overridden when scheduling an activity task using the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultTaskScheduleToStartTimeout If set, specifies the default maximum duration that a task of this + * activity type can wait before being assigned to a worker. This default + * can be overridden when scheduling an activity task using the + * ScheduleActivityTask Decision.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RegisterActivityTypeRequest withDefaultTaskScheduleToStartTimeout(String defaultTaskScheduleToStartTimeout) { + this.defaultTaskScheduleToStartTimeout = defaultTaskScheduleToStartTimeout; + return this; + } + + + /** + * If set, specifies the default maximum duration for a task of this + * activity type. This default can be overridden when scheduling an + * activity task using the ScheduleActivityTask + * Decision.

The valid values are integers greater than or + * equal to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return If set, specifies the default maximum duration for a task of this + * activity type. This default can be overridden when scheduling an + * activity task using the ScheduleActivityTask + * Decision.

The valid values are integers greater than or + * equal to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. + */ + public String getDefaultTaskScheduleToCloseTimeout() { + return defaultTaskScheduleToCloseTimeout; + } + + /** + * If set, specifies the default maximum duration for a task of this + * activity type. This default can be overridden when scheduling an + * activity task using the ScheduleActivityTask + * Decision.

The valid values are integers greater than or + * equal to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultTaskScheduleToCloseTimeout If set, specifies the default maximum duration for a task of this + * activity type. This default can be overridden when scheduling an + * activity task using the ScheduleActivityTask + * Decision.

The valid values are integers greater than or + * equal to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. + */ + public void setDefaultTaskScheduleToCloseTimeout(String defaultTaskScheduleToCloseTimeout) { + this.defaultTaskScheduleToCloseTimeout = defaultTaskScheduleToCloseTimeout; + } + + /** + * If set, specifies the default maximum duration for a task of this + * activity type. This default can be overridden when scheduling an + * activity task using the ScheduleActivityTask + * Decision.

The valid values are integers greater than or + * equal to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultTaskScheduleToCloseTimeout If set, specifies the default maximum duration for a task of this + * activity type. This default can be overridden when scheduling an + * activity task using the ScheduleActivityTask + * Decision.

The valid values are integers greater than or + * equal to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RegisterActivityTypeRequest withDefaultTaskScheduleToCloseTimeout(String defaultTaskScheduleToCloseTimeout) { + this.defaultTaskScheduleToCloseTimeout = defaultTaskScheduleToCloseTimeout; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (name != null) sb.append("Name: " + name + ", "); + if (version != null) sb.append("Version: " + version + ", "); + if (description != null) sb.append("Description: " + description + ", "); + if (defaultTaskStartToCloseTimeout != null) sb.append("DefaultTaskStartToCloseTimeout: " + defaultTaskStartToCloseTimeout + ", "); + if (defaultTaskHeartbeatTimeout != null) sb.append("DefaultTaskHeartbeatTimeout: " + defaultTaskHeartbeatTimeout + ", "); + if (defaultTaskList != null) sb.append("DefaultTaskList: " + defaultTaskList + ", "); + if (defaultTaskScheduleToStartTimeout != null) sb.append("DefaultTaskScheduleToStartTimeout: " + defaultTaskScheduleToStartTimeout + ", "); + if (defaultTaskScheduleToCloseTimeout != null) sb.append("DefaultTaskScheduleToCloseTimeout: " + defaultTaskScheduleToCloseTimeout + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); + hashCode = prime * hashCode + ((getVersion() == null) ? 0 : getVersion().hashCode()); + hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); + hashCode = prime * hashCode + ((getDefaultTaskStartToCloseTimeout() == null) ? 0 : getDefaultTaskStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getDefaultTaskHeartbeatTimeout() == null) ? 0 : getDefaultTaskHeartbeatTimeout().hashCode()); + hashCode = prime * hashCode + ((getDefaultTaskList() == null) ? 0 : getDefaultTaskList().hashCode()); + hashCode = prime * hashCode + ((getDefaultTaskScheduleToStartTimeout() == null) ? 0 : getDefaultTaskScheduleToStartTimeout().hashCode()); + hashCode = prime * hashCode + ((getDefaultTaskScheduleToCloseTimeout() == null) ? 0 : getDefaultTaskScheduleToCloseTimeout().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof RegisterActivityTypeRequest == false) return false; + RegisterActivityTypeRequest other = (RegisterActivityTypeRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getName() == null ^ this.getName() == null) return false; + if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; + if (other.getVersion() == null ^ this.getVersion() == null) return false; + if (other.getVersion() != null && other.getVersion().equals(this.getVersion()) == false) return false; + if (other.getDescription() == null ^ this.getDescription() == null) return false; + if (other.getDescription() != null && other.getDescription().equals(this.getDescription()) == false) return false; + if (other.getDefaultTaskStartToCloseTimeout() == null ^ this.getDefaultTaskStartToCloseTimeout() == null) return false; + if (other.getDefaultTaskStartToCloseTimeout() != null && other.getDefaultTaskStartToCloseTimeout().equals(this.getDefaultTaskStartToCloseTimeout()) == false) return false; + if (other.getDefaultTaskHeartbeatTimeout() == null ^ this.getDefaultTaskHeartbeatTimeout() == null) return false; + if (other.getDefaultTaskHeartbeatTimeout() != null && other.getDefaultTaskHeartbeatTimeout().equals(this.getDefaultTaskHeartbeatTimeout()) == false) return false; + if (other.getDefaultTaskList() == null ^ this.getDefaultTaskList() == null) return false; + if (other.getDefaultTaskList() != null && other.getDefaultTaskList().equals(this.getDefaultTaskList()) == false) return false; + if (other.getDefaultTaskScheduleToStartTimeout() == null ^ this.getDefaultTaskScheduleToStartTimeout() == null) return false; + if (other.getDefaultTaskScheduleToStartTimeout() != null && other.getDefaultTaskScheduleToStartTimeout().equals(this.getDefaultTaskScheduleToStartTimeout()) == false) return false; + if (other.getDefaultTaskScheduleToCloseTimeout() == null ^ this.getDefaultTaskScheduleToCloseTimeout() == null) return false; + if (other.getDefaultTaskScheduleToCloseTimeout() != null && other.getDefaultTaskScheduleToCloseTimeout().equals(this.getDefaultTaskScheduleToCloseTimeout()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/RegisterDomainRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/RegisterDomainRequest.java new file mode 100644 index 000000000000..7109190a98f0 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/RegisterDomainRequest.java @@ -0,0 +1,320 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#registerDomain(RegisterDomainRequest) RegisterDomain operation}. + *

+ * Registers a new domain. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#registerDomain(RegisterDomainRequest) + */ +public class RegisterDomainRequest extends AmazonWebServiceRequest { + + /** + * Name of the domain to register. The name must be unique.

The + * specified string must not start or end with whitespace. It must not + * contain a : (colon), / (slash), + * | (vertical bar), or any control characters + * (\u0000-\u001f | \u007f - \u009f). Also, it must not contain the + * literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String name; + + /** + * Textual description of the domain. + *

+ * Constraints:
+ * Length: 0 - 1024
+ */ + private String description; + + /** + * Specifies the duration--in days--for which the record + * (including the history) of workflow executions in this domain should + * be kept by the service. After the retention period, the workflow + * execution will not be available in the results of visibility calls. If + * a duration of NONE is specified, the records for workflow + * executions in this domain are not retained at all.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 1 - 8
+ */ + private String workflowExecutionRetentionPeriodInDays; + + /** + * Name of the domain to register. The name must be unique.

The + * specified string must not start or end with whitespace. It must not + * contain a : (colon), / (slash), + * | (vertical bar), or any control characters + * (\u0000-\u001f | \u007f - \u009f). Also, it must not contain the + * literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return Name of the domain to register. The name must be unique.

The + * specified string must not start or end with whitespace. It must not + * contain a : (colon), / (slash), + * | (vertical bar), or any control characters + * (\u0000-\u001f | \u007f - \u009f). Also, it must not contain the + * literal string "arn". + */ + public String getName() { + return name; + } + + /** + * Name of the domain to register. The name must be unique.

The + * specified string must not start or end with whitespace. It must not + * contain a : (colon), / (slash), + * | (vertical bar), or any control characters + * (\u0000-\u001f | \u007f - \u009f). Also, it must not contain the + * literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name Name of the domain to register. The name must be unique.

The + * specified string must not start or end with whitespace. It must not + * contain a : (colon), / (slash), + * | (vertical bar), or any control characters + * (\u0000-\u001f | \u007f - \u009f). Also, it must not contain the + * literal string "arn". + */ + public void setName(String name) { + this.name = name; + } + + /** + * Name of the domain to register. The name must be unique.

The + * specified string must not start or end with whitespace. It must not + * contain a : (colon), / (slash), + * | (vertical bar), or any control characters + * (\u0000-\u001f | \u007f - \u009f). Also, it must not contain the + * literal string "arn". + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name Name of the domain to register. The name must be unique.

The + * specified string must not start or end with whitespace. It must not + * contain a : (colon), / (slash), + * | (vertical bar), or any control characters + * (\u0000-\u001f | \u007f - \u009f). Also, it must not contain the + * literal string "arn". + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RegisterDomainRequest withName(String name) { + this.name = name; + return this; + } + + + /** + * Textual description of the domain. + *

+ * Constraints:
+ * Length: 0 - 1024
+ * + * @return Textual description of the domain. + */ + public String getDescription() { + return description; + } + + /** + * Textual description of the domain. + *

+ * Constraints:
+ * Length: 0 - 1024
+ * + * @param description Textual description of the domain. + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Textual description of the domain. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 1024
+ * + * @param description Textual description of the domain. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RegisterDomainRequest withDescription(String description) { + this.description = description; + return this; + } + + + /** + * Specifies the duration--in days--for which the record + * (including the history) of workflow executions in this domain should + * be kept by the service. After the retention period, the workflow + * execution will not be available in the results of visibility calls. If + * a duration of NONE is specified, the records for workflow + * executions in this domain are not retained at all.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 1 - 8
+ * + * @return Specifies the duration--in days--for which the record + * (including the history) of workflow executions in this domain should + * be kept by the service. After the retention period, the workflow + * execution will not be available in the results of visibility calls. If + * a duration of NONE is specified, the records for workflow + * executions in this domain are not retained at all.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + */ + public String getWorkflowExecutionRetentionPeriodInDays() { + return workflowExecutionRetentionPeriodInDays; + } + + /** + * Specifies the duration--in days--for which the record + * (including the history) of workflow executions in this domain should + * be kept by the service. After the retention period, the workflow + * execution will not be available in the results of visibility calls. If + * a duration of NONE is specified, the records for workflow + * executions in this domain are not retained at all.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 1 - 8
+ * + * @param workflowExecutionRetentionPeriodInDays Specifies the duration--in days--for which the record + * (including the history) of workflow executions in this domain should + * be kept by the service. After the retention period, the workflow + * execution will not be available in the results of visibility calls. If + * a duration of NONE is specified, the records for workflow + * executions in this domain are not retained at all.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + */ + public void setWorkflowExecutionRetentionPeriodInDays(String workflowExecutionRetentionPeriodInDays) { + this.workflowExecutionRetentionPeriodInDays = workflowExecutionRetentionPeriodInDays; + } + + /** + * Specifies the duration--in days--for which the record + * (including the history) of workflow executions in this domain should + * be kept by the service. After the retention period, the workflow + * execution will not be available in the results of visibility calls. If + * a duration of NONE is specified, the records for workflow + * executions in this domain are not retained at all.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 8
+ * + * @param workflowExecutionRetentionPeriodInDays Specifies the duration--in days--for which the record + * (including the history) of workflow executions in this domain should + * be kept by the service. After the retention period, the workflow + * execution will not be available in the results of visibility calls. If + * a duration of NONE is specified, the records for workflow + * executions in this domain are not retained at all.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RegisterDomainRequest withWorkflowExecutionRetentionPeriodInDays(String workflowExecutionRetentionPeriodInDays) { + this.workflowExecutionRetentionPeriodInDays = workflowExecutionRetentionPeriodInDays; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (name != null) sb.append("Name: " + name + ", "); + if (description != null) sb.append("Description: " + description + ", "); + if (workflowExecutionRetentionPeriodInDays != null) sb.append("WorkflowExecutionRetentionPeriodInDays: " + workflowExecutionRetentionPeriodInDays + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); + hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); + hashCode = prime * hashCode + ((getWorkflowExecutionRetentionPeriodInDays() == null) ? 0 : getWorkflowExecutionRetentionPeriodInDays().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof RegisterDomainRequest == false) return false; + RegisterDomainRequest other = (RegisterDomainRequest)obj; + + if (other.getName() == null ^ this.getName() == null) return false; + if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; + if (other.getDescription() == null ^ this.getDescription() == null) return false; + if (other.getDescription() != null && other.getDescription().equals(this.getDescription()) == false) return false; + if (other.getWorkflowExecutionRetentionPeriodInDays() == null ^ this.getWorkflowExecutionRetentionPeriodInDays() == null) return false; + if (other.getWorkflowExecutionRetentionPeriodInDays() != null && other.getWorkflowExecutionRetentionPeriodInDays().equals(this.getWorkflowExecutionRetentionPeriodInDays()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/RegisterWorkflowTypeRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/RegisterWorkflowTypeRequest.java new file mode 100644 index 000000000000..48e95e08bb5d --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/RegisterWorkflowTypeRequest.java @@ -0,0 +1,892 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#registerWorkflowType(RegisterWorkflowTypeRequest) RegisterWorkflowType operation}. + *

+ * Registers a new workflow type and its configuration settings + * in the specified domain. + *

+ *

+ * IMPORTANT: If the type already exists, then a TypeAlreadyExists + * fault is returned. You cannot change the configuration settings of a + * workflow type once it is registered and it must be registered as a new + * version. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#registerWorkflowType(RegisterWorkflowTypeRequest) + */ +public class RegisterWorkflowTypeRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain in which to register the workflow type. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * The name of the workflow type.

The specified string must not start + * or end with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String name; + + /** + * The version of the workflow type. The workflow type consists of + * the name and version, the combination of which must be unique within + * the domain. To get a list of all currently registered workflow types, + * use the ListWorkflowTypes action.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 64
+ */ + private String version; + + /** + * Textual description of the workflow type. + *

+ * Constraints:
+ * Length: 0 - 1024
+ */ + private String description; + + /** + * If set, specifies the default maximum duration of decision tasks for + * this workflow type. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String defaultTaskStartToCloseTimeout; + + /** + * If set, specifies the default maximum duration for executions of this + * workflow type. You can override this default when starting an + * execution through the StartWorkflowExecution Action or + * StartChildWorkflowExecution Decision.

The + * duration is specified in seconds. The valid values are integers + * greater than or equal to 0. Unlike some of the other timeout + * parameters in Amazon SWF, you cannot specify a value of "NONE" for + * defaultExecutionStartToCloseTimeout; there is a one-year + * max limit on the time that a workflow execution can run. Exceeding + * this limit will always cause the workflow execution to time out. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String defaultExecutionStartToCloseTimeout; + + /** + * If set, specifies the default task list to use for scheduling decision + * tasks for executions of this workflow type. This default is used only + * if a task list is not provided when starting the execution through the + * StartWorkflowExecution Action or + * StartChildWorkflowExecution Decision. + */ + private TaskList defaultTaskList; + + /** + * If set, specifies the default policy to use for the child workflow + * executions when a workflow execution of this type is terminated, by + * calling the TerminateWorkflowExecution action explicitly or due + * to an expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:

  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + */ + private String defaultChildPolicy; + + /** + * The name of the domain in which to register the workflow type. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain in which to register the workflow type. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain in which to register the workflow type. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain in which to register the workflow type. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain in which to register the workflow type. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain in which to register the workflow type. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RegisterWorkflowTypeRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * The name of the workflow type.

The specified string must not start + * or end with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the workflow type.

The specified string must not start + * or end with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + */ + public String getName() { + return name; + } + + /** + * The name of the workflow type.

The specified string must not start + * or end with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name The name of the workflow type.

The specified string must not start + * or end with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + */ + public void setName(String name) { + this.name = name; + } + + /** + * The name of the workflow type.

The specified string must not start + * or end with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name The name of the workflow type.

The specified string must not start + * or end with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RegisterWorkflowTypeRequest withName(String name) { + this.name = name; + return this; + } + + + /** + * The version of the workflow type. The workflow type consists of + * the name and version, the combination of which must be unique within + * the domain. To get a list of all currently registered workflow types, + * use the ListWorkflowTypes action.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @return The version of the workflow type. The workflow type consists of + * the name and version, the combination of which must be unique within + * the domain. To get a list of all currently registered workflow types, + * use the ListWorkflowTypes action.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + */ + public String getVersion() { + return version; + } + + /** + * The version of the workflow type. The workflow type consists of + * the name and version, the combination of which must be unique within + * the domain. To get a list of all currently registered workflow types, + * use the ListWorkflowTypes action.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param version The version of the workflow type. The workflow type consists of + * the name and version, the combination of which must be unique within + * the domain. To get a list of all currently registered workflow types, + * use the ListWorkflowTypes action.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + */ + public void setVersion(String version) { + this.version = version; + } + + /** + * The version of the workflow type. The workflow type consists of + * the name and version, the combination of which must be unique within + * the domain. To get a list of all currently registered workflow types, + * use the ListWorkflowTypes action.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param version The version of the workflow type. The workflow type consists of + * the name and version, the combination of which must be unique within + * the domain. To get a list of all currently registered workflow types, + * use the ListWorkflowTypes action.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RegisterWorkflowTypeRequest withVersion(String version) { + this.version = version; + return this; + } + + + /** + * Textual description of the workflow type. + *

+ * Constraints:
+ * Length: 0 - 1024
+ * + * @return Textual description of the workflow type. + */ + public String getDescription() { + return description; + } + + /** + * Textual description of the workflow type. + *

+ * Constraints:
+ * Length: 0 - 1024
+ * + * @param description Textual description of the workflow type. + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Textual description of the workflow type. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 1024
+ * + * @param description Textual description of the workflow type. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RegisterWorkflowTypeRequest withDescription(String description) { + this.description = description; + return this; + } + + + /** + * If set, specifies the default maximum duration of decision tasks for + * this workflow type. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return If set, specifies the default maximum duration of decision tasks for + * this workflow type. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + */ + public String getDefaultTaskStartToCloseTimeout() { + return defaultTaskStartToCloseTimeout; + } + + /** + * If set, specifies the default maximum duration of decision tasks for + * this workflow type. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultTaskStartToCloseTimeout If set, specifies the default maximum duration of decision tasks for + * this workflow type. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + */ + public void setDefaultTaskStartToCloseTimeout(String defaultTaskStartToCloseTimeout) { + this.defaultTaskStartToCloseTimeout = defaultTaskStartToCloseTimeout; + } + + /** + * If set, specifies the default maximum duration of decision tasks for + * this workflow type. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultTaskStartToCloseTimeout If set, specifies the default maximum duration of decision tasks for + * this workflow type. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RegisterWorkflowTypeRequest withDefaultTaskStartToCloseTimeout(String defaultTaskStartToCloseTimeout) { + this.defaultTaskStartToCloseTimeout = defaultTaskStartToCloseTimeout; + return this; + } + + + /** + * If set, specifies the default maximum duration for executions of this + * workflow type. You can override this default when starting an + * execution through the StartWorkflowExecution Action or + * StartChildWorkflowExecution Decision.

The + * duration is specified in seconds. The valid values are integers + * greater than or equal to 0. Unlike some of the other timeout + * parameters in Amazon SWF, you cannot specify a value of "NONE" for + * defaultExecutionStartToCloseTimeout; there is a one-year + * max limit on the time that a workflow execution can run. Exceeding + * this limit will always cause the workflow execution to time out. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return If set, specifies the default maximum duration for executions of this + * workflow type. You can override this default when starting an + * execution through the StartWorkflowExecution Action or + * StartChildWorkflowExecution Decision.

The + * duration is specified in seconds. The valid values are integers + * greater than or equal to 0. Unlike some of the other timeout + * parameters in Amazon SWF, you cannot specify a value of "NONE" for + * defaultExecutionStartToCloseTimeout; there is a one-year + * max limit on the time that a workflow execution can run. Exceeding + * this limit will always cause the workflow execution to time out. + */ + public String getDefaultExecutionStartToCloseTimeout() { + return defaultExecutionStartToCloseTimeout; + } + + /** + * If set, specifies the default maximum duration for executions of this + * workflow type. You can override this default when starting an + * execution through the StartWorkflowExecution Action or + * StartChildWorkflowExecution Decision.

The + * duration is specified in seconds. The valid values are integers + * greater than or equal to 0. Unlike some of the other timeout + * parameters in Amazon SWF, you cannot specify a value of "NONE" for + * defaultExecutionStartToCloseTimeout; there is a one-year + * max limit on the time that a workflow execution can run. Exceeding + * this limit will always cause the workflow execution to time out. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultExecutionStartToCloseTimeout If set, specifies the default maximum duration for executions of this + * workflow type. You can override this default when starting an + * execution through the StartWorkflowExecution Action or + * StartChildWorkflowExecution Decision.

The + * duration is specified in seconds. The valid values are integers + * greater than or equal to 0. Unlike some of the other timeout + * parameters in Amazon SWF, you cannot specify a value of "NONE" for + * defaultExecutionStartToCloseTimeout; there is a one-year + * max limit on the time that a workflow execution can run. Exceeding + * this limit will always cause the workflow execution to time out. + */ + public void setDefaultExecutionStartToCloseTimeout(String defaultExecutionStartToCloseTimeout) { + this.defaultExecutionStartToCloseTimeout = defaultExecutionStartToCloseTimeout; + } + + /** + * If set, specifies the default maximum duration for executions of this + * workflow type. You can override this default when starting an + * execution through the StartWorkflowExecution Action or + * StartChildWorkflowExecution Decision.

The + * duration is specified in seconds. The valid values are integers + * greater than or equal to 0. Unlike some of the other timeout + * parameters in Amazon SWF, you cannot specify a value of "NONE" for + * defaultExecutionStartToCloseTimeout; there is a one-year + * max limit on the time that a workflow execution can run. Exceeding + * this limit will always cause the workflow execution to time out. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultExecutionStartToCloseTimeout If set, specifies the default maximum duration for executions of this + * workflow type. You can override this default when starting an + * execution through the StartWorkflowExecution Action or + * StartChildWorkflowExecution Decision.

The + * duration is specified in seconds. The valid values are integers + * greater than or equal to 0. Unlike some of the other timeout + * parameters in Amazon SWF, you cannot specify a value of "NONE" for + * defaultExecutionStartToCloseTimeout; there is a one-year + * max limit on the time that a workflow execution can run. Exceeding + * this limit will always cause the workflow execution to time out. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RegisterWorkflowTypeRequest withDefaultExecutionStartToCloseTimeout(String defaultExecutionStartToCloseTimeout) { + this.defaultExecutionStartToCloseTimeout = defaultExecutionStartToCloseTimeout; + return this; + } + + + /** + * If set, specifies the default task list to use for scheduling decision + * tasks for executions of this workflow type. This default is used only + * if a task list is not provided when starting the execution through the + * StartWorkflowExecution Action or + * StartChildWorkflowExecution Decision. + * + * @return If set, specifies the default task list to use for scheduling decision + * tasks for executions of this workflow type. This default is used only + * if a task list is not provided when starting the execution through the + * StartWorkflowExecution Action or + * StartChildWorkflowExecution Decision. + */ + public TaskList getDefaultTaskList() { + return defaultTaskList; + } + + /** + * If set, specifies the default task list to use for scheduling decision + * tasks for executions of this workflow type. This default is used only + * if a task list is not provided when starting the execution through the + * StartWorkflowExecution Action or + * StartChildWorkflowExecution Decision. + * + * @param defaultTaskList If set, specifies the default task list to use for scheduling decision + * tasks for executions of this workflow type. This default is used only + * if a task list is not provided when starting the execution through the + * StartWorkflowExecution Action or + * StartChildWorkflowExecution Decision. + */ + public void setDefaultTaskList(TaskList defaultTaskList) { + this.defaultTaskList = defaultTaskList; + } + + /** + * If set, specifies the default task list to use for scheduling decision + * tasks for executions of this workflow type. This default is used only + * if a task list is not provided when starting the execution through the + * StartWorkflowExecution Action or + * StartChildWorkflowExecution Decision. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param defaultTaskList If set, specifies the default task list to use for scheduling decision + * tasks for executions of this workflow type. This default is used only + * if a task list is not provided when starting the execution through the + * StartWorkflowExecution Action or + * StartChildWorkflowExecution Decision. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RegisterWorkflowTypeRequest withDefaultTaskList(TaskList defaultTaskList) { + this.defaultTaskList = defaultTaskList; + return this; + } + + + /** + * If set, specifies the default policy to use for the child workflow + * executions when a workflow execution of this type is terminated, by + * calling the TerminateWorkflowExecution action explicitly or due + * to an expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:

  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @return If set, specifies the default policy to use for the child workflow + * executions when a workflow execution of this type is terminated, by + * calling the TerminateWorkflowExecution action explicitly or due + * to an expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:

  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ * + * @see ChildPolicy + */ + public String getDefaultChildPolicy() { + return defaultChildPolicy; + } + + /** + * If set, specifies the default policy to use for the child workflow + * executions when a workflow execution of this type is terminated, by + * calling the TerminateWorkflowExecution action explicitly or due + * to an expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:
  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param defaultChildPolicy If set, specifies the default policy to use for the child workflow + * executions when a workflow execution of this type is terminated, by + * calling the TerminateWorkflowExecution action explicitly or due + * to an expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:

  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ * + * @see ChildPolicy + */ + public void setDefaultChildPolicy(String defaultChildPolicy) { + this.defaultChildPolicy = defaultChildPolicy; + } + + /** + * If set, specifies the default policy to use for the child workflow + * executions when a workflow execution of this type is terminated, by + * calling the TerminateWorkflowExecution action explicitly or due + * to an expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:
  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param defaultChildPolicy If set, specifies the default policy to use for the child workflow + * executions when a workflow execution of this type is terminated, by + * calling the TerminateWorkflowExecution action explicitly or due + * to an expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:

  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public RegisterWorkflowTypeRequest withDefaultChildPolicy(String defaultChildPolicy) { + this.defaultChildPolicy = defaultChildPolicy; + return this; + } + + + /** + * If set, specifies the default policy to use for the child workflow + * executions when a workflow execution of this type is terminated, by + * calling the TerminateWorkflowExecution action explicitly or due + * to an expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:
  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param defaultChildPolicy If set, specifies the default policy to use for the child workflow + * executions when a workflow execution of this type is terminated, by + * calling the TerminateWorkflowExecution action explicitly or due + * to an expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:

  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ * + * @see ChildPolicy + */ + public void setDefaultChildPolicy(ChildPolicy defaultChildPolicy) { + this.defaultChildPolicy = defaultChildPolicy.toString(); + } + + /** + * If set, specifies the default policy to use for the child workflow + * executions when a workflow execution of this type is terminated, by + * calling the TerminateWorkflowExecution action explicitly or due + * to an expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:
  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param defaultChildPolicy If set, specifies the default policy to use for the child workflow + * executions when a workflow execution of this type is terminated, by + * calling the TerminateWorkflowExecution action explicitly or due + * to an expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:

  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public RegisterWorkflowTypeRequest withDefaultChildPolicy(ChildPolicy defaultChildPolicy) { + this.defaultChildPolicy = defaultChildPolicy.toString(); + return this; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (name != null) sb.append("Name: " + name + ", "); + if (version != null) sb.append("Version: " + version + ", "); + if (description != null) sb.append("Description: " + description + ", "); + if (defaultTaskStartToCloseTimeout != null) sb.append("DefaultTaskStartToCloseTimeout: " + defaultTaskStartToCloseTimeout + ", "); + if (defaultExecutionStartToCloseTimeout != null) sb.append("DefaultExecutionStartToCloseTimeout: " + defaultExecutionStartToCloseTimeout + ", "); + if (defaultTaskList != null) sb.append("DefaultTaskList: " + defaultTaskList + ", "); + if (defaultChildPolicy != null) sb.append("DefaultChildPolicy: " + defaultChildPolicy + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); + hashCode = prime * hashCode + ((getVersion() == null) ? 0 : getVersion().hashCode()); + hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); + hashCode = prime * hashCode + ((getDefaultTaskStartToCloseTimeout() == null) ? 0 : getDefaultTaskStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getDefaultExecutionStartToCloseTimeout() == null) ? 0 : getDefaultExecutionStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getDefaultTaskList() == null) ? 0 : getDefaultTaskList().hashCode()); + hashCode = prime * hashCode + ((getDefaultChildPolicy() == null) ? 0 : getDefaultChildPolicy().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof RegisterWorkflowTypeRequest == false) return false; + RegisterWorkflowTypeRequest other = (RegisterWorkflowTypeRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getName() == null ^ this.getName() == null) return false; + if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; + if (other.getVersion() == null ^ this.getVersion() == null) return false; + if (other.getVersion() != null && other.getVersion().equals(this.getVersion()) == false) return false; + if (other.getDescription() == null ^ this.getDescription() == null) return false; + if (other.getDescription() != null && other.getDescription().equals(this.getDescription()) == false) return false; + if (other.getDefaultTaskStartToCloseTimeout() == null ^ this.getDefaultTaskStartToCloseTimeout() == null) return false; + if (other.getDefaultTaskStartToCloseTimeout() != null && other.getDefaultTaskStartToCloseTimeout().equals(this.getDefaultTaskStartToCloseTimeout()) == false) return false; + if (other.getDefaultExecutionStartToCloseTimeout() == null ^ this.getDefaultExecutionStartToCloseTimeout() == null) return false; + if (other.getDefaultExecutionStartToCloseTimeout() != null && other.getDefaultExecutionStartToCloseTimeout().equals(this.getDefaultExecutionStartToCloseTimeout()) == false) return false; + if (other.getDefaultTaskList() == null ^ this.getDefaultTaskList() == null) return false; + if (other.getDefaultTaskList() != null && other.getDefaultTaskList().equals(this.getDefaultTaskList()) == false) return false; + if (other.getDefaultChildPolicy() == null ^ this.getDefaultChildPolicy() == null) return false; + if (other.getDefaultChildPolicy() != null && other.getDefaultChildPolicy().equals(this.getDefaultChildPolicy()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/RegistrationStatus.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/RegistrationStatus.java new file mode 100644 index 000000000000..c58b64692bcb --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/RegistrationStatus.java @@ -0,0 +1,56 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Registration Status + */ +public enum RegistrationStatus { + + REGISTERED("REGISTERED"), + DEPRECATED("DEPRECATED"); + + private String value; + + private RegistrationStatus(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return RegistrationStatus corresponding to the value + */ + public static RegistrationStatus fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("REGISTERED".equals(value)) { + return RegistrationStatus.REGISTERED; + } else if ("DEPRECATED".equals(value)) { + return RegistrationStatus.DEPRECATED; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelActivityTaskDecisionAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelActivityTaskDecisionAttributes.java new file mode 100644 index 000000000000..ff4116e78ed8 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelActivityTaskDecisionAttributes.java @@ -0,0 +1,116 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the RequestCancelActivityTask + * decision. + *

+ */ +public class RequestCancelActivityTaskDecisionAttributes { + + /** + * The activityId of the activity task to be canceled. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String activityId; + + /** + * The activityId of the activity task to be canceled. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The activityId of the activity task to be canceled. + */ + public String getActivityId() { + return activityId; + } + + /** + * The activityId of the activity task to be canceled. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param activityId The activityId of the activity task to be canceled. + */ + public void setActivityId(String activityId) { + this.activityId = activityId; + } + + /** + * The activityId of the activity task to be canceled. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param activityId The activityId of the activity task to be canceled. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RequestCancelActivityTaskDecisionAttributes withActivityId(String activityId) { + this.activityId = activityId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (activityId != null) sb.append("ActivityId: " + activityId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getActivityId() == null) ? 0 : getActivityId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof RequestCancelActivityTaskDecisionAttributes == false) return false; + RequestCancelActivityTaskDecisionAttributes other = (RequestCancelActivityTaskDecisionAttributes)obj; + + if (other.getActivityId() == null ^ this.getActivityId() == null) return false; + if (other.getActivityId() != null && other.getActivityId().equals(this.getActivityId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelActivityTaskFailedCause.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelActivityTaskFailedCause.java new file mode 100644 index 000000000000..e5268445e384 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelActivityTaskFailedCause.java @@ -0,0 +1,53 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Request Cancel Activity Task Failed Cause + */ +public enum RequestCancelActivityTaskFailedCause { + + ACTIVITY_ID_UNKNOWN("ACTIVITY_ID_UNKNOWN"); + + private String value; + + private RequestCancelActivityTaskFailedCause(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return RequestCancelActivityTaskFailedCause corresponding to the value + */ + public static RequestCancelActivityTaskFailedCause fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("ACTIVITY_ID_UNKNOWN".equals(value)) { + return RequestCancelActivityTaskFailedCause.ACTIVITY_ID_UNKNOWN; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelActivityTaskFailedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelActivityTaskFailedEventAttributes.java new file mode 100644 index 000000000000..bf7e577ff4e8 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelActivityTaskFailedEventAttributes.java @@ -0,0 +1,300 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the RequestCancelActivityTaskFailed + * event. + *

+ */ +public class RequestCancelActivityTaskFailedEventAttributes { + + /** + * The activityId provided in the RequestCancelActivityTask + * decision that failed. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String activityId; + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: ACTIVITY_ID_UNKNOWN + */ + private String cause; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelActivityTask decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + private Long decisionTaskCompletedEventId; + + /** + * The activityId provided in the RequestCancelActivityTask + * decision that failed. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The activityId provided in the RequestCancelActivityTask + * decision that failed. + */ + public String getActivityId() { + return activityId; + } + + /** + * The activityId provided in the RequestCancelActivityTask + * decision that failed. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param activityId The activityId provided in the RequestCancelActivityTask + * decision that failed. + */ + public void setActivityId(String activityId) { + this.activityId = activityId; + } + + /** + * The activityId provided in the RequestCancelActivityTask + * decision that failed. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param activityId The activityId provided in the RequestCancelActivityTask + * decision that failed. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RequestCancelActivityTaskFailedEventAttributes withActivityId(String activityId) { + this.activityId = activityId; + return this; + } + + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: ACTIVITY_ID_UNKNOWN + * + * @return The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see RequestCancelActivityTaskFailedCause + */ + public String getCause() { + return cause; + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: ACTIVITY_ID_UNKNOWN + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see RequestCancelActivityTaskFailedCause + */ + public void setCause(String cause) { + this.cause = cause; + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: ACTIVITY_ID_UNKNOWN + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see RequestCancelActivityTaskFailedCause + */ + public RequestCancelActivityTaskFailedEventAttributes withCause(String cause) { + this.cause = cause; + return this; + } + + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: ACTIVITY_ID_UNKNOWN + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see RequestCancelActivityTaskFailedCause + */ + public void setCause(RequestCancelActivityTaskFailedCause cause) { + this.cause = cause.toString(); + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: ACTIVITY_ID_UNKNOWN + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see RequestCancelActivityTaskFailedCause + */ + public RequestCancelActivityTaskFailedEventAttributes withCause(RequestCancelActivityTaskFailedCause cause) { + this.cause = cause.toString(); + return this; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelActivityTask decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelActivityTask decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelActivityTask decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelActivityTask decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelActivityTask decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelActivityTask decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RequestCancelActivityTaskFailedEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (activityId != null) sb.append("ActivityId: " + activityId + ", "); + if (cause != null) sb.append("Cause: " + cause + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getActivityId() == null) ? 0 : getActivityId().hashCode()); + hashCode = prime * hashCode + ((getCause() == null) ? 0 : getCause().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof RequestCancelActivityTaskFailedEventAttributes == false) return false; + RequestCancelActivityTaskFailedEventAttributes other = (RequestCancelActivityTaskFailedEventAttributes)obj; + + if (other.getActivityId() == null ^ this.getActivityId() == null) return false; + if (other.getActivityId() != null && other.getActivityId().equals(this.getActivityId()) == false) return false; + if (other.getCause() == null ^ this.getCause() == null) return false; + if (other.getCause() != null && other.getCause().equals(this.getCause()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelExternalWorkflowExecutionDecisionAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelExternalWorkflowExecutionDecisionAttributes.java new file mode 100644 index 000000000000..8ed60f7272a6 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelExternalWorkflowExecutionDecisionAttributes.java @@ -0,0 +1,240 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the + * RequestCancelExternalWorkflowExecution decision. + *

+ */ +public class RequestCancelExternalWorkflowExecutionDecisionAttributes { + + /** + * The workflowId of the external workflow execution to + * cancel. This field is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String workflowId; + + /** + * The runId of the external workflow execution to cancel. + *

+ * Constraints:
+ * Length: 0 - 64
+ */ + private String runId; + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String control; + + /** + * The workflowId of the external workflow execution to + * cancel. This field is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The workflowId of the external workflow execution to + * cancel. This field is required. + */ + public String getWorkflowId() { + return workflowId; + } + + /** + * The workflowId of the external workflow execution to + * cancel. This field is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the external workflow execution to + * cancel. This field is required. + */ + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + /** + * The workflowId of the external workflow execution to + * cancel. This field is required. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the external workflow execution to + * cancel. This field is required. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RequestCancelExternalWorkflowExecutionDecisionAttributes withWorkflowId(String workflowId) { + this.workflowId = workflowId; + return this; + } + + + /** + * The runId of the external workflow execution to cancel. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @return The runId of the external workflow execution to cancel. + */ + public String getRunId() { + return runId; + } + + /** + * The runId of the external workflow execution to cancel. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param runId The runId of the external workflow execution to cancel. + */ + public void setRunId(String runId) { + this.runId = runId; + } + + /** + * The runId of the external workflow execution to cancel. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param runId The runId of the external workflow execution to cancel. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RequestCancelExternalWorkflowExecutionDecisionAttributes withRunId(String runId) { + this.runId = runId; + return this; + } + + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + */ + public String getControl() { + return control; + } + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + */ + public void setControl(String control) { + this.control = control; + } + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RequestCancelExternalWorkflowExecutionDecisionAttributes withControl(String control) { + this.control = control; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowId != null) sb.append("WorkflowId: " + workflowId + ", "); + if (runId != null) sb.append("RunId: " + runId + ", "); + if (control != null) sb.append("Control: " + control + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowId() == null) ? 0 : getWorkflowId().hashCode()); + hashCode = prime * hashCode + ((getRunId() == null) ? 0 : getRunId().hashCode()); + hashCode = prime * hashCode + ((getControl() == null) ? 0 : getControl().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof RequestCancelExternalWorkflowExecutionDecisionAttributes == false) return false; + RequestCancelExternalWorkflowExecutionDecisionAttributes other = (RequestCancelExternalWorkflowExecutionDecisionAttributes)obj; + + if (other.getWorkflowId() == null ^ this.getWorkflowId() == null) return false; + if (other.getWorkflowId() != null && other.getWorkflowId().equals(this.getWorkflowId()) == false) return false; + if (other.getRunId() == null ^ this.getRunId() == null) return false; + if (other.getRunId() != null && other.getRunId().equals(this.getRunId()) == false) return false; + if (other.getControl() == null ^ this.getControl() == null) return false; + if (other.getControl() != null && other.getControl().equals(this.getControl()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelExternalWorkflowExecutionFailedCause.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelExternalWorkflowExecutionFailedCause.java new file mode 100644 index 000000000000..177277d50212 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelExternalWorkflowExecutionFailedCause.java @@ -0,0 +1,56 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Request Cancel External Workflow Execution Failed Cause + */ +public enum RequestCancelExternalWorkflowExecutionFailedCause { + + UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION("UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION"), + REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_RATE_EXCEEDED("REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_RATE_EXCEEDED"); + + private String value; + + private RequestCancelExternalWorkflowExecutionFailedCause(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return RequestCancelExternalWorkflowExecutionFailedCause corresponding to the value + */ + public static RequestCancelExternalWorkflowExecutionFailedCause fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION".equals(value)) { + return RequestCancelExternalWorkflowExecutionFailedCause.UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION; + } else if ("REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_RATE_EXCEEDED".equals(value)) { + return RequestCancelExternalWorkflowExecutionFailedCause.REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_RATE_EXCEEDED; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelExternalWorkflowExecutionFailedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelExternalWorkflowExecutionFailedEventAttributes.java new file mode 100644 index 000000000000..c31dc415878e --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelExternalWorkflowExecutionFailedEventAttributes.java @@ -0,0 +1,489 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the + * RequestCancelExternalWorkflowExecutionFailed event. + *

+ */ +public class RequestCancelExternalWorkflowExecutionFailedEventAttributes { + + /** + * The workflowId of the external workflow to which the + * cancel request was to be delivered. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String workflowId; + + /** + * The runId of the external workflow execution. + *

+ * Constraints:
+ * Length: 0 - 64
+ */ + private String runId; + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION, REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_RATE_EXCEEDED + */ + private String cause; + + /** + * The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this external workflow execution. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + private Long initiatedEventId; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelExternalWorkflowExecution decision for this + * cancellation request. This information can be useful for diagnosing + * problems by tracing back the cause of events. + */ + private Long decisionTaskCompletedEventId; + + private String control; + + /** + * The workflowId of the external workflow to which the + * cancel request was to be delivered. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The workflowId of the external workflow to which the + * cancel request was to be delivered. + */ + public String getWorkflowId() { + return workflowId; + } + + /** + * The workflowId of the external workflow to which the + * cancel request was to be delivered. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the external workflow to which the + * cancel request was to be delivered. + */ + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + /** + * The workflowId of the external workflow to which the + * cancel request was to be delivered. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the external workflow to which the + * cancel request was to be delivered. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RequestCancelExternalWorkflowExecutionFailedEventAttributes withWorkflowId(String workflowId) { + this.workflowId = workflowId; + return this; + } + + + /** + * The runId of the external workflow execution. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @return The runId of the external workflow execution. + */ + public String getRunId() { + return runId; + } + + /** + * The runId of the external workflow execution. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param runId The runId of the external workflow execution. + */ + public void setRunId(String runId) { + this.runId = runId; + } + + /** + * The runId of the external workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param runId The runId of the external workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RequestCancelExternalWorkflowExecutionFailedEventAttributes withRunId(String runId) { + this.runId = runId; + return this; + } + + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION, REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_RATE_EXCEEDED + * + * @return The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see RequestCancelExternalWorkflowExecutionFailedCause + */ + public String getCause() { + return cause; + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION, REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_RATE_EXCEEDED + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see RequestCancelExternalWorkflowExecutionFailedCause + */ + public void setCause(String cause) { + this.cause = cause; + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION, REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_RATE_EXCEEDED + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see RequestCancelExternalWorkflowExecutionFailedCause + */ + public RequestCancelExternalWorkflowExecutionFailedEventAttributes withCause(String cause) { + this.cause = cause; + return this; + } + + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION, REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_RATE_EXCEEDED + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see RequestCancelExternalWorkflowExecutionFailedCause + */ + public void setCause(RequestCancelExternalWorkflowExecutionFailedCause cause) { + this.cause = cause.toString(); + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION, REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_RATE_EXCEEDED + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see RequestCancelExternalWorkflowExecutionFailedCause + */ + public RequestCancelExternalWorkflowExecutionFailedEventAttributes withCause(RequestCancelExternalWorkflowExecutionFailedCause cause) { + this.cause = cause.toString(); + return this; + } + + /** + * The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this external workflow execution. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @return The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this external workflow execution. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + public Long getInitiatedEventId() { + return initiatedEventId; + } + + /** + * The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this external workflow execution. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @param initiatedEventId The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this external workflow execution. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + */ + public void setInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + } + + /** + * The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this external workflow execution. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param initiatedEventId The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this external workflow execution. This information can be useful for + * diagnosing problems by tracing back the chain of events leading up to + * this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RequestCancelExternalWorkflowExecutionFailedEventAttributes withInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + return this; + } + + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelExternalWorkflowExecution decision for this + * cancellation request. This information can be useful for diagnosing + * problems by tracing back the cause of events. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelExternalWorkflowExecution decision for this + * cancellation request. This information can be useful for diagnosing + * problems by tracing back the cause of events. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelExternalWorkflowExecution decision for this + * cancellation request. This information can be useful for diagnosing + * problems by tracing back the cause of events. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelExternalWorkflowExecution decision for this + * cancellation request. This information can be useful for diagnosing + * problems by tracing back the cause of events. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelExternalWorkflowExecution decision for this + * cancellation request. This information can be useful for diagnosing + * problems by tracing back the cause of events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelExternalWorkflowExecution decision for this + * cancellation request. This information can be useful for diagnosing + * problems by tracing back the cause of events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RequestCancelExternalWorkflowExecutionFailedEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * Returns the value of the Control property for this object. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The value of the Control property for this object. + */ + public String getControl() { + return control; + } + + /** + * Sets the value of the Control property for this object. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control The new value for the Control property for this object. + */ + public void setControl(String control) { + this.control = control; + } + + /** + * Sets the value of the Control property for this object. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control The new value for the Control property for this object. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RequestCancelExternalWorkflowExecutionFailedEventAttributes withControl(String control) { + this.control = control; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowId != null) sb.append("WorkflowId: " + workflowId + ", "); + if (runId != null) sb.append("RunId: " + runId + ", "); + if (cause != null) sb.append("Cause: " + cause + ", "); + if (initiatedEventId != null) sb.append("InitiatedEventId: " + initiatedEventId + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + if (control != null) sb.append("Control: " + control + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowId() == null) ? 0 : getWorkflowId().hashCode()); + hashCode = prime * hashCode + ((getRunId() == null) ? 0 : getRunId().hashCode()); + hashCode = prime * hashCode + ((getCause() == null) ? 0 : getCause().hashCode()); + hashCode = prime * hashCode + ((getInitiatedEventId() == null) ? 0 : getInitiatedEventId().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + hashCode = prime * hashCode + ((getControl() == null) ? 0 : getControl().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof RequestCancelExternalWorkflowExecutionFailedEventAttributes == false) return false; + RequestCancelExternalWorkflowExecutionFailedEventAttributes other = (RequestCancelExternalWorkflowExecutionFailedEventAttributes)obj; + + if (other.getWorkflowId() == null ^ this.getWorkflowId() == null) return false; + if (other.getWorkflowId() != null && other.getWorkflowId().equals(this.getWorkflowId()) == false) return false; + if (other.getRunId() == null ^ this.getRunId() == null) return false; + if (other.getRunId() != null && other.getRunId().equals(this.getRunId()) == false) return false; + if (other.getCause() == null ^ this.getCause() == null) return false; + if (other.getCause() != null && other.getCause().equals(this.getCause()) == false) return false; + if (other.getInitiatedEventId() == null ^ this.getInitiatedEventId() == null) return false; + if (other.getInitiatedEventId() != null && other.getInitiatedEventId().equals(this.getInitiatedEventId()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + if (other.getControl() == null ^ this.getControl() == null) return false; + if (other.getControl() != null && other.getControl().equals(this.getControl()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelExternalWorkflowExecutionInitiatedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelExternalWorkflowExecutionInitiatedEventAttributes.java new file mode 100644 index 000000000000..1e5e67f74720 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelExternalWorkflowExecutionInitiatedEventAttributes.java @@ -0,0 +1,318 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the + * RequestCancelExternalWorkflowExecutionInitiated event. + *

+ */ +public class RequestCancelExternalWorkflowExecutionInitiatedEventAttributes { + + /** + * The workflowId of the external workflow execution to be + * canceled. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String workflowId; + + /** + * The runId of the external workflow execution to be + * canceled. + *

+ * Constraints:
+ * Length: 0 - 64
+ */ + private String runId; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelExternalWorkflowExecution decision for this + * cancellation request. This information can be useful for diagnosing + * problems by tracing back the cause of events. + */ + private Long decisionTaskCompletedEventId; + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String control; + + /** + * The workflowId of the external workflow execution to be + * canceled. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The workflowId of the external workflow execution to be + * canceled. + */ + public String getWorkflowId() { + return workflowId; + } + + /** + * The workflowId of the external workflow execution to be + * canceled. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the external workflow execution to be + * canceled. + */ + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + /** + * The workflowId of the external workflow execution to be + * canceled. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the external workflow execution to be + * canceled. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RequestCancelExternalWorkflowExecutionInitiatedEventAttributes withWorkflowId(String workflowId) { + this.workflowId = workflowId; + return this; + } + + + /** + * The runId of the external workflow execution to be + * canceled. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @return The runId of the external workflow execution to be + * canceled. + */ + public String getRunId() { + return runId; + } + + /** + * The runId of the external workflow execution to be + * canceled. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param runId The runId of the external workflow execution to be + * canceled. + */ + public void setRunId(String runId) { + this.runId = runId; + } + + /** + * The runId of the external workflow execution to be + * canceled. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param runId The runId of the external workflow execution to be + * canceled. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RequestCancelExternalWorkflowExecutionInitiatedEventAttributes withRunId(String runId) { + this.runId = runId; + return this; + } + + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelExternalWorkflowExecution decision for this + * cancellation request. This information can be useful for diagnosing + * problems by tracing back the cause of events. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelExternalWorkflowExecution decision for this + * cancellation request. This information can be useful for diagnosing + * problems by tracing back the cause of events. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelExternalWorkflowExecution decision for this + * cancellation request. This information can be useful for diagnosing + * problems by tracing back the cause of events. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelExternalWorkflowExecution decision for this + * cancellation request. This information can be useful for diagnosing + * problems by tracing back the cause of events. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelExternalWorkflowExecution decision for this + * cancellation request. This information can be useful for diagnosing + * problems by tracing back the cause of events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * RequestCancelExternalWorkflowExecution decision for this + * cancellation request. This information can be useful for diagnosing + * problems by tracing back the cause of events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RequestCancelExternalWorkflowExecutionInitiatedEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + */ + public String getControl() { + return control; + } + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + */ + public void setControl(String control) { + this.control = control; + } + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RequestCancelExternalWorkflowExecutionInitiatedEventAttributes withControl(String control) { + this.control = control; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowId != null) sb.append("WorkflowId: " + workflowId + ", "); + if (runId != null) sb.append("RunId: " + runId + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + if (control != null) sb.append("Control: " + control + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowId() == null) ? 0 : getWorkflowId().hashCode()); + hashCode = prime * hashCode + ((getRunId() == null) ? 0 : getRunId().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + hashCode = prime * hashCode + ((getControl() == null) ? 0 : getControl().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof RequestCancelExternalWorkflowExecutionInitiatedEventAttributes == false) return false; + RequestCancelExternalWorkflowExecutionInitiatedEventAttributes other = (RequestCancelExternalWorkflowExecutionInitiatedEventAttributes)obj; + + if (other.getWorkflowId() == null ^ this.getWorkflowId() == null) return false; + if (other.getWorkflowId() != null && other.getWorkflowId().equals(this.getWorkflowId()) == false) return false; + if (other.getRunId() == null ^ this.getRunId() == null) return false; + if (other.getRunId() != null && other.getRunId().equals(this.getRunId()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + if (other.getControl() == null ^ this.getControl() == null) return false; + if (other.getControl() != null && other.getControl().equals(this.getControl()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelWorkflowExecutionRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelWorkflowExecutionRequest.java new file mode 100644 index 000000000000..f951736e7394 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/RequestCancelWorkflowExecutionRequest.java @@ -0,0 +1,245 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#requestCancelWorkflowExecution(RequestCancelWorkflowExecutionRequest) RequestCancelWorkflowExecution operation}. + *

+ * Records a WorkflowExecutionCancelRequested event in the + * currently running workflow execution identified by the given domain, + * workflowId, and runId. This logically requests the cancellation of the + * workflow execution as a whole. It is up to the decider to take + * appropriate actions when it receives an execution history with this + * event. + *

+ *

+ * NOTE: If the runId is not specified, the + * WorkflowExecutionCancelRequested event is recorded in the history of + * the current open workflow execution with the specified workflowId in + * the domain. + *

+ *

+ * NOTE: Because this action allows the workflow to properly clean + * up and gracefully close, it should be used instead of + * TerminateWorkflowExecution when possible. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#requestCancelWorkflowExecution(RequestCancelWorkflowExecutionRequest) + */ +public class RequestCancelWorkflowExecutionRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain containing the workflow execution to cancel. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * The workflowId of the workflow execution to cancel. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String workflowId; + + /** + * The runId of the workflow execution to cancel. + *

+ * Constraints:
+ * Length: 0 - 64
+ */ + private String runId; + + /** + * The name of the domain containing the workflow execution to cancel. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain containing the workflow execution to cancel. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain containing the workflow execution to cancel. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain containing the workflow execution to cancel. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain containing the workflow execution to cancel. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain containing the workflow execution to cancel. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RequestCancelWorkflowExecutionRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * The workflowId of the workflow execution to cancel. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The workflowId of the workflow execution to cancel. + */ + public String getWorkflowId() { + return workflowId; + } + + /** + * The workflowId of the workflow execution to cancel. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the workflow execution to cancel. + */ + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + /** + * The workflowId of the workflow execution to cancel. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the workflow execution to cancel. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RequestCancelWorkflowExecutionRequest withWorkflowId(String workflowId) { + this.workflowId = workflowId; + return this; + } + + + /** + * The runId of the workflow execution to cancel. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @return The runId of the workflow execution to cancel. + */ + public String getRunId() { + return runId; + } + + /** + * The runId of the workflow execution to cancel. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param runId The runId of the workflow execution to cancel. + */ + public void setRunId(String runId) { + this.runId = runId; + } + + /** + * The runId of the workflow execution to cancel. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param runId The runId of the workflow execution to cancel. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RequestCancelWorkflowExecutionRequest withRunId(String runId) { + this.runId = runId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (workflowId != null) sb.append("WorkflowId: " + workflowId + ", "); + if (runId != null) sb.append("RunId: " + runId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getWorkflowId() == null) ? 0 : getWorkflowId().hashCode()); + hashCode = prime * hashCode + ((getRunId() == null) ? 0 : getRunId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof RequestCancelWorkflowExecutionRequest == false) return false; + RequestCancelWorkflowExecutionRequest other = (RequestCancelWorkflowExecutionRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getWorkflowId() == null ^ this.getWorkflowId() == null) return false; + if (other.getWorkflowId() != null && other.getWorkflowId().equals(this.getWorkflowId()) == false) return false; + if (other.getRunId() == null ^ this.getRunId() == null) return false; + if (other.getRunId() != null && other.getRunId().equals(this.getRunId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/RespondActivityTaskCanceledRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/RespondActivityTaskCanceledRequest.java new file mode 100644 index 000000000000..f907f1816f70 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/RespondActivityTaskCanceledRequest.java @@ -0,0 +1,214 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#respondActivityTaskCanceled(RespondActivityTaskCanceledRequest) RespondActivityTaskCanceled operation}. + *

+ * Used by workers to tell the service that the ActivityTask identified + * by the taskToken was successfully canceled. Additional + * details can be optionally provided using the + * details argument. + *

+ *

+ * These details (if provided) appear in the + * ActivityTaskCanceled event added to the workflow history. + *

+ *

+ * IMPORTANT: Only use this operation if the canceled flag of a + * RecordActivityTaskHeartbeat request returns true and if the activity + * can be safely undone or abandoned. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#respondActivityTaskCanceled(RespondActivityTaskCanceledRequest) + */ +public class RespondActivityTaskCanceledRequest extends AmazonWebServiceRequest { + + /** + * The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + *

+ * Constraints:
+ * Length: 1 - 1024
+ */ + private String taskToken; + + /** + * Optional information about the cancellation. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String details; + + /** + * The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @return The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + */ + public String getTaskToken() { + return taskToken; + } + + /** + * The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @param taskToken The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + */ + public void setTaskToken(String taskToken) { + this.taskToken = taskToken; + } + + /** + * The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @param taskToken The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RespondActivityTaskCanceledRequest withTaskToken(String taskToken) { + this.taskToken = taskToken; + return this; + } + + + /** + * Optional information about the cancellation. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Optional information about the cancellation. + */ + public String getDetails() { + return details; + } + + /** + * Optional information about the cancellation. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details Optional information about the cancellation. + */ + public void setDetails(String details) { + this.details = details; + } + + /** + * Optional information about the cancellation. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details Optional information about the cancellation. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RespondActivityTaskCanceledRequest withDetails(String details) { + this.details = details; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (taskToken != null) sb.append("TaskToken: " + taskToken + ", "); + if (details != null) sb.append("Details: " + details + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTaskToken() == null) ? 0 : getTaskToken().hashCode()); + hashCode = prime * hashCode + ((getDetails() == null) ? 0 : getDetails().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof RespondActivityTaskCanceledRequest == false) return false; + RespondActivityTaskCanceledRequest other = (RespondActivityTaskCanceledRequest)obj; + + if (other.getTaskToken() == null ^ this.getTaskToken() == null) return false; + if (other.getTaskToken() != null && other.getTaskToken().equals(this.getTaskToken()) == false) return false; + if (other.getDetails() == null ^ this.getDetails() == null) return false; + if (other.getDetails() != null && other.getDetails().equals(this.getDetails()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/RespondActivityTaskCompletedRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/RespondActivityTaskCompletedRequest.java new file mode 100644 index 000000000000..59db3e78cc57 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/RespondActivityTaskCompletedRequest.java @@ -0,0 +1,222 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#respondActivityTaskCompleted(RespondActivityTaskCompletedRequest) RespondActivityTaskCompleted operation}. + *

+ * Used by workers to tell the service that the ActivityTask identified + * by the taskToken completed successfully with a + * result (if provided). + *

+ *

+ * The result appears in the + * ActivityTaskCompleted event in the workflow history. + *

+ *

+ * IMPORTANT: If the requested task does not complete + * successfully, use RespondActivityTaskFailed instead. If the worker + * finds that the task is canceled through the canceled flag returned by + * RecordActivityTaskHeartbeat, it should cancel the task, clean up and + * then call RespondActivityTaskCanceled. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#respondActivityTaskCompleted(RespondActivityTaskCompletedRequest) + */ +public class RespondActivityTaskCompletedRequest extends AmazonWebServiceRequest { + + /** + * The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + *

+ * Constraints:
+ * Length: 1 - 1024
+ */ + private String taskToken; + + /** + * The result of the activity task. It is a free form string that is + * implementation specific. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String result; + + /** + * The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @return The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + */ + public String getTaskToken() { + return taskToken; + } + + /** + * The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @param taskToken The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + */ + public void setTaskToken(String taskToken) { + this.taskToken = taskToken; + } + + /** + * The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @param taskToken The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RespondActivityTaskCompletedRequest withTaskToken(String taskToken) { + this.taskToken = taskToken; + return this; + } + + + /** + * The result of the activity task. It is a free form string that is + * implementation specific. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The result of the activity task. It is a free form string that is + * implementation specific. + */ + public String getResult() { + return result; + } + + /** + * The result of the activity task. It is a free form string that is + * implementation specific. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param result The result of the activity task. It is a free form string that is + * implementation specific. + */ + public void setResult(String result) { + this.result = result; + } + + /** + * The result of the activity task. It is a free form string that is + * implementation specific. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param result The result of the activity task. It is a free form string that is + * implementation specific. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RespondActivityTaskCompletedRequest withResult(String result) { + this.result = result; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (taskToken != null) sb.append("TaskToken: " + taskToken + ", "); + if (result != null) sb.append("Result: " + result + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTaskToken() == null) ? 0 : getTaskToken().hashCode()); + hashCode = prime * hashCode + ((getResult() == null) ? 0 : getResult().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof RespondActivityTaskCompletedRequest == false) return false; + RespondActivityTaskCompletedRequest other = (RespondActivityTaskCompletedRequest)obj; + + if (other.getTaskToken() == null ^ this.getTaskToken() == null) return false; + if (other.getTaskToken() != null && other.getTaskToken().equals(this.getTaskToken()) == false) return false; + if (other.getResult() == null ^ this.getResult() == null) return false; + if (other.getResult() != null && other.getResult().equals(this.getResult()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/RespondActivityTaskFailedRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/RespondActivityTaskFailedRequest.java new file mode 100644 index 000000000000..edd1ff7475e7 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/RespondActivityTaskFailedRequest.java @@ -0,0 +1,263 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#respondActivityTaskFailed(RespondActivityTaskFailedRequest) RespondActivityTaskFailed operation}. + *

+ * Used by workers to tell the service that the ActivityTask identified + * by the taskToken has failed with reason (if + * specified). + *

+ *

+ * The reason and details appear in the + * ActivityTaskFailed event added to the workflow history. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#respondActivityTaskFailed(RespondActivityTaskFailedRequest) + */ +public class RespondActivityTaskFailedRequest extends AmazonWebServiceRequest { + + /** + * The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + *

+ * Constraints:
+ * Length: 1 - 1024
+ */ + private String taskToken; + + /** + * Description of the error that may assist in diagnostics. + *

+ * Constraints:
+ * Length: 0 - 256
+ */ + private String reason; + + /** + * Optional detailed information about the failure. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String details; + + /** + * The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @return The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + */ + public String getTaskToken() { + return taskToken; + } + + /** + * The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @param taskToken The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + */ + public void setTaskToken(String taskToken) { + this.taskToken = taskToken; + } + + /** + * The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @param taskToken The taskToken of the ActivityTask. The + * taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RespondActivityTaskFailedRequest withTaskToken(String taskToken) { + this.taskToken = taskToken; + return this; + } + + + /** + * Description of the error that may assist in diagnostics. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @return Description of the error that may assist in diagnostics. + */ + public String getReason() { + return reason; + } + + /** + * Description of the error that may assist in diagnostics. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param reason Description of the error that may assist in diagnostics. + */ + public void setReason(String reason) { + this.reason = reason; + } + + /** + * Description of the error that may assist in diagnostics. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param reason Description of the error that may assist in diagnostics. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RespondActivityTaskFailedRequest withReason(String reason) { + this.reason = reason; + return this; + } + + + /** + * Optional detailed information about the failure. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Optional detailed information about the failure. + */ + public String getDetails() { + return details; + } + + /** + * Optional detailed information about the failure. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details Optional detailed information about the failure. + */ + public void setDetails(String details) { + this.details = details; + } + + /** + * Optional detailed information about the failure. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details Optional detailed information about the failure. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RespondActivityTaskFailedRequest withDetails(String details) { + this.details = details; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (taskToken != null) sb.append("TaskToken: " + taskToken + ", "); + if (reason != null) sb.append("Reason: " + reason + ", "); + if (details != null) sb.append("Details: " + details + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTaskToken() == null) ? 0 : getTaskToken().hashCode()); + hashCode = prime * hashCode + ((getReason() == null) ? 0 : getReason().hashCode()); + hashCode = prime * hashCode + ((getDetails() == null) ? 0 : getDetails().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof RespondActivityTaskFailedRequest == false) return false; + RespondActivityTaskFailedRequest other = (RespondActivityTaskFailedRequest)obj; + + if (other.getTaskToken() == null ^ this.getTaskToken() == null) return false; + if (other.getTaskToken() != null && other.getTaskToken().equals(this.getTaskToken()) == false) return false; + if (other.getReason() == null ^ this.getReason() == null) return false; + if (other.getReason() != null && other.getReason().equals(this.getReason()) == false) return false; + if (other.getDetails() == null ^ this.getDetails() == null) return false; + if (other.getDetails() != null && other.getDetails().equals(this.getDetails()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/RespondDecisionTaskCompletedRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/RespondDecisionTaskCompletedRequest.java new file mode 100644 index 000000000000..816a97c5ab54 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/RespondDecisionTaskCompletedRequest.java @@ -0,0 +1,307 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#respondDecisionTaskCompleted(RespondDecisionTaskCompletedRequest) RespondDecisionTaskCompleted operation}. + *

+ * Used by deciders to tell the service that the DecisionTask identified + * by the taskToken has successfully completed. The + * decisions argument specifies the list of decisions made + * while processing the task. + *

+ *

+ * A + * DecisionTaskCompleted event is added + * to the workflow history. The executionContext specified + * is attached to the event in the workflow execution history. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#respondDecisionTaskCompleted(RespondDecisionTaskCompletedRequest) + */ +public class RespondDecisionTaskCompletedRequest extends AmazonWebServiceRequest { + + /** + * The taskToken from the DecisionTask. + * The taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + *

+ * Constraints:
+ * Length: 1 - 1024
+ */ + private String taskToken; + + /** + * The list of decisions (possibly empty) made by the decider while + * processing this decision task. See the docs for the Decision + * structure for details. + */ + private java.util.List decisions; + + /** + * User defined context to add to workflow execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String executionContext; + + /** + * The taskToken from the DecisionTask. + * The taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @return The taskToken from the DecisionTask. + * The taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + */ + public String getTaskToken() { + return taskToken; + } + + /** + * The taskToken from the DecisionTask. + * The taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @param taskToken The taskToken from the DecisionTask. + * The taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + */ + public void setTaskToken(String taskToken) { + this.taskToken = taskToken; + } + + /** + * The taskToken from the DecisionTask. + * The taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 1024
+ * + * @param taskToken The taskToken from the DecisionTask. + * The taskToken is generated by the service and should be + * treated as an opaque value. If the task is passed to another process, + * its taskToken must also be passed. This enables it to + * provide its progress and respond with results. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RespondDecisionTaskCompletedRequest withTaskToken(String taskToken) { + this.taskToken = taskToken; + return this; + } + + + /** + * The list of decisions (possibly empty) made by the decider while + * processing this decision task. See the docs for the Decision + * structure for details. + * + * @return The list of decisions (possibly empty) made by the decider while + * processing this decision task. See the docs for the Decision + * structure for details. + */ + public java.util.List getDecisions() { + + if (decisions == null) { + decisions = new java.util.ArrayList(); + } + return decisions; + } + + /** + * The list of decisions (possibly empty) made by the decider while + * processing this decision task. See the docs for the Decision + * structure for details. + * + * @param decisions The list of decisions (possibly empty) made by the decider while + * processing this decision task. See the docs for the Decision + * structure for details. + */ + public void setDecisions(java.util.Collection decisions) { + if (decisions == null) { + this.decisions = null; + return; + } + + java.util.List decisionsCopy = new java.util.ArrayList(decisions.size()); + decisionsCopy.addAll(decisions); + this.decisions = decisionsCopy; + } + + /** + * The list of decisions (possibly empty) made by the decider while + * processing this decision task. See the docs for the Decision + * structure for details. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisions The list of decisions (possibly empty) made by the decider while + * processing this decision task. See the docs for the Decision + * structure for details. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RespondDecisionTaskCompletedRequest withDecisions(Decision... decisions) { + if (getDecisions() == null) setDecisions(new java.util.ArrayList(decisions.length)); + for (Decision value : decisions) { + getDecisions().add(value); + } + return this; + } + + /** + * The list of decisions (possibly empty) made by the decider while + * processing this decision task. See the docs for the Decision + * structure for details. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisions The list of decisions (possibly empty) made by the decider while + * processing this decision task. See the docs for the Decision + * structure for details. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RespondDecisionTaskCompletedRequest withDecisions(java.util.Collection decisions) { + if (decisions == null) { + this.decisions = null; + } else { + java.util.List decisionsCopy = new java.util.ArrayList(decisions.size()); + decisionsCopy.addAll(decisions); + this.decisions = decisionsCopy; + } + + return this; + } + + /** + * User defined context to add to workflow execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return User defined context to add to workflow execution. + */ + public String getExecutionContext() { + return executionContext; + } + + /** + * User defined context to add to workflow execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param executionContext User defined context to add to workflow execution. + */ + public void setExecutionContext(String executionContext) { + this.executionContext = executionContext; + } + + /** + * User defined context to add to workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param executionContext User defined context to add to workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public RespondDecisionTaskCompletedRequest withExecutionContext(String executionContext) { + this.executionContext = executionContext; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (taskToken != null) sb.append("TaskToken: " + taskToken + ", "); + if (decisions != null) sb.append("Decisions: " + decisions + ", "); + if (executionContext != null) sb.append("ExecutionContext: " + executionContext + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTaskToken() == null) ? 0 : getTaskToken().hashCode()); + hashCode = prime * hashCode + ((getDecisions() == null) ? 0 : getDecisions().hashCode()); + hashCode = prime * hashCode + ((getExecutionContext() == null) ? 0 : getExecutionContext().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof RespondDecisionTaskCompletedRequest == false) return false; + RespondDecisionTaskCompletedRequest other = (RespondDecisionTaskCompletedRequest)obj; + + if (other.getTaskToken() == null ^ this.getTaskToken() == null) return false; + if (other.getTaskToken() != null && other.getTaskToken().equals(this.getTaskToken()) == false) return false; + if (other.getDecisions() == null ^ this.getDecisions() == null) return false; + if (other.getDecisions() != null && other.getDecisions().equals(this.getDecisions()) == false) return false; + if (other.getExecutionContext() == null ^ this.getExecutionContext() == null) return false; + if (other.getExecutionContext() != null && other.getExecutionContext().equals(this.getExecutionContext()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/Run.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/Run.java new file mode 100644 index 000000000000..48761c245127 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/Run.java @@ -0,0 +1,129 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Specifies the runId of a workflow execution. + *

+ */ +public class Run { + + /** + * The runId of a workflow execution. This Id is generated + * by the service and can be used to uniquely identify the workflow + * execution within a domain. + *

+ * Constraints:
+ * Length: 1 - 64
+ */ + private String runId; + + /** + * The runId of a workflow execution. This Id is generated + * by the service and can be used to uniquely identify the workflow + * execution within a domain. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @return The runId of a workflow execution. This Id is generated + * by the service and can be used to uniquely identify the workflow + * execution within a domain. + */ + public String getRunId() { + return runId; + } + + /** + * The runId of a workflow execution. This Id is generated + * by the service and can be used to uniquely identify the workflow + * execution within a domain. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param runId The runId of a workflow execution. This Id is generated + * by the service and can be used to uniquely identify the workflow + * execution within a domain. + */ + public void setRunId(String runId) { + this.runId = runId; + } + + /** + * The runId of a workflow execution. This Id is generated + * by the service and can be used to uniquely identify the workflow + * execution within a domain. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param runId The runId of a workflow execution. This Id is generated + * by the service and can be used to uniquely identify the workflow + * execution within a domain. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public Run withRunId(String runId) { + this.runId = runId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (runId != null) sb.append("RunId: " + runId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getRunId() == null) ? 0 : getRunId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof Run == false) return false; + Run other = (Run)obj; + + if (other.getRunId() == null ^ this.getRunId() == null) return false; + if (other.getRunId() != null && other.getRunId().equals(this.getRunId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ScheduleActivityTaskDecisionAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ScheduleActivityTaskDecisionAttributes.java new file mode 100644 index 000000000000..fa24953b6998 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ScheduleActivityTaskDecisionAttributes.java @@ -0,0 +1,902 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the ScheduleActivityTask decision. + *

+ */ +public class ScheduleActivityTaskDecisionAttributes { + + /** + * The type of the activity task to schedule. This field is required. + */ + private ActivityType activityType; + + /** + * The activityId of the activity task. This field is + * required.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String activityId; + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the activity. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String control; + + /** + * The input provided to the activity task. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String input; + + /** + * The maximum duration for this activity task.

The valid values are + * integers greater than or equal to 0. An integer value can + * be used to specify the duration in seconds while NONE can + * be used to specify unlimited duration. A schedule-to-close + * timeout for this activity task must be specified either as a default + * for the activity type or through this field. If neither this field is + * set nor a default schedule-to-close timeout was specified at + * registration time then a fault will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String scheduleToCloseTimeout; + + /** + * If set, specifies the name of the task list in which to schedule the + * activity task. If not specified, the defaultTaskList + * registered with the activity type will be used. A task list for + * this activity task must be specified either as a default for the + * activity type or through this field. If neither this field is set nor + * a default task list was specified at registration time then a fault + * will be returned.

The specified string must not start or end + * with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + */ + private TaskList taskList; + + /** + * If set, specifies the maximum duration the activity task can wait to + * be assigned to a worker. This overrides the default schedule-to-start + * timeout specified when registering the activity type using + * RegisterActivityType.

The valid values are integers greater + * than or equal to 0. An integer value can be used to + * specify the duration in seconds while NONE can be used to + * specify unlimited duration. A schedule-to-start timeout for this + * activity task must be specified either as a default for the activity + * type or through this field. If neither this field is set nor a default + * schedule-to-start timeout was specified at registration time then a + * fault will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String scheduleToStartTimeout; + + /** + * If set, specifies the maximum duration a worker may take to process + * this activity task. This overrides the default start-to-close timeout + * specified when registering the activity type using + * RegisterActivityType.

The valid values are integers greater + * than or equal to 0. An integer value can be used to + * specify the duration in seconds while NONE can be used to + * specify unlimited duration. A start-to-close timeout for this + * activity task must be specified either as a default for the activity + * type or through this field. If neither this field is set nor a default + * start-to-close timeout was specified at registration time then a fault + * will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String startToCloseTimeout; + + /** + * If set, specifies the maximum time before which a worker processing a + * task of this type must report progress by calling + * RecordActivityTaskHeartbeat. If the timeout is exceeded, the + * activity task is automatically timed out. If the worker subsequently + * attempts to record a heartbeat or returns a result, it will be + * ignored. This overrides the default heartbeat timeout specified when + * registering the activity type using RegisterActivityType. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String heartbeatTimeout; + + /** + * The type of the activity task to schedule. This field is required. + * + * @return The type of the activity task to schedule. This field is required. + */ + public ActivityType getActivityType() { + return activityType; + } + + /** + * The type of the activity task to schedule. This field is required. + * + * @param activityType The type of the activity task to schedule. This field is required. + */ + public void setActivityType(ActivityType activityType) { + this.activityType = activityType; + } + + /** + * The type of the activity task to schedule. This field is required. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param activityType The type of the activity task to schedule. This field is required. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ScheduleActivityTaskDecisionAttributes withActivityType(ActivityType activityType) { + this.activityType = activityType; + return this; + } + + + /** + * The activityId of the activity task. This field is + * required.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The activityId of the activity task. This field is + * required.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + */ + public String getActivityId() { + return activityId; + } + + /** + * The activityId of the activity task. This field is + * required.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param activityId The activityId of the activity task. This field is + * required.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + */ + public void setActivityId(String activityId) { + this.activityId = activityId; + } + + /** + * The activityId of the activity task. This field is + * required.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param activityId The activityId of the activity task. This field is + * required.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ScheduleActivityTaskDecisionAttributes withActivityId(String activityId) { + this.activityId = activityId; + return this; + } + + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the activity. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the activity. + */ + public String getControl() { + return control; + } + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the activity. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the activity. + */ + public void setControl(String control) { + this.control = control; + } + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the activity. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the activity. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ScheduleActivityTaskDecisionAttributes withControl(String control) { + this.control = control; + return this; + } + + + /** + * The input provided to the activity task. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The input provided to the activity task. + */ + public String getInput() { + return input; + } + + /** + * The input provided to the activity task. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input The input provided to the activity task. + */ + public void setInput(String input) { + this.input = input; + } + + /** + * The input provided to the activity task. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input The input provided to the activity task. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ScheduleActivityTaskDecisionAttributes withInput(String input) { + this.input = input; + return this; + } + + + /** + * The maximum duration for this activity task.

The valid values are + * integers greater than or equal to 0. An integer value can + * be used to specify the duration in seconds while NONE can + * be used to specify unlimited duration. A schedule-to-close + * timeout for this activity task must be specified either as a default + * for the activity type or through this field. If neither this field is + * set nor a default schedule-to-close timeout was specified at + * registration time then a fault will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return The maximum duration for this activity task.

The valid values are + * integers greater than or equal to 0. An integer value can + * be used to specify the duration in seconds while NONE can + * be used to specify unlimited duration. A schedule-to-close + * timeout for this activity task must be specified either as a default + * for the activity type or through this field. If neither this field is + * set nor a default schedule-to-close timeout was specified at + * registration time then a fault will be returned. + */ + public String getScheduleToCloseTimeout() { + return scheduleToCloseTimeout; + } + + /** + * The maximum duration for this activity task.

The valid values are + * integers greater than or equal to 0. An integer value can + * be used to specify the duration in seconds while NONE can + * be used to specify unlimited duration. A schedule-to-close + * timeout for this activity task must be specified either as a default + * for the activity type or through this field. If neither this field is + * set nor a default schedule-to-close timeout was specified at + * registration time then a fault will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param scheduleToCloseTimeout The maximum duration for this activity task.

The valid values are + * integers greater than or equal to 0. An integer value can + * be used to specify the duration in seconds while NONE can + * be used to specify unlimited duration. A schedule-to-close + * timeout for this activity task must be specified either as a default + * for the activity type or through this field. If neither this field is + * set nor a default schedule-to-close timeout was specified at + * registration time then a fault will be returned. + */ + public void setScheduleToCloseTimeout(String scheduleToCloseTimeout) { + this.scheduleToCloseTimeout = scheduleToCloseTimeout; + } + + /** + * The maximum duration for this activity task.

The valid values are + * integers greater than or equal to 0. An integer value can + * be used to specify the duration in seconds while NONE can + * be used to specify unlimited duration. A schedule-to-close + * timeout for this activity task must be specified either as a default + * for the activity type or through this field. If neither this field is + * set nor a default schedule-to-close timeout was specified at + * registration time then a fault will be returned. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param scheduleToCloseTimeout The maximum duration for this activity task.

The valid values are + * integers greater than or equal to 0. An integer value can + * be used to specify the duration in seconds while NONE can + * be used to specify unlimited duration. A schedule-to-close + * timeout for this activity task must be specified either as a default + * for the activity type or through this field. If neither this field is + * set nor a default schedule-to-close timeout was specified at + * registration time then a fault will be returned. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ScheduleActivityTaskDecisionAttributes withScheduleToCloseTimeout(String scheduleToCloseTimeout) { + this.scheduleToCloseTimeout = scheduleToCloseTimeout; + return this; + } + + + /** + * If set, specifies the name of the task list in which to schedule the + * activity task. If not specified, the defaultTaskList + * registered with the activity type will be used. A task list for + * this activity task must be specified either as a default for the + * activity type or through this field. If neither this field is set nor + * a default task list was specified at registration time then a fault + * will be returned.

The specified string must not start or end + * with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + * + * @return If set, specifies the name of the task list in which to schedule the + * activity task. If not specified, the defaultTaskList + * registered with the activity type will be used. A task list for + * this activity task must be specified either as a default for the + * activity type or through this field. If neither this field is set nor + * a default task list was specified at registration time then a fault + * will be returned.

The specified string must not start or end + * with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + */ + public TaskList getTaskList() { + return taskList; + } + + /** + * If set, specifies the name of the task list in which to schedule the + * activity task. If not specified, the defaultTaskList + * registered with the activity type will be used. A task list for + * this activity task must be specified either as a default for the + * activity type or through this field. If neither this field is set nor + * a default task list was specified at registration time then a fault + * will be returned.

The specified string must not start or end + * with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + * + * @param taskList If set, specifies the name of the task list in which to schedule the + * activity task. If not specified, the defaultTaskList + * registered with the activity type will be used. A task list for + * this activity task must be specified either as a default for the + * activity type or through this field. If neither this field is set nor + * a default task list was specified at registration time then a fault + * will be returned.

The specified string must not start or end + * with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + */ + public void setTaskList(TaskList taskList) { + this.taskList = taskList; + } + + /** + * If set, specifies the name of the task list in which to schedule the + * activity task. If not specified, the defaultTaskList + * registered with the activity type will be used. A task list for + * this activity task must be specified either as a default for the + * activity type or through this field. If neither this field is set nor + * a default task list was specified at registration time then a fault + * will be returned.

The specified string must not start or end + * with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param taskList If set, specifies the name of the task list in which to schedule the + * activity task. If not specified, the defaultTaskList + * registered with the activity type will be used. A task list for + * this activity task must be specified either as a default for the + * activity type or through this field. If neither this field is set nor + * a default task list was specified at registration time then a fault + * will be returned.

The specified string must not start or end + * with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ScheduleActivityTaskDecisionAttributes withTaskList(TaskList taskList) { + this.taskList = taskList; + return this; + } + + + /** + * If set, specifies the maximum duration the activity task can wait to + * be assigned to a worker. This overrides the default schedule-to-start + * timeout specified when registering the activity type using + * RegisterActivityType.

The valid values are integers greater + * than or equal to 0. An integer value can be used to + * specify the duration in seconds while NONE can be used to + * specify unlimited duration. A schedule-to-start timeout for this + * activity task must be specified either as a default for the activity + * type or through this field. If neither this field is set nor a default + * schedule-to-start timeout was specified at registration time then a + * fault will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return If set, specifies the maximum duration the activity task can wait to + * be assigned to a worker. This overrides the default schedule-to-start + * timeout specified when registering the activity type using + * RegisterActivityType.

The valid values are integers greater + * than or equal to 0. An integer value can be used to + * specify the duration in seconds while NONE can be used to + * specify unlimited duration. A schedule-to-start timeout for this + * activity task must be specified either as a default for the activity + * type or through this field. If neither this field is set nor a default + * schedule-to-start timeout was specified at registration time then a + * fault will be returned. + */ + public String getScheduleToStartTimeout() { + return scheduleToStartTimeout; + } + + /** + * If set, specifies the maximum duration the activity task can wait to + * be assigned to a worker. This overrides the default schedule-to-start + * timeout specified when registering the activity type using + * RegisterActivityType.

The valid values are integers greater + * than or equal to 0. An integer value can be used to + * specify the duration in seconds while NONE can be used to + * specify unlimited duration. A schedule-to-start timeout for this + * activity task must be specified either as a default for the activity + * type or through this field. If neither this field is set nor a default + * schedule-to-start timeout was specified at registration time then a + * fault will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param scheduleToStartTimeout If set, specifies the maximum duration the activity task can wait to + * be assigned to a worker. This overrides the default schedule-to-start + * timeout specified when registering the activity type using + * RegisterActivityType.

The valid values are integers greater + * than or equal to 0. An integer value can be used to + * specify the duration in seconds while NONE can be used to + * specify unlimited duration. A schedule-to-start timeout for this + * activity task must be specified either as a default for the activity + * type or through this field. If neither this field is set nor a default + * schedule-to-start timeout was specified at registration time then a + * fault will be returned. + */ + public void setScheduleToStartTimeout(String scheduleToStartTimeout) { + this.scheduleToStartTimeout = scheduleToStartTimeout; + } + + /** + * If set, specifies the maximum duration the activity task can wait to + * be assigned to a worker. This overrides the default schedule-to-start + * timeout specified when registering the activity type using + * RegisterActivityType.

The valid values are integers greater + * than or equal to 0. An integer value can be used to + * specify the duration in seconds while NONE can be used to + * specify unlimited duration. A schedule-to-start timeout for this + * activity task must be specified either as a default for the activity + * type or through this field. If neither this field is set nor a default + * schedule-to-start timeout was specified at registration time then a + * fault will be returned. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param scheduleToStartTimeout If set, specifies the maximum duration the activity task can wait to + * be assigned to a worker. This overrides the default schedule-to-start + * timeout specified when registering the activity type using + * RegisterActivityType.

The valid values are integers greater + * than or equal to 0. An integer value can be used to + * specify the duration in seconds while NONE can be used to + * specify unlimited duration. A schedule-to-start timeout for this + * activity task must be specified either as a default for the activity + * type or through this field. If neither this field is set nor a default + * schedule-to-start timeout was specified at registration time then a + * fault will be returned. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ScheduleActivityTaskDecisionAttributes withScheduleToStartTimeout(String scheduleToStartTimeout) { + this.scheduleToStartTimeout = scheduleToStartTimeout; + return this; + } + + + /** + * If set, specifies the maximum duration a worker may take to process + * this activity task. This overrides the default start-to-close timeout + * specified when registering the activity type using + * RegisterActivityType.

The valid values are integers greater + * than or equal to 0. An integer value can be used to + * specify the duration in seconds while NONE can be used to + * specify unlimited duration. A start-to-close timeout for this + * activity task must be specified either as a default for the activity + * type or through this field. If neither this field is set nor a default + * start-to-close timeout was specified at registration time then a fault + * will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return If set, specifies the maximum duration a worker may take to process + * this activity task. This overrides the default start-to-close timeout + * specified when registering the activity type using + * RegisterActivityType.

The valid values are integers greater + * than or equal to 0. An integer value can be used to + * specify the duration in seconds while NONE can be used to + * specify unlimited duration. A start-to-close timeout for this + * activity task must be specified either as a default for the activity + * type or through this field. If neither this field is set nor a default + * start-to-close timeout was specified at registration time then a fault + * will be returned. + */ + public String getStartToCloseTimeout() { + return startToCloseTimeout; + } + + /** + * If set, specifies the maximum duration a worker may take to process + * this activity task. This overrides the default start-to-close timeout + * specified when registering the activity type using + * RegisterActivityType.

The valid values are integers greater + * than or equal to 0. An integer value can be used to + * specify the duration in seconds while NONE can be used to + * specify unlimited duration. A start-to-close timeout for this + * activity task must be specified either as a default for the activity + * type or through this field. If neither this field is set nor a default + * start-to-close timeout was specified at registration time then a fault + * will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param startToCloseTimeout If set, specifies the maximum duration a worker may take to process + * this activity task. This overrides the default start-to-close timeout + * specified when registering the activity type using + * RegisterActivityType.

The valid values are integers greater + * than or equal to 0. An integer value can be used to + * specify the duration in seconds while NONE can be used to + * specify unlimited duration. A start-to-close timeout for this + * activity task must be specified either as a default for the activity + * type or through this field. If neither this field is set nor a default + * start-to-close timeout was specified at registration time then a fault + * will be returned. + */ + public void setStartToCloseTimeout(String startToCloseTimeout) { + this.startToCloseTimeout = startToCloseTimeout; + } + + /** + * If set, specifies the maximum duration a worker may take to process + * this activity task. This overrides the default start-to-close timeout + * specified when registering the activity type using + * RegisterActivityType.

The valid values are integers greater + * than or equal to 0. An integer value can be used to + * specify the duration in seconds while NONE can be used to + * specify unlimited duration. A start-to-close timeout for this + * activity task must be specified either as a default for the activity + * type or through this field. If neither this field is set nor a default + * start-to-close timeout was specified at registration time then a fault + * will be returned. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param startToCloseTimeout If set, specifies the maximum duration a worker may take to process + * this activity task. This overrides the default start-to-close timeout + * specified when registering the activity type using + * RegisterActivityType.

The valid values are integers greater + * than or equal to 0. An integer value can be used to + * specify the duration in seconds while NONE can be used to + * specify unlimited duration. A start-to-close timeout for this + * activity task must be specified either as a default for the activity + * type or through this field. If neither this field is set nor a default + * start-to-close timeout was specified at registration time then a fault + * will be returned. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ScheduleActivityTaskDecisionAttributes withStartToCloseTimeout(String startToCloseTimeout) { + this.startToCloseTimeout = startToCloseTimeout; + return this; + } + + + /** + * If set, specifies the maximum time before which a worker processing a + * task of this type must report progress by calling + * RecordActivityTaskHeartbeat. If the timeout is exceeded, the + * activity task is automatically timed out. If the worker subsequently + * attempts to record a heartbeat or returns a result, it will be + * ignored. This overrides the default heartbeat timeout specified when + * registering the activity type using RegisterActivityType. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return If set, specifies the maximum time before which a worker processing a + * task of this type must report progress by calling + * RecordActivityTaskHeartbeat. If the timeout is exceeded, the + * activity task is automatically timed out. If the worker subsequently + * attempts to record a heartbeat or returns a result, it will be + * ignored. This overrides the default heartbeat timeout specified when + * registering the activity type using RegisterActivityType. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + */ + public String getHeartbeatTimeout() { + return heartbeatTimeout; + } + + /** + * If set, specifies the maximum time before which a worker processing a + * task of this type must report progress by calling + * RecordActivityTaskHeartbeat. If the timeout is exceeded, the + * activity task is automatically timed out. If the worker subsequently + * attempts to record a heartbeat or returns a result, it will be + * ignored. This overrides the default heartbeat timeout specified when + * registering the activity type using RegisterActivityType. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param heartbeatTimeout If set, specifies the maximum time before which a worker processing a + * task of this type must report progress by calling + * RecordActivityTaskHeartbeat. If the timeout is exceeded, the + * activity task is automatically timed out. If the worker subsequently + * attempts to record a heartbeat or returns a result, it will be + * ignored. This overrides the default heartbeat timeout specified when + * registering the activity type using RegisterActivityType. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + */ + public void setHeartbeatTimeout(String heartbeatTimeout) { + this.heartbeatTimeout = heartbeatTimeout; + } + + /** + * If set, specifies the maximum time before which a worker processing a + * task of this type must report progress by calling + * RecordActivityTaskHeartbeat. If the timeout is exceeded, the + * activity task is automatically timed out. If the worker subsequently + * attempts to record a heartbeat or returns a result, it will be + * ignored. This overrides the default heartbeat timeout specified when + * registering the activity type using RegisterActivityType. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param heartbeatTimeout If set, specifies the maximum time before which a worker processing a + * task of this type must report progress by calling + * RecordActivityTaskHeartbeat. If the timeout is exceeded, the + * activity task is automatically timed out. If the worker subsequently + * attempts to record a heartbeat or returns a result, it will be + * ignored. This overrides the default heartbeat timeout specified when + * registering the activity type using RegisterActivityType. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ScheduleActivityTaskDecisionAttributes withHeartbeatTimeout(String heartbeatTimeout) { + this.heartbeatTimeout = heartbeatTimeout; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (activityType != null) sb.append("ActivityType: " + activityType + ", "); + if (activityId != null) sb.append("ActivityId: " + activityId + ", "); + if (control != null) sb.append("Control: " + control + ", "); + if (input != null) sb.append("Input: " + input + ", "); + if (scheduleToCloseTimeout != null) sb.append("ScheduleToCloseTimeout: " + scheduleToCloseTimeout + ", "); + if (taskList != null) sb.append("TaskList: " + taskList + ", "); + if (scheduleToStartTimeout != null) sb.append("ScheduleToStartTimeout: " + scheduleToStartTimeout + ", "); + if (startToCloseTimeout != null) sb.append("StartToCloseTimeout: " + startToCloseTimeout + ", "); + if (heartbeatTimeout != null) sb.append("HeartbeatTimeout: " + heartbeatTimeout + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getActivityType() == null) ? 0 : getActivityType().hashCode()); + hashCode = prime * hashCode + ((getActivityId() == null) ? 0 : getActivityId().hashCode()); + hashCode = prime * hashCode + ((getControl() == null) ? 0 : getControl().hashCode()); + hashCode = prime * hashCode + ((getInput() == null) ? 0 : getInput().hashCode()); + hashCode = prime * hashCode + ((getScheduleToCloseTimeout() == null) ? 0 : getScheduleToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getTaskList() == null) ? 0 : getTaskList().hashCode()); + hashCode = prime * hashCode + ((getScheduleToStartTimeout() == null) ? 0 : getScheduleToStartTimeout().hashCode()); + hashCode = prime * hashCode + ((getStartToCloseTimeout() == null) ? 0 : getStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getHeartbeatTimeout() == null) ? 0 : getHeartbeatTimeout().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ScheduleActivityTaskDecisionAttributes == false) return false; + ScheduleActivityTaskDecisionAttributes other = (ScheduleActivityTaskDecisionAttributes)obj; + + if (other.getActivityType() == null ^ this.getActivityType() == null) return false; + if (other.getActivityType() != null && other.getActivityType().equals(this.getActivityType()) == false) return false; + if (other.getActivityId() == null ^ this.getActivityId() == null) return false; + if (other.getActivityId() != null && other.getActivityId().equals(this.getActivityId()) == false) return false; + if (other.getControl() == null ^ this.getControl() == null) return false; + if (other.getControl() != null && other.getControl().equals(this.getControl()) == false) return false; + if (other.getInput() == null ^ this.getInput() == null) return false; + if (other.getInput() != null && other.getInput().equals(this.getInput()) == false) return false; + if (other.getScheduleToCloseTimeout() == null ^ this.getScheduleToCloseTimeout() == null) return false; + if (other.getScheduleToCloseTimeout() != null && other.getScheduleToCloseTimeout().equals(this.getScheduleToCloseTimeout()) == false) return false; + if (other.getTaskList() == null ^ this.getTaskList() == null) return false; + if (other.getTaskList() != null && other.getTaskList().equals(this.getTaskList()) == false) return false; + if (other.getScheduleToStartTimeout() == null ^ this.getScheduleToStartTimeout() == null) return false; + if (other.getScheduleToStartTimeout() != null && other.getScheduleToStartTimeout().equals(this.getScheduleToStartTimeout()) == false) return false; + if (other.getStartToCloseTimeout() == null ^ this.getStartToCloseTimeout() == null) return false; + if (other.getStartToCloseTimeout() != null && other.getStartToCloseTimeout().equals(this.getStartToCloseTimeout()) == false) return false; + if (other.getHeartbeatTimeout() == null ^ this.getHeartbeatTimeout() == null) return false; + if (other.getHeartbeatTimeout() != null && other.getHeartbeatTimeout().equals(this.getHeartbeatTimeout()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ScheduleActivityTaskFailedCause.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ScheduleActivityTaskFailedCause.java new file mode 100644 index 000000000000..2b5f349e3a66 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ScheduleActivityTaskFailedCause.java @@ -0,0 +1,80 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Schedule Activity Task Failed Cause + */ +public enum ScheduleActivityTaskFailedCause { + + ACTIVITY_TYPE_DEPRECATED("ACTIVITY_TYPE_DEPRECATED"), + ACTIVITY_TYPE_DOES_NOT_EXIST("ACTIVITY_TYPE_DOES_NOT_EXIST"), + ACTIVITY_ID_ALREADY_IN_USE("ACTIVITY_ID_ALREADY_IN_USE"), + OPEN_ACTIVITIES_LIMIT_EXCEEDED("OPEN_ACTIVITIES_LIMIT_EXCEEDED"), + ACTIVITY_CREATION_RATE_EXCEEDED("ACTIVITY_CREATION_RATE_EXCEEDED"), + DEFAULT_SCHEDULE_TO_CLOSE_TIMEOUT_UNDEFINED("DEFAULT_SCHEDULE_TO_CLOSE_TIMEOUT_UNDEFINED"), + DEFAULT_TASK_LIST_UNDEFINED("DEFAULT_TASK_LIST_UNDEFINED"), + DEFAULT_SCHEDULE_TO_START_TIMEOUT_UNDEFINED("DEFAULT_SCHEDULE_TO_START_TIMEOUT_UNDEFINED"), + DEFAULT_START_TO_CLOSE_TIMEOUT_UNDEFINED("DEFAULT_START_TO_CLOSE_TIMEOUT_UNDEFINED"), + DEFAULT_HEARTBEAT_TIMEOUT_UNDEFINED("DEFAULT_HEARTBEAT_TIMEOUT_UNDEFINED"); + + private String value; + + private ScheduleActivityTaskFailedCause(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return ScheduleActivityTaskFailedCause corresponding to the value + */ + public static ScheduleActivityTaskFailedCause fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("ACTIVITY_TYPE_DEPRECATED".equals(value)) { + return ScheduleActivityTaskFailedCause.ACTIVITY_TYPE_DEPRECATED; + } else if ("ACTIVITY_TYPE_DOES_NOT_EXIST".equals(value)) { + return ScheduleActivityTaskFailedCause.ACTIVITY_TYPE_DOES_NOT_EXIST; + } else if ("ACTIVITY_ID_ALREADY_IN_USE".equals(value)) { + return ScheduleActivityTaskFailedCause.ACTIVITY_ID_ALREADY_IN_USE; + } else if ("OPEN_ACTIVITIES_LIMIT_EXCEEDED".equals(value)) { + return ScheduleActivityTaskFailedCause.OPEN_ACTIVITIES_LIMIT_EXCEEDED; + } else if ("ACTIVITY_CREATION_RATE_EXCEEDED".equals(value)) { + return ScheduleActivityTaskFailedCause.ACTIVITY_CREATION_RATE_EXCEEDED; + } else if ("DEFAULT_SCHEDULE_TO_CLOSE_TIMEOUT_UNDEFINED".equals(value)) { + return ScheduleActivityTaskFailedCause.DEFAULT_SCHEDULE_TO_CLOSE_TIMEOUT_UNDEFINED; + } else if ("DEFAULT_TASK_LIST_UNDEFINED".equals(value)) { + return ScheduleActivityTaskFailedCause.DEFAULT_TASK_LIST_UNDEFINED; + } else if ("DEFAULT_SCHEDULE_TO_START_TIMEOUT_UNDEFINED".equals(value)) { + return ScheduleActivityTaskFailedCause.DEFAULT_SCHEDULE_TO_START_TIMEOUT_UNDEFINED; + } else if ("DEFAULT_START_TO_CLOSE_TIMEOUT_UNDEFINED".equals(value)) { + return ScheduleActivityTaskFailedCause.DEFAULT_START_TO_CLOSE_TIMEOUT_UNDEFINED; + } else if ("DEFAULT_HEARTBEAT_TIMEOUT_UNDEFINED".equals(value)) { + return ScheduleActivityTaskFailedCause.DEFAULT_HEARTBEAT_TIMEOUT_UNDEFINED; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/ScheduleActivityTaskFailedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/ScheduleActivityTaskFailedEventAttributes.java new file mode 100644 index 000000000000..fc61da555460 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/ScheduleActivityTaskFailedEventAttributes.java @@ -0,0 +1,343 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the ScheduleActivityTaskFailed + * event. + *

+ */ +public class ScheduleActivityTaskFailedEventAttributes { + + /** + * The activity type provided in the ScheduleActivityTask + * decision that failed. + */ + private ActivityType activityType; + + /** + * The activityId provided in the ScheduleActivityTask + * decision that failed. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String activityId; + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: ACTIVITY_TYPE_DEPRECATED, ACTIVITY_TYPE_DOES_NOT_EXIST, ACTIVITY_ID_ALREADY_IN_USE, OPEN_ACTIVITIES_LIMIT_EXCEEDED, ACTIVITY_CREATION_RATE_EXCEEDED, DEFAULT_SCHEDULE_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_LIST_UNDEFINED, DEFAULT_SCHEDULE_TO_START_TIMEOUT_UNDEFINED, DEFAULT_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_HEARTBEAT_TIMEOUT_UNDEFINED + */ + private String cause; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision that resulted in the scheduling of this activity task. + * This information can be useful for diagnosing problems by tracing back + * the chain of events leading up to this event. + */ + private Long decisionTaskCompletedEventId; + + /** + * The activity type provided in the ScheduleActivityTask + * decision that failed. + * + * @return The activity type provided in the ScheduleActivityTask + * decision that failed. + */ + public ActivityType getActivityType() { + return activityType; + } + + /** + * The activity type provided in the ScheduleActivityTask + * decision that failed. + * + * @param activityType The activity type provided in the ScheduleActivityTask + * decision that failed. + */ + public void setActivityType(ActivityType activityType) { + this.activityType = activityType; + } + + /** + * The activity type provided in the ScheduleActivityTask + * decision that failed. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param activityType The activity type provided in the ScheduleActivityTask + * decision that failed. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ScheduleActivityTaskFailedEventAttributes withActivityType(ActivityType activityType) { + this.activityType = activityType; + return this; + } + + + /** + * The activityId provided in the ScheduleActivityTask + * decision that failed. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The activityId provided in the ScheduleActivityTask + * decision that failed. + */ + public String getActivityId() { + return activityId; + } + + /** + * The activityId provided in the ScheduleActivityTask + * decision that failed. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param activityId The activityId provided in the ScheduleActivityTask + * decision that failed. + */ + public void setActivityId(String activityId) { + this.activityId = activityId; + } + + /** + * The activityId provided in the ScheduleActivityTask + * decision that failed. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param activityId The activityId provided in the ScheduleActivityTask + * decision that failed. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ScheduleActivityTaskFailedEventAttributes withActivityId(String activityId) { + this.activityId = activityId; + return this; + } + + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: ACTIVITY_TYPE_DEPRECATED, ACTIVITY_TYPE_DOES_NOT_EXIST, ACTIVITY_ID_ALREADY_IN_USE, OPEN_ACTIVITIES_LIMIT_EXCEEDED, ACTIVITY_CREATION_RATE_EXCEEDED, DEFAULT_SCHEDULE_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_LIST_UNDEFINED, DEFAULT_SCHEDULE_TO_START_TIMEOUT_UNDEFINED, DEFAULT_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_HEARTBEAT_TIMEOUT_UNDEFINED + * + * @return The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see ScheduleActivityTaskFailedCause + */ + public String getCause() { + return cause; + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: ACTIVITY_TYPE_DEPRECATED, ACTIVITY_TYPE_DOES_NOT_EXIST, ACTIVITY_ID_ALREADY_IN_USE, OPEN_ACTIVITIES_LIMIT_EXCEEDED, ACTIVITY_CREATION_RATE_EXCEEDED, DEFAULT_SCHEDULE_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_LIST_UNDEFINED, DEFAULT_SCHEDULE_TO_START_TIMEOUT_UNDEFINED, DEFAULT_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_HEARTBEAT_TIMEOUT_UNDEFINED + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see ScheduleActivityTaskFailedCause + */ + public void setCause(String cause) { + this.cause = cause; + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: ACTIVITY_TYPE_DEPRECATED, ACTIVITY_TYPE_DOES_NOT_EXIST, ACTIVITY_ID_ALREADY_IN_USE, OPEN_ACTIVITIES_LIMIT_EXCEEDED, ACTIVITY_CREATION_RATE_EXCEEDED, DEFAULT_SCHEDULE_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_LIST_UNDEFINED, DEFAULT_SCHEDULE_TO_START_TIMEOUT_UNDEFINED, DEFAULT_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_HEARTBEAT_TIMEOUT_UNDEFINED + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ScheduleActivityTaskFailedCause + */ + public ScheduleActivityTaskFailedEventAttributes withCause(String cause) { + this.cause = cause; + return this; + } + + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: ACTIVITY_TYPE_DEPRECATED, ACTIVITY_TYPE_DOES_NOT_EXIST, ACTIVITY_ID_ALREADY_IN_USE, OPEN_ACTIVITIES_LIMIT_EXCEEDED, ACTIVITY_CREATION_RATE_EXCEEDED, DEFAULT_SCHEDULE_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_LIST_UNDEFINED, DEFAULT_SCHEDULE_TO_START_TIMEOUT_UNDEFINED, DEFAULT_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_HEARTBEAT_TIMEOUT_UNDEFINED + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see ScheduleActivityTaskFailedCause + */ + public void setCause(ScheduleActivityTaskFailedCause cause) { + this.cause = cause.toString(); + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: ACTIVITY_TYPE_DEPRECATED, ACTIVITY_TYPE_DOES_NOT_EXIST, ACTIVITY_ID_ALREADY_IN_USE, OPEN_ACTIVITIES_LIMIT_EXCEEDED, ACTIVITY_CREATION_RATE_EXCEEDED, DEFAULT_SCHEDULE_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_LIST_UNDEFINED, DEFAULT_SCHEDULE_TO_START_TIMEOUT_UNDEFINED, DEFAULT_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_HEARTBEAT_TIMEOUT_UNDEFINED + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ScheduleActivityTaskFailedCause + */ + public ScheduleActivityTaskFailedEventAttributes withCause(ScheduleActivityTaskFailedCause cause) { + this.cause = cause.toString(); + return this; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision that resulted in the scheduling of this activity task. + * This information can be useful for diagnosing problems by tracing back + * the chain of events leading up to this event. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision that resulted in the scheduling of this activity task. + * This information can be useful for diagnosing problems by tracing back + * the chain of events leading up to this event. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision that resulted in the scheduling of this activity task. + * This information can be useful for diagnosing problems by tracing back + * the chain of events leading up to this event. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision that resulted in the scheduling of this activity task. + * This information can be useful for diagnosing problems by tracing back + * the chain of events leading up to this event. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision that resulted in the scheduling of this activity task. + * This information can be useful for diagnosing problems by tracing back + * the chain of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision that resulted in the scheduling of this activity task. + * This information can be useful for diagnosing problems by tracing back + * the chain of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public ScheduleActivityTaskFailedEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (activityType != null) sb.append("ActivityType: " + activityType + ", "); + if (activityId != null) sb.append("ActivityId: " + activityId + ", "); + if (cause != null) sb.append("Cause: " + cause + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getActivityType() == null) ? 0 : getActivityType().hashCode()); + hashCode = prime * hashCode + ((getActivityId() == null) ? 0 : getActivityId().hashCode()); + hashCode = prime * hashCode + ((getCause() == null) ? 0 : getCause().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof ScheduleActivityTaskFailedEventAttributes == false) return false; + ScheduleActivityTaskFailedEventAttributes other = (ScheduleActivityTaskFailedEventAttributes)obj; + + if (other.getActivityType() == null ^ this.getActivityType() == null) return false; + if (other.getActivityType() != null && other.getActivityType().equals(this.getActivityType()) == false) return false; + if (other.getActivityId() == null ^ this.getActivityId() == null) return false; + if (other.getActivityId() != null && other.getActivityId().equals(this.getActivityId()) == false) return false; + if (other.getCause() == null ^ this.getCause() == null) return false; + if (other.getCause() != null && other.getCause().equals(this.getCause()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/SignalExternalWorkflowExecutionDecisionAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/SignalExternalWorkflowExecutionDecisionAttributes.java new file mode 100644 index 000000000000..2e49f0081947 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/SignalExternalWorkflowExecutionDecisionAttributes.java @@ -0,0 +1,364 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the SignalExternalWorkflowExecution + * decision. + *

+ */ +public class SignalExternalWorkflowExecutionDecisionAttributes { + + /** + * The workflowId of the workflow execution to be signaled. + * This field is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String workflowId; + + /** + * The runId of the workflow execution to be signaled. + *

+ * Constraints:
+ * Length: 0 - 64
+ */ + private String runId; + + /** + * The name of the signal.The target workflow execution will use the + * signal name and input to process the signal. This field is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String signalName; + + /** + * Optional input to be provided with the signal.The target workflow + * execution will use the signal name and input to process the signal. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String input; + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String control; + + /** + * The workflowId of the workflow execution to be signaled. + * This field is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The workflowId of the workflow execution to be signaled. + * This field is required. + */ + public String getWorkflowId() { + return workflowId; + } + + /** + * The workflowId of the workflow execution to be signaled. + * This field is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the workflow execution to be signaled. + * This field is required. + */ + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + /** + * The workflowId of the workflow execution to be signaled. + * This field is required. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the workflow execution to be signaled. + * This field is required. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalExternalWorkflowExecutionDecisionAttributes withWorkflowId(String workflowId) { + this.workflowId = workflowId; + return this; + } + + + /** + * The runId of the workflow execution to be signaled. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @return The runId of the workflow execution to be signaled. + */ + public String getRunId() { + return runId; + } + + /** + * The runId of the workflow execution to be signaled. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param runId The runId of the workflow execution to be signaled. + */ + public void setRunId(String runId) { + this.runId = runId; + } + + /** + * The runId of the workflow execution to be signaled. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param runId The runId of the workflow execution to be signaled. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalExternalWorkflowExecutionDecisionAttributes withRunId(String runId) { + this.runId = runId; + return this; + } + + + /** + * The name of the signal.The target workflow execution will use the + * signal name and input to process the signal. This field is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the signal.The target workflow execution will use the + * signal name and input to process the signal. This field is required. + */ + public String getSignalName() { + return signalName; + } + + /** + * The name of the signal.The target workflow execution will use the + * signal name and input to process the signal. This field is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param signalName The name of the signal.The target workflow execution will use the + * signal name and input to process the signal. This field is required. + */ + public void setSignalName(String signalName) { + this.signalName = signalName; + } + + /** + * The name of the signal.The target workflow execution will use the + * signal name and input to process the signal. This field is required. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param signalName The name of the signal.The target workflow execution will use the + * signal name and input to process the signal. This field is required. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalExternalWorkflowExecutionDecisionAttributes withSignalName(String signalName) { + this.signalName = signalName; + return this; + } + + + /** + * Optional input to be provided with the signal.The target workflow + * execution will use the signal name and input to process the signal. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Optional input to be provided with the signal.The target workflow + * execution will use the signal name and input to process the signal. + */ + public String getInput() { + return input; + } + + /** + * Optional input to be provided with the signal.The target workflow + * execution will use the signal name and input to process the signal. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input Optional input to be provided with the signal.The target workflow + * execution will use the signal name and input to process the signal. + */ + public void setInput(String input) { + this.input = input; + } + + /** + * Optional input to be provided with the signal.The target workflow + * execution will use the signal name and input to process the signal. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input Optional input to be provided with the signal.The target workflow + * execution will use the signal name and input to process the signal. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalExternalWorkflowExecutionDecisionAttributes withInput(String input) { + this.input = input; + return this; + } + + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. + */ + public String getControl() { + return control; + } + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. + */ + public void setControl(String control) { + this.control = control; + } + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalExternalWorkflowExecutionDecisionAttributes withControl(String control) { + this.control = control; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowId != null) sb.append("WorkflowId: " + workflowId + ", "); + if (runId != null) sb.append("RunId: " + runId + ", "); + if (signalName != null) sb.append("SignalName: " + signalName + ", "); + if (input != null) sb.append("Input: " + input + ", "); + if (control != null) sb.append("Control: " + control + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowId() == null) ? 0 : getWorkflowId().hashCode()); + hashCode = prime * hashCode + ((getRunId() == null) ? 0 : getRunId().hashCode()); + hashCode = prime * hashCode + ((getSignalName() == null) ? 0 : getSignalName().hashCode()); + hashCode = prime * hashCode + ((getInput() == null) ? 0 : getInput().hashCode()); + hashCode = prime * hashCode + ((getControl() == null) ? 0 : getControl().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof SignalExternalWorkflowExecutionDecisionAttributes == false) return false; + SignalExternalWorkflowExecutionDecisionAttributes other = (SignalExternalWorkflowExecutionDecisionAttributes)obj; + + if (other.getWorkflowId() == null ^ this.getWorkflowId() == null) return false; + if (other.getWorkflowId() != null && other.getWorkflowId().equals(this.getWorkflowId()) == false) return false; + if (other.getRunId() == null ^ this.getRunId() == null) return false; + if (other.getRunId() != null && other.getRunId().equals(this.getRunId()) == false) return false; + if (other.getSignalName() == null ^ this.getSignalName() == null) return false; + if (other.getSignalName() != null && other.getSignalName().equals(this.getSignalName()) == false) return false; + if (other.getInput() == null ^ this.getInput() == null) return false; + if (other.getInput() != null && other.getInput().equals(this.getInput()) == false) return false; + if (other.getControl() == null ^ this.getControl() == null) return false; + if (other.getControl() != null && other.getControl().equals(this.getControl()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/SignalExternalWorkflowExecutionFailedCause.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/SignalExternalWorkflowExecutionFailedCause.java new file mode 100644 index 000000000000..0bf349a0e7ec --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/SignalExternalWorkflowExecutionFailedCause.java @@ -0,0 +1,56 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Signal External Workflow Execution Failed Cause + */ +public enum SignalExternalWorkflowExecutionFailedCause { + + UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION("UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION"), + SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_RATE_EXCEEDED("SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_RATE_EXCEEDED"); + + private String value; + + private SignalExternalWorkflowExecutionFailedCause(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return SignalExternalWorkflowExecutionFailedCause corresponding to the value + */ + public static SignalExternalWorkflowExecutionFailedCause fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION".equals(value)) { + return SignalExternalWorkflowExecutionFailedCause.UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION; + } else if ("SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_RATE_EXCEEDED".equals(value)) { + return SignalExternalWorkflowExecutionFailedCause.SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_RATE_EXCEEDED; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/SignalExternalWorkflowExecutionFailedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/SignalExternalWorkflowExecutionFailedEventAttributes.java new file mode 100644 index 000000000000..ef7d76981997 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/SignalExternalWorkflowExecutionFailedEventAttributes.java @@ -0,0 +1,482 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the + * SignalExternalWorkflowExecutionFailed event. + *

+ */ +public class SignalExternalWorkflowExecutionFailedEventAttributes { + + /** + * The workflowId of the external workflow execution that + * the signal was being delivered to. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String workflowId; + + /** + * The runId of the external workflow execution that the + * signal was being delivered to. + *

+ * Constraints:
+ * Length: 0 - 64
+ */ + private String runId; + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION, SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_RATE_EXCEEDED + */ + private String cause; + + /** + * The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the + * SignalExternalWorkflowExecution decision to request this + * signal. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + */ + private Long initiatedEventId; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * SignalExternalWorkflowExecution decision for this signal. + * This information can be useful for diagnosing problems by tracing back + * the cause of events leading up to this event. + */ + private Long decisionTaskCompletedEventId; + + private String control; + + /** + * The workflowId of the external workflow execution that + * the signal was being delivered to. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The workflowId of the external workflow execution that + * the signal was being delivered to. + */ + public String getWorkflowId() { + return workflowId; + } + + /** + * The workflowId of the external workflow execution that + * the signal was being delivered to. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the external workflow execution that + * the signal was being delivered to. + */ + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + /** + * The workflowId of the external workflow execution that + * the signal was being delivered to. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the external workflow execution that + * the signal was being delivered to. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalExternalWorkflowExecutionFailedEventAttributes withWorkflowId(String workflowId) { + this.workflowId = workflowId; + return this; + } + + + /** + * The runId of the external workflow execution that the + * signal was being delivered to. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @return The runId of the external workflow execution that the + * signal was being delivered to. + */ + public String getRunId() { + return runId; + } + + /** + * The runId of the external workflow execution that the + * signal was being delivered to. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param runId The runId of the external workflow execution that the + * signal was being delivered to. + */ + public void setRunId(String runId) { + this.runId = runId; + } + + /** + * The runId of the external workflow execution that the + * signal was being delivered to. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param runId The runId of the external workflow execution that the + * signal was being delivered to. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalExternalWorkflowExecutionFailedEventAttributes withRunId(String runId) { + this.runId = runId; + return this; + } + + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION, SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_RATE_EXCEEDED + * + * @return The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see SignalExternalWorkflowExecutionFailedCause + */ + public String getCause() { + return cause; + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION, SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_RATE_EXCEEDED + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see SignalExternalWorkflowExecutionFailedCause + */ + public void setCause(String cause) { + this.cause = cause; + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION, SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_RATE_EXCEEDED + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see SignalExternalWorkflowExecutionFailedCause + */ + public SignalExternalWorkflowExecutionFailedEventAttributes withCause(String cause) { + this.cause = cause; + return this; + } + + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION, SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_RATE_EXCEEDED + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see SignalExternalWorkflowExecutionFailedCause + */ + public void setCause(SignalExternalWorkflowExecutionFailedCause cause) { + this.cause = cause.toString(); + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION, SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_RATE_EXCEEDED + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see SignalExternalWorkflowExecutionFailedCause + */ + public SignalExternalWorkflowExecutionFailedEventAttributes withCause(SignalExternalWorkflowExecutionFailedCause cause) { + this.cause = cause.toString(); + return this; + } + + /** + * The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the + * SignalExternalWorkflowExecution decision to request this + * signal. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + * + * @return The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the + * SignalExternalWorkflowExecution decision to request this + * signal. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + */ + public Long getInitiatedEventId() { + return initiatedEventId; + } + + /** + * The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the + * SignalExternalWorkflowExecution decision to request this + * signal. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + * + * @param initiatedEventId The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the + * SignalExternalWorkflowExecution decision to request this + * signal. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + */ + public void setInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + } + + /** + * The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the + * SignalExternalWorkflowExecution decision to request this + * signal. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param initiatedEventId The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the + * SignalExternalWorkflowExecution decision to request this + * signal. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalExternalWorkflowExecutionFailedEventAttributes withInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + return this; + } + + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * SignalExternalWorkflowExecution decision for this signal. + * This information can be useful for diagnosing problems by tracing back + * the cause of events leading up to this event. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * SignalExternalWorkflowExecution decision for this signal. + * This information can be useful for diagnosing problems by tracing back + * the cause of events leading up to this event. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * SignalExternalWorkflowExecution decision for this signal. + * This information can be useful for diagnosing problems by tracing back + * the cause of events leading up to this event. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * SignalExternalWorkflowExecution decision for this signal. + * This information can be useful for diagnosing problems by tracing back + * the cause of events leading up to this event. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * SignalExternalWorkflowExecution decision for this signal. + * This information can be useful for diagnosing problems by tracing back + * the cause of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * SignalExternalWorkflowExecution decision for this signal. + * This information can be useful for diagnosing problems by tracing back + * the cause of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalExternalWorkflowExecutionFailedEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * Returns the value of the Control property for this object. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The value of the Control property for this object. + */ + public String getControl() { + return control; + } + + /** + * Sets the value of the Control property for this object. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control The new value for the Control property for this object. + */ + public void setControl(String control) { + this.control = control; + } + + /** + * Sets the value of the Control property for this object. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control The new value for the Control property for this object. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalExternalWorkflowExecutionFailedEventAttributes withControl(String control) { + this.control = control; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowId != null) sb.append("WorkflowId: " + workflowId + ", "); + if (runId != null) sb.append("RunId: " + runId + ", "); + if (cause != null) sb.append("Cause: " + cause + ", "); + if (initiatedEventId != null) sb.append("InitiatedEventId: " + initiatedEventId + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + if (control != null) sb.append("Control: " + control + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowId() == null) ? 0 : getWorkflowId().hashCode()); + hashCode = prime * hashCode + ((getRunId() == null) ? 0 : getRunId().hashCode()); + hashCode = prime * hashCode + ((getCause() == null) ? 0 : getCause().hashCode()); + hashCode = prime * hashCode + ((getInitiatedEventId() == null) ? 0 : getInitiatedEventId().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + hashCode = prime * hashCode + ((getControl() == null) ? 0 : getControl().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof SignalExternalWorkflowExecutionFailedEventAttributes == false) return false; + SignalExternalWorkflowExecutionFailedEventAttributes other = (SignalExternalWorkflowExecutionFailedEventAttributes)obj; + + if (other.getWorkflowId() == null ^ this.getWorkflowId() == null) return false; + if (other.getWorkflowId() != null && other.getWorkflowId().equals(this.getWorkflowId()) == false) return false; + if (other.getRunId() == null ^ this.getRunId() == null) return false; + if (other.getRunId() != null && other.getRunId().equals(this.getRunId()) == false) return false; + if (other.getCause() == null ^ this.getCause() == null) return false; + if (other.getCause() != null && other.getCause().equals(this.getCause()) == false) return false; + if (other.getInitiatedEventId() == null ^ this.getInitiatedEventId() == null) return false; + if (other.getInitiatedEventId() != null && other.getInitiatedEventId().equals(this.getInitiatedEventId()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + if (other.getControl() == null ^ this.getControl() == null) return false; + if (other.getControl() != null && other.getControl().equals(this.getControl()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/SignalExternalWorkflowExecutionInitiatedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/SignalExternalWorkflowExecutionInitiatedEventAttributes.java new file mode 100644 index 000000000000..c90d3cefd155 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/SignalExternalWorkflowExecutionInitiatedEventAttributes.java @@ -0,0 +1,421 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the + * SignalExternalWorkflowExecutionInitiated event. + *

+ */ +public class SignalExternalWorkflowExecutionInitiatedEventAttributes { + + /** + * The workflowId of the external workflow execution. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String workflowId; + + /** + * The runId of the external workflow execution to send the + * signal to. + *

+ * Constraints:
+ * Length: 0 - 64
+ */ + private String runId; + + /** + * The name of the signal. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String signalName; + + /** + * Input provided to the signal (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String input; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * SignalExternalWorkflowExecution decision for this signal. + * This information can be useful for diagnosing problems by tracing back + * the cause of events leading up to this event. + */ + private Long decisionTaskCompletedEventId; + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String control; + + /** + * The workflowId of the external workflow execution. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The workflowId of the external workflow execution. + */ + public String getWorkflowId() { + return workflowId; + } + + /** + * The workflowId of the external workflow execution. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the external workflow execution. + */ + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + /** + * The workflowId of the external workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the external workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalExternalWorkflowExecutionInitiatedEventAttributes withWorkflowId(String workflowId) { + this.workflowId = workflowId; + return this; + } + + + /** + * The runId of the external workflow execution to send the + * signal to. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @return The runId of the external workflow execution to send the + * signal to. + */ + public String getRunId() { + return runId; + } + + /** + * The runId of the external workflow execution to send the + * signal to. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param runId The runId of the external workflow execution to send the + * signal to. + */ + public void setRunId(String runId) { + this.runId = runId; + } + + /** + * The runId of the external workflow execution to send the + * signal to. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param runId The runId of the external workflow execution to send the + * signal to. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalExternalWorkflowExecutionInitiatedEventAttributes withRunId(String runId) { + this.runId = runId; + return this; + } + + + /** + * The name of the signal. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the signal. + */ + public String getSignalName() { + return signalName; + } + + /** + * The name of the signal. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param signalName The name of the signal. + */ + public void setSignalName(String signalName) { + this.signalName = signalName; + } + + /** + * The name of the signal. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param signalName The name of the signal. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalExternalWorkflowExecutionInitiatedEventAttributes withSignalName(String signalName) { + this.signalName = signalName; + return this; + } + + + /** + * Input provided to the signal (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Input provided to the signal (if any). + */ + public String getInput() { + return input; + } + + /** + * Input provided to the signal (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input Input provided to the signal (if any). + */ + public void setInput(String input) { + this.input = input; + } + + /** + * Input provided to the signal (if any). + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input Input provided to the signal (if any). + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalExternalWorkflowExecutionInitiatedEventAttributes withInput(String input) { + this.input = input; + return this; + } + + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * SignalExternalWorkflowExecution decision for this signal. + * This information can be useful for diagnosing problems by tracing back + * the cause of events leading up to this event. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * SignalExternalWorkflowExecution decision for this signal. + * This information can be useful for diagnosing problems by tracing back + * the cause of events leading up to this event. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * SignalExternalWorkflowExecution decision for this signal. + * This information can be useful for diagnosing problems by tracing back + * the cause of events leading up to this event. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * SignalExternalWorkflowExecution decision for this signal. + * This information can be useful for diagnosing problems by tracing back + * the cause of events leading up to this event. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * SignalExternalWorkflowExecution decision for this signal. + * This information can be useful for diagnosing problems by tracing back + * the cause of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * SignalExternalWorkflowExecution decision for this signal. + * This information can be useful for diagnosing problems by tracing back + * the cause of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalExternalWorkflowExecutionInitiatedEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. + */ + public String getControl() { + return control; + } + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. + */ + public void setControl(String control) { + this.control = control; + } + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalExternalWorkflowExecutionInitiatedEventAttributes withControl(String control) { + this.control = control; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowId != null) sb.append("WorkflowId: " + workflowId + ", "); + if (runId != null) sb.append("RunId: " + runId + ", "); + if (signalName != null) sb.append("SignalName: " + signalName + ", "); + if (input != null) sb.append("Input: " + input + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + if (control != null) sb.append("Control: " + control + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowId() == null) ? 0 : getWorkflowId().hashCode()); + hashCode = prime * hashCode + ((getRunId() == null) ? 0 : getRunId().hashCode()); + hashCode = prime * hashCode + ((getSignalName() == null) ? 0 : getSignalName().hashCode()); + hashCode = prime * hashCode + ((getInput() == null) ? 0 : getInput().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + hashCode = prime * hashCode + ((getControl() == null) ? 0 : getControl().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof SignalExternalWorkflowExecutionInitiatedEventAttributes == false) return false; + SignalExternalWorkflowExecutionInitiatedEventAttributes other = (SignalExternalWorkflowExecutionInitiatedEventAttributes)obj; + + if (other.getWorkflowId() == null ^ this.getWorkflowId() == null) return false; + if (other.getWorkflowId() != null && other.getWorkflowId().equals(this.getWorkflowId()) == false) return false; + if (other.getRunId() == null ^ this.getRunId() == null) return false; + if (other.getRunId() != null && other.getRunId().equals(this.getRunId()) == false) return false; + if (other.getSignalName() == null ^ this.getSignalName() == null) return false; + if (other.getSignalName() != null && other.getSignalName().equals(this.getSignalName()) == false) return false; + if (other.getInput() == null ^ this.getInput() == null) return false; + if (other.getInput() != null && other.getInput().equals(this.getInput()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + if (other.getControl() == null ^ this.getControl() == null) return false; + if (other.getControl() != null && other.getControl().equals(this.getControl()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/SignalWorkflowExecutionRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/SignalWorkflowExecutionRequest.java new file mode 100644 index 000000000000..669ad38a1ed9 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/SignalWorkflowExecutionRequest.java @@ -0,0 +1,366 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#signalWorkflowExecution(SignalWorkflowExecutionRequest) SignalWorkflowExecution operation}. + *

+ * Records a WorkflowExecutionSignaled event in the + * workflow execution history and creates a decision task for the + * workflow execution identified by the given domain, workflowId and + * runId. The event is recorded with the specified user defined + * signalName and input (if provided). + *

+ *

+ * NOTE: If a runId is not specified, then the + * WorkflowExecutionSignaled event is recorded in the history of the + * current open workflow with the matching workflowId in the domain. + *

+ *

+ * NOTE: If the specified workflow execution is not open, this + * method fails with UnknownResource. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#signalWorkflowExecution(SignalWorkflowExecutionRequest) + */ +public class SignalWorkflowExecutionRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain containing the workflow execution to signal. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * The workflowId of the workflow execution to signal. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String workflowId; + + /** + * The runId of the workflow execution to signal. + *

+ * Constraints:
+ * Length: 0 - 64
+ */ + private String runId; + + /** + * The name of the signal. This name must be meaningful to the target + * workflow. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String signalName; + + /** + * Data to attach to the WorkflowExecutionSignaled event in + * the target workflow execution's history. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String input; + + /** + * The name of the domain containing the workflow execution to signal. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain containing the workflow execution to signal. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain containing the workflow execution to signal. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain containing the workflow execution to signal. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain containing the workflow execution to signal. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain containing the workflow execution to signal. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalWorkflowExecutionRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * The workflowId of the workflow execution to signal. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The workflowId of the workflow execution to signal. + */ + public String getWorkflowId() { + return workflowId; + } + + /** + * The workflowId of the workflow execution to signal. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the workflow execution to signal. + */ + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + /** + * The workflowId of the workflow execution to signal. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the workflow execution to signal. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalWorkflowExecutionRequest withWorkflowId(String workflowId) { + this.workflowId = workflowId; + return this; + } + + + /** + * The runId of the workflow execution to signal. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @return The runId of the workflow execution to signal. + */ + public String getRunId() { + return runId; + } + + /** + * The runId of the workflow execution to signal. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param runId The runId of the workflow execution to signal. + */ + public void setRunId(String runId) { + this.runId = runId; + } + + /** + * The runId of the workflow execution to signal. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param runId The runId of the workflow execution to signal. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalWorkflowExecutionRequest withRunId(String runId) { + this.runId = runId; + return this; + } + + + /** + * The name of the signal. This name must be meaningful to the target + * workflow. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the signal. This name must be meaningful to the target + * workflow. + */ + public String getSignalName() { + return signalName; + } + + /** + * The name of the signal. This name must be meaningful to the target + * workflow. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param signalName The name of the signal. This name must be meaningful to the target + * workflow. + */ + public void setSignalName(String signalName) { + this.signalName = signalName; + } + + /** + * The name of the signal. This name must be meaningful to the target + * workflow. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param signalName The name of the signal. This name must be meaningful to the target + * workflow. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalWorkflowExecutionRequest withSignalName(String signalName) { + this.signalName = signalName; + return this; + } + + + /** + * Data to attach to the WorkflowExecutionSignaled event in + * the target workflow execution's history. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Data to attach to the WorkflowExecutionSignaled event in + * the target workflow execution's history. + */ + public String getInput() { + return input; + } + + /** + * Data to attach to the WorkflowExecutionSignaled event in + * the target workflow execution's history. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input Data to attach to the WorkflowExecutionSignaled event in + * the target workflow execution's history. + */ + public void setInput(String input) { + this.input = input; + } + + /** + * Data to attach to the WorkflowExecutionSignaled event in + * the target workflow execution's history. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input Data to attach to the WorkflowExecutionSignaled event in + * the target workflow execution's history. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public SignalWorkflowExecutionRequest withInput(String input) { + this.input = input; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (workflowId != null) sb.append("WorkflowId: " + workflowId + ", "); + if (runId != null) sb.append("RunId: " + runId + ", "); + if (signalName != null) sb.append("SignalName: " + signalName + ", "); + if (input != null) sb.append("Input: " + input + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getWorkflowId() == null) ? 0 : getWorkflowId().hashCode()); + hashCode = prime * hashCode + ((getRunId() == null) ? 0 : getRunId().hashCode()); + hashCode = prime * hashCode + ((getSignalName() == null) ? 0 : getSignalName().hashCode()); + hashCode = prime * hashCode + ((getInput() == null) ? 0 : getInput().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof SignalWorkflowExecutionRequest == false) return false; + SignalWorkflowExecutionRequest other = (SignalWorkflowExecutionRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getWorkflowId() == null ^ this.getWorkflowId() == null) return false; + if (other.getWorkflowId() != null && other.getWorkflowId().equals(this.getWorkflowId()) == false) return false; + if (other.getRunId() == null ^ this.getRunId() == null) return false; + if (other.getRunId() != null && other.getRunId().equals(this.getRunId()) == false) return false; + if (other.getSignalName() == null ^ this.getSignalName() == null) return false; + if (other.getSignalName() != null && other.getSignalName().equals(this.getSignalName()) == false) return false; + if (other.getInput() == null ^ this.getInput() == null) return false; + if (other.getInput() != null && other.getInput().equals(this.getInput()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/StartChildWorkflowExecutionDecisionAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/StartChildWorkflowExecutionDecisionAttributes.java new file mode 100644 index 000000000000..5931b77536e2 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/StartChildWorkflowExecutionDecisionAttributes.java @@ -0,0 +1,1083 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the StartChildWorkflowExecution + * decision. + *

+ */ +public class StartChildWorkflowExecutionDecisionAttributes { + + /** + * The type of the workflow execution to be started. This field is + * required. + */ + private WorkflowType workflowType; + + /** + * The workflowId of the workflow execution. This field is + * required.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String workflowId; + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the child workflow + * execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String control; + + /** + * The input to be provided to the workflow execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String input; + + /** + * The total duration for this workflow execution. This overrides the + * defaultExecutionStartToCloseTimeout specified when registering the + * workflow type.

The valid values are integers greater than or equal + * to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. An execution start-to-close timeout for this + * workflow execution must be specified either as a default for the + * workflow type or through this parameter. If neither this parameter is + * set nor a default execution start-to-close timeout was specified at + * registration time then a fault will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String executionStartToCloseTimeout; + + /** + * The name of the task list to be used for decision tasks of the child + * workflow execution. A task list for this workflow execution must + * be specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task list + * was specified at registration time then a fault will be + * returned.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + */ + private TaskList taskList; + + /** + * Specifies the maximum duration of decision tasks for this workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for this workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String taskStartToCloseTimeout; + + /** + * If set, specifies the policy to use for the child workflow executions + * if the workflow execution being started is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the workflow execution being started must be + * specified either as a default registered for its workflow type or + * through this field. If neither this field is set nor a default child + * policy was specified at registration time then a fault will be + * returned. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + */ + private String childPolicy; + + /** + * The list of tags to associate with the child workflow execution. A + * maximum of 5 tags can be specified. You can list workflow executions + * with a specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + *

+ * Constraints:
+ * Length: 0 - 5
+ */ + private java.util.List tagList; + + /** + * The type of the workflow execution to be started. This field is + * required. + * + * @return The type of the workflow execution to be started. This field is + * required. + */ + public WorkflowType getWorkflowType() { + return workflowType; + } + + /** + * The type of the workflow execution to be started. This field is + * required. + * + * @param workflowType The type of the workflow execution to be started. This field is + * required. + */ + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + /** + * The type of the workflow execution to be started. This field is + * required. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowType The type of the workflow execution to be started. This field is + * required. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionDecisionAttributes withWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + return this; + } + + + /** + * The workflowId of the workflow execution. This field is + * required.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The workflowId of the workflow execution. This field is + * required.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + */ + public String getWorkflowId() { + return workflowId; + } + + /** + * The workflowId of the workflow execution. This field is + * required.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the workflow execution. This field is + * required.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + */ + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + /** + * The workflowId of the workflow execution. This field is + * required.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the workflow execution. This field is + * required.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionDecisionAttributes withWorkflowId(String workflowId) { + this.workflowId = workflowId; + return this; + } + + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the child workflow + * execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the child workflow + * execution. + */ + public String getControl() { + return control; + } + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the child workflow + * execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the child workflow + * execution. + */ + public void setControl(String control) { + this.control = control; + } + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the child workflow + * execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. This data is not sent to the child workflow + * execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionDecisionAttributes withControl(String control) { + this.control = control; + return this; + } + + + /** + * The input to be provided to the workflow execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The input to be provided to the workflow execution. + */ + public String getInput() { + return input; + } + + /** + * The input to be provided to the workflow execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input The input to be provided to the workflow execution. + */ + public void setInput(String input) { + this.input = input; + } + + /** + * The input to be provided to the workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input The input to be provided to the workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionDecisionAttributes withInput(String input) { + this.input = input; + return this; + } + + + /** + * The total duration for this workflow execution. This overrides the + * defaultExecutionStartToCloseTimeout specified when registering the + * workflow type.

The valid values are integers greater than or equal + * to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. An execution start-to-close timeout for this + * workflow execution must be specified either as a default for the + * workflow type or through this parameter. If neither this parameter is + * set nor a default execution start-to-close timeout was specified at + * registration time then a fault will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return The total duration for this workflow execution. This overrides the + * defaultExecutionStartToCloseTimeout specified when registering the + * workflow type.

The valid values are integers greater than or equal + * to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. An execution start-to-close timeout for this + * workflow execution must be specified either as a default for the + * workflow type or through this parameter. If neither this parameter is + * set nor a default execution start-to-close timeout was specified at + * registration time then a fault will be returned. + */ + public String getExecutionStartToCloseTimeout() { + return executionStartToCloseTimeout; + } + + /** + * The total duration for this workflow execution. This overrides the + * defaultExecutionStartToCloseTimeout specified when registering the + * workflow type.

The valid values are integers greater than or equal + * to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. An execution start-to-close timeout for this + * workflow execution must be specified either as a default for the + * workflow type or through this parameter. If neither this parameter is + * set nor a default execution start-to-close timeout was specified at + * registration time then a fault will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param executionStartToCloseTimeout The total duration for this workflow execution. This overrides the + * defaultExecutionStartToCloseTimeout specified when registering the + * workflow type.

The valid values are integers greater than or equal + * to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. An execution start-to-close timeout for this + * workflow execution must be specified either as a default for the + * workflow type or through this parameter. If neither this parameter is + * set nor a default execution start-to-close timeout was specified at + * registration time then a fault will be returned. + */ + public void setExecutionStartToCloseTimeout(String executionStartToCloseTimeout) { + this.executionStartToCloseTimeout = executionStartToCloseTimeout; + } + + /** + * The total duration for this workflow execution. This overrides the + * defaultExecutionStartToCloseTimeout specified when registering the + * workflow type.

The valid values are integers greater than or equal + * to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. An execution start-to-close timeout for this + * workflow execution must be specified either as a default for the + * workflow type or through this parameter. If neither this parameter is + * set nor a default execution start-to-close timeout was specified at + * registration time then a fault will be returned. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param executionStartToCloseTimeout The total duration for this workflow execution. This overrides the + * defaultExecutionStartToCloseTimeout specified when registering the + * workflow type.

The valid values are integers greater than or equal + * to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. An execution start-to-close timeout for this + * workflow execution must be specified either as a default for the + * workflow type or through this parameter. If neither this parameter is + * set nor a default execution start-to-close timeout was specified at + * registration time then a fault will be returned. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionDecisionAttributes withExecutionStartToCloseTimeout(String executionStartToCloseTimeout) { + this.executionStartToCloseTimeout = executionStartToCloseTimeout; + return this; + } + + + /** + * The name of the task list to be used for decision tasks of the child + * workflow execution. A task list for this workflow execution must + * be specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task list + * was specified at registration time then a fault will be + * returned.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + * + * @return The name of the task list to be used for decision tasks of the child + * workflow execution. A task list for this workflow execution must + * be specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task list + * was specified at registration time then a fault will be + * returned.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + */ + public TaskList getTaskList() { + return taskList; + } + + /** + * The name of the task list to be used for decision tasks of the child + * workflow execution. A task list for this workflow execution must + * be specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task list + * was specified at registration time then a fault will be + * returned.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + * + * @param taskList The name of the task list to be used for decision tasks of the child + * workflow execution. A task list for this workflow execution must + * be specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task list + * was specified at registration time then a fault will be + * returned.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + */ + public void setTaskList(TaskList taskList) { + this.taskList = taskList; + } + + /** + * The name of the task list to be used for decision tasks of the child + * workflow execution. A task list for this workflow execution must + * be specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task list + * was specified at registration time then a fault will be + * returned.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param taskList The name of the task list to be used for decision tasks of the child + * workflow execution. A task list for this workflow execution must + * be specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task list + * was specified at registration time then a fault will be + * returned.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionDecisionAttributes withTaskList(TaskList taskList) { + this.taskList = taskList; + return this; + } + + + /** + * Specifies the maximum duration of decision tasks for this workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for this workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return Specifies the maximum duration of decision tasks for this workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for this workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + */ + public String getTaskStartToCloseTimeout() { + return taskStartToCloseTimeout; + } + + /** + * Specifies the maximum duration of decision tasks for this workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for this workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param taskStartToCloseTimeout Specifies the maximum duration of decision tasks for this workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for this workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + */ + public void setTaskStartToCloseTimeout(String taskStartToCloseTimeout) { + this.taskStartToCloseTimeout = taskStartToCloseTimeout; + } + + /** + * Specifies the maximum duration of decision tasks for this workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for this workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param taskStartToCloseTimeout Specifies the maximum duration of decision tasks for this workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for this workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionDecisionAttributes withTaskStartToCloseTimeout(String taskStartToCloseTimeout) { + this.taskStartToCloseTimeout = taskStartToCloseTimeout; + return this; + } + + + /** + * If set, specifies the policy to use for the child workflow executions + * if the workflow execution being started is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the workflow execution being started must be + * specified either as a default registered for its workflow type or + * through this field. If neither this field is set nor a default child + * policy was specified at registration time then a fault will be + * returned. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @return If set, specifies the policy to use for the child workflow executions + * if the workflow execution being started is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the workflow execution being started must be + * specified either as a default registered for its workflow type or + * through this field. If neither this field is set nor a default child + * policy was specified at registration time then a fault will be + * returned. + * + * @see ChildPolicy + */ + public String getChildPolicy() { + return childPolicy; + } + + /** + * If set, specifies the policy to use for the child workflow executions + * if the workflow execution being started is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the workflow execution being started must be + * specified either as a default registered for its workflow type or + * through this field. If neither this field is set nor a default child + * policy was specified at registration time then a fault will be + * returned. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy If set, specifies the policy to use for the child workflow executions + * if the workflow execution being started is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the workflow execution being started must be + * specified either as a default registered for its workflow type or + * through this field. If neither this field is set nor a default child + * policy was specified at registration time then a fault will be + * returned. + * + * @see ChildPolicy + */ + public void setChildPolicy(String childPolicy) { + this.childPolicy = childPolicy; + } + + /** + * If set, specifies the policy to use for the child workflow executions + * if the workflow execution being started is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the workflow execution being started must be + * specified either as a default registered for its workflow type or + * through this field. If neither this field is set nor a default child + * policy was specified at registration time then a fault will be + * returned. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy If set, specifies the policy to use for the child workflow executions + * if the workflow execution being started is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the workflow execution being started must be + * specified either as a default registered for its workflow type or + * through this field. If neither this field is set nor a default child + * policy was specified at registration time then a fault will be + * returned. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public StartChildWorkflowExecutionDecisionAttributes withChildPolicy(String childPolicy) { + this.childPolicy = childPolicy; + return this; + } + + + /** + * If set, specifies the policy to use for the child workflow executions + * if the workflow execution being started is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the workflow execution being started must be + * specified either as a default registered for its workflow type or + * through this field. If neither this field is set nor a default child + * policy was specified at registration time then a fault will be + * returned. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy If set, specifies the policy to use for the child workflow executions + * if the workflow execution being started is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the workflow execution being started must be + * specified either as a default registered for its workflow type or + * through this field. If neither this field is set nor a default child + * policy was specified at registration time then a fault will be + * returned. + * + * @see ChildPolicy + */ + public void setChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy.toString(); + } + + /** + * If set, specifies the policy to use for the child workflow executions + * if the workflow execution being started is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the workflow execution being started must be + * specified either as a default registered for its workflow type or + * through this field. If neither this field is set nor a default child + * policy was specified at registration time then a fault will be + * returned. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy If set, specifies the policy to use for the child workflow executions + * if the workflow execution being started is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for the workflow execution being started must be + * specified either as a default registered for its workflow type or + * through this field. If neither this field is set nor a default child + * policy was specified at registration time then a fault will be + * returned. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public StartChildWorkflowExecutionDecisionAttributes withChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy.toString(); + return this; + } + + /** + * The list of tags to associate with the child workflow execution. A + * maximum of 5 tags can be specified. You can list workflow executions + * with a specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @return The list of tags to associate with the child workflow execution. A + * maximum of 5 tags can be specified. You can list workflow executions + * with a specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + */ + public java.util.List getTagList() { + + if (tagList == null) { + tagList = new java.util.ArrayList(); + } + return tagList; + } + + /** + * The list of tags to associate with the child workflow execution. A + * maximum of 5 tags can be specified. You can list workflow executions + * with a specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags to associate with the child workflow execution. A + * maximum of 5 tags can be specified. You can list workflow executions + * with a specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + */ + public void setTagList(java.util.Collection tagList) { + if (tagList == null) { + this.tagList = null; + return; + } + + java.util.List tagListCopy = new java.util.ArrayList(tagList.size()); + tagListCopy.addAll(tagList); + this.tagList = tagListCopy; + } + + /** + * The list of tags to associate with the child workflow execution. A + * maximum of 5 tags can be specified. You can list workflow executions + * with a specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags to associate with the child workflow execution. A + * maximum of 5 tags can be specified. You can list workflow executions + * with a specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionDecisionAttributes withTagList(String... tagList) { + if (getTagList() == null) setTagList(new java.util.ArrayList(tagList.length)); + for (String value : tagList) { + getTagList().add(value); + } + return this; + } + + /** + * The list of tags to associate with the child workflow execution. A + * maximum of 5 tags can be specified. You can list workflow executions + * with a specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags to associate with the child workflow execution. A + * maximum of 5 tags can be specified. You can list workflow executions + * with a specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionDecisionAttributes withTagList(java.util.Collection tagList) { + if (tagList == null) { + this.tagList = null; + } else { + java.util.List tagListCopy = new java.util.ArrayList(tagList.size()); + tagListCopy.addAll(tagList); + this.tagList = tagListCopy; + } + + return this; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowType != null) sb.append("WorkflowType: " + workflowType + ", "); + if (workflowId != null) sb.append("WorkflowId: " + workflowId + ", "); + if (control != null) sb.append("Control: " + control + ", "); + if (input != null) sb.append("Input: " + input + ", "); + if (executionStartToCloseTimeout != null) sb.append("ExecutionStartToCloseTimeout: " + executionStartToCloseTimeout + ", "); + if (taskList != null) sb.append("TaskList: " + taskList + ", "); + if (taskStartToCloseTimeout != null) sb.append("TaskStartToCloseTimeout: " + taskStartToCloseTimeout + ", "); + if (childPolicy != null) sb.append("ChildPolicy: " + childPolicy + ", "); + if (tagList != null) sb.append("TagList: " + tagList + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowType() == null) ? 0 : getWorkflowType().hashCode()); + hashCode = prime * hashCode + ((getWorkflowId() == null) ? 0 : getWorkflowId().hashCode()); + hashCode = prime * hashCode + ((getControl() == null) ? 0 : getControl().hashCode()); + hashCode = prime * hashCode + ((getInput() == null) ? 0 : getInput().hashCode()); + hashCode = prime * hashCode + ((getExecutionStartToCloseTimeout() == null) ? 0 : getExecutionStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getTaskList() == null) ? 0 : getTaskList().hashCode()); + hashCode = prime * hashCode + ((getTaskStartToCloseTimeout() == null) ? 0 : getTaskStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getChildPolicy() == null) ? 0 : getChildPolicy().hashCode()); + hashCode = prime * hashCode + ((getTagList() == null) ? 0 : getTagList().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof StartChildWorkflowExecutionDecisionAttributes == false) return false; + StartChildWorkflowExecutionDecisionAttributes other = (StartChildWorkflowExecutionDecisionAttributes)obj; + + if (other.getWorkflowType() == null ^ this.getWorkflowType() == null) return false; + if (other.getWorkflowType() != null && other.getWorkflowType().equals(this.getWorkflowType()) == false) return false; + if (other.getWorkflowId() == null ^ this.getWorkflowId() == null) return false; + if (other.getWorkflowId() != null && other.getWorkflowId().equals(this.getWorkflowId()) == false) return false; + if (other.getControl() == null ^ this.getControl() == null) return false; + if (other.getControl() != null && other.getControl().equals(this.getControl()) == false) return false; + if (other.getInput() == null ^ this.getInput() == null) return false; + if (other.getInput() != null && other.getInput().equals(this.getInput()) == false) return false; + if (other.getExecutionStartToCloseTimeout() == null ^ this.getExecutionStartToCloseTimeout() == null) return false; + if (other.getExecutionStartToCloseTimeout() != null && other.getExecutionStartToCloseTimeout().equals(this.getExecutionStartToCloseTimeout()) == false) return false; + if (other.getTaskList() == null ^ this.getTaskList() == null) return false; + if (other.getTaskList() != null && other.getTaskList().equals(this.getTaskList()) == false) return false; + if (other.getTaskStartToCloseTimeout() == null ^ this.getTaskStartToCloseTimeout() == null) return false; + if (other.getTaskStartToCloseTimeout() != null && other.getTaskStartToCloseTimeout().equals(this.getTaskStartToCloseTimeout()) == false) return false; + if (other.getChildPolicy() == null ^ this.getChildPolicy() == null) return false; + if (other.getChildPolicy() != null && other.getChildPolicy().equals(this.getChildPolicy()) == false) return false; + if (other.getTagList() == null ^ this.getTagList() == null) return false; + if (other.getTagList() != null && other.getTagList().equals(this.getTagList()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/StartChildWorkflowExecutionFailedCause.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/StartChildWorkflowExecutionFailedCause.java new file mode 100644 index 000000000000..330c57b50763 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/StartChildWorkflowExecutionFailedCause.java @@ -0,0 +1,80 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Start Child Workflow Execution Failed Cause + */ +public enum StartChildWorkflowExecutionFailedCause { + + WORKFLOW_TYPE_DOES_NOT_EXIST("WORKFLOW_TYPE_DOES_NOT_EXIST"), + WORKFLOW_TYPE_DEPRECATED("WORKFLOW_TYPE_DEPRECATED"), + OPEN_CHILDREN_LIMIT_EXCEEDED("OPEN_CHILDREN_LIMIT_EXCEEDED"), + OPEN_WORKFLOWS_LIMIT_EXCEEDED("OPEN_WORKFLOWS_LIMIT_EXCEEDED"), + CHILD_CREATION_RATE_EXCEEDED("CHILD_CREATION_RATE_EXCEEDED"), + WORKFLOW_ALREADY_RUNNING("WORKFLOW_ALREADY_RUNNING"), + DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_UNDEFINED("DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_UNDEFINED"), + DEFAULT_TASK_LIST_UNDEFINED("DEFAULT_TASK_LIST_UNDEFINED"), + DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_UNDEFINED("DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_UNDEFINED"), + DEFAULT_CHILD_POLICY_UNDEFINED("DEFAULT_CHILD_POLICY_UNDEFINED"); + + private String value; + + private StartChildWorkflowExecutionFailedCause(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return StartChildWorkflowExecutionFailedCause corresponding to the value + */ + public static StartChildWorkflowExecutionFailedCause fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("WORKFLOW_TYPE_DOES_NOT_EXIST".equals(value)) { + return StartChildWorkflowExecutionFailedCause.WORKFLOW_TYPE_DOES_NOT_EXIST; + } else if ("WORKFLOW_TYPE_DEPRECATED".equals(value)) { + return StartChildWorkflowExecutionFailedCause.WORKFLOW_TYPE_DEPRECATED; + } else if ("OPEN_CHILDREN_LIMIT_EXCEEDED".equals(value)) { + return StartChildWorkflowExecutionFailedCause.OPEN_CHILDREN_LIMIT_EXCEEDED; + } else if ("OPEN_WORKFLOWS_LIMIT_EXCEEDED".equals(value)) { + return StartChildWorkflowExecutionFailedCause.OPEN_WORKFLOWS_LIMIT_EXCEEDED; + } else if ("CHILD_CREATION_RATE_EXCEEDED".equals(value)) { + return StartChildWorkflowExecutionFailedCause.CHILD_CREATION_RATE_EXCEEDED; + } else if ("WORKFLOW_ALREADY_RUNNING".equals(value)) { + return StartChildWorkflowExecutionFailedCause.WORKFLOW_ALREADY_RUNNING; + } else if ("DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_UNDEFINED".equals(value)) { + return StartChildWorkflowExecutionFailedCause.DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_UNDEFINED; + } else if ("DEFAULT_TASK_LIST_UNDEFINED".equals(value)) { + return StartChildWorkflowExecutionFailedCause.DEFAULT_TASK_LIST_UNDEFINED; + } else if ("DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_UNDEFINED".equals(value)) { + return StartChildWorkflowExecutionFailedCause.DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_UNDEFINED; + } else if ("DEFAULT_CHILD_POLICY_UNDEFINED".equals(value)) { + return StartChildWorkflowExecutionFailedCause.DEFAULT_CHILD_POLICY_UNDEFINED; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/StartChildWorkflowExecutionFailedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/StartChildWorkflowExecutionFailedEventAttributes.java new file mode 100644 index 000000000000..c2c1fb8f2ad6 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/StartChildWorkflowExecutionFailedEventAttributes.java @@ -0,0 +1,463 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the + * StartChildWorkflowExecutionFailed event. + *

+ */ +public class StartChildWorkflowExecutionFailedEventAttributes { + + /** + * The workflow type provided in the + * StartChildWorkflowExecution Decision that failed. + */ + private WorkflowType workflowType; + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: WORKFLOW_TYPE_DOES_NOT_EXIST, WORKFLOW_TYPE_DEPRECATED, OPEN_CHILDREN_LIMIT_EXCEEDED, OPEN_WORKFLOWS_LIMIT_EXCEEDED, CHILD_CREATION_RATE_EXCEEDED, WORKFLOW_ALREADY_RUNNING, DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_LIST_UNDEFINED, DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_CHILD_POLICY_UNDEFINED + */ + private String cause; + + /** + * The workflowId of the child workflow execution. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String workflowId; + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + private Long initiatedEventId; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * StartChildWorkflowExecution Decision to request + * this child workflow execution. This information can be useful for + * diagnosing problems by tracing back the cause of events. + */ + private Long decisionTaskCompletedEventId; + + private String control; + + /** + * The workflow type provided in the + * StartChildWorkflowExecution Decision that failed. + * + * @return The workflow type provided in the + * StartChildWorkflowExecution Decision that failed. + */ + public WorkflowType getWorkflowType() { + return workflowType; + } + + /** + * The workflow type provided in the + * StartChildWorkflowExecution Decision that failed. + * + * @param workflowType The workflow type provided in the + * StartChildWorkflowExecution Decision that failed. + */ + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + /** + * The workflow type provided in the + * StartChildWorkflowExecution Decision that failed. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowType The workflow type provided in the + * StartChildWorkflowExecution Decision that failed. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionFailedEventAttributes withWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + return this; + } + + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: WORKFLOW_TYPE_DOES_NOT_EXIST, WORKFLOW_TYPE_DEPRECATED, OPEN_CHILDREN_LIMIT_EXCEEDED, OPEN_WORKFLOWS_LIMIT_EXCEEDED, CHILD_CREATION_RATE_EXCEEDED, WORKFLOW_ALREADY_RUNNING, DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_LIST_UNDEFINED, DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_CHILD_POLICY_UNDEFINED + * + * @return The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see StartChildWorkflowExecutionFailedCause + */ + public String getCause() { + return cause; + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: WORKFLOW_TYPE_DOES_NOT_EXIST, WORKFLOW_TYPE_DEPRECATED, OPEN_CHILDREN_LIMIT_EXCEEDED, OPEN_WORKFLOWS_LIMIT_EXCEEDED, CHILD_CREATION_RATE_EXCEEDED, WORKFLOW_ALREADY_RUNNING, DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_LIST_UNDEFINED, DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_CHILD_POLICY_UNDEFINED + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see StartChildWorkflowExecutionFailedCause + */ + public void setCause(String cause) { + this.cause = cause; + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: WORKFLOW_TYPE_DOES_NOT_EXIST, WORKFLOW_TYPE_DEPRECATED, OPEN_CHILDREN_LIMIT_EXCEEDED, OPEN_WORKFLOWS_LIMIT_EXCEEDED, CHILD_CREATION_RATE_EXCEEDED, WORKFLOW_ALREADY_RUNNING, DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_LIST_UNDEFINED, DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_CHILD_POLICY_UNDEFINED + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see StartChildWorkflowExecutionFailedCause + */ + public StartChildWorkflowExecutionFailedEventAttributes withCause(String cause) { + this.cause = cause; + return this; + } + + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: WORKFLOW_TYPE_DOES_NOT_EXIST, WORKFLOW_TYPE_DEPRECATED, OPEN_CHILDREN_LIMIT_EXCEEDED, OPEN_WORKFLOWS_LIMIT_EXCEEDED, CHILD_CREATION_RATE_EXCEEDED, WORKFLOW_ALREADY_RUNNING, DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_LIST_UNDEFINED, DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_CHILD_POLICY_UNDEFINED + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see StartChildWorkflowExecutionFailedCause + */ + public void setCause(StartChildWorkflowExecutionFailedCause cause) { + this.cause = cause.toString(); + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: WORKFLOW_TYPE_DOES_NOT_EXIST, WORKFLOW_TYPE_DEPRECATED, OPEN_CHILDREN_LIMIT_EXCEEDED, OPEN_WORKFLOWS_LIMIT_EXCEEDED, CHILD_CREATION_RATE_EXCEEDED, WORKFLOW_ALREADY_RUNNING, DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_TASK_LIST_UNDEFINED, DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_UNDEFINED, DEFAULT_CHILD_POLICY_UNDEFINED + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see StartChildWorkflowExecutionFailedCause + */ + public StartChildWorkflowExecutionFailedEventAttributes withCause(StartChildWorkflowExecutionFailedCause cause) { + this.cause = cause.toString(); + return this; + } + + /** + * The workflowId of the child workflow execution. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The workflowId of the child workflow execution. + */ + public String getWorkflowId() { + return workflowId; + } + + /** + * The workflowId of the child workflow execution. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the child workflow execution. + */ + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + /** + * The workflowId of the child workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the child workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionFailedEventAttributes withWorkflowId(String workflowId) { + this.workflowId = workflowId; + return this; + } + + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public Long getInitiatedEventId() { + return initiatedEventId; + } + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @param initiatedEventId The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + */ + public void setInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + } + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param initiatedEventId The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this child workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionFailedEventAttributes withInitiatedEventId(Long initiatedEventId) { + this.initiatedEventId = initiatedEventId; + return this; + } + + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * StartChildWorkflowExecution Decision to request + * this child workflow execution. This information can be useful for + * diagnosing problems by tracing back the cause of events. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * StartChildWorkflowExecution Decision to request + * this child workflow execution. This information can be useful for + * diagnosing problems by tracing back the cause of events. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * StartChildWorkflowExecution Decision to request + * this child workflow execution. This information can be useful for + * diagnosing problems by tracing back the cause of events. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * StartChildWorkflowExecution Decision to request + * this child workflow execution. This information can be useful for + * diagnosing problems by tracing back the cause of events. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * StartChildWorkflowExecution Decision to request + * this child workflow execution. This information can be useful for + * diagnosing problems by tracing back the cause of events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * StartChildWorkflowExecution Decision to request + * this child workflow execution. This information can be useful for + * diagnosing problems by tracing back the cause of events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionFailedEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * Returns the value of the Control property for this object. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The value of the Control property for this object. + */ + public String getControl() { + return control; + } + + /** + * Sets the value of the Control property for this object. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control The new value for the Control property for this object. + */ + public void setControl(String control) { + this.control = control; + } + + /** + * Sets the value of the Control property for this object. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control The new value for the Control property for this object. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionFailedEventAttributes withControl(String control) { + this.control = control; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowType != null) sb.append("WorkflowType: " + workflowType + ", "); + if (cause != null) sb.append("Cause: " + cause + ", "); + if (workflowId != null) sb.append("WorkflowId: " + workflowId + ", "); + if (initiatedEventId != null) sb.append("InitiatedEventId: " + initiatedEventId + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + if (control != null) sb.append("Control: " + control + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowType() == null) ? 0 : getWorkflowType().hashCode()); + hashCode = prime * hashCode + ((getCause() == null) ? 0 : getCause().hashCode()); + hashCode = prime * hashCode + ((getWorkflowId() == null) ? 0 : getWorkflowId().hashCode()); + hashCode = prime * hashCode + ((getInitiatedEventId() == null) ? 0 : getInitiatedEventId().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + hashCode = prime * hashCode + ((getControl() == null) ? 0 : getControl().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof StartChildWorkflowExecutionFailedEventAttributes == false) return false; + StartChildWorkflowExecutionFailedEventAttributes other = (StartChildWorkflowExecutionFailedEventAttributes)obj; + + if (other.getWorkflowType() == null ^ this.getWorkflowType() == null) return false; + if (other.getWorkflowType() != null && other.getWorkflowType().equals(this.getWorkflowType()) == false) return false; + if (other.getCause() == null ^ this.getCause() == null) return false; + if (other.getCause() != null && other.getCause().equals(this.getCause()) == false) return false; + if (other.getWorkflowId() == null ^ this.getWorkflowId() == null) return false; + if (other.getWorkflowId() != null && other.getWorkflowId().equals(this.getWorkflowId()) == false) return false; + if (other.getInitiatedEventId() == null ^ this.getInitiatedEventId() == null) return false; + if (other.getInitiatedEventId() != null && other.getInitiatedEventId().equals(this.getInitiatedEventId()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + if (other.getControl() == null ^ this.getControl() == null) return false; + if (other.getControl() != null && other.getControl().equals(this.getControl()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/StartChildWorkflowExecutionInitiatedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/StartChildWorkflowExecutionInitiatedEventAttributes.java new file mode 100644 index 000000000000..b317876e5b1e --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/StartChildWorkflowExecutionInitiatedEventAttributes.java @@ -0,0 +1,868 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the + * StartChildWorkflowExecutionInitiated event. + *

+ */ +public class StartChildWorkflowExecutionInitiatedEventAttributes { + + /** + * The workflowId of the child workflow execution. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String workflowId; + + /** + * The type of the child workflow execution. + */ + private WorkflowType workflowType; + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. This data is not sent to the activity. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String control; + + /** + * The inputs provided to the child workflow execution (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String input; + + /** + * The maximum duration for the child workflow execution. If the workflow + * execution is not closed within this duration, it will be timed out and + * force terminated.

The valid values are integers greater than or + * equal to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String executionStartToCloseTimeout; + + /** + * The name of the task list used for the decision tasks of the child + * workflow execution. + */ + private TaskList taskList; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * StartChildWorkflowExecution Decision to request + * this child workflow execution. This information can be useful for + * diagnosing problems by tracing back the cause of events. + */ + private Long decisionTaskCompletedEventId; + + /** + * The policy to use for the child workflow executions if this execution + * gets terminated by explicitly calling the + * TerminateWorkflowExecution action or due to an expired timeout. + *

The supported child policies are:

  • TERMINATE: the + * child executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + */ + private String childPolicy; + + /** + * The maximum duration allowed for the decision tasks for this workflow + * execution.

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String taskStartToCloseTimeout; + + /** + * The list of tags to associated with the child workflow execution. + *

+ * Constraints:
+ * Length: 0 - 5
+ */ + private java.util.List tagList; + + /** + * The workflowId of the child workflow execution. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The workflowId of the child workflow execution. + */ + public String getWorkflowId() { + return workflowId; + } + + /** + * The workflowId of the child workflow execution. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the child workflow execution. + */ + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + /** + * The workflowId of the child workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the child workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionInitiatedEventAttributes withWorkflowId(String workflowId) { + this.workflowId = workflowId; + return this; + } + + + /** + * The type of the child workflow execution. + * + * @return The type of the child workflow execution. + */ + public WorkflowType getWorkflowType() { + return workflowType; + } + + /** + * The type of the child workflow execution. + * + * @param workflowType The type of the child workflow execution. + */ + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + /** + * The type of the child workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowType The type of the child workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionInitiatedEventAttributes withWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + return this; + } + + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. This data is not sent to the activity. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. This data is not sent to the activity. + */ + public String getControl() { + return control; + } + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. This data is not sent to the activity. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. This data is not sent to the activity. + */ + public void setControl(String control) { + this.control = control; + } + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. This data is not sent to the activity. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control Optional data attached to the event that can be used by the decider in + * subsequent decision tasks. This data is not sent to the activity. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionInitiatedEventAttributes withControl(String control) { + this.control = control; + return this; + } + + + /** + * The inputs provided to the child workflow execution (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The inputs provided to the child workflow execution (if any). + */ + public String getInput() { + return input; + } + + /** + * The inputs provided to the child workflow execution (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input The inputs provided to the child workflow execution (if any). + */ + public void setInput(String input) { + this.input = input; + } + + /** + * The inputs provided to the child workflow execution (if any). + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input The inputs provided to the child workflow execution (if any). + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionInitiatedEventAttributes withInput(String input) { + this.input = input; + return this; + } + + + /** + * The maximum duration for the child workflow execution. If the workflow + * execution is not closed within this duration, it will be timed out and + * force terminated.

The valid values are integers greater than or + * equal to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return The maximum duration for the child workflow execution. If the workflow + * execution is not closed within this duration, it will be timed out and + * force terminated.

The valid values are integers greater than or + * equal to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. + */ + public String getExecutionStartToCloseTimeout() { + return executionStartToCloseTimeout; + } + + /** + * The maximum duration for the child workflow execution. If the workflow + * execution is not closed within this duration, it will be timed out and + * force terminated.

The valid values are integers greater than or + * equal to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param executionStartToCloseTimeout The maximum duration for the child workflow execution. If the workflow + * execution is not closed within this duration, it will be timed out and + * force terminated.

The valid values are integers greater than or + * equal to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. + */ + public void setExecutionStartToCloseTimeout(String executionStartToCloseTimeout) { + this.executionStartToCloseTimeout = executionStartToCloseTimeout; + } + + /** + * The maximum duration for the child workflow execution. If the workflow + * execution is not closed within this duration, it will be timed out and + * force terminated.

The valid values are integers greater than or + * equal to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param executionStartToCloseTimeout The maximum duration for the child workflow execution. If the workflow + * execution is not closed within this duration, it will be timed out and + * force terminated.

The valid values are integers greater than or + * equal to 0. An integer value can be used to specify the + * duration in seconds while NONE can be used to specify + * unlimited duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionInitiatedEventAttributes withExecutionStartToCloseTimeout(String executionStartToCloseTimeout) { + this.executionStartToCloseTimeout = executionStartToCloseTimeout; + return this; + } + + + /** + * The name of the task list used for the decision tasks of the child + * workflow execution. + * + * @return The name of the task list used for the decision tasks of the child + * workflow execution. + */ + public TaskList getTaskList() { + return taskList; + } + + /** + * The name of the task list used for the decision tasks of the child + * workflow execution. + * + * @param taskList The name of the task list used for the decision tasks of the child + * workflow execution. + */ + public void setTaskList(TaskList taskList) { + this.taskList = taskList; + } + + /** + * The name of the task list used for the decision tasks of the child + * workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param taskList The name of the task list used for the decision tasks of the child + * workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionInitiatedEventAttributes withTaskList(TaskList taskList) { + this.taskList = taskList; + return this; + } + + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * StartChildWorkflowExecution Decision to request + * this child workflow execution. This information can be useful for + * diagnosing problems by tracing back the cause of events. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * StartChildWorkflowExecution Decision to request + * this child workflow execution. This information can be useful for + * diagnosing problems by tracing back the cause of events. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * StartChildWorkflowExecution Decision to request + * this child workflow execution. This information can be useful for + * diagnosing problems by tracing back the cause of events. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * StartChildWorkflowExecution Decision to request + * this child workflow execution. This information can be useful for + * diagnosing problems by tracing back the cause of events. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * StartChildWorkflowExecution Decision to request + * this child workflow execution. This information can be useful for + * diagnosing problems by tracing back the cause of events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * StartChildWorkflowExecution Decision to request + * this child workflow execution. This information can be useful for + * diagnosing problems by tracing back the cause of events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionInitiatedEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * The policy to use for the child workflow executions if this execution + * gets terminated by explicitly calling the + * TerminateWorkflowExecution action or due to an expired timeout. + *

The supported child policies are:

  • TERMINATE: the + * child executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @return The policy to use for the child workflow executions if this execution + * gets terminated by explicitly calling the + * TerminateWorkflowExecution action or due to an expired timeout. + *

The supported child policies are:

  • TERMINATE: the + * child executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ * + * @see ChildPolicy + */ + public String getChildPolicy() { + return childPolicy; + } + + /** + * The policy to use for the child workflow executions if this execution + * gets terminated by explicitly calling the + * TerminateWorkflowExecution action or due to an expired timeout. + *

The supported child policies are:

  • TERMINATE: the + * child executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy to use for the child workflow executions if this execution + * gets terminated by explicitly calling the + * TerminateWorkflowExecution action or due to an expired timeout. + *

The supported child policies are:

  • TERMINATE: the + * child executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ * + * @see ChildPolicy + */ + public void setChildPolicy(String childPolicy) { + this.childPolicy = childPolicy; + } + + /** + * The policy to use for the child workflow executions if this execution + * gets terminated by explicitly calling the + * TerminateWorkflowExecution action or due to an expired timeout. + *

The supported child policies are:

  • TERMINATE: the + * child executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy to use for the child workflow executions if this execution + * gets terminated by explicitly calling the + * TerminateWorkflowExecution action or due to an expired timeout. + *

The supported child policies are:

  • TERMINATE: the + * child executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public StartChildWorkflowExecutionInitiatedEventAttributes withChildPolicy(String childPolicy) { + this.childPolicy = childPolicy; + return this; + } + + + /** + * The policy to use for the child workflow executions if this execution + * gets terminated by explicitly calling the + * TerminateWorkflowExecution action or due to an expired timeout. + *

The supported child policies are:

  • TERMINATE: the + * child executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy to use for the child workflow executions if this execution + * gets terminated by explicitly calling the + * TerminateWorkflowExecution action or due to an expired timeout. + *

The supported child policies are:

  • TERMINATE: the + * child executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ * + * @see ChildPolicy + */ + public void setChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy.toString(); + } + + /** + * The policy to use for the child workflow executions if this execution + * gets terminated by explicitly calling the + * TerminateWorkflowExecution action or due to an expired timeout. + *

The supported child policies are:

  • TERMINATE: the + * child executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy to use for the child workflow executions if this execution + * gets terminated by explicitly calling the + * TerminateWorkflowExecution action or due to an expired timeout. + *

The supported child policies are:

  • TERMINATE: the + * child executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public StartChildWorkflowExecutionInitiatedEventAttributes withChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy.toString(); + return this; + } + + /** + * The maximum duration allowed for the decision tasks for this workflow + * execution.

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return The maximum duration allowed for the decision tasks for this workflow + * execution.

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + */ + public String getTaskStartToCloseTimeout() { + return taskStartToCloseTimeout; + } + + /** + * The maximum duration allowed for the decision tasks for this workflow + * execution.

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param taskStartToCloseTimeout The maximum duration allowed for the decision tasks for this workflow + * execution.

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + */ + public void setTaskStartToCloseTimeout(String taskStartToCloseTimeout) { + this.taskStartToCloseTimeout = taskStartToCloseTimeout; + } + + /** + * The maximum duration allowed for the decision tasks for this workflow + * execution.

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param taskStartToCloseTimeout The maximum duration allowed for the decision tasks for this workflow + * execution.

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionInitiatedEventAttributes withTaskStartToCloseTimeout(String taskStartToCloseTimeout) { + this.taskStartToCloseTimeout = taskStartToCloseTimeout; + return this; + } + + + /** + * The list of tags to associated with the child workflow execution. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @return The list of tags to associated with the child workflow execution. + */ + public java.util.List getTagList() { + + if (tagList == null) { + tagList = new java.util.ArrayList(); + } + return tagList; + } + + /** + * The list of tags to associated with the child workflow execution. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags to associated with the child workflow execution. + */ + public void setTagList(java.util.Collection tagList) { + if (tagList == null) { + this.tagList = null; + return; + } + + java.util.List tagListCopy = new java.util.ArrayList(tagList.size()); + tagListCopy.addAll(tagList); + this.tagList = tagListCopy; + } + + /** + * The list of tags to associated with the child workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags to associated with the child workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionInitiatedEventAttributes withTagList(String... tagList) { + if (getTagList() == null) setTagList(new java.util.ArrayList(tagList.length)); + for (String value : tagList) { + getTagList().add(value); + } + return this; + } + + /** + * The list of tags to associated with the child workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags to associated with the child workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartChildWorkflowExecutionInitiatedEventAttributes withTagList(java.util.Collection tagList) { + if (tagList == null) { + this.tagList = null; + } else { + java.util.List tagListCopy = new java.util.ArrayList(tagList.size()); + tagListCopy.addAll(tagList); + this.tagList = tagListCopy; + } + + return this; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowId != null) sb.append("WorkflowId: " + workflowId + ", "); + if (workflowType != null) sb.append("WorkflowType: " + workflowType + ", "); + if (control != null) sb.append("Control: " + control + ", "); + if (input != null) sb.append("Input: " + input + ", "); + if (executionStartToCloseTimeout != null) sb.append("ExecutionStartToCloseTimeout: " + executionStartToCloseTimeout + ", "); + if (taskList != null) sb.append("TaskList: " + taskList + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + if (childPolicy != null) sb.append("ChildPolicy: " + childPolicy + ", "); + if (taskStartToCloseTimeout != null) sb.append("TaskStartToCloseTimeout: " + taskStartToCloseTimeout + ", "); + if (tagList != null) sb.append("TagList: " + tagList + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowId() == null) ? 0 : getWorkflowId().hashCode()); + hashCode = prime * hashCode + ((getWorkflowType() == null) ? 0 : getWorkflowType().hashCode()); + hashCode = prime * hashCode + ((getControl() == null) ? 0 : getControl().hashCode()); + hashCode = prime * hashCode + ((getInput() == null) ? 0 : getInput().hashCode()); + hashCode = prime * hashCode + ((getExecutionStartToCloseTimeout() == null) ? 0 : getExecutionStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getTaskList() == null) ? 0 : getTaskList().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + hashCode = prime * hashCode + ((getChildPolicy() == null) ? 0 : getChildPolicy().hashCode()); + hashCode = prime * hashCode + ((getTaskStartToCloseTimeout() == null) ? 0 : getTaskStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getTagList() == null) ? 0 : getTagList().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof StartChildWorkflowExecutionInitiatedEventAttributes == false) return false; + StartChildWorkflowExecutionInitiatedEventAttributes other = (StartChildWorkflowExecutionInitiatedEventAttributes)obj; + + if (other.getWorkflowId() == null ^ this.getWorkflowId() == null) return false; + if (other.getWorkflowId() != null && other.getWorkflowId().equals(this.getWorkflowId()) == false) return false; + if (other.getWorkflowType() == null ^ this.getWorkflowType() == null) return false; + if (other.getWorkflowType() != null && other.getWorkflowType().equals(this.getWorkflowType()) == false) return false; + if (other.getControl() == null ^ this.getControl() == null) return false; + if (other.getControl() != null && other.getControl().equals(this.getControl()) == false) return false; + if (other.getInput() == null ^ this.getInput() == null) return false; + if (other.getInput() != null && other.getInput().equals(this.getInput()) == false) return false; + if (other.getExecutionStartToCloseTimeout() == null ^ this.getExecutionStartToCloseTimeout() == null) return false; + if (other.getExecutionStartToCloseTimeout() != null && other.getExecutionStartToCloseTimeout().equals(this.getExecutionStartToCloseTimeout()) == false) return false; + if (other.getTaskList() == null ^ this.getTaskList() == null) return false; + if (other.getTaskList() != null && other.getTaskList().equals(this.getTaskList()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + if (other.getChildPolicy() == null ^ this.getChildPolicy() == null) return false; + if (other.getChildPolicy() != null && other.getChildPolicy().equals(this.getChildPolicy()) == false) return false; + if (other.getTaskStartToCloseTimeout() == null ^ this.getTaskStartToCloseTimeout() == null) return false; + if (other.getTaskStartToCloseTimeout() != null && other.getTaskStartToCloseTimeout().equals(this.getTaskStartToCloseTimeout()) == false) return false; + if (other.getTagList() == null ^ this.getTagList() == null) return false; + if (other.getTagList() != null && other.getTagList().equals(this.getTagList()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/StartTimerDecisionAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/StartTimerDecisionAttributes.java new file mode 100644 index 000000000000..021a4a7f3a68 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/StartTimerDecisionAttributes.java @@ -0,0 +1,274 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the StartTimer decision. + *

+ */ +public class StartTimerDecisionAttributes { + + /** + * The unique Id of the timer. This field is required.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String timerId; + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String control; + + /** + * The duration to wait before firing the timer. This field is required. + *

The duration is specified in seconds. The valid values are integers + * greater than or equal to 0. + *

+ * Constraints:
+ * Length: 1 - 8
+ */ + private String startToFireTimeout; + + /** + * The unique Id of the timer. This field is required.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The unique Id of the timer. This field is required.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + */ + public String getTimerId() { + return timerId; + } + + /** + * The unique Id of the timer. This field is required.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param timerId The unique Id of the timer. This field is required.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + */ + public void setTimerId(String timerId) { + this.timerId = timerId; + } + + /** + * The unique Id of the timer. This field is required.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param timerId The unique Id of the timer. This field is required.

The specified + * string must not start or end with whitespace. It must not contain a + * : (colon), / (slash), | + * (vertical bar), or any control characters (\u0000-\u001f | \u007f - + * \u009f). Also, it must not contain the literal string "arn". + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartTimerDecisionAttributes withTimerId(String timerId) { + this.timerId = timerId; + return this; + } + + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + */ + public String getControl() { + return control; + } + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + */ + public void setControl(String control) { + this.control = control; + } + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartTimerDecisionAttributes withControl(String control) { + this.control = control; + return this; + } + + + /** + * The duration to wait before firing the timer. This field is required. + *

The duration is specified in seconds. The valid values are integers + * greater than or equal to 0. + *

+ * Constraints:
+ * Length: 1 - 8
+ * + * @return The duration to wait before firing the timer. This field is required. + *

The duration is specified in seconds. The valid values are integers + * greater than or equal to 0. + */ + public String getStartToFireTimeout() { + return startToFireTimeout; + } + + /** + * The duration to wait before firing the timer. This field is required. + *

The duration is specified in seconds. The valid values are integers + * greater than or equal to 0. + *

+ * Constraints:
+ * Length: 1 - 8
+ * + * @param startToFireTimeout The duration to wait before firing the timer. This field is required. + *

The duration is specified in seconds. The valid values are integers + * greater than or equal to 0. + */ + public void setStartToFireTimeout(String startToFireTimeout) { + this.startToFireTimeout = startToFireTimeout; + } + + /** + * The duration to wait before firing the timer. This field is required. + *

The duration is specified in seconds. The valid values are integers + * greater than or equal to 0. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 8
+ * + * @param startToFireTimeout The duration to wait before firing the timer. This field is required. + *

The duration is specified in seconds. The valid values are integers + * greater than or equal to 0. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartTimerDecisionAttributes withStartToFireTimeout(String startToFireTimeout) { + this.startToFireTimeout = startToFireTimeout; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (timerId != null) sb.append("TimerId: " + timerId + ", "); + if (control != null) sb.append("Control: " + control + ", "); + if (startToFireTimeout != null) sb.append("StartToFireTimeout: " + startToFireTimeout + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTimerId() == null) ? 0 : getTimerId().hashCode()); + hashCode = prime * hashCode + ((getControl() == null) ? 0 : getControl().hashCode()); + hashCode = prime * hashCode + ((getStartToFireTimeout() == null) ? 0 : getStartToFireTimeout().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof StartTimerDecisionAttributes == false) return false; + StartTimerDecisionAttributes other = (StartTimerDecisionAttributes)obj; + + if (other.getTimerId() == null ^ this.getTimerId() == null) return false; + if (other.getTimerId() != null && other.getTimerId().equals(this.getTimerId()) == false) return false; + if (other.getControl() == null ^ this.getControl() == null) return false; + if (other.getControl() != null && other.getControl().equals(this.getControl()) == false) return false; + if (other.getStartToFireTimeout() == null ^ this.getStartToFireTimeout() == null) return false; + if (other.getStartToFireTimeout() != null && other.getStartToFireTimeout().equals(this.getStartToFireTimeout()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/StartTimerFailedCause.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/StartTimerFailedCause.java new file mode 100644 index 000000000000..129e8efb315b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/StartTimerFailedCause.java @@ -0,0 +1,59 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Start Timer Failed Cause + */ +public enum StartTimerFailedCause { + + TIMER_ID_ALREADY_IN_USE("TIMER_ID_ALREADY_IN_USE"), + OPEN_TIMERS_LIMIT_EXCEEDED("OPEN_TIMERS_LIMIT_EXCEEDED"), + TIMER_CREATION_RATE_EXCEEDED("TIMER_CREATION_RATE_EXCEEDED"); + + private String value; + + private StartTimerFailedCause(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return StartTimerFailedCause corresponding to the value + */ + public static StartTimerFailedCause fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("TIMER_ID_ALREADY_IN_USE".equals(value)) { + return StartTimerFailedCause.TIMER_ID_ALREADY_IN_USE; + } else if ("OPEN_TIMERS_LIMIT_EXCEEDED".equals(value)) { + return StartTimerFailedCause.OPEN_TIMERS_LIMIT_EXCEEDED; + } else if ("TIMER_CREATION_RATE_EXCEEDED".equals(value)) { + return StartTimerFailedCause.TIMER_CREATION_RATE_EXCEEDED; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/StartTimerFailedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/StartTimerFailedEventAttributes.java new file mode 100644 index 000000000000..c4de3eabadd1 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/StartTimerFailedEventAttributes.java @@ -0,0 +1,292 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the StartTimerFailed event. + *

+ */ +public class StartTimerFailedEventAttributes { + + /** + * The timerId provided in the StartTimer decision that + * failed. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String timerId; + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: TIMER_ID_ALREADY_IN_USE, OPEN_TIMERS_LIMIT_EXCEEDED, TIMER_CREATION_RATE_EXCEEDED + */ + private String cause; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the StartTimer + * decision for this activity task. This information can be useful for + * diagnosing problems by tracing back the cause of events. + */ + private Long decisionTaskCompletedEventId; + + /** + * The timerId provided in the StartTimer decision that + * failed. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The timerId provided in the StartTimer decision that + * failed. + */ + public String getTimerId() { + return timerId; + } + + /** + * The timerId provided in the StartTimer decision that + * failed. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param timerId The timerId provided in the StartTimer decision that + * failed. + */ + public void setTimerId(String timerId) { + this.timerId = timerId; + } + + /** + * The timerId provided in the StartTimer decision that + * failed. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param timerId The timerId provided in the StartTimer decision that + * failed. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartTimerFailedEventAttributes withTimerId(String timerId) { + this.timerId = timerId; + return this; + } + + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: TIMER_ID_ALREADY_IN_USE, OPEN_TIMERS_LIMIT_EXCEEDED, TIMER_CREATION_RATE_EXCEEDED + * + * @return The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see StartTimerFailedCause + */ + public String getCause() { + return cause; + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: TIMER_ID_ALREADY_IN_USE, OPEN_TIMERS_LIMIT_EXCEEDED, TIMER_CREATION_RATE_EXCEEDED + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see StartTimerFailedCause + */ + public void setCause(String cause) { + this.cause = cause; + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TIMER_ID_ALREADY_IN_USE, OPEN_TIMERS_LIMIT_EXCEEDED, TIMER_CREATION_RATE_EXCEEDED + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see StartTimerFailedCause + */ + public StartTimerFailedEventAttributes withCause(String cause) { + this.cause = cause; + return this; + } + + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Constraints:
+ * Allowed Values: TIMER_ID_ALREADY_IN_USE, OPEN_TIMERS_LIMIT_EXCEEDED, TIMER_CREATION_RATE_EXCEEDED + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @see StartTimerFailedCause + */ + public void setCause(StartTimerFailedCause cause) { + this.cause = cause.toString(); + } + + /** + * The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TIMER_ID_ALREADY_IN_USE, OPEN_TIMERS_LIMIT_EXCEEDED, TIMER_CREATION_RATE_EXCEEDED + * + * @param cause The cause of the failure to process the decision. This information is + * generated by the system and can be useful for diagnostic purposes. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see StartTimerFailedCause + */ + public StartTimerFailedEventAttributes withCause(StartTimerFailedCause cause) { + this.cause = cause.toString(); + return this; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the StartTimer + * decision for this activity task. This information can be useful for + * diagnosing problems by tracing back the cause of events. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the StartTimer + * decision for this activity task. This information can be useful for + * diagnosing problems by tracing back the cause of events. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the StartTimer + * decision for this activity task. This information can be useful for + * diagnosing problems by tracing back the cause of events. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the StartTimer + * decision for this activity task. This information can be useful for + * diagnosing problems by tracing back the cause of events. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the StartTimer + * decision for this activity task. This information can be useful for + * diagnosing problems by tracing back the cause of events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the StartTimer + * decision for this activity task. This information can be useful for + * diagnosing problems by tracing back the cause of events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartTimerFailedEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (timerId != null) sb.append("TimerId: " + timerId + ", "); + if (cause != null) sb.append("Cause: " + cause + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTimerId() == null) ? 0 : getTimerId().hashCode()); + hashCode = prime * hashCode + ((getCause() == null) ? 0 : getCause().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof StartTimerFailedEventAttributes == false) return false; + StartTimerFailedEventAttributes other = (StartTimerFailedEventAttributes)obj; + + if (other.getTimerId() == null ^ this.getTimerId() == null) return false; + if (other.getTimerId() != null && other.getTimerId().equals(this.getTimerId()) == false) return false; + if (other.getCause() == null ^ this.getCause() == null) return false; + if (other.getCause() != null && other.getCause().equals(this.getCause()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/StartWorkflowExecutionRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/StartWorkflowExecutionRequest.java new file mode 100644 index 000000000000..042cb05a773f --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/StartWorkflowExecutionRequest.java @@ -0,0 +1,1128 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#startWorkflowExecution(StartWorkflowExecutionRequest) StartWorkflowExecution operation}. + *

+ * Starts an execution of the workflow type in the specified domain + * using the provided workflowId and input data. + *

+ *

+ * This action returns the newly started workflow execution. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#startWorkflowExecution(StartWorkflowExecutionRequest) + */ +public class StartWorkflowExecutionRequest extends AmazonWebServiceRequest { + + /** + * The name of the domain in which the workflow execution is created. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * The user defined identifier associated with the workflow execution. + * You can use this to associate a custom identifier with the workflow + * execution. You may specify the same identifier if a workflow execution + * is logically a restart of a previous execution. You cannot have + * two open workflow executions with the same workflowId at + * the same time.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String workflowId; + + /** + * The type of the workflow to start. + */ + private WorkflowType workflowType; + + /** + * The task list to use for the decision tasks generated for this + * workflow execution. This overrides the defaultTaskList + * specified when registering the workflow type. A task list for + * this workflow execution must be specified either as a default for the + * workflow type or through this parameter. If neither this parameter is + * set nor a default task list was specified at registration time then a + * fault will be returned.

The specified string must not start + * or end with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + */ + private TaskList taskList; + + /** + * The input for the workflow execution. This is a free form string which + * should be meaningful to the workflow you are starting. This + * input is made available to the new workflow execution in + * the WorkflowExecutionStarted history event. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String input; + + /** + * The total duration for this workflow execution. This overrides the + * defaultExecutionStartToCloseTimeout specified when registering the + * workflow type.

The duration is specified in seconds. The valid + * values are integers greater than or equal to 0. Exceeding this limit + * will cause the workflow execution to time out. Unlike some of the + * other timeout parameters in Amazon SWF, you cannot specify a value of + * "NONE" for this timeout; there is a one-year max limit on the time + * that a workflow execution can run. An execution start-to-close + * timeout must be specified either through this parameter or as a + * default when the workflow type is registered. If neither this + * parameter nor a default execution start-to-close timeout is specified, + * a fault is returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String executionStartToCloseTimeout; + + /** + * The list of tags to associate with the workflow execution. You can + * specify a maximum of 5 tags. You can list workflow executions with a + * specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + *

+ * Constraints:
+ * Length: 0 - 5
+ */ + private java.util.List tagList; + + /** + * Specifies the maximum duration of decision tasks for this workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for this workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String taskStartToCloseTimeout; + + /** + * If set, specifies the policy to use for the child workflow executions + * of this workflow execution if it is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time then a fault will be returned. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + */ + private String childPolicy; + + /** + * The name of the domain in which the workflow execution is created. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the domain in which the workflow execution is created. + */ + public String getDomain() { + return domain; + } + + /** + * The name of the domain in which the workflow execution is created. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain in which the workflow execution is created. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The name of the domain in which the workflow execution is created. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The name of the domain in which the workflow execution is created. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartWorkflowExecutionRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * The user defined identifier associated with the workflow execution. + * You can use this to associate a custom identifier with the workflow + * execution. You may specify the same identifier if a workflow execution + * is logically a restart of a previous execution. You cannot have + * two open workflow executions with the same workflowId at + * the same time.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The user defined identifier associated with the workflow execution. + * You can use this to associate a custom identifier with the workflow + * execution. You may specify the same identifier if a workflow execution + * is logically a restart of a previous execution. You cannot have + * two open workflow executions with the same workflowId at + * the same time.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + */ + public String getWorkflowId() { + return workflowId; + } + + /** + * The user defined identifier associated with the workflow execution. + * You can use this to associate a custom identifier with the workflow + * execution. You may specify the same identifier if a workflow execution + * is logically a restart of a previous execution. You cannot have + * two open workflow executions with the same workflowId at + * the same time.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The user defined identifier associated with the workflow execution. + * You can use this to associate a custom identifier with the workflow + * execution. You may specify the same identifier if a workflow execution + * is logically a restart of a previous execution. You cannot have + * two open workflow executions with the same workflowId at + * the same time.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + */ + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + /** + * The user defined identifier associated with the workflow execution. + * You can use this to associate a custom identifier with the workflow + * execution. You may specify the same identifier if a workflow execution + * is logically a restart of a previous execution. You cannot have + * two open workflow executions with the same workflowId at + * the same time.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The user defined identifier associated with the workflow execution. + * You can use this to associate a custom identifier with the workflow + * execution. You may specify the same identifier if a workflow execution + * is logically a restart of a previous execution. You cannot have + * two open workflow executions with the same workflowId at + * the same time.

The specified string must not start or end with + * whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartWorkflowExecutionRequest withWorkflowId(String workflowId) { + this.workflowId = workflowId; + return this; + } + + + /** + * The type of the workflow to start. + * + * @return The type of the workflow to start. + */ + public WorkflowType getWorkflowType() { + return workflowType; + } + + /** + * The type of the workflow to start. + * + * @param workflowType The type of the workflow to start. + */ + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + /** + * The type of the workflow to start. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowType The type of the workflow to start. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartWorkflowExecutionRequest withWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + return this; + } + + + /** + * The task list to use for the decision tasks generated for this + * workflow execution. This overrides the defaultTaskList + * specified when registering the workflow type. A task list for + * this workflow execution must be specified either as a default for the + * workflow type or through this parameter. If neither this parameter is + * set nor a default task list was specified at registration time then a + * fault will be returned.

The specified string must not start + * or end with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + * + * @return The task list to use for the decision tasks generated for this + * workflow execution. This overrides the defaultTaskList + * specified when registering the workflow type. A task list for + * this workflow execution must be specified either as a default for the + * workflow type or through this parameter. If neither this parameter is + * set nor a default task list was specified at registration time then a + * fault will be returned.

The specified string must not start + * or end with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + */ + public TaskList getTaskList() { + return taskList; + } + + /** + * The task list to use for the decision tasks generated for this + * workflow execution. This overrides the defaultTaskList + * specified when registering the workflow type. A task list for + * this workflow execution must be specified either as a default for the + * workflow type or through this parameter. If neither this parameter is + * set nor a default task list was specified at registration time then a + * fault will be returned.

The specified string must not start + * or end with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + * + * @param taskList The task list to use for the decision tasks generated for this + * workflow execution. This overrides the defaultTaskList + * specified when registering the workflow type. A task list for + * this workflow execution must be specified either as a default for the + * workflow type or through this parameter. If neither this parameter is + * set nor a default task list was specified at registration time then a + * fault will be returned.

The specified string must not start + * or end with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + */ + public void setTaskList(TaskList taskList) { + this.taskList = taskList; + } + + /** + * The task list to use for the decision tasks generated for this + * workflow execution. This overrides the defaultTaskList + * specified when registering the workflow type. A task list for + * this workflow execution must be specified either as a default for the + * workflow type or through this parameter. If neither this parameter is + * set nor a default task list was specified at registration time then a + * fault will be returned.

The specified string must not start + * or end with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param taskList The task list to use for the decision tasks generated for this + * workflow execution. This overrides the defaultTaskList + * specified when registering the workflow type. A task list for + * this workflow execution must be specified either as a default for the + * workflow type or through this parameter. If neither this parameter is + * set nor a default task list was specified at registration time then a + * fault will be returned.

The specified string must not start + * or end with whitespace. It must not contain a : (colon), + * / (slash), | (vertical bar), or any control + * characters (\u0000-\u001f | \u007f - \u009f). Also, it must not + * contain the literal string "arn". + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartWorkflowExecutionRequest withTaskList(TaskList taskList) { + this.taskList = taskList; + return this; + } + + + /** + * The input for the workflow execution. This is a free form string which + * should be meaningful to the workflow you are starting. This + * input is made available to the new workflow execution in + * the WorkflowExecutionStarted history event. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The input for the workflow execution. This is a free form string which + * should be meaningful to the workflow you are starting. This + * input is made available to the new workflow execution in + * the WorkflowExecutionStarted history event. + */ + public String getInput() { + return input; + } + + /** + * The input for the workflow execution. This is a free form string which + * should be meaningful to the workflow you are starting. This + * input is made available to the new workflow execution in + * the WorkflowExecutionStarted history event. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input The input for the workflow execution. This is a free form string which + * should be meaningful to the workflow you are starting. This + * input is made available to the new workflow execution in + * the WorkflowExecutionStarted history event. + */ + public void setInput(String input) { + this.input = input; + } + + /** + * The input for the workflow execution. This is a free form string which + * should be meaningful to the workflow you are starting. This + * input is made available to the new workflow execution in + * the WorkflowExecutionStarted history event. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input The input for the workflow execution. This is a free form string which + * should be meaningful to the workflow you are starting. This + * input is made available to the new workflow execution in + * the WorkflowExecutionStarted history event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartWorkflowExecutionRequest withInput(String input) { + this.input = input; + return this; + } + + + /** + * The total duration for this workflow execution. This overrides the + * defaultExecutionStartToCloseTimeout specified when registering the + * workflow type.

The duration is specified in seconds. The valid + * values are integers greater than or equal to 0. Exceeding this limit + * will cause the workflow execution to time out. Unlike some of the + * other timeout parameters in Amazon SWF, you cannot specify a value of + * "NONE" for this timeout; there is a one-year max limit on the time + * that a workflow execution can run. An execution start-to-close + * timeout must be specified either through this parameter or as a + * default when the workflow type is registered. If neither this + * parameter nor a default execution start-to-close timeout is specified, + * a fault is returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return The total duration for this workflow execution. This overrides the + * defaultExecutionStartToCloseTimeout specified when registering the + * workflow type.

The duration is specified in seconds. The valid + * values are integers greater than or equal to 0. Exceeding this limit + * will cause the workflow execution to time out. Unlike some of the + * other timeout parameters in Amazon SWF, you cannot specify a value of + * "NONE" for this timeout; there is a one-year max limit on the time + * that a workflow execution can run. An execution start-to-close + * timeout must be specified either through this parameter or as a + * default when the workflow type is registered. If neither this + * parameter nor a default execution start-to-close timeout is specified, + * a fault is returned. + */ + public String getExecutionStartToCloseTimeout() { + return executionStartToCloseTimeout; + } + + /** + * The total duration for this workflow execution. This overrides the + * defaultExecutionStartToCloseTimeout specified when registering the + * workflow type.

The duration is specified in seconds. The valid + * values are integers greater than or equal to 0. Exceeding this limit + * will cause the workflow execution to time out. Unlike some of the + * other timeout parameters in Amazon SWF, you cannot specify a value of + * "NONE" for this timeout; there is a one-year max limit on the time + * that a workflow execution can run. An execution start-to-close + * timeout must be specified either through this parameter or as a + * default when the workflow type is registered. If neither this + * parameter nor a default execution start-to-close timeout is specified, + * a fault is returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param executionStartToCloseTimeout The total duration for this workflow execution. This overrides the + * defaultExecutionStartToCloseTimeout specified when registering the + * workflow type.

The duration is specified in seconds. The valid + * values are integers greater than or equal to 0. Exceeding this limit + * will cause the workflow execution to time out. Unlike some of the + * other timeout parameters in Amazon SWF, you cannot specify a value of + * "NONE" for this timeout; there is a one-year max limit on the time + * that a workflow execution can run. An execution start-to-close + * timeout must be specified either through this parameter or as a + * default when the workflow type is registered. If neither this + * parameter nor a default execution start-to-close timeout is specified, + * a fault is returned. + */ + public void setExecutionStartToCloseTimeout(String executionStartToCloseTimeout) { + this.executionStartToCloseTimeout = executionStartToCloseTimeout; + } + + /** + * The total duration for this workflow execution. This overrides the + * defaultExecutionStartToCloseTimeout specified when registering the + * workflow type.

The duration is specified in seconds. The valid + * values are integers greater than or equal to 0. Exceeding this limit + * will cause the workflow execution to time out. Unlike some of the + * other timeout parameters in Amazon SWF, you cannot specify a value of + * "NONE" for this timeout; there is a one-year max limit on the time + * that a workflow execution can run. An execution start-to-close + * timeout must be specified either through this parameter or as a + * default when the workflow type is registered. If neither this + * parameter nor a default execution start-to-close timeout is specified, + * a fault is returned. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param executionStartToCloseTimeout The total duration for this workflow execution. This overrides the + * defaultExecutionStartToCloseTimeout specified when registering the + * workflow type.

The duration is specified in seconds. The valid + * values are integers greater than or equal to 0. Exceeding this limit + * will cause the workflow execution to time out. Unlike some of the + * other timeout parameters in Amazon SWF, you cannot specify a value of + * "NONE" for this timeout; there is a one-year max limit on the time + * that a workflow execution can run. An execution start-to-close + * timeout must be specified either through this parameter or as a + * default when the workflow type is registered. If neither this + * parameter nor a default execution start-to-close timeout is specified, + * a fault is returned. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartWorkflowExecutionRequest withExecutionStartToCloseTimeout(String executionStartToCloseTimeout) { + this.executionStartToCloseTimeout = executionStartToCloseTimeout; + return this; + } + + + /** + * The list of tags to associate with the workflow execution. You can + * specify a maximum of 5 tags. You can list workflow executions with a + * specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @return The list of tags to associate with the workflow execution. You can + * specify a maximum of 5 tags. You can list workflow executions with a + * specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + */ + public java.util.List getTagList() { + + if (tagList == null) { + tagList = new java.util.ArrayList(); + } + return tagList; + } + + /** + * The list of tags to associate with the workflow execution. You can + * specify a maximum of 5 tags. You can list workflow executions with a + * specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags to associate with the workflow execution. You can + * specify a maximum of 5 tags. You can list workflow executions with a + * specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + */ + public void setTagList(java.util.Collection tagList) { + if (tagList == null) { + this.tagList = null; + return; + } + + java.util.List tagListCopy = new java.util.ArrayList(tagList.size()); + tagListCopy.addAll(tagList); + this.tagList = tagListCopy; + } + + /** + * The list of tags to associate with the workflow execution. You can + * specify a maximum of 5 tags. You can list workflow executions with a + * specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags to associate with the workflow execution. You can + * specify a maximum of 5 tags. You can list workflow executions with a + * specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartWorkflowExecutionRequest withTagList(String... tagList) { + if (getTagList() == null) setTagList(new java.util.ArrayList(tagList.length)); + for (String value : tagList) { + getTagList().add(value); + } + return this; + } + + /** + * The list of tags to associate with the workflow execution. You can + * specify a maximum of 5 tags. You can list workflow executions with a + * specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags to associate with the workflow execution. You can + * specify a maximum of 5 tags. You can list workflow executions with a + * specific tag by calling ListOpenWorkflowExecutions or + * ListClosedWorkflowExecutions and specifying a TagFilter. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartWorkflowExecutionRequest withTagList(java.util.Collection tagList) { + if (tagList == null) { + this.tagList = null; + } else { + java.util.List tagListCopy = new java.util.ArrayList(tagList.size()); + tagListCopy.addAll(tagList); + this.tagList = tagListCopy; + } + + return this; + } + + /** + * Specifies the maximum duration of decision tasks for this workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for this workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return Specifies the maximum duration of decision tasks for this workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for this workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + */ + public String getTaskStartToCloseTimeout() { + return taskStartToCloseTimeout; + } + + /** + * Specifies the maximum duration of decision tasks for this workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for this workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param taskStartToCloseTimeout Specifies the maximum duration of decision tasks for this workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for this workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + */ + public void setTaskStartToCloseTimeout(String taskStartToCloseTimeout) { + this.taskStartToCloseTimeout = taskStartToCloseTimeout; + } + + /** + * Specifies the maximum duration of decision tasks for this workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for this workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param taskStartToCloseTimeout Specifies the maximum duration of decision tasks for this workflow + * execution. This parameter overrides the + * defaultTaskStartToCloseTimout specified when registering + * the workflow type using RegisterWorkflowType.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. A + * task start-to-close timeout for this workflow execution must be + * specified either as a default for the workflow type or through this + * parameter. If neither this parameter is set nor a default task + * start-to-close timeout was specified at registration time then a fault + * will be returned. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public StartWorkflowExecutionRequest withTaskStartToCloseTimeout(String taskStartToCloseTimeout) { + this.taskStartToCloseTimeout = taskStartToCloseTimeout; + return this; + } + + + /** + * If set, specifies the policy to use for the child workflow executions + * of this workflow execution if it is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time then a fault will be returned. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @return If set, specifies the policy to use for the child workflow executions + * of this workflow execution if it is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time then a fault will be returned. + * + * @see ChildPolicy + */ + public String getChildPolicy() { + return childPolicy; + } + + /** + * If set, specifies the policy to use for the child workflow executions + * of this workflow execution if it is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time then a fault will be returned. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy If set, specifies the policy to use for the child workflow executions + * of this workflow execution if it is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time then a fault will be returned. + * + * @see ChildPolicy + */ + public void setChildPolicy(String childPolicy) { + this.childPolicy = childPolicy; + } + + /** + * If set, specifies the policy to use for the child workflow executions + * of this workflow execution if it is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time then a fault will be returned. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy If set, specifies the policy to use for the child workflow executions + * of this workflow execution if it is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time then a fault will be returned. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public StartWorkflowExecutionRequest withChildPolicy(String childPolicy) { + this.childPolicy = childPolicy; + return this; + } + + + /** + * If set, specifies the policy to use for the child workflow executions + * of this workflow execution if it is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time then a fault will be returned. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy If set, specifies the policy to use for the child workflow executions + * of this workflow execution if it is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time then a fault will be returned. + * + * @see ChildPolicy + */ + public void setChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy.toString(); + } + + /** + * If set, specifies the policy to use for the child workflow executions + * of this workflow execution if it is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time then a fault will be returned. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy If set, specifies the policy to use for the child workflow executions + * of this workflow execution if it is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This policy overrides the default child policy + * specified when registering the workflow type using + * RegisterWorkflowType. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time then a fault will be returned. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public StartWorkflowExecutionRequest withChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy.toString(); + return this; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (workflowId != null) sb.append("WorkflowId: " + workflowId + ", "); + if (workflowType != null) sb.append("WorkflowType: " + workflowType + ", "); + if (taskList != null) sb.append("TaskList: " + taskList + ", "); + if (input != null) sb.append("Input: " + input + ", "); + if (executionStartToCloseTimeout != null) sb.append("ExecutionStartToCloseTimeout: " + executionStartToCloseTimeout + ", "); + if (tagList != null) sb.append("TagList: " + tagList + ", "); + if (taskStartToCloseTimeout != null) sb.append("TaskStartToCloseTimeout: " + taskStartToCloseTimeout + ", "); + if (childPolicy != null) sb.append("ChildPolicy: " + childPolicy + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getWorkflowId() == null) ? 0 : getWorkflowId().hashCode()); + hashCode = prime * hashCode + ((getWorkflowType() == null) ? 0 : getWorkflowType().hashCode()); + hashCode = prime * hashCode + ((getTaskList() == null) ? 0 : getTaskList().hashCode()); + hashCode = prime * hashCode + ((getInput() == null) ? 0 : getInput().hashCode()); + hashCode = prime * hashCode + ((getExecutionStartToCloseTimeout() == null) ? 0 : getExecutionStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getTagList() == null) ? 0 : getTagList().hashCode()); + hashCode = prime * hashCode + ((getTaskStartToCloseTimeout() == null) ? 0 : getTaskStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getChildPolicy() == null) ? 0 : getChildPolicy().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof StartWorkflowExecutionRequest == false) return false; + StartWorkflowExecutionRequest other = (StartWorkflowExecutionRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getWorkflowId() == null ^ this.getWorkflowId() == null) return false; + if (other.getWorkflowId() != null && other.getWorkflowId().equals(this.getWorkflowId()) == false) return false; + if (other.getWorkflowType() == null ^ this.getWorkflowType() == null) return false; + if (other.getWorkflowType() != null && other.getWorkflowType().equals(this.getWorkflowType()) == false) return false; + if (other.getTaskList() == null ^ this.getTaskList() == null) return false; + if (other.getTaskList() != null && other.getTaskList().equals(this.getTaskList()) == false) return false; + if (other.getInput() == null ^ this.getInput() == null) return false; + if (other.getInput() != null && other.getInput().equals(this.getInput()) == false) return false; + if (other.getExecutionStartToCloseTimeout() == null ^ this.getExecutionStartToCloseTimeout() == null) return false; + if (other.getExecutionStartToCloseTimeout() != null && other.getExecutionStartToCloseTimeout().equals(this.getExecutionStartToCloseTimeout()) == false) return false; + if (other.getTagList() == null ^ this.getTagList() == null) return false; + if (other.getTagList() != null && other.getTagList().equals(this.getTagList()) == false) return false; + if (other.getTaskStartToCloseTimeout() == null ^ this.getTaskStartToCloseTimeout() == null) return false; + if (other.getTaskStartToCloseTimeout() != null && other.getTaskStartToCloseTimeout().equals(this.getTaskStartToCloseTimeout()) == false) return false; + if (other.getChildPolicy() == null ^ this.getChildPolicy() == null) return false; + if (other.getChildPolicy() != null && other.getChildPolicy().equals(this.getChildPolicy()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/TagFilter.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/TagFilter.java new file mode 100644 index 000000000000..db5105238146 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/TagFilter.java @@ -0,0 +1,123 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Used to filter the workflow executions in visibility APIs based on a + * tag. + *

+ */ +public class TagFilter { + + /** + * Specifies the tag that must be associated with the execution for it to + * meet the filter criteria. This field is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String tag; + + /** + * Specifies the tag that must be associated with the execution for it to + * meet the filter criteria. This field is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return Specifies the tag that must be associated with the execution for it to + * meet the filter criteria. This field is required. + */ + public String getTag() { + return tag; + } + + /** + * Specifies the tag that must be associated with the execution for it to + * meet the filter criteria. This field is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param tag Specifies the tag that must be associated with the execution for it to + * meet the filter criteria. This field is required. + */ + public void setTag(String tag) { + this.tag = tag; + } + + /** + * Specifies the tag that must be associated with the execution for it to + * meet the filter criteria. This field is required. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param tag Specifies the tag that must be associated with the execution for it to + * meet the filter criteria. This field is required. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public TagFilter withTag(String tag) { + this.tag = tag; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (tag != null) sb.append("Tag: " + tag + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTag() == null) ? 0 : getTag().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof TagFilter == false) return false; + TagFilter other = (TagFilter)obj; + + if (other.getTag() == null ^ this.getTag() == null) return false; + if (other.getTag() != null && other.getTag().equals(this.getTag()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/TaskList.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/TaskList.java new file mode 100644 index 000000000000..9d7423ca57b8 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/TaskList.java @@ -0,0 +1,115 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Represents a task list. + *

+ */ +public class TaskList { + + /** + * The name of the task list. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String name; + + /** + * The name of the task list. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the task list. + */ + public String getName() { + return name; + } + + /** + * The name of the task list. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name The name of the task list. + */ + public void setName(String name) { + this.name = name; + } + + /** + * The name of the task list. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name The name of the task list. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public TaskList withName(String name) { + this.name = name; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (name != null) sb.append("Name: " + name + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof TaskList == false) return false; + TaskList other = (TaskList)obj; + + if (other.getName() == null ^ this.getName() == null) return false; + if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/TerminateWorkflowExecutionRequest.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/TerminateWorkflowExecutionRequest.java new file mode 100644 index 000000000000..3afe3a3d6fca --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/TerminateWorkflowExecutionRequest.java @@ -0,0 +1,606 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; +import com.amazonaws.AmazonWebServiceRequest; + +/** + * Container for the parameters to the {@link com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#terminateWorkflowExecution(TerminateWorkflowExecutionRequest) TerminateWorkflowExecution operation}. + *

+ * Records a WorkflowExecutionTerminated event and forces + * closure of the workflow execution identified by the given domain, + * runId, and workflowId. The child policy, registered with the workflow + * type or specified when starting this execution, is applied to any open + * child workflow executions of this workflow execution. + *

+ *

+ * IMPORTANT: If the identified workflow execution was in + * progress, it is terminated immediately. + *

+ *

+ * NOTE: If a runId is not specified, then the + * WorkflowExecutionTerminated event is recorded in the history of the + * current open workflow with the matching workflowId in the domain. + *

+ *

+ * NOTE: You should consider using RequestCancelWorkflowExecution + * action instead because it allows the workflow to gracefully close + * while TerminateWorkflowExecution does not. + *

+ * + * @see com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow#terminateWorkflowExecution(TerminateWorkflowExecutionRequest) + */ +public class TerminateWorkflowExecutionRequest extends AmazonWebServiceRequest { + + /** + * The domain of the workflow execution to terminate. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String domain; + + /** + * The workflowId of the workflow execution to terminate. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String workflowId; + + /** + * The runId of the workflow execution to terminate. + *

+ * Constraints:
+ * Length: 0 - 64
+ */ + private String runId; + + /** + * An optional descriptive reason for terminating the workflow execution. + *

+ * Constraints:
+ * Length: 0 - 256
+ */ + private String reason; + + /** + * Optional details for terminating the workflow execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String details; + + /** + * If set, specifies the policy to use for the child workflow executions + * of the workflow execution being terminated. This policy overrides the + * child policy specified for the workflow execution at registration time + * or when starting the execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time, a fault will be returned. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + */ + private String childPolicy; + + /** + * The domain of the workflow execution to terminate. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The domain of the workflow execution to terminate. + */ + public String getDomain() { + return domain; + } + + /** + * The domain of the workflow execution to terminate. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The domain of the workflow execution to terminate. + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * The domain of the workflow execution to terminate. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param domain The domain of the workflow execution to terminate. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public TerminateWorkflowExecutionRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + + /** + * The workflowId of the workflow execution to terminate. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The workflowId of the workflow execution to terminate. + */ + public String getWorkflowId() { + return workflowId; + } + + /** + * The workflowId of the workflow execution to terminate. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the workflow execution to terminate. + */ + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + /** + * The workflowId of the workflow execution to terminate. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId of the workflow execution to terminate. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public TerminateWorkflowExecutionRequest withWorkflowId(String workflowId) { + this.workflowId = workflowId; + return this; + } + + + /** + * The runId of the workflow execution to terminate. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @return The runId of the workflow execution to terminate. + */ + public String getRunId() { + return runId; + } + + /** + * The runId of the workflow execution to terminate. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param runId The runId of the workflow execution to terminate. + */ + public void setRunId(String runId) { + this.runId = runId; + } + + /** + * The runId of the workflow execution to terminate. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param runId The runId of the workflow execution to terminate. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public TerminateWorkflowExecutionRequest withRunId(String runId) { + this.runId = runId; + return this; + } + + + /** + * An optional descriptive reason for terminating the workflow execution. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @return An optional descriptive reason for terminating the workflow execution. + */ + public String getReason() { + return reason; + } + + /** + * An optional descriptive reason for terminating the workflow execution. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param reason An optional descriptive reason for terminating the workflow execution. + */ + public void setReason(String reason) { + this.reason = reason; + } + + /** + * An optional descriptive reason for terminating the workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param reason An optional descriptive reason for terminating the workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public TerminateWorkflowExecutionRequest withReason(String reason) { + this.reason = reason; + return this; + } + + + /** + * Optional details for terminating the workflow execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Optional details for terminating the workflow execution. + */ + public String getDetails() { + return details; + } + + /** + * Optional details for terminating the workflow execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details Optional details for terminating the workflow execution. + */ + public void setDetails(String details) { + this.details = details; + } + + /** + * Optional details for terminating the workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details Optional details for terminating the workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public TerminateWorkflowExecutionRequest withDetails(String details) { + this.details = details; + return this; + } + + + /** + * If set, specifies the policy to use for the child workflow executions + * of the workflow execution being terminated. This policy overrides the + * child policy specified for the workflow execution at registration time + * or when starting the execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time, a fault will be returned. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @return If set, specifies the policy to use for the child workflow executions + * of the workflow execution being terminated. This policy overrides the + * child policy specified for the workflow execution at registration time + * or when starting the execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time, a fault will be returned. + * + * @see ChildPolicy + */ + public String getChildPolicy() { + return childPolicy; + } + + /** + * If set, specifies the policy to use for the child workflow executions + * of the workflow execution being terminated. This policy overrides the + * child policy specified for the workflow execution at registration time + * or when starting the execution. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time, a fault will be returned. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy If set, specifies the policy to use for the child workflow executions + * of the workflow execution being terminated. This policy overrides the + * child policy specified for the workflow execution at registration time + * or when starting the execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time, a fault will be returned. + * + * @see ChildPolicy + */ + public void setChildPolicy(String childPolicy) { + this.childPolicy = childPolicy; + } + + /** + * If set, specifies the policy to use for the child workflow executions + * of the workflow execution being terminated. This policy overrides the + * child policy specified for the workflow execution at registration time + * or when starting the execution. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time, a fault will be returned. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy If set, specifies the policy to use for the child workflow executions + * of the workflow execution being terminated. This policy overrides the + * child policy specified for the workflow execution at registration time + * or when starting the execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time, a fault will be returned. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public TerminateWorkflowExecutionRequest withChildPolicy(String childPolicy) { + this.childPolicy = childPolicy; + return this; + } + + + /** + * If set, specifies the policy to use for the child workflow executions + * of the workflow execution being terminated. This policy overrides the + * child policy specified for the workflow execution at registration time + * or when starting the execution. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time, a fault will be returned. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy If set, specifies the policy to use for the child workflow executions + * of the workflow execution being terminated. This policy overrides the + * child policy specified for the workflow execution at registration time + * or when starting the execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time, a fault will be returned. + * + * @see ChildPolicy + */ + public void setChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy.toString(); + } + + /** + * If set, specifies the policy to use for the child workflow executions + * of the workflow execution being terminated. This policy overrides the + * child policy specified for the workflow execution at registration time + * or when starting the execution. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time, a fault will be returned. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy If set, specifies the policy to use for the child workflow executions + * of the workflow execution being terminated. This policy overrides the + * child policy specified for the workflow execution at registration time + * or when starting the execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * A child policy for this workflow execution must be specified + * either as a default for the workflow type or through this parameter. + * If neither this parameter is set nor a default child policy was + * specified at registration time, a fault will be returned. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public TerminateWorkflowExecutionRequest withChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy.toString(); + return this; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (domain != null) sb.append("Domain: " + domain + ", "); + if (workflowId != null) sb.append("WorkflowId: " + workflowId + ", "); + if (runId != null) sb.append("RunId: " + runId + ", "); + if (reason != null) sb.append("Reason: " + reason + ", "); + if (details != null) sb.append("Details: " + details + ", "); + if (childPolicy != null) sb.append("ChildPolicy: " + childPolicy + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDomain() == null) ? 0 : getDomain().hashCode()); + hashCode = prime * hashCode + ((getWorkflowId() == null) ? 0 : getWorkflowId().hashCode()); + hashCode = prime * hashCode + ((getRunId() == null) ? 0 : getRunId().hashCode()); + hashCode = prime * hashCode + ((getReason() == null) ? 0 : getReason().hashCode()); + hashCode = prime * hashCode + ((getDetails() == null) ? 0 : getDetails().hashCode()); + hashCode = prime * hashCode + ((getChildPolicy() == null) ? 0 : getChildPolicy().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof TerminateWorkflowExecutionRequest == false) return false; + TerminateWorkflowExecutionRequest other = (TerminateWorkflowExecutionRequest)obj; + + if (other.getDomain() == null ^ this.getDomain() == null) return false; + if (other.getDomain() != null && other.getDomain().equals(this.getDomain()) == false) return false; + if (other.getWorkflowId() == null ^ this.getWorkflowId() == null) return false; + if (other.getWorkflowId() != null && other.getWorkflowId().equals(this.getWorkflowId()) == false) return false; + if (other.getRunId() == null ^ this.getRunId() == null) return false; + if (other.getRunId() != null && other.getRunId().equals(this.getRunId()) == false) return false; + if (other.getReason() == null ^ this.getReason() == null) return false; + if (other.getReason() != null && other.getReason().equals(this.getReason()) == false) return false; + if (other.getDetails() == null ^ this.getDetails() == null) return false; + if (other.getDetails() != null && other.getDetails().equals(this.getDetails()) == false) return false; + if (other.getChildPolicy() == null ^ this.getChildPolicy() == null) return false; + if (other.getChildPolicy() != null && other.getChildPolicy().equals(this.getChildPolicy()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/TimerCanceledEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/TimerCanceledEventAttributes.java new file mode 100644 index 000000000000..42b3bc1eece9 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/TimerCanceledEventAttributes.java @@ -0,0 +1,236 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the TimerCanceled event. + *

+ */ +public class TimerCanceledEventAttributes { + + /** + * The unique Id of the timer that was canceled. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String timerId; + + /** + * The id of the TimerStarted event that was recorded when + * this timer was started. This information can be useful for diagnosing + * problems by tracing back the chain of events leading up to this event. + */ + private Long startedEventId; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the CancelTimer + * decision to cancel this timer. This information can be useful for + * diagnosing problems by tracing back the cause of events. + */ + private Long decisionTaskCompletedEventId; + + /** + * The unique Id of the timer that was canceled. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The unique Id of the timer that was canceled. + */ + public String getTimerId() { + return timerId; + } + + /** + * The unique Id of the timer that was canceled. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param timerId The unique Id of the timer that was canceled. + */ + public void setTimerId(String timerId) { + this.timerId = timerId; + } + + /** + * The unique Id of the timer that was canceled. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param timerId The unique Id of the timer that was canceled. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public TimerCanceledEventAttributes withTimerId(String timerId) { + this.timerId = timerId; + return this; + } + + + /** + * The id of the TimerStarted event that was recorded when + * this timer was started. This information can be useful for diagnosing + * problems by tracing back the chain of events leading up to this event. + * + * @return The id of the TimerStarted event that was recorded when + * this timer was started. This information can be useful for diagnosing + * problems by tracing back the chain of events leading up to this event. + */ + public Long getStartedEventId() { + return startedEventId; + } + + /** + * The id of the TimerStarted event that was recorded when + * this timer was started. This information can be useful for diagnosing + * problems by tracing back the chain of events leading up to this event. + * + * @param startedEventId The id of the TimerStarted event that was recorded when + * this timer was started. This information can be useful for diagnosing + * problems by tracing back the chain of events leading up to this event. + */ + public void setStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + } + + /** + * The id of the TimerStarted event that was recorded when + * this timer was started. This information can be useful for diagnosing + * problems by tracing back the chain of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startedEventId The id of the TimerStarted event that was recorded when + * this timer was started. This information can be useful for diagnosing + * problems by tracing back the chain of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public TimerCanceledEventAttributes withStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + return this; + } + + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the CancelTimer + * decision to cancel this timer. This information can be useful for + * diagnosing problems by tracing back the cause of events. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the CancelTimer + * decision to cancel this timer. This information can be useful for + * diagnosing problems by tracing back the cause of events. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the CancelTimer + * decision to cancel this timer. This information can be useful for + * diagnosing problems by tracing back the cause of events. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the CancelTimer + * decision to cancel this timer. This information can be useful for + * diagnosing problems by tracing back the cause of events. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the CancelTimer + * decision to cancel this timer. This information can be useful for + * diagnosing problems by tracing back the cause of events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the CancelTimer + * decision to cancel this timer. This information can be useful for + * diagnosing problems by tracing back the cause of events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public TimerCanceledEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (timerId != null) sb.append("TimerId: " + timerId + ", "); + if (startedEventId != null) sb.append("StartedEventId: " + startedEventId + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTimerId() == null) ? 0 : getTimerId().hashCode()); + hashCode = prime * hashCode + ((getStartedEventId() == null) ? 0 : getStartedEventId().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof TimerCanceledEventAttributes == false) return false; + TimerCanceledEventAttributes other = (TimerCanceledEventAttributes)obj; + + if (other.getTimerId() == null ^ this.getTimerId() == null) return false; + if (other.getTimerId() != null && other.getTimerId().equals(this.getTimerId()) == false) return false; + if (other.getStartedEventId() == null ^ this.getStartedEventId() == null) return false; + if (other.getStartedEventId() != null && other.getStartedEventId().equals(this.getStartedEventId()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/TimerFiredEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/TimerFiredEventAttributes.java new file mode 100644 index 000000000000..2b553998a177 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/TimerFiredEventAttributes.java @@ -0,0 +1,172 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the TimerFired event. + *

+ */ +public class TimerFiredEventAttributes { + + /** + * The unique Id of the timer that fired. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String timerId; + + /** + * The id of the TimerStarted event that was recorded when + * this timer was started. This information can be useful for diagnosing + * problems by tracing back the chain of events leading up to this event. + */ + private Long startedEventId; + + /** + * The unique Id of the timer that fired. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The unique Id of the timer that fired. + */ + public String getTimerId() { + return timerId; + } + + /** + * The unique Id of the timer that fired. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param timerId The unique Id of the timer that fired. + */ + public void setTimerId(String timerId) { + this.timerId = timerId; + } + + /** + * The unique Id of the timer that fired. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param timerId The unique Id of the timer that fired. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public TimerFiredEventAttributes withTimerId(String timerId) { + this.timerId = timerId; + return this; + } + + + /** + * The id of the TimerStarted event that was recorded when + * this timer was started. This information can be useful for diagnosing + * problems by tracing back the chain of events leading up to this event. + * + * @return The id of the TimerStarted event that was recorded when + * this timer was started. This information can be useful for diagnosing + * problems by tracing back the chain of events leading up to this event. + */ + public Long getStartedEventId() { + return startedEventId; + } + + /** + * The id of the TimerStarted event that was recorded when + * this timer was started. This information can be useful for diagnosing + * problems by tracing back the chain of events leading up to this event. + * + * @param startedEventId The id of the TimerStarted event that was recorded when + * this timer was started. This information can be useful for diagnosing + * problems by tracing back the chain of events leading up to this event. + */ + public void setStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + } + + /** + * The id of the TimerStarted event that was recorded when + * this timer was started. This information can be useful for diagnosing + * problems by tracing back the chain of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startedEventId The id of the TimerStarted event that was recorded when + * this timer was started. This information can be useful for diagnosing + * problems by tracing back the chain of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public TimerFiredEventAttributes withStartedEventId(Long startedEventId) { + this.startedEventId = startedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (timerId != null) sb.append("TimerId: " + timerId + ", "); + if (startedEventId != null) sb.append("StartedEventId: " + startedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTimerId() == null) ? 0 : getTimerId().hashCode()); + hashCode = prime * hashCode + ((getStartedEventId() == null) ? 0 : getStartedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof TimerFiredEventAttributes == false) return false; + TimerFiredEventAttributes other = (TimerFiredEventAttributes)obj; + + if (other.getTimerId() == null ^ this.getTimerId() == null) return false; + if (other.getTimerId() != null && other.getTimerId().equals(this.getTimerId()) == false) return false; + if (other.getStartedEventId() == null ^ this.getStartedEventId() == null) return false; + if (other.getStartedEventId() != null && other.getStartedEventId().equals(this.getStartedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/TimerStartedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/TimerStartedEventAttributes.java new file mode 100644 index 000000000000..26ae1ec15935 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/TimerStartedEventAttributes.java @@ -0,0 +1,310 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the TimerStarted event. + *

+ */ +public class TimerStartedEventAttributes { + + /** + * The unique Id of the timer that was started. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String timerId; + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String control; + + /** + * The duration of time after which the timer will fire.

The duration + * is specified in seconds. The valid values are integers greater than or + * equal to 0. + *

+ * Constraints:
+ * Length: 1 - 8
+ */ + private String startToFireTimeout; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the StartTimer + * decision for this activity task. This information can be useful for + * diagnosing problems by tracing back the cause of events. + */ + private Long decisionTaskCompletedEventId; + + /** + * The unique Id of the timer that was started. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The unique Id of the timer that was started. + */ + public String getTimerId() { + return timerId; + } + + /** + * The unique Id of the timer that was started. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param timerId The unique Id of the timer that was started. + */ + public void setTimerId(String timerId) { + this.timerId = timerId; + } + + /** + * The unique Id of the timer that was started. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param timerId The unique Id of the timer that was started. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public TimerStartedEventAttributes withTimerId(String timerId) { + this.timerId = timerId; + return this; + } + + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + */ + public String getControl() { + return control; + } + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + */ + public void setControl(String control) { + this.control = control; + } + + /** + * Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param control Optional data attached to the event that can be used by the decider in + * subsequent workflow tasks. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public TimerStartedEventAttributes withControl(String control) { + this.control = control; + return this; + } + + + /** + * The duration of time after which the timer will fire.

The duration + * is specified in seconds. The valid values are integers greater than or + * equal to 0. + *

+ * Constraints:
+ * Length: 1 - 8
+ * + * @return The duration of time after which the timer will fire.

The duration + * is specified in seconds. The valid values are integers greater than or + * equal to 0. + */ + public String getStartToFireTimeout() { + return startToFireTimeout; + } + + /** + * The duration of time after which the timer will fire.

The duration + * is specified in seconds. The valid values are integers greater than or + * equal to 0. + *

+ * Constraints:
+ * Length: 1 - 8
+ * + * @param startToFireTimeout The duration of time after which the timer will fire.

The duration + * is specified in seconds. The valid values are integers greater than or + * equal to 0. + */ + public void setStartToFireTimeout(String startToFireTimeout) { + this.startToFireTimeout = startToFireTimeout; + } + + /** + * The duration of time after which the timer will fire.

The duration + * is specified in seconds. The valid values are integers greater than or + * equal to 0. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 8
+ * + * @param startToFireTimeout The duration of time after which the timer will fire.

The duration + * is specified in seconds. The valid values are integers greater than or + * equal to 0. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public TimerStartedEventAttributes withStartToFireTimeout(String startToFireTimeout) { + this.startToFireTimeout = startToFireTimeout; + return this; + } + + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the StartTimer + * decision for this activity task. This information can be useful for + * diagnosing problems by tracing back the cause of events. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the StartTimer + * decision for this activity task. This information can be useful for + * diagnosing problems by tracing back the cause of events. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the StartTimer + * decision for this activity task. This information can be useful for + * diagnosing problems by tracing back the cause of events. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the StartTimer + * decision for this activity task. This information can be useful for + * diagnosing problems by tracing back the cause of events. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the StartTimer + * decision for this activity task. This information can be useful for + * diagnosing problems by tracing back the cause of events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the StartTimer + * decision for this activity task. This information can be useful for + * diagnosing problems by tracing back the cause of events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public TimerStartedEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (timerId != null) sb.append("TimerId: " + timerId + ", "); + if (control != null) sb.append("Control: " + control + ", "); + if (startToFireTimeout != null) sb.append("StartToFireTimeout: " + startToFireTimeout + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTimerId() == null) ? 0 : getTimerId().hashCode()); + hashCode = prime * hashCode + ((getControl() == null) ? 0 : getControl().hashCode()); + hashCode = prime * hashCode + ((getStartToFireTimeout() == null) ? 0 : getStartToFireTimeout().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof TimerStartedEventAttributes == false) return false; + TimerStartedEventAttributes other = (TimerStartedEventAttributes)obj; + + if (other.getTimerId() == null ^ this.getTimerId() == null) return false; + if (other.getTimerId() != null && other.getTimerId().equals(this.getTimerId()) == false) return false; + if (other.getControl() == null ^ this.getControl() == null) return false; + if (other.getControl() != null && other.getControl().equals(this.getControl()) == false) return false; + if (other.getStartToFireTimeout() == null ^ this.getStartToFireTimeout() == null) return false; + if (other.getStartToFireTimeout() != null && other.getStartToFireTimeout().equals(this.getStartToFireTimeout()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/TypeAlreadyExistsException.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/TypeAlreadyExistsException.java new file mode 100644 index 000000000000..8508482600da --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/TypeAlreadyExistsException.java @@ -0,0 +1,41 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +import com.amazonaws.AmazonServiceException; + +/** + *

+ * Returned if the type already exists in the specified domain. You will + * get this fault even if the existing type is in deprecated status. You + * can specify another version if the intent is to create a new distinct + * version of the type. + *

+ */ +public class TypeAlreadyExistsException extends AmazonServiceException { + private static final long serialVersionUID = 1L; + + /** + * Constructs a new TypeAlreadyExistsException with the specified error + * message. + * + * @param message Describes the error encountered. + */ + public TypeAlreadyExistsException(String message) { + super(message); + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/TypeDeprecatedException.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/TypeDeprecatedException.java new file mode 100644 index 000000000000..baefaa89c71e --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/TypeDeprecatedException.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +import com.amazonaws.AmazonServiceException; + +/** + *

+ * Returned when the specified activity or workflow type was already + * deprecated. + *

+ */ +public class TypeDeprecatedException extends AmazonServiceException { + private static final long serialVersionUID = 1L; + + /** + * Constructs a new TypeDeprecatedException with the specified error + * message. + * + * @param message Describes the error encountered. + */ + public TypeDeprecatedException(String message) { + super(message); + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/UnknownResourceException.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/UnknownResourceException.java new file mode 100644 index 000000000000..a1c561702f6c --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/UnknownResourceException.java @@ -0,0 +1,41 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +import com.amazonaws.AmazonServiceException; + +/** + *

+ * Returned when the named resource cannot be found with in the scope of + * this operation (region or domain). This could happen if the named + * resource was never created or is no longer available for this + * operation. + *

+ */ +public class UnknownResourceException extends AmazonServiceException { + private static final long serialVersionUID = 1L; + + /** + * Constructs a new UnknownResourceException with the specified error + * message. + * + * @param message Describes the error encountered. + */ + public UnknownResourceException(String message) { + super(message); + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecution.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecution.java new file mode 100644 index 000000000000..b6d0511dc4a8 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecution.java @@ -0,0 +1,170 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Represents a workflow execution. + *

+ */ +public class WorkflowExecution { + + /** + * The user defined identifier associated with the workflow execution. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String workflowId; + + /** + * A system generated unique identifier for the workflow execution. + *

+ * Constraints:
+ * Length: 1 - 64
+ */ + private String runId; + + /** + * The user defined identifier associated with the workflow execution. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The user defined identifier associated with the workflow execution. + */ + public String getWorkflowId() { + return workflowId; + } + + /** + * The user defined identifier associated with the workflow execution. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The user defined identifier associated with the workflow execution. + */ + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + /** + * The user defined identifier associated with the workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The user defined identifier associated with the workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecution withWorkflowId(String workflowId) { + this.workflowId = workflowId; + return this; + } + + + /** + * A system generated unique identifier for the workflow execution. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @return A system generated unique identifier for the workflow execution. + */ + public String getRunId() { + return runId; + } + + /** + * A system generated unique identifier for the workflow execution. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param runId A system generated unique identifier for the workflow execution. + */ + public void setRunId(String runId) { + this.runId = runId; + } + + /** + * A system generated unique identifier for the workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param runId A system generated unique identifier for the workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecution withRunId(String runId) { + this.runId = runId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowId != null) sb.append("WorkflowId: " + workflowId + ", "); + if (runId != null) sb.append("RunId: " + runId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowId() == null) ? 0 : getWorkflowId().hashCode()); + hashCode = prime * hashCode + ((getRunId() == null) ? 0 : getRunId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowExecution == false) return false; + WorkflowExecution other = (WorkflowExecution)obj; + + if (other.getWorkflowId() == null ^ this.getWorkflowId() == null) return false; + if (other.getWorkflowId() != null && other.getWorkflowId().equals(this.getWorkflowId()) == false) return false; + if (other.getRunId() == null ^ this.getRunId() == null) return false; + if (other.getRunId() != null && other.getRunId().equals(this.getRunId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionAlreadyStartedException.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionAlreadyStartedException.java new file mode 100644 index 000000000000..ef5b26d39b40 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionAlreadyStartedException.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +import com.amazonaws.AmazonServiceException; + +/** + *

+ * Returned by StartWorkflowExecution when an open execution with the + * same workflowId is already running in the specified domain. + *

+ */ +public class WorkflowExecutionAlreadyStartedException extends AmazonServiceException { + private static final long serialVersionUID = 1L; + + /** + * Constructs a new WorkflowExecutionAlreadyStartedException with the specified error + * message. + * + * @param message Describes the error encountered. + */ + public WorkflowExecutionAlreadyStartedException(String message) { + super(message); + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionCancelRequestedCause.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionCancelRequestedCause.java new file mode 100644 index 000000000000..d597027b36be --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionCancelRequestedCause.java @@ -0,0 +1,53 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Workflow Execution Cancel Requested Cause + */ +public enum WorkflowExecutionCancelRequestedCause { + + CHILD_POLICY_APPLIED("CHILD_POLICY_APPLIED"); + + private String value; + + private WorkflowExecutionCancelRequestedCause(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return WorkflowExecutionCancelRequestedCause corresponding to the value + */ + public static WorkflowExecutionCancelRequestedCause fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("CHILD_POLICY_APPLIED".equals(value)) { + return WorkflowExecutionCancelRequestedCause.CHILD_POLICY_APPLIED; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionCancelRequestedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionCancelRequestedEventAttributes.java new file mode 100644 index 000000000000..217a724f2dd5 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionCancelRequestedEventAttributes.java @@ -0,0 +1,331 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the WorkflowExecutionCancelRequested + * event. + *

+ */ +public class WorkflowExecutionCancelRequestedEventAttributes { + + /** + * The external workflow execution for which the cancellation was + * requested. + */ + private WorkflowExecution externalWorkflowExecution; + + /** + * The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this workflow execution.The source event with this Id can be found in + * the history of the source workflow execution. This information can be + * useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + private Long externalInitiatedEventId; + + /** + * If set, indicates that the request to cancel the workflow execution + * was automatically generated, and specifies the cause. This happens if + * the parent workflow execution times out or is terminated, and the + * child policy is set to cancel child executions. + *

+ * Constraints:
+ * Allowed Values: CHILD_POLICY_APPLIED + */ + private String cause; + + /** + * The external workflow execution for which the cancellation was + * requested. + * + * @return The external workflow execution for which the cancellation was + * requested. + */ + public WorkflowExecution getExternalWorkflowExecution() { + return externalWorkflowExecution; + } + + /** + * The external workflow execution for which the cancellation was + * requested. + * + * @param externalWorkflowExecution The external workflow execution for which the cancellation was + * requested. + */ + public void setExternalWorkflowExecution(WorkflowExecution externalWorkflowExecution) { + this.externalWorkflowExecution = externalWorkflowExecution; + } + + /** + * The external workflow execution for which the cancellation was + * requested. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param externalWorkflowExecution The external workflow execution for which the cancellation was + * requested. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionCancelRequestedEventAttributes withExternalWorkflowExecution(WorkflowExecution externalWorkflowExecution) { + this.externalWorkflowExecution = externalWorkflowExecution; + return this; + } + + + /** + * The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this workflow execution.The source event with this Id can be found in + * the history of the source workflow execution. This information can be + * useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @return The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this workflow execution.The source event with this Id can be found in + * the history of the source workflow execution. This information can be + * useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + public Long getExternalInitiatedEventId() { + return externalInitiatedEventId; + } + + /** + * The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this workflow execution.The source event with this Id can be found in + * the history of the source workflow execution. This information can be + * useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @param externalInitiatedEventId The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this workflow execution.The source event with this Id can be found in + * the history of the source workflow execution. This information can be + * useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + */ + public void setExternalInitiatedEventId(Long externalInitiatedEventId) { + this.externalInitiatedEventId = externalInitiatedEventId; + } + + /** + * The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this workflow execution.The source event with this Id can be found in + * the history of the source workflow execution. This information can be + * useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param externalInitiatedEventId The id of the + * RequestCancelExternalWorkflowExecutionInitiated event + * corresponding to the + * RequestCancelExternalWorkflowExecution decision to cancel + * this workflow execution.The source event with this Id can be found in + * the history of the source workflow execution. This information can be + * useful for diagnosing problems by tracing back the chain of events + * leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionCancelRequestedEventAttributes withExternalInitiatedEventId(Long externalInitiatedEventId) { + this.externalInitiatedEventId = externalInitiatedEventId; + return this; + } + + + /** + * If set, indicates that the request to cancel the workflow execution + * was automatically generated, and specifies the cause. This happens if + * the parent workflow execution times out or is terminated, and the + * child policy is set to cancel child executions. + *

+ * Constraints:
+ * Allowed Values: CHILD_POLICY_APPLIED + * + * @return If set, indicates that the request to cancel the workflow execution + * was automatically generated, and specifies the cause. This happens if + * the parent workflow execution times out or is terminated, and the + * child policy is set to cancel child executions. + * + * @see WorkflowExecutionCancelRequestedCause + */ + public String getCause() { + return cause; + } + + /** + * If set, indicates that the request to cancel the workflow execution + * was automatically generated, and specifies the cause. This happens if + * the parent workflow execution times out or is terminated, and the + * child policy is set to cancel child executions. + *

+ * Constraints:
+ * Allowed Values: CHILD_POLICY_APPLIED + * + * @param cause If set, indicates that the request to cancel the workflow execution + * was automatically generated, and specifies the cause. This happens if + * the parent workflow execution times out or is terminated, and the + * child policy is set to cancel child executions. + * + * @see WorkflowExecutionCancelRequestedCause + */ + public void setCause(String cause) { + this.cause = cause; + } + + /** + * If set, indicates that the request to cancel the workflow execution + * was automatically generated, and specifies the cause. This happens if + * the parent workflow execution times out or is terminated, and the + * child policy is set to cancel child executions. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: CHILD_POLICY_APPLIED + * + * @param cause If set, indicates that the request to cancel the workflow execution + * was automatically generated, and specifies the cause. This happens if + * the parent workflow execution times out or is terminated, and the + * child policy is set to cancel child executions. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see WorkflowExecutionCancelRequestedCause + */ + public WorkflowExecutionCancelRequestedEventAttributes withCause(String cause) { + this.cause = cause; + return this; + } + + + /** + * If set, indicates that the request to cancel the workflow execution + * was automatically generated, and specifies the cause. This happens if + * the parent workflow execution times out or is terminated, and the + * child policy is set to cancel child executions. + *

+ * Constraints:
+ * Allowed Values: CHILD_POLICY_APPLIED + * + * @param cause If set, indicates that the request to cancel the workflow execution + * was automatically generated, and specifies the cause. This happens if + * the parent workflow execution times out or is terminated, and the + * child policy is set to cancel child executions. + * + * @see WorkflowExecutionCancelRequestedCause + */ + public void setCause(WorkflowExecutionCancelRequestedCause cause) { + this.cause = cause.toString(); + } + + /** + * If set, indicates that the request to cancel the workflow execution + * was automatically generated, and specifies the cause. This happens if + * the parent workflow execution times out or is terminated, and the + * child policy is set to cancel child executions. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: CHILD_POLICY_APPLIED + * + * @param cause If set, indicates that the request to cancel the workflow execution + * was automatically generated, and specifies the cause. This happens if + * the parent workflow execution times out or is terminated, and the + * child policy is set to cancel child executions. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see WorkflowExecutionCancelRequestedCause + */ + public WorkflowExecutionCancelRequestedEventAttributes withCause(WorkflowExecutionCancelRequestedCause cause) { + this.cause = cause.toString(); + return this; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (externalWorkflowExecution != null) sb.append("ExternalWorkflowExecution: " + externalWorkflowExecution + ", "); + if (externalInitiatedEventId != null) sb.append("ExternalInitiatedEventId: " + externalInitiatedEventId + ", "); + if (cause != null) sb.append("Cause: " + cause + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getExternalWorkflowExecution() == null) ? 0 : getExternalWorkflowExecution().hashCode()); + hashCode = prime * hashCode + ((getExternalInitiatedEventId() == null) ? 0 : getExternalInitiatedEventId().hashCode()); + hashCode = prime * hashCode + ((getCause() == null) ? 0 : getCause().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowExecutionCancelRequestedEventAttributes == false) return false; + WorkflowExecutionCancelRequestedEventAttributes other = (WorkflowExecutionCancelRequestedEventAttributes)obj; + + if (other.getExternalWorkflowExecution() == null ^ this.getExternalWorkflowExecution() == null) return false; + if (other.getExternalWorkflowExecution() != null && other.getExternalWorkflowExecution().equals(this.getExternalWorkflowExecution()) == false) return false; + if (other.getExternalInitiatedEventId() == null ^ this.getExternalInitiatedEventId() == null) return false; + if (other.getExternalInitiatedEventId() != null && other.getExternalInitiatedEventId().equals(this.getExternalInitiatedEventId()) == false) return false; + if (other.getCause() == null ^ this.getCause() == null) return false; + if (other.getCause() != null && other.getCause().equals(this.getCause()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionCanceledEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionCanceledEventAttributes.java new file mode 100644 index 000000000000..0a1affffedd9 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionCanceledEventAttributes.java @@ -0,0 +1,186 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the WorkflowExecutionCanceled event. + *

+ */ +public class WorkflowExecutionCanceledEventAttributes { + + /** + * Details for the cancellation (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String details; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CancelWorkflowExecution decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + private Long decisionTaskCompletedEventId; + + /** + * Details for the cancellation (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Details for the cancellation (if any). + */ + public String getDetails() { + return details; + } + + /** + * Details for the cancellation (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details Details for the cancellation (if any). + */ + public void setDetails(String details) { + this.details = details; + } + + /** + * Details for the cancellation (if any). + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details Details for the cancellation (if any). + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionCanceledEventAttributes withDetails(String details) { + this.details = details; + return this; + } + + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CancelWorkflowExecution decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CancelWorkflowExecution decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CancelWorkflowExecution decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CancelWorkflowExecution decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CancelWorkflowExecution decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CancelWorkflowExecution decision for this cancellation + * request. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionCanceledEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (details != null) sb.append("Details: " + details + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDetails() == null) ? 0 : getDetails().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowExecutionCanceledEventAttributes == false) return false; + WorkflowExecutionCanceledEventAttributes other = (WorkflowExecutionCanceledEventAttributes)obj; + + if (other.getDetails() == null ^ this.getDetails() == null) return false; + if (other.getDetails() != null && other.getDetails().equals(this.getDetails()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionCompletedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionCompletedEventAttributes.java new file mode 100644 index 000000000000..53c8d63ca26b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionCompletedEventAttributes.java @@ -0,0 +1,194 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the WorkflowExecutionCompleted + * event. + *

+ */ +public class WorkflowExecutionCompletedEventAttributes { + + /** + * The result produced by the workflow execution upon successful + * completion. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String result; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CompleteWorkflowExecution decision to complete this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + private Long decisionTaskCompletedEventId; + + /** + * The result produced by the workflow execution upon successful + * completion. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The result produced by the workflow execution upon successful + * completion. + */ + public String getResult() { + return result; + } + + /** + * The result produced by the workflow execution upon successful + * completion. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param result The result produced by the workflow execution upon successful + * completion. + */ + public void setResult(String result) { + this.result = result; + } + + /** + * The result produced by the workflow execution upon successful + * completion. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param result The result produced by the workflow execution upon successful + * completion. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionCompletedEventAttributes withResult(String result) { + this.result = result; + return this; + } + + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CompleteWorkflowExecution decision to complete this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CompleteWorkflowExecution decision to complete this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CompleteWorkflowExecution decision to complete this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CompleteWorkflowExecution decision to complete this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CompleteWorkflowExecution decision to complete this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * CompleteWorkflowExecution decision to complete this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionCompletedEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (result != null) sb.append("Result: " + result + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getResult() == null) ? 0 : getResult().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowExecutionCompletedEventAttributes == false) return false; + WorkflowExecutionCompletedEventAttributes other = (WorkflowExecutionCompletedEventAttributes)obj; + + if (other.getResult() == null ^ this.getResult() == null) return false; + if (other.getResult() != null && other.getResult().equals(this.getResult()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionConfiguration.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionConfiguration.java new file mode 100644 index 000000000000..1fec9b174282 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionConfiguration.java @@ -0,0 +1,477 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * The configuration settings for a workflow execution including timeout + * values, tasklist etc. These configuration settings are determined from + * the defaults specified when registering the workflow type and those + * specified when starting the workflow execution. + *

+ */ +public class WorkflowExecutionConfiguration { + + /** + * The maximum duration allowed for decision tasks for this workflow + * execution.

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 1 - 8
+ */ + private String taskStartToCloseTimeout; + + /** + * The total duration for this workflow execution.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 1 - 8
+ */ + private String executionStartToCloseTimeout; + + /** + * The task list used for the decision tasks generated for this workflow + * execution. + */ + private TaskList taskList; + + /** + * The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + */ + private String childPolicy; + + /** + * The maximum duration allowed for decision tasks for this workflow + * execution.

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 1 - 8
+ * + * @return The maximum duration allowed for decision tasks for this workflow + * execution.

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + */ + public String getTaskStartToCloseTimeout() { + return taskStartToCloseTimeout; + } + + /** + * The maximum duration allowed for decision tasks for this workflow + * execution.

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 1 - 8
+ * + * @param taskStartToCloseTimeout The maximum duration allowed for decision tasks for this workflow + * execution.

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + */ + public void setTaskStartToCloseTimeout(String taskStartToCloseTimeout) { + this.taskStartToCloseTimeout = taskStartToCloseTimeout; + } + + /** + * The maximum duration allowed for decision tasks for this workflow + * execution.

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 8
+ * + * @param taskStartToCloseTimeout The maximum duration allowed for decision tasks for this workflow + * execution.

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionConfiguration withTaskStartToCloseTimeout(String taskStartToCloseTimeout) { + this.taskStartToCloseTimeout = taskStartToCloseTimeout; + return this; + } + + + /** + * The total duration for this workflow execution.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 1 - 8
+ * + * @return The total duration for this workflow execution.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + */ + public String getExecutionStartToCloseTimeout() { + return executionStartToCloseTimeout; + } + + /** + * The total duration for this workflow execution.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 1 - 8
+ * + * @param executionStartToCloseTimeout The total duration for this workflow execution.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + */ + public void setExecutionStartToCloseTimeout(String executionStartToCloseTimeout) { + this.executionStartToCloseTimeout = executionStartToCloseTimeout; + } + + /** + * The total duration for this workflow execution.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 8
+ * + * @param executionStartToCloseTimeout The total duration for this workflow execution.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionConfiguration withExecutionStartToCloseTimeout(String executionStartToCloseTimeout) { + this.executionStartToCloseTimeout = executionStartToCloseTimeout; + return this; + } + + + /** + * The task list used for the decision tasks generated for this workflow + * execution. + * + * @return The task list used for the decision tasks generated for this workflow + * execution. + */ + public TaskList getTaskList() { + return taskList; + } + + /** + * The task list used for the decision tasks generated for this workflow + * execution. + * + * @param taskList The task list used for the decision tasks generated for this workflow + * execution. + */ + public void setTaskList(TaskList taskList) { + this.taskList = taskList; + } + + /** + * The task list used for the decision tasks generated for this workflow + * execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param taskList The task list used for the decision tasks generated for this workflow + * execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionConfiguration withTaskList(TaskList taskList) { + this.taskList = taskList; + return this; + } + + + /** + * The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @return The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @see ChildPolicy + */ + public String getChildPolicy() { + return childPolicy; + } + + /** + * The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @see ChildPolicy + */ + public void setChildPolicy(String childPolicy) { + this.childPolicy = childPolicy; + } + + /** + * The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public WorkflowExecutionConfiguration withChildPolicy(String childPolicy) { + this.childPolicy = childPolicy; + return this; + } + + + /** + * The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @see ChildPolicy + */ + public void setChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy.toString(); + } + + /** + * The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public WorkflowExecutionConfiguration withChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy.toString(); + return this; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (taskStartToCloseTimeout != null) sb.append("TaskStartToCloseTimeout: " + taskStartToCloseTimeout + ", "); + if (executionStartToCloseTimeout != null) sb.append("ExecutionStartToCloseTimeout: " + executionStartToCloseTimeout + ", "); + if (taskList != null) sb.append("TaskList: " + taskList + ", "); + if (childPolicy != null) sb.append("ChildPolicy: " + childPolicy + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTaskStartToCloseTimeout() == null) ? 0 : getTaskStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getExecutionStartToCloseTimeout() == null) ? 0 : getExecutionStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getTaskList() == null) ? 0 : getTaskList().hashCode()); + hashCode = prime * hashCode + ((getChildPolicy() == null) ? 0 : getChildPolicy().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowExecutionConfiguration == false) return false; + WorkflowExecutionConfiguration other = (WorkflowExecutionConfiguration)obj; + + if (other.getTaskStartToCloseTimeout() == null ^ this.getTaskStartToCloseTimeout() == null) return false; + if (other.getTaskStartToCloseTimeout() != null && other.getTaskStartToCloseTimeout().equals(this.getTaskStartToCloseTimeout()) == false) return false; + if (other.getExecutionStartToCloseTimeout() == null ^ this.getExecutionStartToCloseTimeout() == null) return false; + if (other.getExecutionStartToCloseTimeout() != null && other.getExecutionStartToCloseTimeout().equals(this.getExecutionStartToCloseTimeout()) == false) return false; + if (other.getTaskList() == null ^ this.getTaskList() == null) return false; + if (other.getTaskList() != null && other.getTaskList().equals(this.getTaskList()) == false) return false; + if (other.getChildPolicy() == null ^ this.getChildPolicy() == null) return false; + if (other.getChildPolicy() != null && other.getChildPolicy().equals(this.getChildPolicy()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionContinuedAsNewEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionContinuedAsNewEventAttributes.java new file mode 100644 index 000000000000..2fa4ca6443dd --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionContinuedAsNewEventAttributes.java @@ -0,0 +1,785 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the WorkflowExecutionContinuedAsNew + * event. + *

+ */ +public class WorkflowExecutionContinuedAsNewEventAttributes { + + /** + * The input provided to the new workflow execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String input; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * ContinueAsNewWorkflowExecution decision that started this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + private Long decisionTaskCompletedEventId; + + /** + * The runId of the new workflow execution. + *

+ * Constraints:
+ * Length: 1 - 64
+ */ + private String newExecutionRunId; + + /** + * The total duration allowed for the new workflow execution.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String executionStartToCloseTimeout; + + /** + * Represents a task list. + */ + private TaskList taskList; + + /** + * The maximum duration of decision tasks for the new workflow execution. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String taskStartToCloseTimeout; + + /** + * The policy to use for the child workflow executions of the new + * execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout.

The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + */ + private String childPolicy; + + /** + * The list of tags associated with the new workflow execution. + *

+ * Constraints:
+ * Length: 0 - 5
+ */ + private java.util.List tagList; + + /** + * Represents a workflow type. + */ + private WorkflowType workflowType; + + /** + * The input provided to the new workflow execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The input provided to the new workflow execution. + */ + public String getInput() { + return input; + } + + /** + * The input provided to the new workflow execution. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input The input provided to the new workflow execution. + */ + public void setInput(String input) { + this.input = input; + } + + /** + * The input provided to the new workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input The input provided to the new workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionContinuedAsNewEventAttributes withInput(String input) { + this.input = input; + return this; + } + + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * ContinueAsNewWorkflowExecution decision that started this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * ContinueAsNewWorkflowExecution decision that started this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * ContinueAsNewWorkflowExecution decision that started this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * ContinueAsNewWorkflowExecution decision that started this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * ContinueAsNewWorkflowExecution decision that started this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * ContinueAsNewWorkflowExecution decision that started this + * execution. This information can be useful for diagnosing problems by + * tracing back the cause of events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionContinuedAsNewEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * The runId of the new workflow execution. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @return The runId of the new workflow execution. + */ + public String getNewExecutionRunId() { + return newExecutionRunId; + } + + /** + * The runId of the new workflow execution. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param newExecutionRunId The runId of the new workflow execution. + */ + public void setNewExecutionRunId(String newExecutionRunId) { + this.newExecutionRunId = newExecutionRunId; + } + + /** + * The runId of the new workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param newExecutionRunId The runId of the new workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionContinuedAsNewEventAttributes withNewExecutionRunId(String newExecutionRunId) { + this.newExecutionRunId = newExecutionRunId; + return this; + } + + + /** + * The total duration allowed for the new workflow execution.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return The total duration allowed for the new workflow execution.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + */ + public String getExecutionStartToCloseTimeout() { + return executionStartToCloseTimeout; + } + + /** + * The total duration allowed for the new workflow execution.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param executionStartToCloseTimeout The total duration allowed for the new workflow execution.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + */ + public void setExecutionStartToCloseTimeout(String executionStartToCloseTimeout) { + this.executionStartToCloseTimeout = executionStartToCloseTimeout; + } + + /** + * The total duration allowed for the new workflow execution.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param executionStartToCloseTimeout The total duration allowed for the new workflow execution.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionContinuedAsNewEventAttributes withExecutionStartToCloseTimeout(String executionStartToCloseTimeout) { + this.executionStartToCloseTimeout = executionStartToCloseTimeout; + return this; + } + + + /** + * Represents a task list. + * + * @return Represents a task list. + */ + public TaskList getTaskList() { + return taskList; + } + + /** + * Represents a task list. + * + * @param taskList Represents a task list. + */ + public void setTaskList(TaskList taskList) { + this.taskList = taskList; + } + + /** + * Represents a task list. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param taskList Represents a task list. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionContinuedAsNewEventAttributes withTaskList(TaskList taskList) { + this.taskList = taskList; + return this; + } + + + /** + * The maximum duration of decision tasks for the new workflow execution. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return The maximum duration of decision tasks for the new workflow execution. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + */ + public String getTaskStartToCloseTimeout() { + return taskStartToCloseTimeout; + } + + /** + * The maximum duration of decision tasks for the new workflow execution. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param taskStartToCloseTimeout The maximum duration of decision tasks for the new workflow execution. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + */ + public void setTaskStartToCloseTimeout(String taskStartToCloseTimeout) { + this.taskStartToCloseTimeout = taskStartToCloseTimeout; + } + + /** + * The maximum duration of decision tasks for the new workflow execution. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param taskStartToCloseTimeout The maximum duration of decision tasks for the new workflow execution. + *

The valid values are integers greater than or equal to + * 0. An integer value can be used to specify the duration + * in seconds while NONE can be used to specify unlimited + * duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionContinuedAsNewEventAttributes withTaskStartToCloseTimeout(String taskStartToCloseTimeout) { + this.taskStartToCloseTimeout = taskStartToCloseTimeout; + return this; + } + + + /** + * The policy to use for the child workflow executions of the new + * execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout.

The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @return The policy to use for the child workflow executions of the new + * execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout.

The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @see ChildPolicy + */ + public String getChildPolicy() { + return childPolicy; + } + + /** + * The policy to use for the child workflow executions of the new + * execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout.

The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy to use for the child workflow executions of the new + * execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout.

The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @see ChildPolicy + */ + public void setChildPolicy(String childPolicy) { + this.childPolicy = childPolicy; + } + + /** + * The policy to use for the child workflow executions of the new + * execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout.

The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy to use for the child workflow executions of the new + * execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout.

The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public WorkflowExecutionContinuedAsNewEventAttributes withChildPolicy(String childPolicy) { + this.childPolicy = childPolicy; + return this; + } + + + /** + * The policy to use for the child workflow executions of the new + * execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout.

The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy to use for the child workflow executions of the new + * execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout.

The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @see ChildPolicy + */ + public void setChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy.toString(); + } + + /** + * The policy to use for the child workflow executions of the new + * execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout.

The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy to use for the child workflow executions of the new + * execution if it is terminated by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout.

The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public WorkflowExecutionContinuedAsNewEventAttributes withChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy.toString(); + return this; + } + + /** + * The list of tags associated with the new workflow execution. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @return The list of tags associated with the new workflow execution. + */ + public java.util.List getTagList() { + + if (tagList == null) { + tagList = new java.util.ArrayList(); + } + return tagList; + } + + /** + * The list of tags associated with the new workflow execution. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags associated with the new workflow execution. + */ + public void setTagList(java.util.Collection tagList) { + if (tagList == null) { + this.tagList = null; + return; + } + + java.util.List tagListCopy = new java.util.ArrayList(tagList.size()); + tagListCopy.addAll(tagList); + this.tagList = tagListCopy; + } + + /** + * The list of tags associated with the new workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags associated with the new workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionContinuedAsNewEventAttributes withTagList(String... tagList) { + if (getTagList() == null) setTagList(new java.util.ArrayList(tagList.length)); + for (String value : tagList) { + getTagList().add(value); + } + return this; + } + + /** + * The list of tags associated with the new workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags associated with the new workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionContinuedAsNewEventAttributes withTagList(java.util.Collection tagList) { + if (tagList == null) { + this.tagList = null; + } else { + java.util.List tagListCopy = new java.util.ArrayList(tagList.size()); + tagListCopy.addAll(tagList); + this.tagList = tagListCopy; + } + + return this; + } + + /** + * Represents a workflow type. + * + * @return Represents a workflow type. + */ + public WorkflowType getWorkflowType() { + return workflowType; + } + + /** + * Represents a workflow type. + * + * @param workflowType Represents a workflow type. + */ + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + /** + * Represents a workflow type. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowType Represents a workflow type. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionContinuedAsNewEventAttributes withWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (input != null) sb.append("Input: " + input + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + if (newExecutionRunId != null) sb.append("NewExecutionRunId: " + newExecutionRunId + ", "); + if (executionStartToCloseTimeout != null) sb.append("ExecutionStartToCloseTimeout: " + executionStartToCloseTimeout + ", "); + if (taskList != null) sb.append("TaskList: " + taskList + ", "); + if (taskStartToCloseTimeout != null) sb.append("TaskStartToCloseTimeout: " + taskStartToCloseTimeout + ", "); + if (childPolicy != null) sb.append("ChildPolicy: " + childPolicy + ", "); + if (tagList != null) sb.append("TagList: " + tagList + ", "); + if (workflowType != null) sb.append("WorkflowType: " + workflowType + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getInput() == null) ? 0 : getInput().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + hashCode = prime * hashCode + ((getNewExecutionRunId() == null) ? 0 : getNewExecutionRunId().hashCode()); + hashCode = prime * hashCode + ((getExecutionStartToCloseTimeout() == null) ? 0 : getExecutionStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getTaskList() == null) ? 0 : getTaskList().hashCode()); + hashCode = prime * hashCode + ((getTaskStartToCloseTimeout() == null) ? 0 : getTaskStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getChildPolicy() == null) ? 0 : getChildPolicy().hashCode()); + hashCode = prime * hashCode + ((getTagList() == null) ? 0 : getTagList().hashCode()); + hashCode = prime * hashCode + ((getWorkflowType() == null) ? 0 : getWorkflowType().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowExecutionContinuedAsNewEventAttributes == false) return false; + WorkflowExecutionContinuedAsNewEventAttributes other = (WorkflowExecutionContinuedAsNewEventAttributes)obj; + + if (other.getInput() == null ^ this.getInput() == null) return false; + if (other.getInput() != null && other.getInput().equals(this.getInput()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + if (other.getNewExecutionRunId() == null ^ this.getNewExecutionRunId() == null) return false; + if (other.getNewExecutionRunId() != null && other.getNewExecutionRunId().equals(this.getNewExecutionRunId()) == false) return false; + if (other.getExecutionStartToCloseTimeout() == null ^ this.getExecutionStartToCloseTimeout() == null) return false; + if (other.getExecutionStartToCloseTimeout() != null && other.getExecutionStartToCloseTimeout().equals(this.getExecutionStartToCloseTimeout()) == false) return false; + if (other.getTaskList() == null ^ this.getTaskList() == null) return false; + if (other.getTaskList() != null && other.getTaskList().equals(this.getTaskList()) == false) return false; + if (other.getTaskStartToCloseTimeout() == null ^ this.getTaskStartToCloseTimeout() == null) return false; + if (other.getTaskStartToCloseTimeout() != null && other.getTaskStartToCloseTimeout().equals(this.getTaskStartToCloseTimeout()) == false) return false; + if (other.getChildPolicy() == null ^ this.getChildPolicy() == null) return false; + if (other.getChildPolicy() != null && other.getChildPolicy().equals(this.getChildPolicy()) == false) return false; + if (other.getTagList() == null ^ this.getTagList() == null) return false; + if (other.getTagList() != null && other.getTagList().equals(this.getTagList()) == false) return false; + if (other.getWorkflowType() == null ^ this.getWorkflowType() == null) return false; + if (other.getWorkflowType() != null && other.getWorkflowType().equals(this.getWorkflowType()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionCount.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionCount.java new file mode 100644 index 000000000000..9a687af4addb --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionCount.java @@ -0,0 +1,186 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Contains the count of workflow executions returned from + * CountOpenWorkflowExecutions or CountClosedWorkflowExecutions + *

+ */ +public class WorkflowExecutionCount { + + /** + * The number of workflow executions. + *

+ * Constraints:
+ * Range: 0 -
+ */ + private Integer count; + + /** + * If set to true, indicates that the actual count was more than the + * maximum supported by this API and the count returned is the truncated + * value. + */ + private Boolean truncated; + + /** + * The number of workflow executions. + *

+ * Constraints:
+ * Range: 0 -
+ * + * @return The number of workflow executions. + */ + public Integer getCount() { + return count; + } + + /** + * The number of workflow executions. + *

+ * Constraints:
+ * Range: 0 -
+ * + * @param count The number of workflow executions. + */ + public void setCount(Integer count) { + this.count = count; + } + + /** + * The number of workflow executions. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Range: 0 -
+ * + * @param count The number of workflow executions. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionCount withCount(Integer count) { + this.count = count; + return this; + } + + + /** + * If set to true, indicates that the actual count was more than the + * maximum supported by this API and the count returned is the truncated + * value. + * + * @return If set to true, indicates that the actual count was more than the + * maximum supported by this API and the count returned is the truncated + * value. + */ + public Boolean isTruncated() { + return truncated; + } + + /** + * If set to true, indicates that the actual count was more than the + * maximum supported by this API and the count returned is the truncated + * value. + * + * @param truncated If set to true, indicates that the actual count was more than the + * maximum supported by this API and the count returned is the truncated + * value. + */ + public void setTruncated(Boolean truncated) { + this.truncated = truncated; + } + + /** + * If set to true, indicates that the actual count was more than the + * maximum supported by this API and the count returned is the truncated + * value. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param truncated If set to true, indicates that the actual count was more than the + * maximum supported by this API and the count returned is the truncated + * value. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionCount withTruncated(Boolean truncated) { + this.truncated = truncated; + return this; + } + + + /** + * If set to true, indicates that the actual count was more than the + * maximum supported by this API and the count returned is the truncated + * value. + * + * @return If set to true, indicates that the actual count was more than the + * maximum supported by this API and the count returned is the truncated + * value. + */ + public Boolean getTruncated() { + return truncated; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (count != null) sb.append("Count: " + count + ", "); + if (truncated != null) sb.append("Truncated: " + truncated + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getCount() == null) ? 0 : getCount().hashCode()); + hashCode = prime * hashCode + ((isTruncated() == null) ? 0 : isTruncated().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowExecutionCount == false) return false; + WorkflowExecutionCount other = (WorkflowExecutionCount)obj; + + if (other.getCount() == null ^ this.getCount() == null) return false; + if (other.getCount() != null && other.getCount().equals(this.getCount()) == false) return false; + if (other.isTruncated() == null ^ this.isTruncated() == null) return false; + if (other.isTruncated() != null && other.isTruncated().equals(this.isTruncated()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionDetail.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionDetail.java new file mode 100644 index 000000000000..86f7519600d0 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionDetail.java @@ -0,0 +1,343 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Contains details about a workflow execution. + *

+ */ +public class WorkflowExecutionDetail { + + /** + * Information about the workflow execution. + */ + private WorkflowExecutionInfo executionInfo; + + /** + * The configuration settings for this workflow execution including + * timeout values, tasklist etc. + */ + private WorkflowExecutionConfiguration executionConfiguration; + + /** + * The number of tasks for this workflow execution. This includes open + * and closed tasks of all types. + */ + private WorkflowExecutionOpenCounts openCounts; + + /** + * The time when the last activity task was scheduled for this workflow + * execution. You can use this information to determine if the workflow + * has not made progress for an unusually long period of time and might + * require a corrective action. + */ + private java.util.Date latestActivityTaskTimestamp; + + /** + * The latest executionContext provided by the decider for this workflow + * execution. A decider can provide an executionContext, which is a free + * form string, when closing a decision task using + * RespondDecisionTaskCompleted. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String latestExecutionContext; + + /** + * Information about the workflow execution. + * + * @return Information about the workflow execution. + */ + public WorkflowExecutionInfo getExecutionInfo() { + return executionInfo; + } + + /** + * Information about the workflow execution. + * + * @param executionInfo Information about the workflow execution. + */ + public void setExecutionInfo(WorkflowExecutionInfo executionInfo) { + this.executionInfo = executionInfo; + } + + /** + * Information about the workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param executionInfo Information about the workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionDetail withExecutionInfo(WorkflowExecutionInfo executionInfo) { + this.executionInfo = executionInfo; + return this; + } + + + /** + * The configuration settings for this workflow execution including + * timeout values, tasklist etc. + * + * @return The configuration settings for this workflow execution including + * timeout values, tasklist etc. + */ + public WorkflowExecutionConfiguration getExecutionConfiguration() { + return executionConfiguration; + } + + /** + * The configuration settings for this workflow execution including + * timeout values, tasklist etc. + * + * @param executionConfiguration The configuration settings for this workflow execution including + * timeout values, tasklist etc. + */ + public void setExecutionConfiguration(WorkflowExecutionConfiguration executionConfiguration) { + this.executionConfiguration = executionConfiguration; + } + + /** + * The configuration settings for this workflow execution including + * timeout values, tasklist etc. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param executionConfiguration The configuration settings for this workflow execution including + * timeout values, tasklist etc. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionDetail withExecutionConfiguration(WorkflowExecutionConfiguration executionConfiguration) { + this.executionConfiguration = executionConfiguration; + return this; + } + + + /** + * The number of tasks for this workflow execution. This includes open + * and closed tasks of all types. + * + * @return The number of tasks for this workflow execution. This includes open + * and closed tasks of all types. + */ + public WorkflowExecutionOpenCounts getOpenCounts() { + return openCounts; + } + + /** + * The number of tasks for this workflow execution. This includes open + * and closed tasks of all types. + * + * @param openCounts The number of tasks for this workflow execution. This includes open + * and closed tasks of all types. + */ + public void setOpenCounts(WorkflowExecutionOpenCounts openCounts) { + this.openCounts = openCounts; + } + + /** + * The number of tasks for this workflow execution. This includes open + * and closed tasks of all types. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param openCounts The number of tasks for this workflow execution. This includes open + * and closed tasks of all types. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionDetail withOpenCounts(WorkflowExecutionOpenCounts openCounts) { + this.openCounts = openCounts; + return this; + } + + + /** + * The time when the last activity task was scheduled for this workflow + * execution. You can use this information to determine if the workflow + * has not made progress for an unusually long period of time and might + * require a corrective action. + * + * @return The time when the last activity task was scheduled for this workflow + * execution. You can use this information to determine if the workflow + * has not made progress for an unusually long period of time and might + * require a corrective action. + */ + public java.util.Date getLatestActivityTaskTimestamp() { + return latestActivityTaskTimestamp; + } + + /** + * The time when the last activity task was scheduled for this workflow + * execution. You can use this information to determine if the workflow + * has not made progress for an unusually long period of time and might + * require a corrective action. + * + * @param latestActivityTaskTimestamp The time when the last activity task was scheduled for this workflow + * execution. You can use this information to determine if the workflow + * has not made progress for an unusually long period of time and might + * require a corrective action. + */ + public void setLatestActivityTaskTimestamp(java.util.Date latestActivityTaskTimestamp) { + this.latestActivityTaskTimestamp = latestActivityTaskTimestamp; + } + + /** + * The time when the last activity task was scheduled for this workflow + * execution. You can use this information to determine if the workflow + * has not made progress for an unusually long period of time and might + * require a corrective action. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param latestActivityTaskTimestamp The time when the last activity task was scheduled for this workflow + * execution. You can use this information to determine if the workflow + * has not made progress for an unusually long period of time and might + * require a corrective action. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionDetail withLatestActivityTaskTimestamp(java.util.Date latestActivityTaskTimestamp) { + this.latestActivityTaskTimestamp = latestActivityTaskTimestamp; + return this; + } + + + /** + * The latest executionContext provided by the decider for this workflow + * execution. A decider can provide an executionContext, which is a free + * form string, when closing a decision task using + * RespondDecisionTaskCompleted. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The latest executionContext provided by the decider for this workflow + * execution. A decider can provide an executionContext, which is a free + * form string, when closing a decision task using + * RespondDecisionTaskCompleted. + */ + public String getLatestExecutionContext() { + return latestExecutionContext; + } + + /** + * The latest executionContext provided by the decider for this workflow + * execution. A decider can provide an executionContext, which is a free + * form string, when closing a decision task using + * RespondDecisionTaskCompleted. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param latestExecutionContext The latest executionContext provided by the decider for this workflow + * execution. A decider can provide an executionContext, which is a free + * form string, when closing a decision task using + * RespondDecisionTaskCompleted. + */ + public void setLatestExecutionContext(String latestExecutionContext) { + this.latestExecutionContext = latestExecutionContext; + } + + /** + * The latest executionContext provided by the decider for this workflow + * execution. A decider can provide an executionContext, which is a free + * form string, when closing a decision task using + * RespondDecisionTaskCompleted. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param latestExecutionContext The latest executionContext provided by the decider for this workflow + * execution. A decider can provide an executionContext, which is a free + * form string, when closing a decision task using + * RespondDecisionTaskCompleted. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionDetail withLatestExecutionContext(String latestExecutionContext) { + this.latestExecutionContext = latestExecutionContext; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (executionInfo != null) sb.append("ExecutionInfo: " + executionInfo + ", "); + if (executionConfiguration != null) sb.append("ExecutionConfiguration: " + executionConfiguration + ", "); + if (openCounts != null) sb.append("OpenCounts: " + openCounts + ", "); + if (latestActivityTaskTimestamp != null) sb.append("LatestActivityTaskTimestamp: " + latestActivityTaskTimestamp + ", "); + if (latestExecutionContext != null) sb.append("LatestExecutionContext: " + latestExecutionContext + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getExecutionInfo() == null) ? 0 : getExecutionInfo().hashCode()); + hashCode = prime * hashCode + ((getExecutionConfiguration() == null) ? 0 : getExecutionConfiguration().hashCode()); + hashCode = prime * hashCode + ((getOpenCounts() == null) ? 0 : getOpenCounts().hashCode()); + hashCode = prime * hashCode + ((getLatestActivityTaskTimestamp() == null) ? 0 : getLatestActivityTaskTimestamp().hashCode()); + hashCode = prime * hashCode + ((getLatestExecutionContext() == null) ? 0 : getLatestExecutionContext().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowExecutionDetail == false) return false; + WorkflowExecutionDetail other = (WorkflowExecutionDetail)obj; + + if (other.getExecutionInfo() == null ^ this.getExecutionInfo() == null) return false; + if (other.getExecutionInfo() != null && other.getExecutionInfo().equals(this.getExecutionInfo()) == false) return false; + if (other.getExecutionConfiguration() == null ^ this.getExecutionConfiguration() == null) return false; + if (other.getExecutionConfiguration() != null && other.getExecutionConfiguration().equals(this.getExecutionConfiguration()) == false) return false; + if (other.getOpenCounts() == null ^ this.getOpenCounts() == null) return false; + if (other.getOpenCounts() != null && other.getOpenCounts().equals(this.getOpenCounts()) == false) return false; + if (other.getLatestActivityTaskTimestamp() == null ^ this.getLatestActivityTaskTimestamp() == null) return false; + if (other.getLatestActivityTaskTimestamp() != null && other.getLatestActivityTaskTimestamp().equals(this.getLatestActivityTaskTimestamp()) == false) return false; + if (other.getLatestExecutionContext() == null ^ this.getLatestExecutionContext() == null) return false; + if (other.getLatestExecutionContext() != null && other.getLatestExecutionContext().equals(this.getLatestExecutionContext()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionFailedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionFailedEventAttributes.java new file mode 100644 index 000000000000..9a0cff8fbcf7 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionFailedEventAttributes.java @@ -0,0 +1,241 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the WorkflowExecutionFailed event. + *

+ */ +public class WorkflowExecutionFailedEventAttributes { + + /** + * The descriptive reason provided for the failure (if any). + *

+ * Constraints:
+ * Length: 0 - 256
+ */ + private String reason; + + /** + * The details of the failure (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String details; + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * FailWorkflowExecution decision to fail this execution. + * This information can be useful for diagnosing problems by tracing back + * the cause of events. + */ + private Long decisionTaskCompletedEventId; + + /** + * The descriptive reason provided for the failure (if any). + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @return The descriptive reason provided for the failure (if any). + */ + public String getReason() { + return reason; + } + + /** + * The descriptive reason provided for the failure (if any). + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param reason The descriptive reason provided for the failure (if any). + */ + public void setReason(String reason) { + this.reason = reason; + } + + /** + * The descriptive reason provided for the failure (if any). + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param reason The descriptive reason provided for the failure (if any). + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionFailedEventAttributes withReason(String reason) { + this.reason = reason; + return this; + } + + + /** + * The details of the failure (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The details of the failure (if any). + */ + public String getDetails() { + return details; + } + + /** + * The details of the failure (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details The details of the failure (if any). + */ + public void setDetails(String details) { + this.details = details; + } + + /** + * The details of the failure (if any). + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details The details of the failure (if any). + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionFailedEventAttributes withDetails(String details) { + this.details = details; + return this; + } + + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * FailWorkflowExecution decision to fail this execution. + * This information can be useful for diagnosing problems by tracing back + * the cause of events. + * + * @return The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * FailWorkflowExecution decision to fail this execution. + * This information can be useful for diagnosing problems by tracing back + * the cause of events. + */ + public Long getDecisionTaskCompletedEventId() { + return decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * FailWorkflowExecution decision to fail this execution. + * This information can be useful for diagnosing problems by tracing back + * the cause of events. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * FailWorkflowExecution decision to fail this execution. + * This information can be useful for diagnosing problems by tracing back + * the cause of events. + */ + public void setDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + } + + /** + * The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * FailWorkflowExecution decision to fail this execution. + * This information can be useful for diagnosing problems by tracing back + * the cause of events. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param decisionTaskCompletedEventId The id of the DecisionTaskCompleted event corresponding + * to the decision task that resulted in the + * FailWorkflowExecution decision to fail this execution. + * This information can be useful for diagnosing problems by tracing back + * the cause of events. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionFailedEventAttributes withDecisionTaskCompletedEventId(Long decisionTaskCompletedEventId) { + this.decisionTaskCompletedEventId = decisionTaskCompletedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (reason != null) sb.append("Reason: " + reason + ", "); + if (details != null) sb.append("Details: " + details + ", "); + if (decisionTaskCompletedEventId != null) sb.append("DecisionTaskCompletedEventId: " + decisionTaskCompletedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getReason() == null) ? 0 : getReason().hashCode()); + hashCode = prime * hashCode + ((getDetails() == null) ? 0 : getDetails().hashCode()); + hashCode = prime * hashCode + ((getDecisionTaskCompletedEventId() == null) ? 0 : getDecisionTaskCompletedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowExecutionFailedEventAttributes == false) return false; + WorkflowExecutionFailedEventAttributes other = (WorkflowExecutionFailedEventAttributes)obj; + + if (other.getReason() == null ^ this.getReason() == null) return false; + if (other.getReason() != null && other.getReason().equals(this.getReason()) == false) return false; + if (other.getDetails() == null ^ this.getDetails() == null) return false; + if (other.getDetails() != null && other.getDetails().equals(this.getDetails()) == false) return false; + if (other.getDecisionTaskCompletedEventId() == null ^ this.getDecisionTaskCompletedEventId() == null) return false; + if (other.getDecisionTaskCompletedEventId() != null && other.getDecisionTaskCompletedEventId().equals(this.getDecisionTaskCompletedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionFilter.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionFilter.java new file mode 100644 index 000000000000..079d8f44f24d --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionFilter.java @@ -0,0 +1,117 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Used to filter the workflow executions in visibility APIs by their + * workflowId . + * + *

+ */ +public class WorkflowExecutionFilter { + + /** + * The workflowId to pass of match the criteria of this filter. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String workflowId; + + /** + * The workflowId to pass of match the criteria of this filter. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The workflowId to pass of match the criteria of this filter. + */ + public String getWorkflowId() { + return workflowId; + } + + /** + * The workflowId to pass of match the criteria of this filter. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId to pass of match the criteria of this filter. + */ + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + /** + * The workflowId to pass of match the criteria of this filter. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param workflowId The workflowId to pass of match the criteria of this filter. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionFilter withWorkflowId(String workflowId) { + this.workflowId = workflowId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowId != null) sb.append("WorkflowId: " + workflowId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowId() == null) ? 0 : getWorkflowId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowExecutionFilter == false) return false; + WorkflowExecutionFilter other = (WorkflowExecutionFilter)obj; + + if (other.getWorkflowId() == null ^ this.getWorkflowId() == null) return false; + if (other.getWorkflowId() != null && other.getWorkflowId().equals(this.getWorkflowId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionInfo.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionInfo.java new file mode 100644 index 000000000000..745c364cfda0 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionInfo.java @@ -0,0 +1,761 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Contains information about a workflow execution. + *

+ */ +public class WorkflowExecutionInfo { + + /** + * The workflow execution this information is about. + */ + private WorkflowExecution execution; + + /** + * The type of the workflow execution. + */ + private WorkflowType workflowType; + + /** + * The time when the execution was started. + */ + private java.util.Date startTimestamp; + + /** + * The time when the workflow execution was closed. Set only if the + * execution status is CLOSED. + */ + private java.util.Date closeTimestamp; + + /** + * The current status of the execution. + *

+ * Constraints:
+ * Allowed Values: OPEN, CLOSED + */ + private String executionStatus; + + /** + * If the execution status is closed then this specifies how the + * execution was closed:

  • COMPLETED: the execution was + * successfully completed.
  • CANCELED: the execution was + * canceled.Cancellation allows the implementation to gracefully clean up + * before the execution is closed.
  • TERMINATED: the execution was + * force terminated.
  • FAILED: the execution failed to + * complete.
  • TIMED_OUT: the execution did not complete in the + * alloted time and was automatically timed out.
  • + *
  • CONTINUED_AS_NEW: the execution is logically continued. This means + * the current execution was completed and a new execution was started to + * carry on the workflow.
+ *

+ * Constraints:
+ * Allowed Values: COMPLETED, FAILED, CANCELED, TERMINATED, CONTINUED_AS_NEW, TIMED_OUT + */ + private String closeStatus; + + /** + * If this workflow execution is a child of another execution then + * contains the workflow execution that started this execution. + */ + private WorkflowExecution parent; + + /** + * The list of tags associated with the workflow execution. Tags can be + * used to identify and list workflow executions of interest through the + * visibility APIs. A workflow execution can have a maximum of 5 tags. + *

+ * Constraints:
+ * Length: 0 - 5
+ */ + private java.util.List tagList; + + /** + * Set to true if a cancellation is requested for this workflow + * execution. + */ + private Boolean cancelRequested; + + /** + * The workflow execution this information is about. + * + * @return The workflow execution this information is about. + */ + public WorkflowExecution getExecution() { + return execution; + } + + /** + * The workflow execution this information is about. + * + * @param execution The workflow execution this information is about. + */ + public void setExecution(WorkflowExecution execution) { + this.execution = execution; + } + + /** + * The workflow execution this information is about. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param execution The workflow execution this information is about. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionInfo withExecution(WorkflowExecution execution) { + this.execution = execution; + return this; + } + + + /** + * The type of the workflow execution. + * + * @return The type of the workflow execution. + */ + public WorkflowType getWorkflowType() { + return workflowType; + } + + /** + * The type of the workflow execution. + * + * @param workflowType The type of the workflow execution. + */ + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + /** + * The type of the workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowType The type of the workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionInfo withWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + return this; + } + + + /** + * The time when the execution was started. + * + * @return The time when the execution was started. + */ + public java.util.Date getStartTimestamp() { + return startTimestamp; + } + + /** + * The time when the execution was started. + * + * @param startTimestamp The time when the execution was started. + */ + public void setStartTimestamp(java.util.Date startTimestamp) { + this.startTimestamp = startTimestamp; + } + + /** + * The time when the execution was started. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param startTimestamp The time when the execution was started. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionInfo withStartTimestamp(java.util.Date startTimestamp) { + this.startTimestamp = startTimestamp; + return this; + } + + + /** + * The time when the workflow execution was closed. Set only if the + * execution status is CLOSED. + * + * @return The time when the workflow execution was closed. Set only if the + * execution status is CLOSED. + */ + public java.util.Date getCloseTimestamp() { + return closeTimestamp; + } + + /** + * The time when the workflow execution was closed. Set only if the + * execution status is CLOSED. + * + * @param closeTimestamp The time when the workflow execution was closed. Set only if the + * execution status is CLOSED. + */ + public void setCloseTimestamp(java.util.Date closeTimestamp) { + this.closeTimestamp = closeTimestamp; + } + + /** + * The time when the workflow execution was closed. Set only if the + * execution status is CLOSED. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param closeTimestamp The time when the workflow execution was closed. Set only if the + * execution status is CLOSED. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionInfo withCloseTimestamp(java.util.Date closeTimestamp) { + this.closeTimestamp = closeTimestamp; + return this; + } + + + /** + * The current status of the execution. + *

+ * Constraints:
+ * Allowed Values: OPEN, CLOSED + * + * @return The current status of the execution. + * + * @see ExecutionStatus + */ + public String getExecutionStatus() { + return executionStatus; + } + + /** + * The current status of the execution. + *

+ * Constraints:
+ * Allowed Values: OPEN, CLOSED + * + * @param executionStatus The current status of the execution. + * + * @see ExecutionStatus + */ + public void setExecutionStatus(String executionStatus) { + this.executionStatus = executionStatus; + } + + /** + * The current status of the execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: OPEN, CLOSED + * + * @param executionStatus The current status of the execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ExecutionStatus + */ + public WorkflowExecutionInfo withExecutionStatus(String executionStatus) { + this.executionStatus = executionStatus; + return this; + } + + + /** + * The current status of the execution. + *

+ * Constraints:
+ * Allowed Values: OPEN, CLOSED + * + * @param executionStatus The current status of the execution. + * + * @see ExecutionStatus + */ + public void setExecutionStatus(ExecutionStatus executionStatus) { + this.executionStatus = executionStatus.toString(); + } + + /** + * The current status of the execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: OPEN, CLOSED + * + * @param executionStatus The current status of the execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ExecutionStatus + */ + public WorkflowExecutionInfo withExecutionStatus(ExecutionStatus executionStatus) { + this.executionStatus = executionStatus.toString(); + return this; + } + + /** + * If the execution status is closed then this specifies how the + * execution was closed:

  • COMPLETED: the execution was + * successfully completed.
  • CANCELED: the execution was + * canceled.Cancellation allows the implementation to gracefully clean up + * before the execution is closed.
  • TERMINATED: the execution was + * force terminated.
  • FAILED: the execution failed to + * complete.
  • TIMED_OUT: the execution did not complete in the + * alloted time and was automatically timed out.
  • + *
  • CONTINUED_AS_NEW: the execution is logically continued. This means + * the current execution was completed and a new execution was started to + * carry on the workflow.
+ *

+ * Constraints:
+ * Allowed Values: COMPLETED, FAILED, CANCELED, TERMINATED, CONTINUED_AS_NEW, TIMED_OUT + * + * @return If the execution status is closed then this specifies how the + * execution was closed:

  • COMPLETED: the execution was + * successfully completed.
  • CANCELED: the execution was + * canceled.Cancellation allows the implementation to gracefully clean up + * before the execution is closed.
  • TERMINATED: the execution was + * force terminated.
  • FAILED: the execution failed to + * complete.
  • TIMED_OUT: the execution did not complete in the + * alloted time and was automatically timed out.
  • + *
  • CONTINUED_AS_NEW: the execution is logically continued. This means + * the current execution was completed and a new execution was started to + * carry on the workflow.
+ * + * @see CloseStatus + */ + public String getCloseStatus() { + return closeStatus; + } + + /** + * If the execution status is closed then this specifies how the + * execution was closed:
  • COMPLETED: the execution was + * successfully completed.
  • CANCELED: the execution was + * canceled.Cancellation allows the implementation to gracefully clean up + * before the execution is closed.
  • TERMINATED: the execution was + * force terminated.
  • FAILED: the execution failed to + * complete.
  • TIMED_OUT: the execution did not complete in the + * alloted time and was automatically timed out.
  • + *
  • CONTINUED_AS_NEW: the execution is logically continued. This means + * the current execution was completed and a new execution was started to + * carry on the workflow.
+ *

+ * Constraints:
+ * Allowed Values: COMPLETED, FAILED, CANCELED, TERMINATED, CONTINUED_AS_NEW, TIMED_OUT + * + * @param closeStatus If the execution status is closed then this specifies how the + * execution was closed:

  • COMPLETED: the execution was + * successfully completed.
  • CANCELED: the execution was + * canceled.Cancellation allows the implementation to gracefully clean up + * before the execution is closed.
  • TERMINATED: the execution was + * force terminated.
  • FAILED: the execution failed to + * complete.
  • TIMED_OUT: the execution did not complete in the + * alloted time and was automatically timed out.
  • + *
  • CONTINUED_AS_NEW: the execution is logically continued. This means + * the current execution was completed and a new execution was started to + * carry on the workflow.
+ * + * @see CloseStatus + */ + public void setCloseStatus(String closeStatus) { + this.closeStatus = closeStatus; + } + + /** + * If the execution status is closed then this specifies how the + * execution was closed:
  • COMPLETED: the execution was + * successfully completed.
  • CANCELED: the execution was + * canceled.Cancellation allows the implementation to gracefully clean up + * before the execution is closed.
  • TERMINATED: the execution was + * force terminated.
  • FAILED: the execution failed to + * complete.
  • TIMED_OUT: the execution did not complete in the + * alloted time and was automatically timed out.
  • + *
  • CONTINUED_AS_NEW: the execution is logically continued. This means + * the current execution was completed and a new execution was started to + * carry on the workflow.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: COMPLETED, FAILED, CANCELED, TERMINATED, CONTINUED_AS_NEW, TIMED_OUT + * + * @param closeStatus If the execution status is closed then this specifies how the + * execution was closed:

  • COMPLETED: the execution was + * successfully completed.
  • CANCELED: the execution was + * canceled.Cancellation allows the implementation to gracefully clean up + * before the execution is closed.
  • TERMINATED: the execution was + * force terminated.
  • FAILED: the execution failed to + * complete.
  • TIMED_OUT: the execution did not complete in the + * alloted time and was automatically timed out.
  • + *
  • CONTINUED_AS_NEW: the execution is logically continued. This means + * the current execution was completed and a new execution was started to + * carry on the workflow.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see CloseStatus + */ + public WorkflowExecutionInfo withCloseStatus(String closeStatus) { + this.closeStatus = closeStatus; + return this; + } + + + /** + * If the execution status is closed then this specifies how the + * execution was closed:
  • COMPLETED: the execution was + * successfully completed.
  • CANCELED: the execution was + * canceled.Cancellation allows the implementation to gracefully clean up + * before the execution is closed.
  • TERMINATED: the execution was + * force terminated.
  • FAILED: the execution failed to + * complete.
  • TIMED_OUT: the execution did not complete in the + * alloted time and was automatically timed out.
  • + *
  • CONTINUED_AS_NEW: the execution is logically continued. This means + * the current execution was completed and a new execution was started to + * carry on the workflow.
+ *

+ * Constraints:
+ * Allowed Values: COMPLETED, FAILED, CANCELED, TERMINATED, CONTINUED_AS_NEW, TIMED_OUT + * + * @param closeStatus If the execution status is closed then this specifies how the + * execution was closed:

  • COMPLETED: the execution was + * successfully completed.
  • CANCELED: the execution was + * canceled.Cancellation allows the implementation to gracefully clean up + * before the execution is closed.
  • TERMINATED: the execution was + * force terminated.
  • FAILED: the execution failed to + * complete.
  • TIMED_OUT: the execution did not complete in the + * alloted time and was automatically timed out.
  • + *
  • CONTINUED_AS_NEW: the execution is logically continued. This means + * the current execution was completed and a new execution was started to + * carry on the workflow.
+ * + * @see CloseStatus + */ + public void setCloseStatus(CloseStatus closeStatus) { + this.closeStatus = closeStatus.toString(); + } + + /** + * If the execution status is closed then this specifies how the + * execution was closed:
  • COMPLETED: the execution was + * successfully completed.
  • CANCELED: the execution was + * canceled.Cancellation allows the implementation to gracefully clean up + * before the execution is closed.
  • TERMINATED: the execution was + * force terminated.
  • FAILED: the execution failed to + * complete.
  • TIMED_OUT: the execution did not complete in the + * alloted time and was automatically timed out.
  • + *
  • CONTINUED_AS_NEW: the execution is logically continued. This means + * the current execution was completed and a new execution was started to + * carry on the workflow.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: COMPLETED, FAILED, CANCELED, TERMINATED, CONTINUED_AS_NEW, TIMED_OUT + * + * @param closeStatus If the execution status is closed then this specifies how the + * execution was closed:

  • COMPLETED: the execution was + * successfully completed.
  • CANCELED: the execution was + * canceled.Cancellation allows the implementation to gracefully clean up + * before the execution is closed.
  • TERMINATED: the execution was + * force terminated.
  • FAILED: the execution failed to + * complete.
  • TIMED_OUT: the execution did not complete in the + * alloted time and was automatically timed out.
  • + *
  • CONTINUED_AS_NEW: the execution is logically continued. This means + * the current execution was completed and a new execution was started to + * carry on the workflow.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see CloseStatus + */ + public WorkflowExecutionInfo withCloseStatus(CloseStatus closeStatus) { + this.closeStatus = closeStatus.toString(); + return this; + } + + /** + * If this workflow execution is a child of another execution then + * contains the workflow execution that started this execution. + * + * @return If this workflow execution is a child of another execution then + * contains the workflow execution that started this execution. + */ + public WorkflowExecution getParent() { + return parent; + } + + /** + * If this workflow execution is a child of another execution then + * contains the workflow execution that started this execution. + * + * @param parent If this workflow execution is a child of another execution then + * contains the workflow execution that started this execution. + */ + public void setParent(WorkflowExecution parent) { + this.parent = parent; + } + + /** + * If this workflow execution is a child of another execution then + * contains the workflow execution that started this execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param parent If this workflow execution is a child of another execution then + * contains the workflow execution that started this execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionInfo withParent(WorkflowExecution parent) { + this.parent = parent; + return this; + } + + + /** + * The list of tags associated with the workflow execution. Tags can be + * used to identify and list workflow executions of interest through the + * visibility APIs. A workflow execution can have a maximum of 5 tags. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @return The list of tags associated with the workflow execution. Tags can be + * used to identify and list workflow executions of interest through the + * visibility APIs. A workflow execution can have a maximum of 5 tags. + */ + public java.util.List getTagList() { + + if (tagList == null) { + tagList = new java.util.ArrayList(); + } + return tagList; + } + + /** + * The list of tags associated with the workflow execution. Tags can be + * used to identify and list workflow executions of interest through the + * visibility APIs. A workflow execution can have a maximum of 5 tags. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags associated with the workflow execution. Tags can be + * used to identify and list workflow executions of interest through the + * visibility APIs. A workflow execution can have a maximum of 5 tags. + */ + public void setTagList(java.util.Collection tagList) { + if (tagList == null) { + this.tagList = null; + return; + } + + java.util.List tagListCopy = new java.util.ArrayList(tagList.size()); + tagListCopy.addAll(tagList); + this.tagList = tagListCopy; + } + + /** + * The list of tags associated with the workflow execution. Tags can be + * used to identify and list workflow executions of interest through the + * visibility APIs. A workflow execution can have a maximum of 5 tags. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags associated with the workflow execution. Tags can be + * used to identify and list workflow executions of interest through the + * visibility APIs. A workflow execution can have a maximum of 5 tags. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionInfo withTagList(String... tagList) { + if (getTagList() == null) setTagList(new java.util.ArrayList(tagList.length)); + for (String value : tagList) { + getTagList().add(value); + } + return this; + } + + /** + * The list of tags associated with the workflow execution. Tags can be + * used to identify and list workflow executions of interest through the + * visibility APIs. A workflow execution can have a maximum of 5 tags. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags associated with the workflow execution. Tags can be + * used to identify and list workflow executions of interest through the + * visibility APIs. A workflow execution can have a maximum of 5 tags. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionInfo withTagList(java.util.Collection tagList) { + if (tagList == null) { + this.tagList = null; + } else { + java.util.List tagListCopy = new java.util.ArrayList(tagList.size()); + tagListCopy.addAll(tagList); + this.tagList = tagListCopy; + } + + return this; + } + + /** + * Set to true if a cancellation is requested for this workflow + * execution. + * + * @return Set to true if a cancellation is requested for this workflow + * execution. + */ + public Boolean isCancelRequested() { + return cancelRequested; + } + + /** + * Set to true if a cancellation is requested for this workflow + * execution. + * + * @param cancelRequested Set to true if a cancellation is requested for this workflow + * execution. + */ + public void setCancelRequested(Boolean cancelRequested) { + this.cancelRequested = cancelRequested; + } + + /** + * Set to true if a cancellation is requested for this workflow + * execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param cancelRequested Set to true if a cancellation is requested for this workflow + * execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionInfo withCancelRequested(Boolean cancelRequested) { + this.cancelRequested = cancelRequested; + return this; + } + + + /** + * Set to true if a cancellation is requested for this workflow + * execution. + * + * @return Set to true if a cancellation is requested for this workflow + * execution. + */ + public Boolean getCancelRequested() { + return cancelRequested; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (execution != null) sb.append("Execution: " + execution + ", "); + if (workflowType != null) sb.append("WorkflowType: " + workflowType + ", "); + if (startTimestamp != null) sb.append("StartTimestamp: " + startTimestamp + ", "); + if (closeTimestamp != null) sb.append("CloseTimestamp: " + closeTimestamp + ", "); + if (executionStatus != null) sb.append("ExecutionStatus: " + executionStatus + ", "); + if (closeStatus != null) sb.append("CloseStatus: " + closeStatus + ", "); + if (parent != null) sb.append("Parent: " + parent + ", "); + if (tagList != null) sb.append("TagList: " + tagList + ", "); + if (cancelRequested != null) sb.append("CancelRequested: " + cancelRequested + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getExecution() == null) ? 0 : getExecution().hashCode()); + hashCode = prime * hashCode + ((getWorkflowType() == null) ? 0 : getWorkflowType().hashCode()); + hashCode = prime * hashCode + ((getStartTimestamp() == null) ? 0 : getStartTimestamp().hashCode()); + hashCode = prime * hashCode + ((getCloseTimestamp() == null) ? 0 : getCloseTimestamp().hashCode()); + hashCode = prime * hashCode + ((getExecutionStatus() == null) ? 0 : getExecutionStatus().hashCode()); + hashCode = prime * hashCode + ((getCloseStatus() == null) ? 0 : getCloseStatus().hashCode()); + hashCode = prime * hashCode + ((getParent() == null) ? 0 : getParent().hashCode()); + hashCode = prime * hashCode + ((getTagList() == null) ? 0 : getTagList().hashCode()); + hashCode = prime * hashCode + ((isCancelRequested() == null) ? 0 : isCancelRequested().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowExecutionInfo == false) return false; + WorkflowExecutionInfo other = (WorkflowExecutionInfo)obj; + + if (other.getExecution() == null ^ this.getExecution() == null) return false; + if (other.getExecution() != null && other.getExecution().equals(this.getExecution()) == false) return false; + if (other.getWorkflowType() == null ^ this.getWorkflowType() == null) return false; + if (other.getWorkflowType() != null && other.getWorkflowType().equals(this.getWorkflowType()) == false) return false; + if (other.getStartTimestamp() == null ^ this.getStartTimestamp() == null) return false; + if (other.getStartTimestamp() != null && other.getStartTimestamp().equals(this.getStartTimestamp()) == false) return false; + if (other.getCloseTimestamp() == null ^ this.getCloseTimestamp() == null) return false; + if (other.getCloseTimestamp() != null && other.getCloseTimestamp().equals(this.getCloseTimestamp()) == false) return false; + if (other.getExecutionStatus() == null ^ this.getExecutionStatus() == null) return false; + if (other.getExecutionStatus() != null && other.getExecutionStatus().equals(this.getExecutionStatus()) == false) return false; + if (other.getCloseStatus() == null ^ this.getCloseStatus() == null) return false; + if (other.getCloseStatus() != null && other.getCloseStatus().equals(this.getCloseStatus()) == false) return false; + if (other.getParent() == null ^ this.getParent() == null) return false; + if (other.getParent() != null && other.getParent().equals(this.getParent()) == false) return false; + if (other.getTagList() == null ^ this.getTagList() == null) return false; + if (other.getTagList() != null && other.getTagList().equals(this.getTagList()) == false) return false; + if (other.isCancelRequested() == null ^ this.isCancelRequested() == null) return false; + if (other.isCancelRequested() != null && other.isCancelRequested().equals(this.isCancelRequested()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionInfos.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionInfos.java new file mode 100644 index 000000000000..81efddefa19f --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionInfos.java @@ -0,0 +1,207 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Contains a paginated list of information about workflow executions. + *

+ */ +public class WorkflowExecutionInfos { + + /** + * The list of workflow information structures. + */ + private java.util.List executionInfos; + + /** + * The token of the next page in the result. If set, the results have + * more than one page. The next page can be retrieved by repeating the + * request with this token and all other arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ */ + private String nextPageToken; + + /** + * The list of workflow information structures. + * + * @return The list of workflow information structures. + */ + public java.util.List getExecutionInfos() { + + if (executionInfos == null) { + executionInfos = new java.util.ArrayList(); + } + return executionInfos; + } + + /** + * The list of workflow information structures. + * + * @param executionInfos The list of workflow information structures. + */ + public void setExecutionInfos(java.util.Collection executionInfos) { + if (executionInfos == null) { + this.executionInfos = null; + return; + } + + java.util.List executionInfosCopy = new java.util.ArrayList(executionInfos.size()); + executionInfosCopy.addAll(executionInfos); + this.executionInfos = executionInfosCopy; + } + + /** + * The list of workflow information structures. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param executionInfos The list of workflow information structures. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionInfos withExecutionInfos(WorkflowExecutionInfo... executionInfos) { + if (getExecutionInfos() == null) setExecutionInfos(new java.util.ArrayList(executionInfos.length)); + for (WorkflowExecutionInfo value : executionInfos) { + getExecutionInfos().add(value); + } + return this; + } + + /** + * The list of workflow information structures. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param executionInfos The list of workflow information structures. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionInfos withExecutionInfos(java.util.Collection executionInfos) { + if (executionInfos == null) { + this.executionInfos = null; + } else { + java.util.List executionInfosCopy = new java.util.ArrayList(executionInfos.size()); + executionInfosCopy.addAll(executionInfos); + this.executionInfos = executionInfosCopy; + } + + return this; + } + + /** + * The token of the next page in the result. If set, the results have + * more than one page. The next page can be retrieved by repeating the + * request with this token and all other arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @return The token of the next page in the result. If set, the results have + * more than one page. The next page can be retrieved by repeating the + * request with this token and all other arguments unchanged. + */ + public String getNextPageToken() { + return nextPageToken; + } + + /** + * The token of the next page in the result. If set, the results have + * more than one page. The next page can be retrieved by repeating the + * request with this token and all other arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken The token of the next page in the result. If set, the results have + * more than one page. The next page can be retrieved by repeating the + * request with this token and all other arguments unchanged. + */ + public void setNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + } + + /** + * The token of the next page in the result. If set, the results have + * more than one page. The next page can be retrieved by repeating the + * request with this token and all other arguments unchanged. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken The token of the next page in the result. If set, the results have + * more than one page. The next page can be retrieved by repeating the + * request with this token and all other arguments unchanged. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionInfos withNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (executionInfos != null) sb.append("ExecutionInfos: " + executionInfos + ", "); + if (nextPageToken != null) sb.append("NextPageToken: " + nextPageToken + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getExecutionInfos() == null) ? 0 : getExecutionInfos().hashCode()); + hashCode = prime * hashCode + ((getNextPageToken() == null) ? 0 : getNextPageToken().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowExecutionInfos == false) return false; + WorkflowExecutionInfos other = (WorkflowExecutionInfos)obj; + + if (other.getExecutionInfos() == null ^ this.getExecutionInfos() == null) return false; + if (other.getExecutionInfos() != null && other.getExecutionInfos().equals(this.getExecutionInfos()) == false) return false; + if (other.getNextPageToken() == null ^ this.getNextPageToken() == null) return false; + if (other.getNextPageToken() != null && other.getNextPageToken().equals(this.getNextPageToken()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionOpenCounts.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionOpenCounts.java new file mode 100644 index 000000000000..49cd1996a49e --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionOpenCounts.java @@ -0,0 +1,295 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Contains the counts of open tasks, child workflow executions and + * timers for a workflow execution. + *

+ */ +public class WorkflowExecutionOpenCounts { + + /** + * The count of activity tasks whose status is OPEN. + *

+ * Constraints:
+ * Range: 0 -
+ */ + private Integer openActivityTasks; + + /** + * The count of decision tasks whose status is OPEN. A workflow execution + * can have at most one open decision task. + *

+ * Constraints:
+ * Range: 0 - 1
+ */ + private Integer openDecisionTasks; + + /** + * The count of timers started by this workflow execution that have not + * fired yet. + *

+ * Constraints:
+ * Range: 0 -
+ */ + private Integer openTimers; + + /** + * The count of child workflow executions whose status is OPEN. + *

+ * Constraints:
+ * Range: 0 -
+ */ + private Integer openChildWorkflowExecutions; + + /** + * The count of activity tasks whose status is OPEN. + *

+ * Constraints:
+ * Range: 0 -
+ * + * @return The count of activity tasks whose status is OPEN. + */ + public Integer getOpenActivityTasks() { + return openActivityTasks; + } + + /** + * The count of activity tasks whose status is OPEN. + *

+ * Constraints:
+ * Range: 0 -
+ * + * @param openActivityTasks The count of activity tasks whose status is OPEN. + */ + public void setOpenActivityTasks(Integer openActivityTasks) { + this.openActivityTasks = openActivityTasks; + } + + /** + * The count of activity tasks whose status is OPEN. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Range: 0 -
+ * + * @param openActivityTasks The count of activity tasks whose status is OPEN. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionOpenCounts withOpenActivityTasks(Integer openActivityTasks) { + this.openActivityTasks = openActivityTasks; + return this; + } + + + /** + * The count of decision tasks whose status is OPEN. A workflow execution + * can have at most one open decision task. + *

+ * Constraints:
+ * Range: 0 - 1
+ * + * @return The count of decision tasks whose status is OPEN. A workflow execution + * can have at most one open decision task. + */ + public Integer getOpenDecisionTasks() { + return openDecisionTasks; + } + + /** + * The count of decision tasks whose status is OPEN. A workflow execution + * can have at most one open decision task. + *

+ * Constraints:
+ * Range: 0 - 1
+ * + * @param openDecisionTasks The count of decision tasks whose status is OPEN. A workflow execution + * can have at most one open decision task. + */ + public void setOpenDecisionTasks(Integer openDecisionTasks) { + this.openDecisionTasks = openDecisionTasks; + } + + /** + * The count of decision tasks whose status is OPEN. A workflow execution + * can have at most one open decision task. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Range: 0 - 1
+ * + * @param openDecisionTasks The count of decision tasks whose status is OPEN. A workflow execution + * can have at most one open decision task. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionOpenCounts withOpenDecisionTasks(Integer openDecisionTasks) { + this.openDecisionTasks = openDecisionTasks; + return this; + } + + + /** + * The count of timers started by this workflow execution that have not + * fired yet. + *

+ * Constraints:
+ * Range: 0 -
+ * + * @return The count of timers started by this workflow execution that have not + * fired yet. + */ + public Integer getOpenTimers() { + return openTimers; + } + + /** + * The count of timers started by this workflow execution that have not + * fired yet. + *

+ * Constraints:
+ * Range: 0 -
+ * + * @param openTimers The count of timers started by this workflow execution that have not + * fired yet. + */ + public void setOpenTimers(Integer openTimers) { + this.openTimers = openTimers; + } + + /** + * The count of timers started by this workflow execution that have not + * fired yet. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Range: 0 -
+ * + * @param openTimers The count of timers started by this workflow execution that have not + * fired yet. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionOpenCounts withOpenTimers(Integer openTimers) { + this.openTimers = openTimers; + return this; + } + + + /** + * The count of child workflow executions whose status is OPEN. + *

+ * Constraints:
+ * Range: 0 -
+ * + * @return The count of child workflow executions whose status is OPEN. + */ + public Integer getOpenChildWorkflowExecutions() { + return openChildWorkflowExecutions; + } + + /** + * The count of child workflow executions whose status is OPEN. + *

+ * Constraints:
+ * Range: 0 -
+ * + * @param openChildWorkflowExecutions The count of child workflow executions whose status is OPEN. + */ + public void setOpenChildWorkflowExecutions(Integer openChildWorkflowExecutions) { + this.openChildWorkflowExecutions = openChildWorkflowExecutions; + } + + /** + * The count of child workflow executions whose status is OPEN. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Range: 0 -
+ * + * @param openChildWorkflowExecutions The count of child workflow executions whose status is OPEN. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionOpenCounts withOpenChildWorkflowExecutions(Integer openChildWorkflowExecutions) { + this.openChildWorkflowExecutions = openChildWorkflowExecutions; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (openActivityTasks != null) sb.append("OpenActivityTasks: " + openActivityTasks + ", "); + if (openDecisionTasks != null) sb.append("OpenDecisionTasks: " + openDecisionTasks + ", "); + if (openTimers != null) sb.append("OpenTimers: " + openTimers + ", "); + if (openChildWorkflowExecutions != null) sb.append("OpenChildWorkflowExecutions: " + openChildWorkflowExecutions + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getOpenActivityTasks() == null) ? 0 : getOpenActivityTasks().hashCode()); + hashCode = prime * hashCode + ((getOpenDecisionTasks() == null) ? 0 : getOpenDecisionTasks().hashCode()); + hashCode = prime * hashCode + ((getOpenTimers() == null) ? 0 : getOpenTimers().hashCode()); + hashCode = prime * hashCode + ((getOpenChildWorkflowExecutions() == null) ? 0 : getOpenChildWorkflowExecutions().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowExecutionOpenCounts == false) return false; + WorkflowExecutionOpenCounts other = (WorkflowExecutionOpenCounts)obj; + + if (other.getOpenActivityTasks() == null ^ this.getOpenActivityTasks() == null) return false; + if (other.getOpenActivityTasks() != null && other.getOpenActivityTasks().equals(this.getOpenActivityTasks()) == false) return false; + if (other.getOpenDecisionTasks() == null ^ this.getOpenDecisionTasks() == null) return false; + if (other.getOpenDecisionTasks() != null && other.getOpenDecisionTasks().equals(this.getOpenDecisionTasks()) == false) return false; + if (other.getOpenTimers() == null ^ this.getOpenTimers() == null) return false; + if (other.getOpenTimers() != null && other.getOpenTimers().equals(this.getOpenTimers()) == false) return false; + if (other.getOpenChildWorkflowExecutions() == null ^ this.getOpenChildWorkflowExecutions() == null) return false; + if (other.getOpenChildWorkflowExecutions() != null && other.getOpenChildWorkflowExecutions().equals(this.getOpenChildWorkflowExecutions()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionSignaledEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionSignaledEventAttributes.java new file mode 100644 index 000000000000..a4b2fa89f0fc --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionSignaledEventAttributes.java @@ -0,0 +1,319 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the WorkflowExecutionSignaled event. + *

+ */ +public class WorkflowExecutionSignaledEventAttributes { + + /** + * The name of the signal received. The decider can use the signal name + * and inputs to determine how to the process the signal. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String signalName; + + /** + * Inputs provided with the signal (if any). The decider can use the + * signal name and inputs to determine how to process the signal. + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String input; + + /** + * The workflow execution that sent the signal. This is set only of the + * signal was sent by another workflow execution. + */ + private WorkflowExecution externalWorkflowExecution; + + /** + * The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the SignalExternalWorkflow + * decision to signal this workflow execution.The source event with this + * Id can be found in the history of the source workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. This field is set only if + * the signal was initiated by another workflow execution. + */ + private Long externalInitiatedEventId; + + /** + * The name of the signal received. The decider can use the signal name + * and inputs to determine how to the process the signal. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the signal received. The decider can use the signal name + * and inputs to determine how to the process the signal. + */ + public String getSignalName() { + return signalName; + } + + /** + * The name of the signal received. The decider can use the signal name + * and inputs to determine how to the process the signal. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param signalName The name of the signal received. The decider can use the signal name + * and inputs to determine how to the process the signal. + */ + public void setSignalName(String signalName) { + this.signalName = signalName; + } + + /** + * The name of the signal received. The decider can use the signal name + * and inputs to determine how to the process the signal. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param signalName The name of the signal received. The decider can use the signal name + * and inputs to determine how to the process the signal. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionSignaledEventAttributes withSignalName(String signalName) { + this.signalName = signalName; + return this; + } + + + /** + * Inputs provided with the signal (if any). The decider can use the + * signal name and inputs to determine how to process the signal. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return Inputs provided with the signal (if any). The decider can use the + * signal name and inputs to determine how to process the signal. + */ + public String getInput() { + return input; + } + + /** + * Inputs provided with the signal (if any). The decider can use the + * signal name and inputs to determine how to process the signal. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input Inputs provided with the signal (if any). The decider can use the + * signal name and inputs to determine how to process the signal. + */ + public void setInput(String input) { + this.input = input; + } + + /** + * Inputs provided with the signal (if any). The decider can use the + * signal name and inputs to determine how to process the signal. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input Inputs provided with the signal (if any). The decider can use the + * signal name and inputs to determine how to process the signal. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionSignaledEventAttributes withInput(String input) { + this.input = input; + return this; + } + + + /** + * The workflow execution that sent the signal. This is set only of the + * signal was sent by another workflow execution. + * + * @return The workflow execution that sent the signal. This is set only of the + * signal was sent by another workflow execution. + */ + public WorkflowExecution getExternalWorkflowExecution() { + return externalWorkflowExecution; + } + + /** + * The workflow execution that sent the signal. This is set only of the + * signal was sent by another workflow execution. + * + * @param externalWorkflowExecution The workflow execution that sent the signal. This is set only of the + * signal was sent by another workflow execution. + */ + public void setExternalWorkflowExecution(WorkflowExecution externalWorkflowExecution) { + this.externalWorkflowExecution = externalWorkflowExecution; + } + + /** + * The workflow execution that sent the signal. This is set only of the + * signal was sent by another workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param externalWorkflowExecution The workflow execution that sent the signal. This is set only of the + * signal was sent by another workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionSignaledEventAttributes withExternalWorkflowExecution(WorkflowExecution externalWorkflowExecution) { + this.externalWorkflowExecution = externalWorkflowExecution; + return this; + } + + + /** + * The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the SignalExternalWorkflow + * decision to signal this workflow execution.The source event with this + * Id can be found in the history of the source workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. This field is set only if + * the signal was initiated by another workflow execution. + * + * @return The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the SignalExternalWorkflow + * decision to signal this workflow execution.The source event with this + * Id can be found in the history of the source workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. This field is set only if + * the signal was initiated by another workflow execution. + */ + public Long getExternalInitiatedEventId() { + return externalInitiatedEventId; + } + + /** + * The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the SignalExternalWorkflow + * decision to signal this workflow execution.The source event with this + * Id can be found in the history of the source workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. This field is set only if + * the signal was initiated by another workflow execution. + * + * @param externalInitiatedEventId The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the SignalExternalWorkflow + * decision to signal this workflow execution.The source event with this + * Id can be found in the history of the source workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. This field is set only if + * the signal was initiated by another workflow execution. + */ + public void setExternalInitiatedEventId(Long externalInitiatedEventId) { + this.externalInitiatedEventId = externalInitiatedEventId; + } + + /** + * The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the SignalExternalWorkflow + * decision to signal this workflow execution.The source event with this + * Id can be found in the history of the source workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. This field is set only if + * the signal was initiated by another workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param externalInitiatedEventId The id of the SignalExternalWorkflowExecutionInitiated + * event corresponding to the SignalExternalWorkflow + * decision to signal this workflow execution.The source event with this + * Id can be found in the history of the source workflow execution. This + * information can be useful for diagnosing problems by tracing back the + * chain of events leading up to this event. This field is set only if + * the signal was initiated by another workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionSignaledEventAttributes withExternalInitiatedEventId(Long externalInitiatedEventId) { + this.externalInitiatedEventId = externalInitiatedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (signalName != null) sb.append("SignalName: " + signalName + ", "); + if (input != null) sb.append("Input: " + input + ", "); + if (externalWorkflowExecution != null) sb.append("ExternalWorkflowExecution: " + externalWorkflowExecution + ", "); + if (externalInitiatedEventId != null) sb.append("ExternalInitiatedEventId: " + externalInitiatedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getSignalName() == null) ? 0 : getSignalName().hashCode()); + hashCode = prime * hashCode + ((getInput() == null) ? 0 : getInput().hashCode()); + hashCode = prime * hashCode + ((getExternalWorkflowExecution() == null) ? 0 : getExternalWorkflowExecution().hashCode()); + hashCode = prime * hashCode + ((getExternalInitiatedEventId() == null) ? 0 : getExternalInitiatedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowExecutionSignaledEventAttributes == false) return false; + WorkflowExecutionSignaledEventAttributes other = (WorkflowExecutionSignaledEventAttributes)obj; + + if (other.getSignalName() == null ^ this.getSignalName() == null) return false; + if (other.getSignalName() != null && other.getSignalName().equals(this.getSignalName()) == false) return false; + if (other.getInput() == null ^ this.getInput() == null) return false; + if (other.getInput() != null && other.getInput().equals(this.getInput()) == false) return false; + if (other.getExternalWorkflowExecution() == null ^ this.getExternalWorkflowExecution() == null) return false; + if (other.getExternalWorkflowExecution() != null && other.getExternalWorkflowExecution().equals(this.getExternalWorkflowExecution()) == false) return false; + if (other.getExternalInitiatedEventId() == null ^ this.getExternalInitiatedEventId() == null) return false; + if (other.getExternalInitiatedEventId() != null && other.getExternalInitiatedEventId().equals(this.getExternalInitiatedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionStartedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionStartedEventAttributes.java new file mode 100644 index 000000000000..9774eae61b17 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionStartedEventAttributes.java @@ -0,0 +1,878 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of WorkflowExecutionStarted event. + *

+ */ +public class WorkflowExecutionStartedEventAttributes { + + /** + * The input provided to the workflow execution (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String input; + + /** + * The maximum duration for this workflow execution.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String executionStartToCloseTimeout; + + /** + * The maximum duration of decision tasks for this workflow type.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String taskStartToCloseTimeout; + + /** + * The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + */ + private String childPolicy; + + /** + * The name of the task list for scheduling the decision tasks for this + * workflow execution. + */ + private TaskList taskList; + + /** + * The workflow type of this execution. + */ + private WorkflowType workflowType; + + /** + * The list of tags associated with this workflow execution. An execution + * can have up to 5 tags. + *

+ * Constraints:
+ * Length: 0 - 5
+ */ + private java.util.List tagList; + + /** + * If this workflow execution was started due to a + * ContinueAsNewWorkflowExecution decision, then it contains + * the runId of the previous workflow execution that was + * closed and continued as this execution. + *

+ * Constraints:
+ * Length: 0 - 64
+ */ + private String continuedExecutionRunId; + + /** + * The source workflow execution that started this workflow execution. + * The member is not set if the workflow execution was not started by a + * workflow. + */ + private WorkflowExecution parentWorkflowExecution; + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this workflow execution. The source event + * with this Id can be found in the history of the source workflow + * execution. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + */ + private Long parentInitiatedEventId; + + /** + * The input provided to the workflow execution (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The input provided to the workflow execution (if any). + */ + public String getInput() { + return input; + } + + /** + * The input provided to the workflow execution (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input The input provided to the workflow execution (if any). + */ + public void setInput(String input) { + this.input = input; + } + + /** + * The input provided to the workflow execution (if any). + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param input The input provided to the workflow execution (if any). + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionStartedEventAttributes withInput(String input) { + this.input = input; + return this; + } + + + /** + * The maximum duration for this workflow execution.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return The maximum duration for this workflow execution.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + */ + public String getExecutionStartToCloseTimeout() { + return executionStartToCloseTimeout; + } + + /** + * The maximum duration for this workflow execution.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param executionStartToCloseTimeout The maximum duration for this workflow execution.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + */ + public void setExecutionStartToCloseTimeout(String executionStartToCloseTimeout) { + this.executionStartToCloseTimeout = executionStartToCloseTimeout; + } + + /** + * The maximum duration for this workflow execution.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param executionStartToCloseTimeout The maximum duration for this workflow execution.

The valid values + * are integers greater than or equal to 0. An integer value + * can be used to specify the duration in seconds while NONE + * can be used to specify unlimited duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionStartedEventAttributes withExecutionStartToCloseTimeout(String executionStartToCloseTimeout) { + this.executionStartToCloseTimeout = executionStartToCloseTimeout; + return this; + } + + + /** + * The maximum duration of decision tasks for this workflow type.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return The maximum duration of decision tasks for this workflow type.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + */ + public String getTaskStartToCloseTimeout() { + return taskStartToCloseTimeout; + } + + /** + * The maximum duration of decision tasks for this workflow type.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param taskStartToCloseTimeout The maximum duration of decision tasks for this workflow type.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + */ + public void setTaskStartToCloseTimeout(String taskStartToCloseTimeout) { + this.taskStartToCloseTimeout = taskStartToCloseTimeout; + } + + /** + * The maximum duration of decision tasks for this workflow type.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param taskStartToCloseTimeout The maximum duration of decision tasks for this workflow type.

The + * valid values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionStartedEventAttributes withTaskStartToCloseTimeout(String taskStartToCloseTimeout) { + this.taskStartToCloseTimeout = taskStartToCloseTimeout; + return this; + } + + + /** + * The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @return The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @see ChildPolicy + */ + public String getChildPolicy() { + return childPolicy; + } + + /** + * The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @see ChildPolicy + */ + public void setChildPolicy(String childPolicy) { + this.childPolicy = childPolicy; + } + + /** + * The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public WorkflowExecutionStartedEventAttributes withChildPolicy(String childPolicy) { + this.childPolicy = childPolicy; + return this; + } + + + /** + * The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @see ChildPolicy + */ + public void setChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy.toString(); + } + + /** + * The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy to use for the child workflow executions if this workflow + * execution is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public WorkflowExecutionStartedEventAttributes withChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy.toString(); + return this; + } + + /** + * The name of the task list for scheduling the decision tasks for this + * workflow execution. + * + * @return The name of the task list for scheduling the decision tasks for this + * workflow execution. + */ + public TaskList getTaskList() { + return taskList; + } + + /** + * The name of the task list for scheduling the decision tasks for this + * workflow execution. + * + * @param taskList The name of the task list for scheduling the decision tasks for this + * workflow execution. + */ + public void setTaskList(TaskList taskList) { + this.taskList = taskList; + } + + /** + * The name of the task list for scheduling the decision tasks for this + * workflow execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param taskList The name of the task list for scheduling the decision tasks for this + * workflow execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionStartedEventAttributes withTaskList(TaskList taskList) { + this.taskList = taskList; + return this; + } + + + /** + * The workflow type of this execution. + * + * @return The workflow type of this execution. + */ + public WorkflowType getWorkflowType() { + return workflowType; + } + + /** + * The workflow type of this execution. + * + * @param workflowType The workflow type of this execution. + */ + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + /** + * The workflow type of this execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowType The workflow type of this execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionStartedEventAttributes withWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + return this; + } + + + /** + * The list of tags associated with this workflow execution. An execution + * can have up to 5 tags. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @return The list of tags associated with this workflow execution. An execution + * can have up to 5 tags. + */ + public java.util.List getTagList() { + + if (tagList == null) { + tagList = new java.util.ArrayList(); + } + return tagList; + } + + /** + * The list of tags associated with this workflow execution. An execution + * can have up to 5 tags. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags associated with this workflow execution. An execution + * can have up to 5 tags. + */ + public void setTagList(java.util.Collection tagList) { + if (tagList == null) { + this.tagList = null; + return; + } + + java.util.List tagListCopy = new java.util.ArrayList(tagList.size()); + tagListCopy.addAll(tagList); + this.tagList = tagListCopy; + } + + /** + * The list of tags associated with this workflow execution. An execution + * can have up to 5 tags. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags associated with this workflow execution. An execution + * can have up to 5 tags. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionStartedEventAttributes withTagList(String... tagList) { + if (getTagList() == null) setTagList(new java.util.ArrayList(tagList.length)); + for (String value : tagList) { + getTagList().add(value); + } + return this; + } + + /** + * The list of tags associated with this workflow execution. An execution + * can have up to 5 tags. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 5
+ * + * @param tagList The list of tags associated with this workflow execution. An execution + * can have up to 5 tags. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionStartedEventAttributes withTagList(java.util.Collection tagList) { + if (tagList == null) { + this.tagList = null; + } else { + java.util.List tagListCopy = new java.util.ArrayList(tagList.size()); + tagListCopy.addAll(tagList); + this.tagList = tagListCopy; + } + + return this; + } + + /** + * If this workflow execution was started due to a + * ContinueAsNewWorkflowExecution decision, then it contains + * the runId of the previous workflow execution that was + * closed and continued as this execution. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @return If this workflow execution was started due to a + * ContinueAsNewWorkflowExecution decision, then it contains + * the runId of the previous workflow execution that was + * closed and continued as this execution. + */ + public String getContinuedExecutionRunId() { + return continuedExecutionRunId; + } + + /** + * If this workflow execution was started due to a + * ContinueAsNewWorkflowExecution decision, then it contains + * the runId of the previous workflow execution that was + * closed and continued as this execution. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param continuedExecutionRunId If this workflow execution was started due to a + * ContinueAsNewWorkflowExecution decision, then it contains + * the runId of the previous workflow execution that was + * closed and continued as this execution. + */ + public void setContinuedExecutionRunId(String continuedExecutionRunId) { + this.continuedExecutionRunId = continuedExecutionRunId; + } + + /** + * If this workflow execution was started due to a + * ContinueAsNewWorkflowExecution decision, then it contains + * the runId of the previous workflow execution that was + * closed and continued as this execution. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param continuedExecutionRunId If this workflow execution was started due to a + * ContinueAsNewWorkflowExecution decision, then it contains + * the runId of the previous workflow execution that was + * closed and continued as this execution. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionStartedEventAttributes withContinuedExecutionRunId(String continuedExecutionRunId) { + this.continuedExecutionRunId = continuedExecutionRunId; + return this; + } + + + /** + * The source workflow execution that started this workflow execution. + * The member is not set if the workflow execution was not started by a + * workflow. + * + * @return The source workflow execution that started this workflow execution. + * The member is not set if the workflow execution was not started by a + * workflow. + */ + public WorkflowExecution getParentWorkflowExecution() { + return parentWorkflowExecution; + } + + /** + * The source workflow execution that started this workflow execution. + * The member is not set if the workflow execution was not started by a + * workflow. + * + * @param parentWorkflowExecution The source workflow execution that started this workflow execution. + * The member is not set if the workflow execution was not started by a + * workflow. + */ + public void setParentWorkflowExecution(WorkflowExecution parentWorkflowExecution) { + this.parentWorkflowExecution = parentWorkflowExecution; + } + + /** + * The source workflow execution that started this workflow execution. + * The member is not set if the workflow execution was not started by a + * workflow. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param parentWorkflowExecution The source workflow execution that started this workflow execution. + * The member is not set if the workflow execution was not started by a + * workflow. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionStartedEventAttributes withParentWorkflowExecution(WorkflowExecution parentWorkflowExecution) { + this.parentWorkflowExecution = parentWorkflowExecution; + return this; + } + + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this workflow execution. The source event + * with this Id can be found in the history of the source workflow + * execution. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + * + * @return The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this workflow execution. The source event + * with this Id can be found in the history of the source workflow + * execution. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + */ + public Long getParentInitiatedEventId() { + return parentInitiatedEventId; + } + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this workflow execution. The source event + * with this Id can be found in the history of the source workflow + * execution. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + * + * @param parentInitiatedEventId The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this workflow execution. The source event + * with this Id can be found in the history of the source workflow + * execution. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + */ + public void setParentInitiatedEventId(Long parentInitiatedEventId) { + this.parentInitiatedEventId = parentInitiatedEventId; + } + + /** + * The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this workflow execution. The source event + * with this Id can be found in the history of the source workflow + * execution. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param parentInitiatedEventId The id of the StartChildWorkflowExecutionInitiated event + * corresponding to the StartChildWorkflowExecution + * Decision to start this workflow execution. The source event + * with this Id can be found in the history of the source workflow + * execution. This information can be useful for diagnosing problems by + * tracing back the chain of events leading up to this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionStartedEventAttributes withParentInitiatedEventId(Long parentInitiatedEventId) { + this.parentInitiatedEventId = parentInitiatedEventId; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (input != null) sb.append("Input: " + input + ", "); + if (executionStartToCloseTimeout != null) sb.append("ExecutionStartToCloseTimeout: " + executionStartToCloseTimeout + ", "); + if (taskStartToCloseTimeout != null) sb.append("TaskStartToCloseTimeout: " + taskStartToCloseTimeout + ", "); + if (childPolicy != null) sb.append("ChildPolicy: " + childPolicy + ", "); + if (taskList != null) sb.append("TaskList: " + taskList + ", "); + if (workflowType != null) sb.append("WorkflowType: " + workflowType + ", "); + if (tagList != null) sb.append("TagList: " + tagList + ", "); + if (continuedExecutionRunId != null) sb.append("ContinuedExecutionRunId: " + continuedExecutionRunId + ", "); + if (parentWorkflowExecution != null) sb.append("ParentWorkflowExecution: " + parentWorkflowExecution + ", "); + if (parentInitiatedEventId != null) sb.append("ParentInitiatedEventId: " + parentInitiatedEventId + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getInput() == null) ? 0 : getInput().hashCode()); + hashCode = prime * hashCode + ((getExecutionStartToCloseTimeout() == null) ? 0 : getExecutionStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getTaskStartToCloseTimeout() == null) ? 0 : getTaskStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getChildPolicy() == null) ? 0 : getChildPolicy().hashCode()); + hashCode = prime * hashCode + ((getTaskList() == null) ? 0 : getTaskList().hashCode()); + hashCode = prime * hashCode + ((getWorkflowType() == null) ? 0 : getWorkflowType().hashCode()); + hashCode = prime * hashCode + ((getTagList() == null) ? 0 : getTagList().hashCode()); + hashCode = prime * hashCode + ((getContinuedExecutionRunId() == null) ? 0 : getContinuedExecutionRunId().hashCode()); + hashCode = prime * hashCode + ((getParentWorkflowExecution() == null) ? 0 : getParentWorkflowExecution().hashCode()); + hashCode = prime * hashCode + ((getParentInitiatedEventId() == null) ? 0 : getParentInitiatedEventId().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowExecutionStartedEventAttributes == false) return false; + WorkflowExecutionStartedEventAttributes other = (WorkflowExecutionStartedEventAttributes)obj; + + if (other.getInput() == null ^ this.getInput() == null) return false; + if (other.getInput() != null && other.getInput().equals(this.getInput()) == false) return false; + if (other.getExecutionStartToCloseTimeout() == null ^ this.getExecutionStartToCloseTimeout() == null) return false; + if (other.getExecutionStartToCloseTimeout() != null && other.getExecutionStartToCloseTimeout().equals(this.getExecutionStartToCloseTimeout()) == false) return false; + if (other.getTaskStartToCloseTimeout() == null ^ this.getTaskStartToCloseTimeout() == null) return false; + if (other.getTaskStartToCloseTimeout() != null && other.getTaskStartToCloseTimeout().equals(this.getTaskStartToCloseTimeout()) == false) return false; + if (other.getChildPolicy() == null ^ this.getChildPolicy() == null) return false; + if (other.getChildPolicy() != null && other.getChildPolicy().equals(this.getChildPolicy()) == false) return false; + if (other.getTaskList() == null ^ this.getTaskList() == null) return false; + if (other.getTaskList() != null && other.getTaskList().equals(this.getTaskList()) == false) return false; + if (other.getWorkflowType() == null ^ this.getWorkflowType() == null) return false; + if (other.getWorkflowType() != null && other.getWorkflowType().equals(this.getWorkflowType()) == false) return false; + if (other.getTagList() == null ^ this.getTagList() == null) return false; + if (other.getTagList() != null && other.getTagList().equals(this.getTagList()) == false) return false; + if (other.getContinuedExecutionRunId() == null ^ this.getContinuedExecutionRunId() == null) return false; + if (other.getContinuedExecutionRunId() != null && other.getContinuedExecutionRunId().equals(this.getContinuedExecutionRunId()) == false) return false; + if (other.getParentWorkflowExecution() == null ^ this.getParentWorkflowExecution() == null) return false; + if (other.getParentWorkflowExecution() != null && other.getParentWorkflowExecution().equals(this.getParentWorkflowExecution()) == false) return false; + if (other.getParentInitiatedEventId() == null ^ this.getParentInitiatedEventId() == null) return false; + if (other.getParentInitiatedEventId() != null && other.getParentInitiatedEventId().equals(this.getParentInitiatedEventId()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionTerminatedCause.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionTerminatedCause.java new file mode 100644 index 000000000000..eafeff2daa18 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionTerminatedCause.java @@ -0,0 +1,59 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Workflow Execution Terminated Cause + */ +public enum WorkflowExecutionTerminatedCause { + + CHILD_POLICY_APPLIED("CHILD_POLICY_APPLIED"), + EVENT_LIMIT_EXCEEDED("EVENT_LIMIT_EXCEEDED"), + OPERATOR_INITIATED("OPERATOR_INITIATED"); + + private String value; + + private WorkflowExecutionTerminatedCause(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return WorkflowExecutionTerminatedCause corresponding to the value + */ + public static WorkflowExecutionTerminatedCause fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("CHILD_POLICY_APPLIED".equals(value)) { + return WorkflowExecutionTerminatedCause.CHILD_POLICY_APPLIED; + } else if ("EVENT_LIMIT_EXCEEDED".equals(value)) { + return WorkflowExecutionTerminatedCause.EVENT_LIMIT_EXCEEDED; + } else if ("OPERATOR_INITIATED".equals(value)) { + return WorkflowExecutionTerminatedCause.OPERATOR_INITIATED; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionTerminatedEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionTerminatedEventAttributes.java new file mode 100644 index 000000000000..085742aff478 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionTerminatedEventAttributes.java @@ -0,0 +1,482 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the WorkflowExecutionTerminated + * event. + *

+ */ +public class WorkflowExecutionTerminatedEventAttributes { + + /** + * The reason provided for the termination (if any). + *

+ * Constraints:
+ * Length: 0 - 256
+ */ + private String reason; + + /** + * The details provided for the termination (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ */ + private String details; + + /** + * The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + */ + private String childPolicy; + + /** + * If set, indicates that the workflow execution was automatically + * terminated, and specifies the cause. This happens if the parent + * workflow execution times out or is terminated and the child policy is + * set to terminate child executions. + *

+ * Constraints:
+ * Allowed Values: CHILD_POLICY_APPLIED, EVENT_LIMIT_EXCEEDED, OPERATOR_INITIATED + */ + private String cause; + + /** + * The reason provided for the termination (if any). + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @return The reason provided for the termination (if any). + */ + public String getReason() { + return reason; + } + + /** + * The reason provided for the termination (if any). + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param reason The reason provided for the termination (if any). + */ + public void setReason(String reason) { + this.reason = reason; + } + + /** + * The reason provided for the termination (if any). + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 256
+ * + * @param reason The reason provided for the termination (if any). + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionTerminatedEventAttributes withReason(String reason) { + this.reason = reason; + return this; + } + + + /** + * The details provided for the termination (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @return The details provided for the termination (if any). + */ + public String getDetails() { + return details; + } + + /** + * The details provided for the termination (if any). + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details The details provided for the termination (if any). + */ + public void setDetails(String details) { + this.details = details; + } + + /** + * The details provided for the termination (if any). + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 32768
+ * + * @param details The details provided for the termination (if any). + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowExecutionTerminatedEventAttributes withDetails(String details) { + this.details = details; + return this; + } + + + /** + * The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @return The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @see ChildPolicy + */ + public String getChildPolicy() { + return childPolicy; + } + + /** + * The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @see ChildPolicy + */ + public void setChildPolicy(String childPolicy) { + this.childPolicy = childPolicy; + } + + /** + * The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public WorkflowExecutionTerminatedEventAttributes withChildPolicy(String childPolicy) { + this.childPolicy = childPolicy; + return this; + } + + + /** + * The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @see ChildPolicy + */ + public void setChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy.toString(); + } + + /** + * The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public WorkflowExecutionTerminatedEventAttributes withChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy.toString(); + return this; + } + + /** + * If set, indicates that the workflow execution was automatically + * terminated, and specifies the cause. This happens if the parent + * workflow execution times out or is terminated and the child policy is + * set to terminate child executions. + *

+ * Constraints:
+ * Allowed Values: CHILD_POLICY_APPLIED, EVENT_LIMIT_EXCEEDED, OPERATOR_INITIATED + * + * @return If set, indicates that the workflow execution was automatically + * terminated, and specifies the cause. This happens if the parent + * workflow execution times out or is terminated and the child policy is + * set to terminate child executions. + * + * @see WorkflowExecutionTerminatedCause + */ + public String getCause() { + return cause; + } + + /** + * If set, indicates that the workflow execution was automatically + * terminated, and specifies the cause. This happens if the parent + * workflow execution times out or is terminated and the child policy is + * set to terminate child executions. + *

+ * Constraints:
+ * Allowed Values: CHILD_POLICY_APPLIED, EVENT_LIMIT_EXCEEDED, OPERATOR_INITIATED + * + * @param cause If set, indicates that the workflow execution was automatically + * terminated, and specifies the cause. This happens if the parent + * workflow execution times out or is terminated and the child policy is + * set to terminate child executions. + * + * @see WorkflowExecutionTerminatedCause + */ + public void setCause(String cause) { + this.cause = cause; + } + + /** + * If set, indicates that the workflow execution was automatically + * terminated, and specifies the cause. This happens if the parent + * workflow execution times out or is terminated and the child policy is + * set to terminate child executions. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: CHILD_POLICY_APPLIED, EVENT_LIMIT_EXCEEDED, OPERATOR_INITIATED + * + * @param cause If set, indicates that the workflow execution was automatically + * terminated, and specifies the cause. This happens if the parent + * workflow execution times out or is terminated and the child policy is + * set to terminate child executions. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see WorkflowExecutionTerminatedCause + */ + public WorkflowExecutionTerminatedEventAttributes withCause(String cause) { + this.cause = cause; + return this; + } + + + /** + * If set, indicates that the workflow execution was automatically + * terminated, and specifies the cause. This happens if the parent + * workflow execution times out or is terminated and the child policy is + * set to terminate child executions. + *

+ * Constraints:
+ * Allowed Values: CHILD_POLICY_APPLIED, EVENT_LIMIT_EXCEEDED, OPERATOR_INITIATED + * + * @param cause If set, indicates that the workflow execution was automatically + * terminated, and specifies the cause. This happens if the parent + * workflow execution times out or is terminated and the child policy is + * set to terminate child executions. + * + * @see WorkflowExecutionTerminatedCause + */ + public void setCause(WorkflowExecutionTerminatedCause cause) { + this.cause = cause.toString(); + } + + /** + * If set, indicates that the workflow execution was automatically + * terminated, and specifies the cause. This happens if the parent + * workflow execution times out or is terminated and the child policy is + * set to terminate child executions. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: CHILD_POLICY_APPLIED, EVENT_LIMIT_EXCEEDED, OPERATOR_INITIATED + * + * @param cause If set, indicates that the workflow execution was automatically + * terminated, and specifies the cause. This happens if the parent + * workflow execution times out or is terminated and the child policy is + * set to terminate child executions. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see WorkflowExecutionTerminatedCause + */ + public WorkflowExecutionTerminatedEventAttributes withCause(WorkflowExecutionTerminatedCause cause) { + this.cause = cause.toString(); + return this; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (reason != null) sb.append("Reason: " + reason + ", "); + if (details != null) sb.append("Details: " + details + ", "); + if (childPolicy != null) sb.append("ChildPolicy: " + childPolicy + ", "); + if (cause != null) sb.append("Cause: " + cause + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getReason() == null) ? 0 : getReason().hashCode()); + hashCode = prime * hashCode + ((getDetails() == null) ? 0 : getDetails().hashCode()); + hashCode = prime * hashCode + ((getChildPolicy() == null) ? 0 : getChildPolicy().hashCode()); + hashCode = prime * hashCode + ((getCause() == null) ? 0 : getCause().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowExecutionTerminatedEventAttributes == false) return false; + WorkflowExecutionTerminatedEventAttributes other = (WorkflowExecutionTerminatedEventAttributes)obj; + + if (other.getReason() == null ^ this.getReason() == null) return false; + if (other.getReason() != null && other.getReason().equals(this.getReason()) == false) return false; + if (other.getDetails() == null ^ this.getDetails() == null) return false; + if (other.getDetails() != null && other.getDetails().equals(this.getDetails()) == false) return false; + if (other.getChildPolicy() == null ^ this.getChildPolicy() == null) return false; + if (other.getChildPolicy() != null && other.getChildPolicy().equals(this.getChildPolicy()) == false) return false; + if (other.getCause() == null ^ this.getCause() == null) return false; + if (other.getCause() != null && other.getCause().equals(this.getCause()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionTimedOutEventAttributes.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionTimedOutEventAttributes.java new file mode 100644 index 000000000000..e35a1ad8fab5 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionTimedOutEventAttributes.java @@ -0,0 +1,338 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Provides details of the WorkflowExecutionTimedOut event. + *

+ */ +public class WorkflowExecutionTimedOutEventAttributes { + + /** + * The type of timeout that caused this event. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE + */ + private String timeoutType; + + /** + * The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + */ + private String childPolicy; + + /** + * The type of timeout that caused this event. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE + * + * @return The type of timeout that caused this event. + * + * @see WorkflowExecutionTimeoutType + */ + public String getTimeoutType() { + return timeoutType; + } + + /** + * The type of timeout that caused this event. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE + * + * @param timeoutType The type of timeout that caused this event. + * + * @see WorkflowExecutionTimeoutType + */ + public void setTimeoutType(String timeoutType) { + this.timeoutType = timeoutType; + } + + /** + * The type of timeout that caused this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE + * + * @param timeoutType The type of timeout that caused this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see WorkflowExecutionTimeoutType + */ + public WorkflowExecutionTimedOutEventAttributes withTimeoutType(String timeoutType) { + this.timeoutType = timeoutType; + return this; + } + + + /** + * The type of timeout that caused this event. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE + * + * @param timeoutType The type of timeout that caused this event. + * + * @see WorkflowExecutionTimeoutType + */ + public void setTimeoutType(WorkflowExecutionTimeoutType timeoutType) { + this.timeoutType = timeoutType.toString(); + } + + /** + * The type of timeout that caused this event. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: START_TO_CLOSE + * + * @param timeoutType The type of timeout that caused this event. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see WorkflowExecutionTimeoutType + */ + public WorkflowExecutionTimedOutEventAttributes withTimeoutType(WorkflowExecutionTimeoutType timeoutType) { + this.timeoutType = timeoutType.toString(); + return this; + } + + /** + * The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @return The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @see ChildPolicy + */ + public String getChildPolicy() { + return childPolicy; + } + + /** + * The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @see ChildPolicy + */ + public void setChildPolicy(String childPolicy) { + this.childPolicy = childPolicy; + } + + /** + * The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public WorkflowExecutionTimedOutEventAttributes withChildPolicy(String childPolicy) { + this.childPolicy = childPolicy; + return this; + } + + + /** + * The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @see ChildPolicy + */ + public void setChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy.toString(); + } + + /** + * The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:
    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param childPolicy The policy used for the child workflow executions of this workflow + * execution. The supported child policies are:

    + *
  • TERMINATE: the child executions will be terminated.
  • + *
  • REQUEST_CANCEL: a request to cancel will be attempted for + * each child execution by recording a + * WorkflowExecutionCancelRequested event in its history. It + * is up to the decider to take appropriate actions when it receives an + * execution history with this event.
  • ABANDON: no action + * will be taken. The child executions will continue to run.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public WorkflowExecutionTimedOutEventAttributes withChildPolicy(ChildPolicy childPolicy) { + this.childPolicy = childPolicy.toString(); + return this; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (timeoutType != null) sb.append("TimeoutType: " + timeoutType + ", "); + if (childPolicy != null) sb.append("ChildPolicy: " + childPolicy + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTimeoutType() == null) ? 0 : getTimeoutType().hashCode()); + hashCode = prime * hashCode + ((getChildPolicy() == null) ? 0 : getChildPolicy().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowExecutionTimedOutEventAttributes == false) return false; + WorkflowExecutionTimedOutEventAttributes other = (WorkflowExecutionTimedOutEventAttributes)obj; + + if (other.getTimeoutType() == null ^ this.getTimeoutType() == null) return false; + if (other.getTimeoutType() != null && other.getTimeoutType().equals(this.getTimeoutType()) == false) return false; + if (other.getChildPolicy() == null ^ this.getChildPolicy() == null) return false; + if (other.getChildPolicy() != null && other.getChildPolicy().equals(this.getChildPolicy()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionTimeoutType.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionTimeoutType.java new file mode 100644 index 000000000000..085c85f44955 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowExecutionTimeoutType.java @@ -0,0 +1,53 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + * Workflow Execution Timeout Type + */ +public enum WorkflowExecutionTimeoutType { + + START_TO_CLOSE("START_TO_CLOSE"); + + private String value; + + private WorkflowExecutionTimeoutType(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + /** + * Use this in place of valueOf. + * + * @param value + * real value + * @return WorkflowExecutionTimeoutType corresponding to the value + */ + public static WorkflowExecutionTimeoutType fromValue(String value) { + if (value == null || "".equals(value)) { + throw new IllegalArgumentException("Value cannot be null or empty!"); + + } else if ("START_TO_CLOSE".equals(value)) { + return WorkflowExecutionTimeoutType.START_TO_CLOSE; + } else { + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); + } + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowType.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowType.java new file mode 100644 index 000000000000..a7158911f6e5 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowType.java @@ -0,0 +1,198 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Represents a workflow type. + *

+ */ +public class WorkflowType { + + /** + * The name of the workflow type. This field is required. The + * combination of workflow type name and version must be unique with in a + * domain. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String name; + + /** + * The version of the workflow type. This field is required. The + * combination of workflow type name and version must be unique with in a + * domain. + *

+ * Constraints:
+ * Length: 1 - 64
+ */ + private String version; + + /** + * The name of the workflow type. This field is required. The + * combination of workflow type name and version must be unique with in a + * domain. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return The name of the workflow type. This field is required. The + * combination of workflow type name and version must be unique with in a + * domain. + */ + public String getName() { + return name; + } + + /** + * The name of the workflow type. This field is required. The + * combination of workflow type name and version must be unique with in a + * domain. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name The name of the workflow type. This field is required. The + * combination of workflow type name and version must be unique with in a + * domain. + */ + public void setName(String name) { + this.name = name; + } + + /** + * The name of the workflow type. This field is required. The + * combination of workflow type name and version must be unique with in a + * domain. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name The name of the workflow type. This field is required. The + * combination of workflow type name and version must be unique with in a + * domain. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowType withName(String name) { + this.name = name; + return this; + } + + + /** + * The version of the workflow type. This field is required. The + * combination of workflow type name and version must be unique with in a + * domain. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @return The version of the workflow type. This field is required. The + * combination of workflow type name and version must be unique with in a + * domain. + */ + public String getVersion() { + return version; + } + + /** + * The version of the workflow type. This field is required. The + * combination of workflow type name and version must be unique with in a + * domain. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param version The version of the workflow type. This field is required. The + * combination of workflow type name and version must be unique with in a + * domain. + */ + public void setVersion(String version) { + this.version = version; + } + + /** + * The version of the workflow type. This field is required. The + * combination of workflow type name and version must be unique with in a + * domain. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 64
+ * + * @param version The version of the workflow type. This field is required. The + * combination of workflow type name and version must be unique with in a + * domain. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowType withVersion(String version) { + this.version = version; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (name != null) sb.append("Name: " + name + ", "); + if (version != null) sb.append("Version: " + version + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); + hashCode = prime * hashCode + ((getVersion() == null) ? 0 : getVersion().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowType == false) return false; + WorkflowType other = (WorkflowType)obj; + + if (other.getName() == null ^ this.getName() == null) return false; + if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; + if (other.getVersion() == null ^ this.getVersion() == null) return false; + if (other.getVersion() != null && other.getVersion().equals(this.getVersion()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowTypeConfiguration.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowTypeConfiguration.java new file mode 100644 index 000000000000..9465dcd81d32 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowTypeConfiguration.java @@ -0,0 +1,605 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * The configuration settings of a workflow type. + *

+ */ +public class WorkflowTypeConfiguration { + + /** + * The optional default maximum duration, specified when registering the + * workflow type, that a decision task for executions of this workflow + * type might take before returning completion or failure. If the task + * does not close in the specified time then the task is automatically + * timed out and rescheduled. If the decider eventually reports a + * completion or failure, it is ignored. This default can be overridden + * when starting a workflow execution using the + * StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String defaultTaskStartToCloseTimeout; + + /** + * The optional default maximum duration, specified when registering the + * workflow type, for executions of this workflow type. This default can + * be overridden when starting a workflow execution using the + * StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ */ + private String defaultExecutionStartToCloseTimeout; + + /** + * The optional default task list, specified when registering the + * workflow type, for decisions tasks scheduled for workflow executions + * of this type. This default can be overridden when starting a workflow + * execution using the StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision. + */ + private TaskList defaultTaskList; + + /** + * The optional default policy to use for the child workflow executions + * when a workflow execution of this type is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:

  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + */ + private String defaultChildPolicy; + + /** + * The optional default maximum duration, specified when registering the + * workflow type, that a decision task for executions of this workflow + * type might take before returning completion or failure. If the task + * does not close in the specified time then the task is automatically + * timed out and rescheduled. If the decider eventually reports a + * completion or failure, it is ignored. This default can be overridden + * when starting a workflow execution using the + * StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return The optional default maximum duration, specified when registering the + * workflow type, that a decision task for executions of this workflow + * type might take before returning completion or failure. If the task + * does not close in the specified time then the task is automatically + * timed out and rescheduled. If the decider eventually reports a + * completion or failure, it is ignored. This default can be overridden + * when starting a workflow execution using the + * StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + */ + public String getDefaultTaskStartToCloseTimeout() { + return defaultTaskStartToCloseTimeout; + } + + /** + * The optional default maximum duration, specified when registering the + * workflow type, that a decision task for executions of this workflow + * type might take before returning completion or failure. If the task + * does not close in the specified time then the task is automatically + * timed out and rescheduled. If the decider eventually reports a + * completion or failure, it is ignored. This default can be overridden + * when starting a workflow execution using the + * StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultTaskStartToCloseTimeout The optional default maximum duration, specified when registering the + * workflow type, that a decision task for executions of this workflow + * type might take before returning completion or failure. If the task + * does not close in the specified time then the task is automatically + * timed out and rescheduled. If the decider eventually reports a + * completion or failure, it is ignored. This default can be overridden + * when starting a workflow execution using the + * StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + */ + public void setDefaultTaskStartToCloseTimeout(String defaultTaskStartToCloseTimeout) { + this.defaultTaskStartToCloseTimeout = defaultTaskStartToCloseTimeout; + } + + /** + * The optional default maximum duration, specified when registering the + * workflow type, that a decision task for executions of this workflow + * type might take before returning completion or failure. If the task + * does not close in the specified time then the task is automatically + * timed out and rescheduled. If the decider eventually reports a + * completion or failure, it is ignored. This default can be overridden + * when starting a workflow execution using the + * StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultTaskStartToCloseTimeout The optional default maximum duration, specified when registering the + * workflow type, that a decision task for executions of this workflow + * type might take before returning completion or failure. If the task + * does not close in the specified time then the task is automatically + * timed out and rescheduled. If the decider eventually reports a + * completion or failure, it is ignored. This default can be overridden + * when starting a workflow execution using the + * StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowTypeConfiguration withDefaultTaskStartToCloseTimeout(String defaultTaskStartToCloseTimeout) { + this.defaultTaskStartToCloseTimeout = defaultTaskStartToCloseTimeout; + return this; + } + + + /** + * The optional default maximum duration, specified when registering the + * workflow type, for executions of this workflow type. This default can + * be overridden when starting a workflow execution using the + * StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @return The optional default maximum duration, specified when registering the + * workflow type, for executions of this workflow type. This default can + * be overridden when starting a workflow execution using the + * StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + */ + public String getDefaultExecutionStartToCloseTimeout() { + return defaultExecutionStartToCloseTimeout; + } + + /** + * The optional default maximum duration, specified when registering the + * workflow type, for executions of this workflow type. This default can + * be overridden when starting a workflow execution using the + * StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultExecutionStartToCloseTimeout The optional default maximum duration, specified when registering the + * workflow type, for executions of this workflow type. This default can + * be overridden when starting a workflow execution using the + * StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + */ + public void setDefaultExecutionStartToCloseTimeout(String defaultExecutionStartToCloseTimeout) { + this.defaultExecutionStartToCloseTimeout = defaultExecutionStartToCloseTimeout; + } + + /** + * The optional default maximum duration, specified when registering the + * workflow type, for executions of this workflow type. This default can + * be overridden when starting a workflow execution using the + * StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 8
+ * + * @param defaultExecutionStartToCloseTimeout The optional default maximum duration, specified when registering the + * workflow type, for executions of this workflow type. This default can + * be overridden when starting a workflow execution using the + * StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision.

The valid + * values are integers greater than or equal to 0. An + * integer value can be used to specify the duration in seconds while + * NONE can be used to specify unlimited duration. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowTypeConfiguration withDefaultExecutionStartToCloseTimeout(String defaultExecutionStartToCloseTimeout) { + this.defaultExecutionStartToCloseTimeout = defaultExecutionStartToCloseTimeout; + return this; + } + + + /** + * The optional default task list, specified when registering the + * workflow type, for decisions tasks scheduled for workflow executions + * of this type. This default can be overridden when starting a workflow + * execution using the StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision. + * + * @return The optional default task list, specified when registering the + * workflow type, for decisions tasks scheduled for workflow executions + * of this type. This default can be overridden when starting a workflow + * execution using the StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision. + */ + public TaskList getDefaultTaskList() { + return defaultTaskList; + } + + /** + * The optional default task list, specified when registering the + * workflow type, for decisions tasks scheduled for workflow executions + * of this type. This default can be overridden when starting a workflow + * execution using the StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision. + * + * @param defaultTaskList The optional default task list, specified when registering the + * workflow type, for decisions tasks scheduled for workflow executions + * of this type. This default can be overridden when starting a workflow + * execution using the StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision. + */ + public void setDefaultTaskList(TaskList defaultTaskList) { + this.defaultTaskList = defaultTaskList; + } + + /** + * The optional default task list, specified when registering the + * workflow type, for decisions tasks scheduled for workflow executions + * of this type. This default can be overridden when starting a workflow + * execution using the StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param defaultTaskList The optional default task list, specified when registering the + * workflow type, for decisions tasks scheduled for workflow executions + * of this type. This default can be overridden when starting a workflow + * execution using the StartWorkflowExecution action or the + * StartChildWorkflowExecution Decision. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowTypeConfiguration withDefaultTaskList(TaskList defaultTaskList) { + this.defaultTaskList = defaultTaskList; + return this; + } + + + /** + * The optional default policy to use for the child workflow executions + * when a workflow execution of this type is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:

  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @return The optional default policy to use for the child workflow executions + * when a workflow execution of this type is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:

  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ * + * @see ChildPolicy + */ + public String getDefaultChildPolicy() { + return defaultChildPolicy; + } + + /** + * The optional default policy to use for the child workflow executions + * when a workflow execution of this type is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:
  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param defaultChildPolicy The optional default policy to use for the child workflow executions + * when a workflow execution of this type is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:

  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ * + * @see ChildPolicy + */ + public void setDefaultChildPolicy(String defaultChildPolicy) { + this.defaultChildPolicy = defaultChildPolicy; + } + + /** + * The optional default policy to use for the child workflow executions + * when a workflow execution of this type is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:
  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param defaultChildPolicy The optional default policy to use for the child workflow executions + * when a workflow execution of this type is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:

  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public WorkflowTypeConfiguration withDefaultChildPolicy(String defaultChildPolicy) { + this.defaultChildPolicy = defaultChildPolicy; + return this; + } + + + /** + * The optional default policy to use for the child workflow executions + * when a workflow execution of this type is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:
  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param defaultChildPolicy The optional default policy to use for the child workflow executions + * when a workflow execution of this type is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:

  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ * + * @see ChildPolicy + */ + public void setDefaultChildPolicy(ChildPolicy defaultChildPolicy) { + this.defaultChildPolicy = defaultChildPolicy.toString(); + } + + /** + * The optional default policy to use for the child workflow executions + * when a workflow execution of this type is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:
  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: TERMINATE, REQUEST_CANCEL, ABANDON + * + * @param defaultChildPolicy The optional default policy to use for the child workflow executions + * when a workflow execution of this type is terminated, by calling the + * TerminateWorkflowExecution action explicitly or due to an + * expired timeout. This default can be overridden when starting a + * workflow execution using the StartWorkflowExecution action or + * the StartChildWorkflowExecution Decision. The + * supported child policies are:

  • TERMINATE: the child + * executions will be terminated.
  • REQUEST_CANCEL: a + * request to cancel will be attempted for each child execution by + * recording a WorkflowExecutionCancelRequested event in its + * history. It is up to the decider to take appropriate actions when it + * receives an execution history with this event.
  • + *
  • ABANDON: no action will be taken. The child executions will + * continue to run.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see ChildPolicy + */ + public WorkflowTypeConfiguration withDefaultChildPolicy(ChildPolicy defaultChildPolicy) { + this.defaultChildPolicy = defaultChildPolicy.toString(); + return this; + } + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (defaultTaskStartToCloseTimeout != null) sb.append("DefaultTaskStartToCloseTimeout: " + defaultTaskStartToCloseTimeout + ", "); + if (defaultExecutionStartToCloseTimeout != null) sb.append("DefaultExecutionStartToCloseTimeout: " + defaultExecutionStartToCloseTimeout + ", "); + if (defaultTaskList != null) sb.append("DefaultTaskList: " + defaultTaskList + ", "); + if (defaultChildPolicy != null) sb.append("DefaultChildPolicy: " + defaultChildPolicy + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getDefaultTaskStartToCloseTimeout() == null) ? 0 : getDefaultTaskStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getDefaultExecutionStartToCloseTimeout() == null) ? 0 : getDefaultExecutionStartToCloseTimeout().hashCode()); + hashCode = prime * hashCode + ((getDefaultTaskList() == null) ? 0 : getDefaultTaskList().hashCode()); + hashCode = prime * hashCode + ((getDefaultChildPolicy() == null) ? 0 : getDefaultChildPolicy().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowTypeConfiguration == false) return false; + WorkflowTypeConfiguration other = (WorkflowTypeConfiguration)obj; + + if (other.getDefaultTaskStartToCloseTimeout() == null ^ this.getDefaultTaskStartToCloseTimeout() == null) return false; + if (other.getDefaultTaskStartToCloseTimeout() != null && other.getDefaultTaskStartToCloseTimeout().equals(this.getDefaultTaskStartToCloseTimeout()) == false) return false; + if (other.getDefaultExecutionStartToCloseTimeout() == null ^ this.getDefaultExecutionStartToCloseTimeout() == null) return false; + if (other.getDefaultExecutionStartToCloseTimeout() != null && other.getDefaultExecutionStartToCloseTimeout().equals(this.getDefaultExecutionStartToCloseTimeout()) == false) return false; + if (other.getDefaultTaskList() == null ^ this.getDefaultTaskList() == null) return false; + if (other.getDefaultTaskList() != null && other.getDefaultTaskList().equals(this.getDefaultTaskList()) == false) return false; + if (other.getDefaultChildPolicy() == null ^ this.getDefaultChildPolicy() == null) return false; + if (other.getDefaultChildPolicy() != null && other.getDefaultChildPolicy().equals(this.getDefaultChildPolicy()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowTypeDetail.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowTypeDetail.java new file mode 100644 index 000000000000..191fc1272cc9 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowTypeDetail.java @@ -0,0 +1,202 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Contains details about a workflow type. + *

+ */ +public class WorkflowTypeDetail { + + /** + * General information about the workflow type.

The status of the + * workflow type (returned in the WorkflowTypeInfo structure) can be one + * of the following.

  • REGISTERED: The type is registered + * and available. Workers supporting this type should be running.
  • + *
  • DEPRECATED: The type was deprecated using + * DeprecateWorkflowType, but is still in use. You should keep + * workers supporting this type running. You cannot create new workflow + * executions of this type.
+ */ + private WorkflowTypeInfo typeInfo; + + /** + * Configuration settings of the workflow type registered through + * RegisterWorkflowType + */ + private WorkflowTypeConfiguration configuration; + + /** + * General information about the workflow type.

The status of the + * workflow type (returned in the WorkflowTypeInfo structure) can be one + * of the following.

  • REGISTERED: The type is registered + * and available. Workers supporting this type should be running.
  • + *
  • DEPRECATED: The type was deprecated using + * DeprecateWorkflowType, but is still in use. You should keep + * workers supporting this type running. You cannot create new workflow + * executions of this type.
+ * + * @return General information about the workflow type.

The status of the + * workflow type (returned in the WorkflowTypeInfo structure) can be one + * of the following.

  • REGISTERED: The type is registered + * and available. Workers supporting this type should be running.
  • + *
  • DEPRECATED: The type was deprecated using + * DeprecateWorkflowType, but is still in use. You should keep + * workers supporting this type running. You cannot create new workflow + * executions of this type.
+ */ + public WorkflowTypeInfo getTypeInfo() { + return typeInfo; + } + + /** + * General information about the workflow type.

The status of the + * workflow type (returned in the WorkflowTypeInfo structure) can be one + * of the following.

  • REGISTERED: The type is registered + * and available. Workers supporting this type should be running.
  • + *
  • DEPRECATED: The type was deprecated using + * DeprecateWorkflowType, but is still in use. You should keep + * workers supporting this type running. You cannot create new workflow + * executions of this type.
+ * + * @param typeInfo General information about the workflow type.

The status of the + * workflow type (returned in the WorkflowTypeInfo structure) can be one + * of the following.

  • REGISTERED: The type is registered + * and available. Workers supporting this type should be running.
  • + *
  • DEPRECATED: The type was deprecated using + * DeprecateWorkflowType, but is still in use. You should keep + * workers supporting this type running. You cannot create new workflow + * executions of this type.
+ */ + public void setTypeInfo(WorkflowTypeInfo typeInfo) { + this.typeInfo = typeInfo; + } + + /** + * General information about the workflow type.

The status of the + * workflow type (returned in the WorkflowTypeInfo structure) can be one + * of the following.

  • REGISTERED: The type is registered + * and available. Workers supporting this type should be running.
  • + *
  • DEPRECATED: The type was deprecated using + * DeprecateWorkflowType, but is still in use. You should keep + * workers supporting this type running. You cannot create new workflow + * executions of this type.
+ *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param typeInfo General information about the workflow type.

The status of the + * workflow type (returned in the WorkflowTypeInfo structure) can be one + * of the following.

  • REGISTERED: The type is registered + * and available. Workers supporting this type should be running.
  • + *
  • DEPRECATED: The type was deprecated using + * DeprecateWorkflowType, but is still in use. You should keep + * workers supporting this type running. You cannot create new workflow + * executions of this type.
+ * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowTypeDetail withTypeInfo(WorkflowTypeInfo typeInfo) { + this.typeInfo = typeInfo; + return this; + } + + + /** + * Configuration settings of the workflow type registered through + * RegisterWorkflowType + * + * @return Configuration settings of the workflow type registered through + * RegisterWorkflowType + */ + public WorkflowTypeConfiguration getConfiguration() { + return configuration; + } + + /** + * Configuration settings of the workflow type registered through + * RegisterWorkflowType + * + * @param configuration Configuration settings of the workflow type registered through + * RegisterWorkflowType + */ + public void setConfiguration(WorkflowTypeConfiguration configuration) { + this.configuration = configuration; + } + + /** + * Configuration settings of the workflow type registered through + * RegisterWorkflowType + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param configuration Configuration settings of the workflow type registered through + * RegisterWorkflowType + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowTypeDetail withConfiguration(WorkflowTypeConfiguration configuration) { + this.configuration = configuration; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (typeInfo != null) sb.append("TypeInfo: " + typeInfo + ", "); + if (configuration != null) sb.append("Configuration: " + configuration + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTypeInfo() == null) ? 0 : getTypeInfo().hashCode()); + hashCode = prime * hashCode + ((getConfiguration() == null) ? 0 : getConfiguration().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowTypeDetail == false) return false; + WorkflowTypeDetail other = (WorkflowTypeDetail)obj; + + if (other.getTypeInfo() == null ^ this.getTypeInfo() == null) return false; + if (other.getTypeInfo() != null && other.getTypeInfo().equals(this.getTypeInfo()) == false) return false; + if (other.getConfiguration() == null ^ this.getConfiguration() == null) return false; + if (other.getConfiguration() != null && other.getConfiguration().equals(this.getConfiguration()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowTypeFilter.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowTypeFilter.java new file mode 100644 index 000000000000..ebddeaf35dde --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowTypeFilter.java @@ -0,0 +1,172 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Used to filter workflow execution query results by type. Each + * parameter, if specified, defines a rule that must be satisfied by each + * returned result. + *

+ */ +public class WorkflowTypeFilter { + + /** + * Name of the workflow type. This field is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ */ + private String name; + + /** + * Version of the workflow type. + *

+ * Constraints:
+ * Length: 0 - 64
+ */ + private String version; + + /** + * Name of the workflow type. This field is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @return Name of the workflow type. This field is required. + */ + public String getName() { + return name; + } + + /** + * Name of the workflow type. This field is required. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name Name of the workflow type. This field is required. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Name of the workflow type. This field is required. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 1 - 256
+ * + * @param name Name of the workflow type. This field is required. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowTypeFilter withName(String name) { + this.name = name; + return this; + } + + + /** + * Version of the workflow type. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @return Version of the workflow type. + */ + public String getVersion() { + return version; + } + + /** + * Version of the workflow type. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param version Version of the workflow type. + */ + public void setVersion(String version) { + this.version = version; + } + + /** + * Version of the workflow type. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 64
+ * + * @param version Version of the workflow type. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowTypeFilter withVersion(String version) { + this.version = version; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (name != null) sb.append("Name: " + name + ", "); + if (version != null) sb.append("Version: " + version + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); + hashCode = prime * hashCode + ((getVersion() == null) ? 0 : getVersion().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowTypeFilter == false) return false; + WorkflowTypeFilter other = (WorkflowTypeFilter)obj; + + if (other.getName() == null ^ this.getName() == null) return false; + if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; + if (other.getVersion() == null ^ this.getVersion() == null) return false; + if (other.getVersion() != null && other.getVersion().equals(this.getVersion()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowTypeInfo.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowTypeInfo.java new file mode 100644 index 000000000000..307e82ef8621 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowTypeInfo.java @@ -0,0 +1,353 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Contains information about a workflow type. + *

+ */ +public class WorkflowTypeInfo { + + /** + * The workflow type this information is about. + */ + private WorkflowType workflowType; + + /** + * The current status of the workflow type. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + */ + private String status; + + /** + * The description of the type registered through + * RegisterWorkflowType. + *

+ * Constraints:
+ * Length: 0 - 1024
+ */ + private String description; + + /** + * The date when this type was registered. + */ + private java.util.Date creationDate; + + /** + * If the type is in deprecated state, then it is set to the date when + * the type was deprecated. + */ + private java.util.Date deprecationDate; + + /** + * The workflow type this information is about. + * + * @return The workflow type this information is about. + */ + public WorkflowType getWorkflowType() { + return workflowType; + } + + /** + * The workflow type this information is about. + * + * @param workflowType The workflow type this information is about. + */ + public void setWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + } + + /** + * The workflow type this information is about. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param workflowType The workflow type this information is about. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowTypeInfo withWorkflowType(WorkflowType workflowType) { + this.workflowType = workflowType; + return this; + } + + + /** + * The current status of the workflow type. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @return The current status of the workflow type. + * + * @see RegistrationStatus + */ + public String getStatus() { + return status; + } + + /** + * The current status of the workflow type. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param status The current status of the workflow type. + * + * @see RegistrationStatus + */ + public void setStatus(String status) { + this.status = status; + } + + /** + * The current status of the workflow type. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param status The current status of the workflow type. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see RegistrationStatus + */ + public WorkflowTypeInfo withStatus(String status) { + this.status = status; + return this; + } + + + /** + * The current status of the workflow type. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param status The current status of the workflow type. + * + * @see RegistrationStatus + */ + public void setStatus(RegistrationStatus status) { + this.status = status.toString(); + } + + /** + * The current status of the workflow type. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Allowed Values: REGISTERED, DEPRECATED + * + * @param status The current status of the workflow type. + * + * @return A reference to this updated object so that method calls can be chained + * together. + * + * @see RegistrationStatus + */ + public WorkflowTypeInfo withStatus(RegistrationStatus status) { + this.status = status.toString(); + return this; + } + + /** + * The description of the type registered through + * RegisterWorkflowType. + *

+ * Constraints:
+ * Length: 0 - 1024
+ * + * @return The description of the type registered through + * RegisterWorkflowType. + */ + public String getDescription() { + return description; + } + + /** + * The description of the type registered through + * RegisterWorkflowType. + *

+ * Constraints:
+ * Length: 0 - 1024
+ * + * @param description The description of the type registered through + * RegisterWorkflowType. + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * The description of the type registered through + * RegisterWorkflowType. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 1024
+ * + * @param description The description of the type registered through + * RegisterWorkflowType. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowTypeInfo withDescription(String description) { + this.description = description; + return this; + } + + + /** + * The date when this type was registered. + * + * @return The date when this type was registered. + */ + public java.util.Date getCreationDate() { + return creationDate; + } + + /** + * The date when this type was registered. + * + * @param creationDate The date when this type was registered. + */ + public void setCreationDate(java.util.Date creationDate) { + this.creationDate = creationDate; + } + + /** + * The date when this type was registered. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param creationDate The date when this type was registered. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowTypeInfo withCreationDate(java.util.Date creationDate) { + this.creationDate = creationDate; + return this; + } + + + /** + * If the type is in deprecated state, then it is set to the date when + * the type was deprecated. + * + * @return If the type is in deprecated state, then it is set to the date when + * the type was deprecated. + */ + public java.util.Date getDeprecationDate() { + return deprecationDate; + } + + /** + * If the type is in deprecated state, then it is set to the date when + * the type was deprecated. + * + * @param deprecationDate If the type is in deprecated state, then it is set to the date when + * the type was deprecated. + */ + public void setDeprecationDate(java.util.Date deprecationDate) { + this.deprecationDate = deprecationDate; + } + + /** + * If the type is in deprecated state, then it is set to the date when + * the type was deprecated. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param deprecationDate If the type is in deprecated state, then it is set to the date when + * the type was deprecated. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowTypeInfo withDeprecationDate(java.util.Date deprecationDate) { + this.deprecationDate = deprecationDate; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (workflowType != null) sb.append("WorkflowType: " + workflowType + ", "); + if (status != null) sb.append("Status: " + status + ", "); + if (description != null) sb.append("Description: " + description + ", "); + if (creationDate != null) sb.append("CreationDate: " + creationDate + ", "); + if (deprecationDate != null) sb.append("DeprecationDate: " + deprecationDate + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getWorkflowType() == null) ? 0 : getWorkflowType().hashCode()); + hashCode = prime * hashCode + ((getStatus() == null) ? 0 : getStatus().hashCode()); + hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); + hashCode = prime * hashCode + ((getCreationDate() == null) ? 0 : getCreationDate().hashCode()); + hashCode = prime * hashCode + ((getDeprecationDate() == null) ? 0 : getDeprecationDate().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowTypeInfo == false) return false; + WorkflowTypeInfo other = (WorkflowTypeInfo)obj; + + if (other.getWorkflowType() == null ^ this.getWorkflowType() == null) return false; + if (other.getWorkflowType() != null && other.getWorkflowType().equals(this.getWorkflowType()) == false) return false; + if (other.getStatus() == null ^ this.getStatus() == null) return false; + if (other.getStatus() != null && other.getStatus().equals(this.getStatus()) == false) return false; + if (other.getDescription() == null ^ this.getDescription() == null) return false; + if (other.getDescription() != null && other.getDescription().equals(this.getDescription()) == false) return false; + if (other.getCreationDate() == null ^ this.getCreationDate() == null) return false; + if (other.getCreationDate() != null && other.getCreationDate().equals(this.getCreationDate()) == false) return false; + if (other.getDeprecationDate() == null ^ this.getDeprecationDate() == null) return false; + if (other.getDeprecationDate() != null && other.getDeprecationDate().equals(this.getDeprecationDate()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowTypeInfos.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowTypeInfos.java new file mode 100644 index 000000000000..2f2a7b245d6d --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/WorkflowTypeInfos.java @@ -0,0 +1,215 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model; + +/** + *

+ * Contains a paginated list of information structures about workflow + * types. + *

+ */ +public class WorkflowTypeInfos { + + /** + * The list of workflow type information. + */ + private java.util.List typeInfos; + + /** + * The token for the next page of type information. If set then the list + * consists of more than one page. You can retrieve the next page by + * repeating the request (that returned the structure) with the this + * token and all other arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ */ + private String nextPageToken; + + /** + * The list of workflow type information. + * + * @return The list of workflow type information. + */ + public java.util.List getTypeInfos() { + + if (typeInfos == null) { + typeInfos = new java.util.ArrayList(); + } + return typeInfos; + } + + /** + * The list of workflow type information. + * + * @param typeInfos The list of workflow type information. + */ + public void setTypeInfos(java.util.Collection typeInfos) { + if (typeInfos == null) { + this.typeInfos = null; + return; + } + + java.util.List typeInfosCopy = new java.util.ArrayList(typeInfos.size()); + typeInfosCopy.addAll(typeInfos); + this.typeInfos = typeInfosCopy; + } + + /** + * The list of workflow type information. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param typeInfos The list of workflow type information. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowTypeInfos withTypeInfos(WorkflowTypeInfo... typeInfos) { + if (getTypeInfos() == null) setTypeInfos(new java.util.ArrayList(typeInfos.length)); + for (WorkflowTypeInfo value : typeInfos) { + getTypeInfos().add(value); + } + return this; + } + + /** + * The list of workflow type information. + *

+ * Returns a reference to this object so that method calls can be chained together. + * + * @param typeInfos The list of workflow type information. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowTypeInfos withTypeInfos(java.util.Collection typeInfos) { + if (typeInfos == null) { + this.typeInfos = null; + } else { + java.util.List typeInfosCopy = new java.util.ArrayList(typeInfos.size()); + typeInfosCopy.addAll(typeInfos); + this.typeInfos = typeInfosCopy; + } + + return this; + } + + /** + * The token for the next page of type information. If set then the list + * consists of more than one page. You can retrieve the next page by + * repeating the request (that returned the structure) with the this + * token and all other arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @return The token for the next page of type information. If set then the list + * consists of more than one page. You can retrieve the next page by + * repeating the request (that returned the structure) with the this + * token and all other arguments unchanged. + */ + public String getNextPageToken() { + return nextPageToken; + } + + /** + * The token for the next page of type information. If set then the list + * consists of more than one page. You can retrieve the next page by + * repeating the request (that returned the structure) with the this + * token and all other arguments unchanged. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken The token for the next page of type information. If set then the list + * consists of more than one page. You can retrieve the next page by + * repeating the request (that returned the structure) with the this + * token and all other arguments unchanged. + */ + public void setNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + } + + /** + * The token for the next page of type information. If set then the list + * consists of more than one page. You can retrieve the next page by + * repeating the request (that returned the structure) with the this + * token and all other arguments unchanged. + *

+ * Returns a reference to this object so that method calls can be chained together. + *

+ * Constraints:
+ * Length: 0 - 2048
+ * + * @param nextPageToken The token for the next page of type information. If set then the list + * consists of more than one page. You can retrieve the next page by + * repeating the request (that returned the structure) with the this + * token and all other arguments unchanged. + * + * @return A reference to this updated object so that method calls can be chained + * together. + */ + public WorkflowTypeInfos withNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + + /** + * Returns a string representation of this object; useful for testing and + * debugging. + * + * @return A string representation of this object. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{"); + if (typeInfos != null) sb.append("TypeInfos: " + typeInfos + ", "); + if (nextPageToken != null) sb.append("NextPageToken: " + nextPageToken + ", "); + sb.append("}"); + return sb.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int hashCode = 1; + + hashCode = prime * hashCode + ((getTypeInfos() == null) ? 0 : getTypeInfos().hashCode()); + hashCode = prime * hashCode + ((getNextPageToken() == null) ? 0 : getNextPageToken().hashCode()); + return hashCode; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + + if (obj instanceof WorkflowTypeInfos == false) return false; + WorkflowTypeInfos other = (WorkflowTypeInfos)obj; + + if (other.getTypeInfos() == null ^ this.getTypeInfos() == null) return false; + if (other.getTypeInfos() != null && other.getTypeInfos().equals(this.getTypeInfos()) == false) return false; + if (other.getNextPageToken() == null ^ this.getNextPageToken() == null) return false; + if (other.getNextPageToken() != null && other.getNextPageToken().equals(this.getNextPageToken()) == false) return false; + return true; + } + +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/package-info.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/package-info.java new file mode 100644 index 000000000000..e2388da5ddb4 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/package-info.java @@ -0,0 +1,6 @@ + +/** + * Classes modeling the various types represented by AmazonSimpleWorkflow. + */ + package com.amazonaws.services.simpleworkflow.model; + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskCancelRequestedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskCancelRequestedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..22355b79eac0 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskCancelRequestedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Activity Task Cancel Requested Event Attributes JSON Unmarshaller + */ +public class ActivityTaskCancelRequestedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public ActivityTaskCancelRequestedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + ActivityTaskCancelRequestedEventAttributes activityTaskCancelRequestedEventAttributes = new ActivityTaskCancelRequestedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return activityTaskCancelRequestedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + activityTaskCancelRequestedEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("activityId", targetDepth)) { + context.nextToken(); + activityTaskCancelRequestedEventAttributes.setActivityId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return activityTaskCancelRequestedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static ActivityTaskCancelRequestedEventAttributesJsonUnmarshaller instance; + public static ActivityTaskCancelRequestedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new ActivityTaskCancelRequestedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskCanceledEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskCanceledEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..7c25d75063a5 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskCanceledEventAttributesJsonUnmarshaller.java @@ -0,0 +1,78 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Activity Task Canceled Event Attributes JSON Unmarshaller + */ +public class ActivityTaskCanceledEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public ActivityTaskCanceledEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + ActivityTaskCanceledEventAttributes activityTaskCanceledEventAttributes = new ActivityTaskCanceledEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return activityTaskCanceledEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("details", targetDepth)) { + context.nextToken(); + activityTaskCanceledEventAttributes.setDetails(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("scheduledEventId", targetDepth)) { + context.nextToken(); + activityTaskCanceledEventAttributes.setScheduledEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startedEventId", targetDepth)) { + context.nextToken(); + activityTaskCanceledEventAttributes.setStartedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("latestCancelRequestedEventId", targetDepth)) { + context.nextToken(); + activityTaskCanceledEventAttributes.setLatestCancelRequestedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return activityTaskCanceledEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static ActivityTaskCanceledEventAttributesJsonUnmarshaller instance; + public static ActivityTaskCanceledEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new ActivityTaskCanceledEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskCompletedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskCompletedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..b3c50b7415e7 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskCompletedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Activity Task Completed Event Attributes JSON Unmarshaller + */ +public class ActivityTaskCompletedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public ActivityTaskCompletedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + ActivityTaskCompletedEventAttributes activityTaskCompletedEventAttributes = new ActivityTaskCompletedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return activityTaskCompletedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("result", targetDepth)) { + context.nextToken(); + activityTaskCompletedEventAttributes.setResult(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("scheduledEventId", targetDepth)) { + context.nextToken(); + activityTaskCompletedEventAttributes.setScheduledEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startedEventId", targetDepth)) { + context.nextToken(); + activityTaskCompletedEventAttributes.setStartedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return activityTaskCompletedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static ActivityTaskCompletedEventAttributesJsonUnmarshaller instance; + public static ActivityTaskCompletedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new ActivityTaskCompletedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskFailedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskFailedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..9a09ecc6539e --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskFailedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,78 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Activity Task Failed Event Attributes JSON Unmarshaller + */ +public class ActivityTaskFailedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public ActivityTaskFailedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + ActivityTaskFailedEventAttributes activityTaskFailedEventAttributes = new ActivityTaskFailedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return activityTaskFailedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("reason", targetDepth)) { + context.nextToken(); + activityTaskFailedEventAttributes.setReason(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("details", targetDepth)) { + context.nextToken(); + activityTaskFailedEventAttributes.setDetails(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("scheduledEventId", targetDepth)) { + context.nextToken(); + activityTaskFailedEventAttributes.setScheduledEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startedEventId", targetDepth)) { + context.nextToken(); + activityTaskFailedEventAttributes.setStartedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return activityTaskFailedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static ActivityTaskFailedEventAttributesJsonUnmarshaller instance; + public static ActivityTaskFailedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new ActivityTaskFailedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskJsonUnmarshaller.java new file mode 100644 index 000000000000..12b1d52987fd --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskJsonUnmarshaller.java @@ -0,0 +1,86 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Activity Task JSON Unmarshaller + */ +public class ActivityTaskJsonUnmarshaller implements Unmarshaller { + + + + public ActivityTask unmarshall(JsonUnmarshallerContext context) throws Exception { + ActivityTask activityTask = new ActivityTask(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return activityTask; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("taskToken", targetDepth)) { + context.nextToken(); + activityTask.setTaskToken(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("activityId", targetDepth)) { + context.nextToken(); + activityTask.setActivityId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startedEventId", targetDepth)) { + context.nextToken(); + activityTask.setStartedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowExecution", targetDepth)) { + context.nextToken(); + activityTask.setWorkflowExecution(WorkflowExecutionJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("activityType", targetDepth)) { + context.nextToken(); + activityTask.setActivityType(ActivityTypeJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("input", targetDepth)) { + context.nextToken(); + activityTask.setInput(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return activityTask; + } + } + token = context.nextToken(); + } + } + + private static ActivityTaskJsonUnmarshaller instance; + public static ActivityTaskJsonUnmarshaller getInstance() { + if (instance == null) instance = new ActivityTaskJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskScheduledEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskScheduledEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..3333d7532f2b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskScheduledEventAttributesJsonUnmarshaller.java @@ -0,0 +1,102 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Activity Task Scheduled Event Attributes JSON Unmarshaller + */ +public class ActivityTaskScheduledEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public ActivityTaskScheduledEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + ActivityTaskScheduledEventAttributes activityTaskScheduledEventAttributes = new ActivityTaskScheduledEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return activityTaskScheduledEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("activityType", targetDepth)) { + context.nextToken(); + activityTaskScheduledEventAttributes.setActivityType(ActivityTypeJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("activityId", targetDepth)) { + context.nextToken(); + activityTaskScheduledEventAttributes.setActivityId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("input", targetDepth)) { + context.nextToken(); + activityTaskScheduledEventAttributes.setInput(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("control", targetDepth)) { + context.nextToken(); + activityTaskScheduledEventAttributes.setControl(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("scheduleToStartTimeout", targetDepth)) { + context.nextToken(); + activityTaskScheduledEventAttributes.setScheduleToStartTimeout(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("scheduleToCloseTimeout", targetDepth)) { + context.nextToken(); + activityTaskScheduledEventAttributes.setScheduleToCloseTimeout(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startToCloseTimeout", targetDepth)) { + context.nextToken(); + activityTaskScheduledEventAttributes.setStartToCloseTimeout(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("taskList", targetDepth)) { + context.nextToken(); + activityTaskScheduledEventAttributes.setTaskList(TaskListJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + activityTaskScheduledEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("heartbeatTimeout", targetDepth)) { + context.nextToken(); + activityTaskScheduledEventAttributes.setHeartbeatTimeout(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return activityTaskScheduledEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static ActivityTaskScheduledEventAttributesJsonUnmarshaller instance; + public static ActivityTaskScheduledEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new ActivityTaskScheduledEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskStartedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskStartedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..fde25ce6fdb4 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskStartedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Activity Task Started Event Attributes JSON Unmarshaller + */ +public class ActivityTaskStartedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public ActivityTaskStartedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + ActivityTaskStartedEventAttributes activityTaskStartedEventAttributes = new ActivityTaskStartedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return activityTaskStartedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("identity", targetDepth)) { + context.nextToken(); + activityTaskStartedEventAttributes.setIdentity(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("scheduledEventId", targetDepth)) { + context.nextToken(); + activityTaskStartedEventAttributes.setScheduledEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return activityTaskStartedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static ActivityTaskStartedEventAttributesJsonUnmarshaller instance; + public static ActivityTaskStartedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new ActivityTaskStartedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskStatusJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskStatusJsonUnmarshaller.java new file mode 100644 index 000000000000..7a055e63ad78 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskStatusJsonUnmarshaller.java @@ -0,0 +1,66 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Activity Task Status JSON Unmarshaller + */ +public class ActivityTaskStatusJsonUnmarshaller implements Unmarshaller { + + + + public ActivityTaskStatus unmarshall(JsonUnmarshallerContext context) throws Exception { + ActivityTaskStatus activityTaskStatus = new ActivityTaskStatus(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return activityTaskStatus; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("cancelRequested", targetDepth)) { + context.nextToken(); + activityTaskStatus.setCancelRequested(BooleanJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return activityTaskStatus; + } + } + token = context.nextToken(); + } + } + + private static ActivityTaskStatusJsonUnmarshaller instance; + public static ActivityTaskStatusJsonUnmarshaller getInstance() { + if (instance == null) instance = new ActivityTaskStatusJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskTimedOutEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskTimedOutEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..c24774082ea6 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTaskTimedOutEventAttributesJsonUnmarshaller.java @@ -0,0 +1,78 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Activity Task Timed Out Event Attributes JSON Unmarshaller + */ +public class ActivityTaskTimedOutEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public ActivityTaskTimedOutEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + ActivityTaskTimedOutEventAttributes activityTaskTimedOutEventAttributes = new ActivityTaskTimedOutEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return activityTaskTimedOutEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("timeoutType", targetDepth)) { + context.nextToken(); + activityTaskTimedOutEventAttributes.setTimeoutType(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("scheduledEventId", targetDepth)) { + context.nextToken(); + activityTaskTimedOutEventAttributes.setScheduledEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startedEventId", targetDepth)) { + context.nextToken(); + activityTaskTimedOutEventAttributes.setStartedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("details", targetDepth)) { + context.nextToken(); + activityTaskTimedOutEventAttributes.setDetails(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return activityTaskTimedOutEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static ActivityTaskTimedOutEventAttributesJsonUnmarshaller instance; + public static ActivityTaskTimedOutEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new ActivityTaskTimedOutEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTypeConfigurationJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTypeConfigurationJsonUnmarshaller.java new file mode 100644 index 000000000000..e033a12657be --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTypeConfigurationJsonUnmarshaller.java @@ -0,0 +1,82 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Activity Type Configuration JSON Unmarshaller + */ +public class ActivityTypeConfigurationJsonUnmarshaller implements Unmarshaller { + + + + public ActivityTypeConfiguration unmarshall(JsonUnmarshallerContext context) throws Exception { + ActivityTypeConfiguration activityTypeConfiguration = new ActivityTypeConfiguration(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return activityTypeConfiguration; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("defaultTaskStartToCloseTimeout", targetDepth)) { + context.nextToken(); + activityTypeConfiguration.setDefaultTaskStartToCloseTimeout(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("defaultTaskHeartbeatTimeout", targetDepth)) { + context.nextToken(); + activityTypeConfiguration.setDefaultTaskHeartbeatTimeout(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("defaultTaskList", targetDepth)) { + context.nextToken(); + activityTypeConfiguration.setDefaultTaskList(TaskListJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("defaultTaskScheduleToStartTimeout", targetDepth)) { + context.nextToken(); + activityTypeConfiguration.setDefaultTaskScheduleToStartTimeout(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("defaultTaskScheduleToCloseTimeout", targetDepth)) { + context.nextToken(); + activityTypeConfiguration.setDefaultTaskScheduleToCloseTimeout(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return activityTypeConfiguration; + } + } + token = context.nextToken(); + } + } + + private static ActivityTypeConfigurationJsonUnmarshaller instance; + public static ActivityTypeConfigurationJsonUnmarshaller getInstance() { + if (instance == null) instance = new ActivityTypeConfigurationJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTypeDetailJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTypeDetailJsonUnmarshaller.java new file mode 100644 index 000000000000..59d8f12ff227 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTypeDetailJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Activity Type Detail JSON Unmarshaller + */ +public class ActivityTypeDetailJsonUnmarshaller implements Unmarshaller { + + + + public ActivityTypeDetail unmarshall(JsonUnmarshallerContext context) throws Exception { + ActivityTypeDetail activityTypeDetail = new ActivityTypeDetail(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return activityTypeDetail; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("typeInfo", targetDepth)) { + context.nextToken(); + activityTypeDetail.setTypeInfo(ActivityTypeInfoJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("configuration", targetDepth)) { + context.nextToken(); + activityTypeDetail.setConfiguration(ActivityTypeConfigurationJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return activityTypeDetail; + } + } + token = context.nextToken(); + } + } + + private static ActivityTypeDetailJsonUnmarshaller instance; + public static ActivityTypeDetailJsonUnmarshaller getInstance() { + if (instance == null) instance = new ActivityTypeDetailJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTypeInfoJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTypeInfoJsonUnmarshaller.java new file mode 100644 index 000000000000..ae101af4a159 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTypeInfoJsonUnmarshaller.java @@ -0,0 +1,82 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Activity Type Info JSON Unmarshaller + */ +public class ActivityTypeInfoJsonUnmarshaller implements Unmarshaller { + + + + public ActivityTypeInfo unmarshall(JsonUnmarshallerContext context) throws Exception { + ActivityTypeInfo activityTypeInfo = new ActivityTypeInfo(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return activityTypeInfo; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("activityType", targetDepth)) { + context.nextToken(); + activityTypeInfo.setActivityType(ActivityTypeJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("status", targetDepth)) { + context.nextToken(); + activityTypeInfo.setStatus(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("description", targetDepth)) { + context.nextToken(); + activityTypeInfo.setDescription(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("creationDate", targetDepth)) { + context.nextToken(); + activityTypeInfo.setCreationDate(DateJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("deprecationDate", targetDepth)) { + context.nextToken(); + activityTypeInfo.setDeprecationDate(DateJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return activityTypeInfo; + } + } + token = context.nextToken(); + } + } + + private static ActivityTypeInfoJsonUnmarshaller instance; + public static ActivityTypeInfoJsonUnmarshaller getInstance() { + if (instance == null) instance = new ActivityTypeInfoJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTypeInfosJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTypeInfosJsonUnmarshaller.java new file mode 100644 index 000000000000..8d06bf9045a1 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTypeInfosJsonUnmarshaller.java @@ -0,0 +1,69 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Activity Type Infos JSON Unmarshaller + */ +public class ActivityTypeInfosJsonUnmarshaller implements Unmarshaller { + + + + public ActivityTypeInfos unmarshall(JsonUnmarshallerContext context) throws Exception { + ActivityTypeInfos activityTypeInfos = new ActivityTypeInfos(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return activityTypeInfos; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("typeInfos", targetDepth)) { + activityTypeInfos.setTypeInfos(new ListUnmarshaller(ActivityTypeInfoJsonUnmarshaller.getInstance()).unmarshall(context)); + } + if (context.testExpression("nextPageToken", targetDepth)) { + context.nextToken(); + activityTypeInfos.setNextPageToken(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return activityTypeInfos; + } + } + token = context.nextToken(); + } + } + + private static ActivityTypeInfosJsonUnmarshaller instance; + public static ActivityTypeInfosJsonUnmarshaller getInstance() { + if (instance == null) instance = new ActivityTypeInfosJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTypeJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTypeJsonUnmarshaller.java new file mode 100644 index 000000000000..6e97b2807ac8 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ActivityTypeJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Activity Type JSON Unmarshaller + */ +public class ActivityTypeJsonUnmarshaller implements Unmarshaller { + + + + public ActivityType unmarshall(JsonUnmarshallerContext context) throws Exception { + ActivityType activityType = new ActivityType(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return activityType; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("name", targetDepth)) { + context.nextToken(); + activityType.setName(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("version", targetDepth)) { + context.nextToken(); + activityType.setVersion(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return activityType; + } + } + token = context.nextToken(); + } + } + + private static ActivityTypeJsonUnmarshaller instance; + public static ActivityTypeJsonUnmarshaller getInstance() { + if (instance == null) instance = new ActivityTypeJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CancelTimerFailedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CancelTimerFailedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..3d95d8f10ced --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CancelTimerFailedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Cancel Timer Failed Event Attributes JSON Unmarshaller + */ +public class CancelTimerFailedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public CancelTimerFailedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + CancelTimerFailedEventAttributes cancelTimerFailedEventAttributes = new CancelTimerFailedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return cancelTimerFailedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("timerId", targetDepth)) { + context.nextToken(); + cancelTimerFailedEventAttributes.setTimerId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("cause", targetDepth)) { + context.nextToken(); + cancelTimerFailedEventAttributes.setCause(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + cancelTimerFailedEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return cancelTimerFailedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static CancelTimerFailedEventAttributesJsonUnmarshaller instance; + public static CancelTimerFailedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new CancelTimerFailedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CancelWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CancelWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..4594448d1011 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CancelWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Cancel Workflow Execution Failed Event Attributes JSON Unmarshaller + */ +public class CancelWorkflowExecutionFailedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public CancelWorkflowExecutionFailedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + CancelWorkflowExecutionFailedEventAttributes cancelWorkflowExecutionFailedEventAttributes = new CancelWorkflowExecutionFailedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return cancelWorkflowExecutionFailedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("cause", targetDepth)) { + context.nextToken(); + cancelWorkflowExecutionFailedEventAttributes.setCause(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + cancelWorkflowExecutionFailedEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return cancelWorkflowExecutionFailedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static CancelWorkflowExecutionFailedEventAttributesJsonUnmarshaller instance; + public static CancelWorkflowExecutionFailedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new CancelWorkflowExecutionFailedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionCanceledEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionCanceledEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..05ca60859709 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionCanceledEventAttributesJsonUnmarshaller.java @@ -0,0 +1,82 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Child Workflow Execution Canceled Event Attributes JSON Unmarshaller + */ +public class ChildWorkflowExecutionCanceledEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public ChildWorkflowExecutionCanceledEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + ChildWorkflowExecutionCanceledEventAttributes childWorkflowExecutionCanceledEventAttributes = new ChildWorkflowExecutionCanceledEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return childWorkflowExecutionCanceledEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("workflowExecution", targetDepth)) { + context.nextToken(); + childWorkflowExecutionCanceledEventAttributes.setWorkflowExecution(WorkflowExecutionJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowType", targetDepth)) { + context.nextToken(); + childWorkflowExecutionCanceledEventAttributes.setWorkflowType(WorkflowTypeJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("details", targetDepth)) { + context.nextToken(); + childWorkflowExecutionCanceledEventAttributes.setDetails(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("initiatedEventId", targetDepth)) { + context.nextToken(); + childWorkflowExecutionCanceledEventAttributes.setInitiatedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startedEventId", targetDepth)) { + context.nextToken(); + childWorkflowExecutionCanceledEventAttributes.setStartedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return childWorkflowExecutionCanceledEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static ChildWorkflowExecutionCanceledEventAttributesJsonUnmarshaller instance; + public static ChildWorkflowExecutionCanceledEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new ChildWorkflowExecutionCanceledEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionCompletedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionCompletedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..f88c62ac0e47 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionCompletedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,82 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Child Workflow Execution Completed Event Attributes JSON Unmarshaller + */ +public class ChildWorkflowExecutionCompletedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public ChildWorkflowExecutionCompletedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + ChildWorkflowExecutionCompletedEventAttributes childWorkflowExecutionCompletedEventAttributes = new ChildWorkflowExecutionCompletedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return childWorkflowExecutionCompletedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("workflowExecution", targetDepth)) { + context.nextToken(); + childWorkflowExecutionCompletedEventAttributes.setWorkflowExecution(WorkflowExecutionJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowType", targetDepth)) { + context.nextToken(); + childWorkflowExecutionCompletedEventAttributes.setWorkflowType(WorkflowTypeJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("result", targetDepth)) { + context.nextToken(); + childWorkflowExecutionCompletedEventAttributes.setResult(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("initiatedEventId", targetDepth)) { + context.nextToken(); + childWorkflowExecutionCompletedEventAttributes.setInitiatedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startedEventId", targetDepth)) { + context.nextToken(); + childWorkflowExecutionCompletedEventAttributes.setStartedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return childWorkflowExecutionCompletedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static ChildWorkflowExecutionCompletedEventAttributesJsonUnmarshaller instance; + public static ChildWorkflowExecutionCompletedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new ChildWorkflowExecutionCompletedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..13e958edbc0c --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,86 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Child Workflow Execution Failed Event Attributes JSON Unmarshaller + */ +public class ChildWorkflowExecutionFailedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public ChildWorkflowExecutionFailedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + ChildWorkflowExecutionFailedEventAttributes childWorkflowExecutionFailedEventAttributes = new ChildWorkflowExecutionFailedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return childWorkflowExecutionFailedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("workflowExecution", targetDepth)) { + context.nextToken(); + childWorkflowExecutionFailedEventAttributes.setWorkflowExecution(WorkflowExecutionJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowType", targetDepth)) { + context.nextToken(); + childWorkflowExecutionFailedEventAttributes.setWorkflowType(WorkflowTypeJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("reason", targetDepth)) { + context.nextToken(); + childWorkflowExecutionFailedEventAttributes.setReason(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("details", targetDepth)) { + context.nextToken(); + childWorkflowExecutionFailedEventAttributes.setDetails(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("initiatedEventId", targetDepth)) { + context.nextToken(); + childWorkflowExecutionFailedEventAttributes.setInitiatedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startedEventId", targetDepth)) { + context.nextToken(); + childWorkflowExecutionFailedEventAttributes.setStartedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return childWorkflowExecutionFailedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static ChildWorkflowExecutionFailedEventAttributesJsonUnmarshaller instance; + public static ChildWorkflowExecutionFailedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new ChildWorkflowExecutionFailedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionStartedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionStartedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..11507e9d7fc0 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionStartedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Child Workflow Execution Started Event Attributes JSON Unmarshaller + */ +public class ChildWorkflowExecutionStartedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public ChildWorkflowExecutionStartedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + ChildWorkflowExecutionStartedEventAttributes childWorkflowExecutionStartedEventAttributes = new ChildWorkflowExecutionStartedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return childWorkflowExecutionStartedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("workflowExecution", targetDepth)) { + context.nextToken(); + childWorkflowExecutionStartedEventAttributes.setWorkflowExecution(WorkflowExecutionJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowType", targetDepth)) { + context.nextToken(); + childWorkflowExecutionStartedEventAttributes.setWorkflowType(WorkflowTypeJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("initiatedEventId", targetDepth)) { + context.nextToken(); + childWorkflowExecutionStartedEventAttributes.setInitiatedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return childWorkflowExecutionStartedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static ChildWorkflowExecutionStartedEventAttributesJsonUnmarshaller instance; + public static ChildWorkflowExecutionStartedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new ChildWorkflowExecutionStartedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionTerminatedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionTerminatedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..beaf9796217c --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionTerminatedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,78 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Child Workflow Execution Terminated Event Attributes JSON Unmarshaller + */ +public class ChildWorkflowExecutionTerminatedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public ChildWorkflowExecutionTerminatedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + ChildWorkflowExecutionTerminatedEventAttributes childWorkflowExecutionTerminatedEventAttributes = new ChildWorkflowExecutionTerminatedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return childWorkflowExecutionTerminatedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("workflowExecution", targetDepth)) { + context.nextToken(); + childWorkflowExecutionTerminatedEventAttributes.setWorkflowExecution(WorkflowExecutionJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowType", targetDepth)) { + context.nextToken(); + childWorkflowExecutionTerminatedEventAttributes.setWorkflowType(WorkflowTypeJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("initiatedEventId", targetDepth)) { + context.nextToken(); + childWorkflowExecutionTerminatedEventAttributes.setInitiatedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startedEventId", targetDepth)) { + context.nextToken(); + childWorkflowExecutionTerminatedEventAttributes.setStartedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return childWorkflowExecutionTerminatedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static ChildWorkflowExecutionTerminatedEventAttributesJsonUnmarshaller instance; + public static ChildWorkflowExecutionTerminatedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new ChildWorkflowExecutionTerminatedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionTimedOutEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionTimedOutEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..8c6fb8f2a1ec --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ChildWorkflowExecutionTimedOutEventAttributesJsonUnmarshaller.java @@ -0,0 +1,82 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Child Workflow Execution Timed Out Event Attributes JSON Unmarshaller + */ +public class ChildWorkflowExecutionTimedOutEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public ChildWorkflowExecutionTimedOutEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + ChildWorkflowExecutionTimedOutEventAttributes childWorkflowExecutionTimedOutEventAttributes = new ChildWorkflowExecutionTimedOutEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return childWorkflowExecutionTimedOutEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("workflowExecution", targetDepth)) { + context.nextToken(); + childWorkflowExecutionTimedOutEventAttributes.setWorkflowExecution(WorkflowExecutionJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowType", targetDepth)) { + context.nextToken(); + childWorkflowExecutionTimedOutEventAttributes.setWorkflowType(WorkflowTypeJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("timeoutType", targetDepth)) { + context.nextToken(); + childWorkflowExecutionTimedOutEventAttributes.setTimeoutType(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("initiatedEventId", targetDepth)) { + context.nextToken(); + childWorkflowExecutionTimedOutEventAttributes.setInitiatedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startedEventId", targetDepth)) { + context.nextToken(); + childWorkflowExecutionTimedOutEventAttributes.setStartedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return childWorkflowExecutionTimedOutEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static ChildWorkflowExecutionTimedOutEventAttributesJsonUnmarshaller instance; + public static ChildWorkflowExecutionTimedOutEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new ChildWorkflowExecutionTimedOutEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CompleteWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CompleteWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..4dab2e416789 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CompleteWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Complete Workflow Execution Failed Event Attributes JSON Unmarshaller + */ +public class CompleteWorkflowExecutionFailedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public CompleteWorkflowExecutionFailedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + CompleteWorkflowExecutionFailedEventAttributes completeWorkflowExecutionFailedEventAttributes = new CompleteWorkflowExecutionFailedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return completeWorkflowExecutionFailedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("cause", targetDepth)) { + context.nextToken(); + completeWorkflowExecutionFailedEventAttributes.setCause(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + completeWorkflowExecutionFailedEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return completeWorkflowExecutionFailedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static CompleteWorkflowExecutionFailedEventAttributesJsonUnmarshaller instance; + public static CompleteWorkflowExecutionFailedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new CompleteWorkflowExecutionFailedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ContinueAsNewWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ContinueAsNewWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..33e330a1deef --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ContinueAsNewWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Continue As New Workflow Execution Failed Event Attributes JSON Unmarshaller + */ +public class ContinueAsNewWorkflowExecutionFailedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public ContinueAsNewWorkflowExecutionFailedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + ContinueAsNewWorkflowExecutionFailedEventAttributes continueAsNewWorkflowExecutionFailedEventAttributes = new ContinueAsNewWorkflowExecutionFailedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return continueAsNewWorkflowExecutionFailedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("cause", targetDepth)) { + context.nextToken(); + continueAsNewWorkflowExecutionFailedEventAttributes.setCause(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + continueAsNewWorkflowExecutionFailedEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return continueAsNewWorkflowExecutionFailedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static ContinueAsNewWorkflowExecutionFailedEventAttributesJsonUnmarshaller instance; + public static ContinueAsNewWorkflowExecutionFailedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new ContinueAsNewWorkflowExecutionFailedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CountClosedWorkflowExecutionsRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CountClosedWorkflowExecutionsRequestMarshaller.java new file mode 100644 index 000000000000..72bf5cb9a30d --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CountClosedWorkflowExecutionsRequestMarshaller.java @@ -0,0 +1,142 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Count Closed Workflow Executions Request Marshaller + */ +public class CountClosedWorkflowExecutionsRequestMarshaller implements Marshaller, CountClosedWorkflowExecutionsRequest> { + + public Request marshall(CountClosedWorkflowExecutionsRequest countClosedWorkflowExecutionsRequest) { + if (countClosedWorkflowExecutionsRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(countClosedWorkflowExecutionsRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.CountClosedWorkflowExecutions"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (countClosedWorkflowExecutionsRequest.getDomain() != null) { + jsonWriter.key("domain").value(countClosedWorkflowExecutionsRequest.getDomain()); + } + if (countClosedWorkflowExecutionsRequest != null) { + ExecutionTimeFilter executionTimeFilterStartTimeFilter = countClosedWorkflowExecutionsRequest.getStartTimeFilter(); + if (executionTimeFilterStartTimeFilter != null) { + jsonWriter.key("startTimeFilter").object(); + if (executionTimeFilterStartTimeFilter.getOldestDate() != null) { + jsonWriter.key("oldestDate").value(executionTimeFilterStartTimeFilter.getOldestDate()); + } + if (executionTimeFilterStartTimeFilter.getLatestDate() != null) { + jsonWriter.key("latestDate").value(executionTimeFilterStartTimeFilter.getLatestDate()); + } + jsonWriter.endObject(); + } + } + if (countClosedWorkflowExecutionsRequest != null) { + ExecutionTimeFilter executionTimeFilterCloseTimeFilter = countClosedWorkflowExecutionsRequest.getCloseTimeFilter(); + if (executionTimeFilterCloseTimeFilter != null) { + jsonWriter.key("closeTimeFilter").object(); + if (executionTimeFilterCloseTimeFilter.getOldestDate() != null) { + jsonWriter.key("oldestDate").value(executionTimeFilterCloseTimeFilter.getOldestDate()); + } + if (executionTimeFilterCloseTimeFilter.getLatestDate() != null) { + jsonWriter.key("latestDate").value(executionTimeFilterCloseTimeFilter.getLatestDate()); + } + jsonWriter.endObject(); + } + } + if (countClosedWorkflowExecutionsRequest != null) { + WorkflowExecutionFilter workflowExecutionFilterExecutionFilter = countClosedWorkflowExecutionsRequest.getExecutionFilter(); + if (workflowExecutionFilterExecutionFilter != null) { + jsonWriter.key("executionFilter").object(); + if (workflowExecutionFilterExecutionFilter.getWorkflowId() != null) { + jsonWriter.key("workflowId").value(workflowExecutionFilterExecutionFilter.getWorkflowId()); + } + jsonWriter.endObject(); + } + } + if (countClosedWorkflowExecutionsRequest != null) { + WorkflowTypeFilter workflowTypeFilterTypeFilter = countClosedWorkflowExecutionsRequest.getTypeFilter(); + if (workflowTypeFilterTypeFilter != null) { + jsonWriter.key("typeFilter").object(); + if (workflowTypeFilterTypeFilter.getName() != null) { + jsonWriter.key("name").value(workflowTypeFilterTypeFilter.getName()); + } + if (workflowTypeFilterTypeFilter.getVersion() != null) { + jsonWriter.key("version").value(workflowTypeFilterTypeFilter.getVersion()); + } + jsonWriter.endObject(); + } + } + if (countClosedWorkflowExecutionsRequest != null) { + TagFilter tagFilterTagFilter = countClosedWorkflowExecutionsRequest.getTagFilter(); + if (tagFilterTagFilter != null) { + jsonWriter.key("tagFilter").object(); + if (tagFilterTagFilter.getTag() != null) { + jsonWriter.key("tag").value(tagFilterTagFilter.getTag()); + } + jsonWriter.endObject(); + } + } + if (countClosedWorkflowExecutionsRequest != null) { + CloseStatusFilter closeStatusFilterCloseStatusFilter = countClosedWorkflowExecutionsRequest.getCloseStatusFilter(); + if (closeStatusFilterCloseStatusFilter != null) { + jsonWriter.key("closeStatusFilter").object(); + if (closeStatusFilterCloseStatusFilter.getStatus() != null) { + jsonWriter.key("status").value(closeStatusFilterCloseStatusFilter.getStatus()); + } + jsonWriter.endObject(); + } + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CountOpenWorkflowExecutionsRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CountOpenWorkflowExecutionsRequestMarshaller.java new file mode 100644 index 000000000000..953959a344fd --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CountOpenWorkflowExecutionsRequestMarshaller.java @@ -0,0 +1,119 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Count Open Workflow Executions Request Marshaller + */ +public class CountOpenWorkflowExecutionsRequestMarshaller implements Marshaller, CountOpenWorkflowExecutionsRequest> { + + public Request marshall(CountOpenWorkflowExecutionsRequest countOpenWorkflowExecutionsRequest) { + if (countOpenWorkflowExecutionsRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(countOpenWorkflowExecutionsRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.CountOpenWorkflowExecutions"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (countOpenWorkflowExecutionsRequest.getDomain() != null) { + jsonWriter.key("domain").value(countOpenWorkflowExecutionsRequest.getDomain()); + } + if (countOpenWorkflowExecutionsRequest != null) { + ExecutionTimeFilter executionTimeFilterStartTimeFilter = countOpenWorkflowExecutionsRequest.getStartTimeFilter(); + if (executionTimeFilterStartTimeFilter != null) { + jsonWriter.key("startTimeFilter").object(); + if (executionTimeFilterStartTimeFilter.getOldestDate() != null) { + jsonWriter.key("oldestDate").value(executionTimeFilterStartTimeFilter.getOldestDate()); + } + if (executionTimeFilterStartTimeFilter.getLatestDate() != null) { + jsonWriter.key("latestDate").value(executionTimeFilterStartTimeFilter.getLatestDate()); + } + jsonWriter.endObject(); + } + } + if (countOpenWorkflowExecutionsRequest != null) { + WorkflowTypeFilter workflowTypeFilterTypeFilter = countOpenWorkflowExecutionsRequest.getTypeFilter(); + if (workflowTypeFilterTypeFilter != null) { + jsonWriter.key("typeFilter").object(); + if (workflowTypeFilterTypeFilter.getName() != null) { + jsonWriter.key("name").value(workflowTypeFilterTypeFilter.getName()); + } + if (workflowTypeFilterTypeFilter.getVersion() != null) { + jsonWriter.key("version").value(workflowTypeFilterTypeFilter.getVersion()); + } + jsonWriter.endObject(); + } + } + if (countOpenWorkflowExecutionsRequest != null) { + TagFilter tagFilterTagFilter = countOpenWorkflowExecutionsRequest.getTagFilter(); + if (tagFilterTagFilter != null) { + jsonWriter.key("tagFilter").object(); + if (tagFilterTagFilter.getTag() != null) { + jsonWriter.key("tag").value(tagFilterTagFilter.getTag()); + } + jsonWriter.endObject(); + } + } + if (countOpenWorkflowExecutionsRequest != null) { + WorkflowExecutionFilter workflowExecutionFilterExecutionFilter = countOpenWorkflowExecutionsRequest.getExecutionFilter(); + if (workflowExecutionFilterExecutionFilter != null) { + jsonWriter.key("executionFilter").object(); + if (workflowExecutionFilterExecutionFilter.getWorkflowId() != null) { + jsonWriter.key("workflowId").value(workflowExecutionFilterExecutionFilter.getWorkflowId()); + } + jsonWriter.endObject(); + } + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CountPendingActivityTasksRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CountPendingActivityTasksRequestMarshaller.java new file mode 100644 index 000000000000..e6e720c083c1 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CountPendingActivityTasksRequestMarshaller.java @@ -0,0 +1,83 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Count Pending Activity Tasks Request Marshaller + */ +public class CountPendingActivityTasksRequestMarshaller implements Marshaller, CountPendingActivityTasksRequest> { + + public Request marshall(CountPendingActivityTasksRequest countPendingActivityTasksRequest) { + if (countPendingActivityTasksRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(countPendingActivityTasksRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.CountPendingActivityTasks"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (countPendingActivityTasksRequest.getDomain() != null) { + jsonWriter.key("domain").value(countPendingActivityTasksRequest.getDomain()); + } + if (countPendingActivityTasksRequest != null) { + TaskList taskListTaskList = countPendingActivityTasksRequest.getTaskList(); + if (taskListTaskList != null) { + jsonWriter.key("taskList").object(); + if (taskListTaskList.getName() != null) { + jsonWriter.key("name").value(taskListTaskList.getName()); + } + jsonWriter.endObject(); + } + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CountPendingDecisionTasksRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CountPendingDecisionTasksRequestMarshaller.java new file mode 100644 index 000000000000..3dcbc69ab569 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/CountPendingDecisionTasksRequestMarshaller.java @@ -0,0 +1,83 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Count Pending Decision Tasks Request Marshaller + */ +public class CountPendingDecisionTasksRequestMarshaller implements Marshaller, CountPendingDecisionTasksRequest> { + + public Request marshall(CountPendingDecisionTasksRequest countPendingDecisionTasksRequest) { + if (countPendingDecisionTasksRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(countPendingDecisionTasksRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.CountPendingDecisionTasks"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (countPendingDecisionTasksRequest.getDomain() != null) { + jsonWriter.key("domain").value(countPendingDecisionTasksRequest.getDomain()); + } + if (countPendingDecisionTasksRequest != null) { + TaskList taskListTaskList = countPendingDecisionTasksRequest.getTaskList(); + if (taskListTaskList != null) { + jsonWriter.key("taskList").object(); + if (taskListTaskList.getName() != null) { + jsonWriter.key("name").value(taskListTaskList.getName()); + } + jsonWriter.endObject(); + } + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DecisionTaskCompletedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DecisionTaskCompletedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..d0c3e24c1bfe --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DecisionTaskCompletedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Decision Task Completed Event Attributes JSON Unmarshaller + */ +public class DecisionTaskCompletedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public DecisionTaskCompletedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + DecisionTaskCompletedEventAttributes decisionTaskCompletedEventAttributes = new DecisionTaskCompletedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return decisionTaskCompletedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("executionContext", targetDepth)) { + context.nextToken(); + decisionTaskCompletedEventAttributes.setExecutionContext(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("scheduledEventId", targetDepth)) { + context.nextToken(); + decisionTaskCompletedEventAttributes.setScheduledEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startedEventId", targetDepth)) { + context.nextToken(); + decisionTaskCompletedEventAttributes.setStartedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return decisionTaskCompletedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static DecisionTaskCompletedEventAttributesJsonUnmarshaller instance; + public static DecisionTaskCompletedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new DecisionTaskCompletedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DecisionTaskJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DecisionTaskJsonUnmarshaller.java new file mode 100644 index 000000000000..d8206a639942 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DecisionTaskJsonUnmarshaller.java @@ -0,0 +1,89 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Decision Task JSON Unmarshaller + */ +public class DecisionTaskJsonUnmarshaller implements Unmarshaller { + + + + public DecisionTask unmarshall(JsonUnmarshallerContext context) throws Exception { + DecisionTask decisionTask = new DecisionTask(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return decisionTask; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("taskToken", targetDepth)) { + context.nextToken(); + decisionTask.setTaskToken(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startedEventId", targetDepth)) { + context.nextToken(); + decisionTask.setStartedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowExecution", targetDepth)) { + context.nextToken(); + decisionTask.setWorkflowExecution(WorkflowExecutionJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowType", targetDepth)) { + context.nextToken(); + decisionTask.setWorkflowType(WorkflowTypeJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("events", targetDepth)) { + decisionTask.setEvents(new ListUnmarshaller(HistoryEventJsonUnmarshaller.getInstance()).unmarshall(context)); + } + if (context.testExpression("nextPageToken", targetDepth)) { + context.nextToken(); + decisionTask.setNextPageToken(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("previousStartedEventId", targetDepth)) { + context.nextToken(); + decisionTask.setPreviousStartedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return decisionTask; + } + } + token = context.nextToken(); + } + } + + private static DecisionTaskJsonUnmarshaller instance; + public static DecisionTaskJsonUnmarshaller getInstance() { + if (instance == null) instance = new DecisionTaskJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DecisionTaskScheduledEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DecisionTaskScheduledEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..5e9fa4d7e229 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DecisionTaskScheduledEventAttributesJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Decision Task Scheduled Event Attributes JSON Unmarshaller + */ +public class DecisionTaskScheduledEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public DecisionTaskScheduledEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + DecisionTaskScheduledEventAttributes decisionTaskScheduledEventAttributes = new DecisionTaskScheduledEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return decisionTaskScheduledEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("taskList", targetDepth)) { + context.nextToken(); + decisionTaskScheduledEventAttributes.setTaskList(TaskListJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startToCloseTimeout", targetDepth)) { + context.nextToken(); + decisionTaskScheduledEventAttributes.setStartToCloseTimeout(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return decisionTaskScheduledEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static DecisionTaskScheduledEventAttributesJsonUnmarshaller instance; + public static DecisionTaskScheduledEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new DecisionTaskScheduledEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DecisionTaskStartedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DecisionTaskStartedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..25ee0d916c6c --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DecisionTaskStartedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Decision Task Started Event Attributes JSON Unmarshaller + */ +public class DecisionTaskStartedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public DecisionTaskStartedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + DecisionTaskStartedEventAttributes decisionTaskStartedEventAttributes = new DecisionTaskStartedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return decisionTaskStartedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("identity", targetDepth)) { + context.nextToken(); + decisionTaskStartedEventAttributes.setIdentity(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("scheduledEventId", targetDepth)) { + context.nextToken(); + decisionTaskStartedEventAttributes.setScheduledEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return decisionTaskStartedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static DecisionTaskStartedEventAttributesJsonUnmarshaller instance; + public static DecisionTaskStartedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new DecisionTaskStartedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DecisionTaskTimedOutEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DecisionTaskTimedOutEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..9243b7069631 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DecisionTaskTimedOutEventAttributesJsonUnmarshaller.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Decision Task Timed Out Event Attributes JSON Unmarshaller + */ +public class DecisionTaskTimedOutEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public DecisionTaskTimedOutEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + DecisionTaskTimedOutEventAttributes decisionTaskTimedOutEventAttributes = new DecisionTaskTimedOutEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return decisionTaskTimedOutEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("timeoutType", targetDepth)) { + context.nextToken(); + decisionTaskTimedOutEventAttributes.setTimeoutType(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("scheduledEventId", targetDepth)) { + context.nextToken(); + decisionTaskTimedOutEventAttributes.setScheduledEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startedEventId", targetDepth)) { + context.nextToken(); + decisionTaskTimedOutEventAttributes.setStartedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return decisionTaskTimedOutEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static DecisionTaskTimedOutEventAttributesJsonUnmarshaller instance; + public static DecisionTaskTimedOutEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new DecisionTaskTimedOutEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DefaultUndefinedExceptionUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DefaultUndefinedExceptionUnmarshaller.java new file mode 100644 index 000000000000..52b8ae11892a --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DefaultUndefinedExceptionUnmarshaller.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + +import com.amazonaws.AmazonServiceException; +import com.amazonaws.transform.JsonErrorUnmarshaller; +import com.amazonaws.util.json.JSONObject; + +import com.amazonaws.services.simpleworkflow.model.DefaultUndefinedException; + +public class DefaultUndefinedExceptionUnmarshaller extends JsonErrorUnmarshaller { + + public DefaultUndefinedExceptionUnmarshaller() { + super(DefaultUndefinedException.class); + } + + public AmazonServiceException unmarshall(JSONObject json) throws Exception { + // Bail out if this isn't the right error code that this + // marshaller understands. + String errorCode = parseErrorCode(json); + if (errorCode == null || !errorCode.equals("DefaultUndefinedFault")) + return null; + + DefaultUndefinedException e = (DefaultUndefinedException)super.unmarshall(json); + + + + return e; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DeprecateActivityTypeRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DeprecateActivityTypeRequestMarshaller.java new file mode 100644 index 000000000000..bbdfe9207693 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DeprecateActivityTypeRequestMarshaller.java @@ -0,0 +1,86 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Deprecate Activity Type Request Marshaller + */ +public class DeprecateActivityTypeRequestMarshaller implements Marshaller, DeprecateActivityTypeRequest> { + + public Request marshall(DeprecateActivityTypeRequest deprecateActivityTypeRequest) { + if (deprecateActivityTypeRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(deprecateActivityTypeRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.DeprecateActivityType"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (deprecateActivityTypeRequest.getDomain() != null) { + jsonWriter.key("domain").value(deprecateActivityTypeRequest.getDomain()); + } + if (deprecateActivityTypeRequest != null) { + ActivityType activityTypeActivityType = deprecateActivityTypeRequest.getActivityType(); + if (activityTypeActivityType != null) { + jsonWriter.key("activityType").object(); + if (activityTypeActivityType.getName() != null) { + jsonWriter.key("name").value(activityTypeActivityType.getName()); + } + if (activityTypeActivityType.getVersion() != null) { + jsonWriter.key("version").value(activityTypeActivityType.getVersion()); + } + jsonWriter.endObject(); + } + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DeprecateDomainRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DeprecateDomainRequestMarshaller.java new file mode 100644 index 000000000000..2e864f946f7b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DeprecateDomainRequestMarshaller.java @@ -0,0 +1,73 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Deprecate Domain Request Marshaller + */ +public class DeprecateDomainRequestMarshaller implements Marshaller, DeprecateDomainRequest> { + + public Request marshall(DeprecateDomainRequest deprecateDomainRequest) { + if (deprecateDomainRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(deprecateDomainRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.DeprecateDomain"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (deprecateDomainRequest.getName() != null) { + jsonWriter.key("name").value(deprecateDomainRequest.getName()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DeprecateWorkflowTypeRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DeprecateWorkflowTypeRequestMarshaller.java new file mode 100644 index 000000000000..8c1694c168b8 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DeprecateWorkflowTypeRequestMarshaller.java @@ -0,0 +1,86 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Deprecate Workflow Type Request Marshaller + */ +public class DeprecateWorkflowTypeRequestMarshaller implements Marshaller, DeprecateWorkflowTypeRequest> { + + public Request marshall(DeprecateWorkflowTypeRequest deprecateWorkflowTypeRequest) { + if (deprecateWorkflowTypeRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(deprecateWorkflowTypeRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.DeprecateWorkflowType"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (deprecateWorkflowTypeRequest.getDomain() != null) { + jsonWriter.key("domain").value(deprecateWorkflowTypeRequest.getDomain()); + } + if (deprecateWorkflowTypeRequest != null) { + WorkflowType workflowTypeWorkflowType = deprecateWorkflowTypeRequest.getWorkflowType(); + if (workflowTypeWorkflowType != null) { + jsonWriter.key("workflowType").object(); + if (workflowTypeWorkflowType.getName() != null) { + jsonWriter.key("name").value(workflowTypeWorkflowType.getName()); + } + if (workflowTypeWorkflowType.getVersion() != null) { + jsonWriter.key("version").value(workflowTypeWorkflowType.getVersion()); + } + jsonWriter.endObject(); + } + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DescribeActivityTypeRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DescribeActivityTypeRequestMarshaller.java new file mode 100644 index 000000000000..1a5b46be7de7 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DescribeActivityTypeRequestMarshaller.java @@ -0,0 +1,86 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Describe Activity Type Request Marshaller + */ +public class DescribeActivityTypeRequestMarshaller implements Marshaller, DescribeActivityTypeRequest> { + + public Request marshall(DescribeActivityTypeRequest describeActivityTypeRequest) { + if (describeActivityTypeRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(describeActivityTypeRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.DescribeActivityType"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (describeActivityTypeRequest.getDomain() != null) { + jsonWriter.key("domain").value(describeActivityTypeRequest.getDomain()); + } + if (describeActivityTypeRequest != null) { + ActivityType activityTypeActivityType = describeActivityTypeRequest.getActivityType(); + if (activityTypeActivityType != null) { + jsonWriter.key("activityType").object(); + if (activityTypeActivityType.getName() != null) { + jsonWriter.key("name").value(activityTypeActivityType.getName()); + } + if (activityTypeActivityType.getVersion() != null) { + jsonWriter.key("version").value(activityTypeActivityType.getVersion()); + } + jsonWriter.endObject(); + } + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DescribeDomainRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DescribeDomainRequestMarshaller.java new file mode 100644 index 000000000000..9427e14b8188 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DescribeDomainRequestMarshaller.java @@ -0,0 +1,73 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Describe Domain Request Marshaller + */ +public class DescribeDomainRequestMarshaller implements Marshaller, DescribeDomainRequest> { + + public Request marshall(DescribeDomainRequest describeDomainRequest) { + if (describeDomainRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(describeDomainRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.DescribeDomain"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (describeDomainRequest.getName() != null) { + jsonWriter.key("name").value(describeDomainRequest.getName()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DescribeWorkflowExecutionRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DescribeWorkflowExecutionRequestMarshaller.java new file mode 100644 index 000000000000..73f2d974daa8 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DescribeWorkflowExecutionRequestMarshaller.java @@ -0,0 +1,86 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Describe Workflow Execution Request Marshaller + */ +public class DescribeWorkflowExecutionRequestMarshaller implements Marshaller, DescribeWorkflowExecutionRequest> { + + public Request marshall(DescribeWorkflowExecutionRequest describeWorkflowExecutionRequest) { + if (describeWorkflowExecutionRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(describeWorkflowExecutionRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.DescribeWorkflowExecution"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (describeWorkflowExecutionRequest.getDomain() != null) { + jsonWriter.key("domain").value(describeWorkflowExecutionRequest.getDomain()); + } + if (describeWorkflowExecutionRequest != null) { + WorkflowExecution workflowExecutionExecution = describeWorkflowExecutionRequest.getExecution(); + if (workflowExecutionExecution != null) { + jsonWriter.key("execution").object(); + if (workflowExecutionExecution.getWorkflowId() != null) { + jsonWriter.key("workflowId").value(workflowExecutionExecution.getWorkflowId()); + } + if (workflowExecutionExecution.getRunId() != null) { + jsonWriter.key("runId").value(workflowExecutionExecution.getRunId()); + } + jsonWriter.endObject(); + } + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DescribeWorkflowTypeRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DescribeWorkflowTypeRequestMarshaller.java new file mode 100644 index 000000000000..93add4fed644 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DescribeWorkflowTypeRequestMarshaller.java @@ -0,0 +1,86 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Describe Workflow Type Request Marshaller + */ +public class DescribeWorkflowTypeRequestMarshaller implements Marshaller, DescribeWorkflowTypeRequest> { + + public Request marshall(DescribeWorkflowTypeRequest describeWorkflowTypeRequest) { + if (describeWorkflowTypeRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(describeWorkflowTypeRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.DescribeWorkflowType"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (describeWorkflowTypeRequest.getDomain() != null) { + jsonWriter.key("domain").value(describeWorkflowTypeRequest.getDomain()); + } + if (describeWorkflowTypeRequest != null) { + WorkflowType workflowTypeWorkflowType = describeWorkflowTypeRequest.getWorkflowType(); + if (workflowTypeWorkflowType != null) { + jsonWriter.key("workflowType").object(); + if (workflowTypeWorkflowType.getName() != null) { + jsonWriter.key("name").value(workflowTypeWorkflowType.getName()); + } + if (workflowTypeWorkflowType.getVersion() != null) { + jsonWriter.key("version").value(workflowTypeWorkflowType.getVersion()); + } + jsonWriter.endObject(); + } + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainAlreadyExistsExceptionUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainAlreadyExistsExceptionUnmarshaller.java new file mode 100644 index 000000000000..2d6bf500eb2e --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainAlreadyExistsExceptionUnmarshaller.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + +import com.amazonaws.AmazonServiceException; +import com.amazonaws.transform.JsonErrorUnmarshaller; +import com.amazonaws.util.json.JSONObject; + +import com.amazonaws.services.simpleworkflow.model.DomainAlreadyExistsException; + +public class DomainAlreadyExistsExceptionUnmarshaller extends JsonErrorUnmarshaller { + + public DomainAlreadyExistsExceptionUnmarshaller() { + super(DomainAlreadyExistsException.class); + } + + public AmazonServiceException unmarshall(JSONObject json) throws Exception { + // Bail out if this isn't the right error code that this + // marshaller understands. + String errorCode = parseErrorCode(json); + if (errorCode == null || !errorCode.equals("DomainAlreadyExistsFault")) + return null; + + DomainAlreadyExistsException e = (DomainAlreadyExistsException)super.unmarshall(json); + + + + return e; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainConfigurationJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainConfigurationJsonUnmarshaller.java new file mode 100644 index 000000000000..4ca6e1fdc120 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainConfigurationJsonUnmarshaller.java @@ -0,0 +1,66 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Domain Configuration JSON Unmarshaller + */ +public class DomainConfigurationJsonUnmarshaller implements Unmarshaller { + + + + public DomainConfiguration unmarshall(JsonUnmarshallerContext context) throws Exception { + DomainConfiguration domainConfiguration = new DomainConfiguration(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return domainConfiguration; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("workflowExecutionRetentionPeriodInDays", targetDepth)) { + context.nextToken(); + domainConfiguration.setWorkflowExecutionRetentionPeriodInDays(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return domainConfiguration; + } + } + token = context.nextToken(); + } + } + + private static DomainConfigurationJsonUnmarshaller instance; + public static DomainConfigurationJsonUnmarshaller getInstance() { + if (instance == null) instance = new DomainConfigurationJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainDeprecatedExceptionUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainDeprecatedExceptionUnmarshaller.java new file mode 100644 index 000000000000..fd36474598f9 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainDeprecatedExceptionUnmarshaller.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + +import com.amazonaws.AmazonServiceException; +import com.amazonaws.transform.JsonErrorUnmarshaller; +import com.amazonaws.util.json.JSONObject; + +import com.amazonaws.services.simpleworkflow.model.DomainDeprecatedException; + +public class DomainDeprecatedExceptionUnmarshaller extends JsonErrorUnmarshaller { + + public DomainDeprecatedExceptionUnmarshaller() { + super(DomainDeprecatedException.class); + } + + public AmazonServiceException unmarshall(JSONObject json) throws Exception { + // Bail out if this isn't the right error code that this + // marshaller understands. + String errorCode = parseErrorCode(json); + if (errorCode == null || !errorCode.equals("DomainDeprecatedFault")) + return null; + + DomainDeprecatedException e = (DomainDeprecatedException)super.unmarshall(json); + + + + return e; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainDetailJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainDetailJsonUnmarshaller.java new file mode 100644 index 000000000000..b80fb2958c9b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainDetailJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Domain Detail JSON Unmarshaller + */ +public class DomainDetailJsonUnmarshaller implements Unmarshaller { + + + + public DomainDetail unmarshall(JsonUnmarshallerContext context) throws Exception { + DomainDetail domainDetail = new DomainDetail(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return domainDetail; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("domainInfo", targetDepth)) { + context.nextToken(); + domainDetail.setDomainInfo(DomainInfoJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("configuration", targetDepth)) { + context.nextToken(); + domainDetail.setConfiguration(DomainConfigurationJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return domainDetail; + } + } + token = context.nextToken(); + } + } + + private static DomainDetailJsonUnmarshaller instance; + public static DomainDetailJsonUnmarshaller getInstance() { + if (instance == null) instance = new DomainDetailJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainInfoJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainInfoJsonUnmarshaller.java new file mode 100644 index 000000000000..bcd210949663 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainInfoJsonUnmarshaller.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Domain Info JSON Unmarshaller + */ +public class DomainInfoJsonUnmarshaller implements Unmarshaller { + + + + public DomainInfo unmarshall(JsonUnmarshallerContext context) throws Exception { + DomainInfo domainInfo = new DomainInfo(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return domainInfo; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("name", targetDepth)) { + context.nextToken(); + domainInfo.setName(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("status", targetDepth)) { + context.nextToken(); + domainInfo.setStatus(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("description", targetDepth)) { + context.nextToken(); + domainInfo.setDescription(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return domainInfo; + } + } + token = context.nextToken(); + } + } + + private static DomainInfoJsonUnmarshaller instance; + public static DomainInfoJsonUnmarshaller getInstance() { + if (instance == null) instance = new DomainInfoJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainInfosJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainInfosJsonUnmarshaller.java new file mode 100644 index 000000000000..2b9dc45b7590 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/DomainInfosJsonUnmarshaller.java @@ -0,0 +1,69 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Domain Infos JSON Unmarshaller + */ +public class DomainInfosJsonUnmarshaller implements Unmarshaller { + + + + public DomainInfos unmarshall(JsonUnmarshallerContext context) throws Exception { + DomainInfos domainInfos = new DomainInfos(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return domainInfos; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("domainInfos", targetDepth)) { + domainInfos.setDomainInfos(new ListUnmarshaller(DomainInfoJsonUnmarshaller.getInstance()).unmarshall(context)); + } + if (context.testExpression("nextPageToken", targetDepth)) { + context.nextToken(); + domainInfos.setNextPageToken(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return domainInfos; + } + } + token = context.nextToken(); + } + } + + private static DomainInfosJsonUnmarshaller instance; + public static DomainInfosJsonUnmarshaller getInstance() { + if (instance == null) instance = new DomainInfosJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ExternalWorkflowExecutionCancelRequestedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ExternalWorkflowExecutionCancelRequestedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..2c76b35d3753 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ExternalWorkflowExecutionCancelRequestedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * External Workflow Execution Cancel Requested Event Attributes JSON Unmarshaller + */ +public class ExternalWorkflowExecutionCancelRequestedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public ExternalWorkflowExecutionCancelRequestedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + ExternalWorkflowExecutionCancelRequestedEventAttributes externalWorkflowExecutionCancelRequestedEventAttributes = new ExternalWorkflowExecutionCancelRequestedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return externalWorkflowExecutionCancelRequestedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("workflowExecution", targetDepth)) { + context.nextToken(); + externalWorkflowExecutionCancelRequestedEventAttributes.setWorkflowExecution(WorkflowExecutionJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("initiatedEventId", targetDepth)) { + context.nextToken(); + externalWorkflowExecutionCancelRequestedEventAttributes.setInitiatedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return externalWorkflowExecutionCancelRequestedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static ExternalWorkflowExecutionCancelRequestedEventAttributesJsonUnmarshaller instance; + public static ExternalWorkflowExecutionCancelRequestedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new ExternalWorkflowExecutionCancelRequestedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ExternalWorkflowExecutionSignaledEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ExternalWorkflowExecutionSignaledEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..752a9418bd66 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ExternalWorkflowExecutionSignaledEventAttributesJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * External Workflow Execution Signaled Event Attributes JSON Unmarshaller + */ +public class ExternalWorkflowExecutionSignaledEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public ExternalWorkflowExecutionSignaledEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + ExternalWorkflowExecutionSignaledEventAttributes externalWorkflowExecutionSignaledEventAttributes = new ExternalWorkflowExecutionSignaledEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return externalWorkflowExecutionSignaledEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("workflowExecution", targetDepth)) { + context.nextToken(); + externalWorkflowExecutionSignaledEventAttributes.setWorkflowExecution(WorkflowExecutionJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("initiatedEventId", targetDepth)) { + context.nextToken(); + externalWorkflowExecutionSignaledEventAttributes.setInitiatedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return externalWorkflowExecutionSignaledEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static ExternalWorkflowExecutionSignaledEventAttributesJsonUnmarshaller instance; + public static ExternalWorkflowExecutionSignaledEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new ExternalWorkflowExecutionSignaledEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/FailWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/FailWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..d5aa196874a2 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/FailWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Fail Workflow Execution Failed Event Attributes JSON Unmarshaller + */ +public class FailWorkflowExecutionFailedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public FailWorkflowExecutionFailedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + FailWorkflowExecutionFailedEventAttributes failWorkflowExecutionFailedEventAttributes = new FailWorkflowExecutionFailedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return failWorkflowExecutionFailedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("cause", targetDepth)) { + context.nextToken(); + failWorkflowExecutionFailedEventAttributes.setCause(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + failWorkflowExecutionFailedEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return failWorkflowExecutionFailedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static FailWorkflowExecutionFailedEventAttributesJsonUnmarshaller instance; + public static FailWorkflowExecutionFailedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new FailWorkflowExecutionFailedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/GetWorkflowExecutionHistoryRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/GetWorkflowExecutionHistoryRequestMarshaller.java new file mode 100644 index 000000000000..55f5913cb438 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/GetWorkflowExecutionHistoryRequestMarshaller.java @@ -0,0 +1,95 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Get Workflow Execution History Request Marshaller + */ +public class GetWorkflowExecutionHistoryRequestMarshaller implements Marshaller, GetWorkflowExecutionHistoryRequest> { + + public Request marshall(GetWorkflowExecutionHistoryRequest getWorkflowExecutionHistoryRequest) { + if (getWorkflowExecutionHistoryRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(getWorkflowExecutionHistoryRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.GetWorkflowExecutionHistory"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (getWorkflowExecutionHistoryRequest.getDomain() != null) { + jsonWriter.key("domain").value(getWorkflowExecutionHistoryRequest.getDomain()); + } + if (getWorkflowExecutionHistoryRequest != null) { + WorkflowExecution workflowExecutionExecution = getWorkflowExecutionHistoryRequest.getExecution(); + if (workflowExecutionExecution != null) { + jsonWriter.key("execution").object(); + if (workflowExecutionExecution.getWorkflowId() != null) { + jsonWriter.key("workflowId").value(workflowExecutionExecution.getWorkflowId()); + } + if (workflowExecutionExecution.getRunId() != null) { + jsonWriter.key("runId").value(workflowExecutionExecution.getRunId()); + } + jsonWriter.endObject(); + } + } + if (getWorkflowExecutionHistoryRequest.getNextPageToken() != null) { + jsonWriter.key("nextPageToken").value(getWorkflowExecutionHistoryRequest.getNextPageToken()); + } + if (getWorkflowExecutionHistoryRequest.getMaximumPageSize() != null) { + jsonWriter.key("maximumPageSize").value(getWorkflowExecutionHistoryRequest.getMaximumPageSize()); + } + if (getWorkflowExecutionHistoryRequest.isReverseOrder() != null) { + jsonWriter.key("reverseOrder").value(getWorkflowExecutionHistoryRequest.isReverseOrder()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/HistoryEventJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/HistoryEventJsonUnmarshaller.java new file mode 100644 index 000000000000..f602064e9872 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/HistoryEventJsonUnmarshaller.java @@ -0,0 +1,258 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * History Event JSON Unmarshaller + */ +public class HistoryEventJsonUnmarshaller implements Unmarshaller { + + + + public HistoryEvent unmarshall(JsonUnmarshallerContext context) throws Exception { + HistoryEvent historyEvent = new HistoryEvent(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return historyEvent; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("eventTimestamp", targetDepth)) { + context.nextToken(); + historyEvent.setEventTimestamp(DateJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("eventType", targetDepth)) { + context.nextToken(); + historyEvent.setEventType(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("eventId", targetDepth)) { + context.nextToken(); + historyEvent.setEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowExecutionStartedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setWorkflowExecutionStartedEventAttributes(WorkflowExecutionStartedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowExecutionCompletedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setWorkflowExecutionCompletedEventAttributes(WorkflowExecutionCompletedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("completeWorkflowExecutionFailedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setCompleteWorkflowExecutionFailedEventAttributes(CompleteWorkflowExecutionFailedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowExecutionFailedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setWorkflowExecutionFailedEventAttributes(WorkflowExecutionFailedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("failWorkflowExecutionFailedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setFailWorkflowExecutionFailedEventAttributes(FailWorkflowExecutionFailedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowExecutionTimedOutEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setWorkflowExecutionTimedOutEventAttributes(WorkflowExecutionTimedOutEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowExecutionCanceledEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setWorkflowExecutionCanceledEventAttributes(WorkflowExecutionCanceledEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("cancelWorkflowExecutionFailedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setCancelWorkflowExecutionFailedEventAttributes(CancelWorkflowExecutionFailedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowExecutionContinuedAsNewEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setWorkflowExecutionContinuedAsNewEventAttributes(WorkflowExecutionContinuedAsNewEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("continueAsNewWorkflowExecutionFailedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setContinueAsNewWorkflowExecutionFailedEventAttributes(ContinueAsNewWorkflowExecutionFailedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowExecutionTerminatedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setWorkflowExecutionTerminatedEventAttributes(WorkflowExecutionTerminatedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowExecutionCancelRequestedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setWorkflowExecutionCancelRequestedEventAttributes(WorkflowExecutionCancelRequestedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskScheduledEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setDecisionTaskScheduledEventAttributes(DecisionTaskScheduledEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskStartedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setDecisionTaskStartedEventAttributes(DecisionTaskStartedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setDecisionTaskCompletedEventAttributes(DecisionTaskCompletedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskTimedOutEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setDecisionTaskTimedOutEventAttributes(DecisionTaskTimedOutEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("activityTaskScheduledEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setActivityTaskScheduledEventAttributes(ActivityTaskScheduledEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("activityTaskStartedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setActivityTaskStartedEventAttributes(ActivityTaskStartedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("activityTaskCompletedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setActivityTaskCompletedEventAttributes(ActivityTaskCompletedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("activityTaskFailedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setActivityTaskFailedEventAttributes(ActivityTaskFailedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("activityTaskTimedOutEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setActivityTaskTimedOutEventAttributes(ActivityTaskTimedOutEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("activityTaskCanceledEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setActivityTaskCanceledEventAttributes(ActivityTaskCanceledEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("activityTaskCancelRequestedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setActivityTaskCancelRequestedEventAttributes(ActivityTaskCancelRequestedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowExecutionSignaledEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setWorkflowExecutionSignaledEventAttributes(WorkflowExecutionSignaledEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("markerRecordedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setMarkerRecordedEventAttributes(MarkerRecordedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("timerStartedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setTimerStartedEventAttributes(TimerStartedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("timerFiredEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setTimerFiredEventAttributes(TimerFiredEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("timerCanceledEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setTimerCanceledEventAttributes(TimerCanceledEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startChildWorkflowExecutionInitiatedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setStartChildWorkflowExecutionInitiatedEventAttributes(StartChildWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("childWorkflowExecutionStartedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setChildWorkflowExecutionStartedEventAttributes(ChildWorkflowExecutionStartedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("childWorkflowExecutionCompletedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setChildWorkflowExecutionCompletedEventAttributes(ChildWorkflowExecutionCompletedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("childWorkflowExecutionFailedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setChildWorkflowExecutionFailedEventAttributes(ChildWorkflowExecutionFailedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("childWorkflowExecutionTimedOutEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setChildWorkflowExecutionTimedOutEventAttributes(ChildWorkflowExecutionTimedOutEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("childWorkflowExecutionCanceledEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setChildWorkflowExecutionCanceledEventAttributes(ChildWorkflowExecutionCanceledEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("childWorkflowExecutionTerminatedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setChildWorkflowExecutionTerminatedEventAttributes(ChildWorkflowExecutionTerminatedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("signalExternalWorkflowExecutionInitiatedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setSignalExternalWorkflowExecutionInitiatedEventAttributes(SignalExternalWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("externalWorkflowExecutionSignaledEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setExternalWorkflowExecutionSignaledEventAttributes(ExternalWorkflowExecutionSignaledEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("signalExternalWorkflowExecutionFailedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setSignalExternalWorkflowExecutionFailedEventAttributes(SignalExternalWorkflowExecutionFailedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("externalWorkflowExecutionCancelRequestedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setExternalWorkflowExecutionCancelRequestedEventAttributes(ExternalWorkflowExecutionCancelRequestedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("requestCancelExternalWorkflowExecutionInitiatedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setRequestCancelExternalWorkflowExecutionInitiatedEventAttributes(RequestCancelExternalWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("requestCancelExternalWorkflowExecutionFailedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setRequestCancelExternalWorkflowExecutionFailedEventAttributes(RequestCancelExternalWorkflowExecutionFailedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("scheduleActivityTaskFailedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setScheduleActivityTaskFailedEventAttributes(ScheduleActivityTaskFailedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("requestCancelActivityTaskFailedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setRequestCancelActivityTaskFailedEventAttributes(RequestCancelActivityTaskFailedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startTimerFailedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setStartTimerFailedEventAttributes(StartTimerFailedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("cancelTimerFailedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setCancelTimerFailedEventAttributes(CancelTimerFailedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startChildWorkflowExecutionFailedEventAttributes", targetDepth)) { + context.nextToken(); + historyEvent.setStartChildWorkflowExecutionFailedEventAttributes(StartChildWorkflowExecutionFailedEventAttributesJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return historyEvent; + } + } + token = context.nextToken(); + } + } + + private static HistoryEventJsonUnmarshaller instance; + public static HistoryEventJsonUnmarshaller getInstance() { + if (instance == null) instance = new HistoryEventJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/HistoryJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/HistoryJsonUnmarshaller.java new file mode 100644 index 000000000000..1c87ee013fb4 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/HistoryJsonUnmarshaller.java @@ -0,0 +1,69 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * History JSON Unmarshaller + */ +public class HistoryJsonUnmarshaller implements Unmarshaller { + + + + public History unmarshall(JsonUnmarshallerContext context) throws Exception { + History history = new History(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return history; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("events", targetDepth)) { + history.setEvents(new ListUnmarshaller(HistoryEventJsonUnmarshaller.getInstance()).unmarshall(context)); + } + if (context.testExpression("nextPageToken", targetDepth)) { + context.nextToken(); + history.setNextPageToken(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return history; + } + } + token = context.nextToken(); + } + } + + private static HistoryJsonUnmarshaller instance; + public static HistoryJsonUnmarshaller getInstance() { + if (instance == null) instance = new HistoryJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/LimitExceededExceptionUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/LimitExceededExceptionUnmarshaller.java new file mode 100644 index 000000000000..ab53ba2e7d02 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/LimitExceededExceptionUnmarshaller.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + +import com.amazonaws.AmazonServiceException; +import com.amazonaws.transform.JsonErrorUnmarshaller; +import com.amazonaws.util.json.JSONObject; + +import com.amazonaws.services.simpleworkflow.model.LimitExceededException; + +public class LimitExceededExceptionUnmarshaller extends JsonErrorUnmarshaller { + + public LimitExceededExceptionUnmarshaller() { + super(LimitExceededException.class); + } + + public AmazonServiceException unmarshall(JSONObject json) throws Exception { + // Bail out if this isn't the right error code that this + // marshaller understands. + String errorCode = parseErrorCode(json); + if (errorCode == null || !errorCode.equals("LimitExceededFault")) + return null; + + LimitExceededException e = (LimitExceededException)super.unmarshall(json); + + + + return e; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ListActivityTypesRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ListActivityTypesRequestMarshaller.java new file mode 100644 index 000000000000..a7f6566313b3 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ListActivityTypesRequestMarshaller.java @@ -0,0 +1,88 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * List Activity Types Request Marshaller + */ +public class ListActivityTypesRequestMarshaller implements Marshaller, ListActivityTypesRequest> { + + public Request marshall(ListActivityTypesRequest listActivityTypesRequest) { + if (listActivityTypesRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(listActivityTypesRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.ListActivityTypes"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (listActivityTypesRequest.getDomain() != null) { + jsonWriter.key("domain").value(listActivityTypesRequest.getDomain()); + } + if (listActivityTypesRequest.getName() != null) { + jsonWriter.key("name").value(listActivityTypesRequest.getName()); + } + if (listActivityTypesRequest.getRegistrationStatus() != null) { + jsonWriter.key("registrationStatus").value(listActivityTypesRequest.getRegistrationStatus()); + } + if (listActivityTypesRequest.getNextPageToken() != null) { + jsonWriter.key("nextPageToken").value(listActivityTypesRequest.getNextPageToken()); + } + if (listActivityTypesRequest.getMaximumPageSize() != null) { + jsonWriter.key("maximumPageSize").value(listActivityTypesRequest.getMaximumPageSize()); + } + if (listActivityTypesRequest.isReverseOrder() != null) { + jsonWriter.key("reverseOrder").value(listActivityTypesRequest.isReverseOrder()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ListClosedWorkflowExecutionsRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ListClosedWorkflowExecutionsRequestMarshaller.java new file mode 100644 index 000000000000..43a1b7859b56 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ListClosedWorkflowExecutionsRequestMarshaller.java @@ -0,0 +1,151 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * List Closed Workflow Executions Request Marshaller + */ +public class ListClosedWorkflowExecutionsRequestMarshaller implements Marshaller, ListClosedWorkflowExecutionsRequest> { + + public Request marshall(ListClosedWorkflowExecutionsRequest listClosedWorkflowExecutionsRequest) { + if (listClosedWorkflowExecutionsRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(listClosedWorkflowExecutionsRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.ListClosedWorkflowExecutions"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (listClosedWorkflowExecutionsRequest.getDomain() != null) { + jsonWriter.key("domain").value(listClosedWorkflowExecutionsRequest.getDomain()); + } + if (listClosedWorkflowExecutionsRequest != null) { + ExecutionTimeFilter executionTimeFilterStartTimeFilter = listClosedWorkflowExecutionsRequest.getStartTimeFilter(); + if (executionTimeFilterStartTimeFilter != null) { + jsonWriter.key("startTimeFilter").object(); + if (executionTimeFilterStartTimeFilter.getOldestDate() != null) { + jsonWriter.key("oldestDate").value(executionTimeFilterStartTimeFilter.getOldestDate()); + } + if (executionTimeFilterStartTimeFilter.getLatestDate() != null) { + jsonWriter.key("latestDate").value(executionTimeFilterStartTimeFilter.getLatestDate()); + } + jsonWriter.endObject(); + } + } + if (listClosedWorkflowExecutionsRequest != null) { + ExecutionTimeFilter executionTimeFilterCloseTimeFilter = listClosedWorkflowExecutionsRequest.getCloseTimeFilter(); + if (executionTimeFilterCloseTimeFilter != null) { + jsonWriter.key("closeTimeFilter").object(); + if (executionTimeFilterCloseTimeFilter.getOldestDate() != null) { + jsonWriter.key("oldestDate").value(executionTimeFilterCloseTimeFilter.getOldestDate()); + } + if (executionTimeFilterCloseTimeFilter.getLatestDate() != null) { + jsonWriter.key("latestDate").value(executionTimeFilterCloseTimeFilter.getLatestDate()); + } + jsonWriter.endObject(); + } + } + if (listClosedWorkflowExecutionsRequest != null) { + WorkflowExecutionFilter workflowExecutionFilterExecutionFilter = listClosedWorkflowExecutionsRequest.getExecutionFilter(); + if (workflowExecutionFilterExecutionFilter != null) { + jsonWriter.key("executionFilter").object(); + if (workflowExecutionFilterExecutionFilter.getWorkflowId() != null) { + jsonWriter.key("workflowId").value(workflowExecutionFilterExecutionFilter.getWorkflowId()); + } + jsonWriter.endObject(); + } + } + if (listClosedWorkflowExecutionsRequest != null) { + CloseStatusFilter closeStatusFilterCloseStatusFilter = listClosedWorkflowExecutionsRequest.getCloseStatusFilter(); + if (closeStatusFilterCloseStatusFilter != null) { + jsonWriter.key("closeStatusFilter").object(); + if (closeStatusFilterCloseStatusFilter.getStatus() != null) { + jsonWriter.key("status").value(closeStatusFilterCloseStatusFilter.getStatus()); + } + jsonWriter.endObject(); + } + } + if (listClosedWorkflowExecutionsRequest != null) { + WorkflowTypeFilter workflowTypeFilterTypeFilter = listClosedWorkflowExecutionsRequest.getTypeFilter(); + if (workflowTypeFilterTypeFilter != null) { + jsonWriter.key("typeFilter").object(); + if (workflowTypeFilterTypeFilter.getName() != null) { + jsonWriter.key("name").value(workflowTypeFilterTypeFilter.getName()); + } + if (workflowTypeFilterTypeFilter.getVersion() != null) { + jsonWriter.key("version").value(workflowTypeFilterTypeFilter.getVersion()); + } + jsonWriter.endObject(); + } + } + if (listClosedWorkflowExecutionsRequest != null) { + TagFilter tagFilterTagFilter = listClosedWorkflowExecutionsRequest.getTagFilter(); + if (tagFilterTagFilter != null) { + jsonWriter.key("tagFilter").object(); + if (tagFilterTagFilter.getTag() != null) { + jsonWriter.key("tag").value(tagFilterTagFilter.getTag()); + } + jsonWriter.endObject(); + } + } + if (listClosedWorkflowExecutionsRequest.getNextPageToken() != null) { + jsonWriter.key("nextPageToken").value(listClosedWorkflowExecutionsRequest.getNextPageToken()); + } + if (listClosedWorkflowExecutionsRequest.getMaximumPageSize() != null) { + jsonWriter.key("maximumPageSize").value(listClosedWorkflowExecutionsRequest.getMaximumPageSize()); + } + if (listClosedWorkflowExecutionsRequest.isReverseOrder() != null) { + jsonWriter.key("reverseOrder").value(listClosedWorkflowExecutionsRequest.isReverseOrder()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ListDomainsRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ListDomainsRequestMarshaller.java new file mode 100644 index 000000000000..208280efa23c --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ListDomainsRequestMarshaller.java @@ -0,0 +1,82 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * List Domains Request Marshaller + */ +public class ListDomainsRequestMarshaller implements Marshaller, ListDomainsRequest> { + + public Request marshall(ListDomainsRequest listDomainsRequest) { + if (listDomainsRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(listDomainsRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.ListDomains"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (listDomainsRequest.getNextPageToken() != null) { + jsonWriter.key("nextPageToken").value(listDomainsRequest.getNextPageToken()); + } + if (listDomainsRequest.getRegistrationStatus() != null) { + jsonWriter.key("registrationStatus").value(listDomainsRequest.getRegistrationStatus()); + } + if (listDomainsRequest.getMaximumPageSize() != null) { + jsonWriter.key("maximumPageSize").value(listDomainsRequest.getMaximumPageSize()); + } + if (listDomainsRequest.isReverseOrder() != null) { + jsonWriter.key("reverseOrder").value(listDomainsRequest.isReverseOrder()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ListOpenWorkflowExecutionsRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ListOpenWorkflowExecutionsRequestMarshaller.java new file mode 100644 index 000000000000..2659a18ead53 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ListOpenWorkflowExecutionsRequestMarshaller.java @@ -0,0 +1,128 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * List Open Workflow Executions Request Marshaller + */ +public class ListOpenWorkflowExecutionsRequestMarshaller implements Marshaller, ListOpenWorkflowExecutionsRequest> { + + public Request marshall(ListOpenWorkflowExecutionsRequest listOpenWorkflowExecutionsRequest) { + if (listOpenWorkflowExecutionsRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(listOpenWorkflowExecutionsRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.ListOpenWorkflowExecutions"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (listOpenWorkflowExecutionsRequest.getDomain() != null) { + jsonWriter.key("domain").value(listOpenWorkflowExecutionsRequest.getDomain()); + } + if (listOpenWorkflowExecutionsRequest != null) { + ExecutionTimeFilter executionTimeFilterStartTimeFilter = listOpenWorkflowExecutionsRequest.getStartTimeFilter(); + if (executionTimeFilterStartTimeFilter != null) { + jsonWriter.key("startTimeFilter").object(); + if (executionTimeFilterStartTimeFilter.getOldestDate() != null) { + jsonWriter.key("oldestDate").value(executionTimeFilterStartTimeFilter.getOldestDate()); + } + if (executionTimeFilterStartTimeFilter.getLatestDate() != null) { + jsonWriter.key("latestDate").value(executionTimeFilterStartTimeFilter.getLatestDate()); + } + jsonWriter.endObject(); + } + } + if (listOpenWorkflowExecutionsRequest != null) { + WorkflowTypeFilter workflowTypeFilterTypeFilter = listOpenWorkflowExecutionsRequest.getTypeFilter(); + if (workflowTypeFilterTypeFilter != null) { + jsonWriter.key("typeFilter").object(); + if (workflowTypeFilterTypeFilter.getName() != null) { + jsonWriter.key("name").value(workflowTypeFilterTypeFilter.getName()); + } + if (workflowTypeFilterTypeFilter.getVersion() != null) { + jsonWriter.key("version").value(workflowTypeFilterTypeFilter.getVersion()); + } + jsonWriter.endObject(); + } + } + if (listOpenWorkflowExecutionsRequest != null) { + TagFilter tagFilterTagFilter = listOpenWorkflowExecutionsRequest.getTagFilter(); + if (tagFilterTagFilter != null) { + jsonWriter.key("tagFilter").object(); + if (tagFilterTagFilter.getTag() != null) { + jsonWriter.key("tag").value(tagFilterTagFilter.getTag()); + } + jsonWriter.endObject(); + } + } + if (listOpenWorkflowExecutionsRequest.getNextPageToken() != null) { + jsonWriter.key("nextPageToken").value(listOpenWorkflowExecutionsRequest.getNextPageToken()); + } + if (listOpenWorkflowExecutionsRequest.getMaximumPageSize() != null) { + jsonWriter.key("maximumPageSize").value(listOpenWorkflowExecutionsRequest.getMaximumPageSize()); + } + if (listOpenWorkflowExecutionsRequest.isReverseOrder() != null) { + jsonWriter.key("reverseOrder").value(listOpenWorkflowExecutionsRequest.isReverseOrder()); + } + if (listOpenWorkflowExecutionsRequest != null) { + WorkflowExecutionFilter workflowExecutionFilterExecutionFilter = listOpenWorkflowExecutionsRequest.getExecutionFilter(); + if (workflowExecutionFilterExecutionFilter != null) { + jsonWriter.key("executionFilter").object(); + if (workflowExecutionFilterExecutionFilter.getWorkflowId() != null) { + jsonWriter.key("workflowId").value(workflowExecutionFilterExecutionFilter.getWorkflowId()); + } + jsonWriter.endObject(); + } + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ListWorkflowTypesRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ListWorkflowTypesRequestMarshaller.java new file mode 100644 index 000000000000..5f840a7df589 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ListWorkflowTypesRequestMarshaller.java @@ -0,0 +1,88 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * List Workflow Types Request Marshaller + */ +public class ListWorkflowTypesRequestMarshaller implements Marshaller, ListWorkflowTypesRequest> { + + public Request marshall(ListWorkflowTypesRequest listWorkflowTypesRequest) { + if (listWorkflowTypesRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(listWorkflowTypesRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.ListWorkflowTypes"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (listWorkflowTypesRequest.getDomain() != null) { + jsonWriter.key("domain").value(listWorkflowTypesRequest.getDomain()); + } + if (listWorkflowTypesRequest.getName() != null) { + jsonWriter.key("name").value(listWorkflowTypesRequest.getName()); + } + if (listWorkflowTypesRequest.getRegistrationStatus() != null) { + jsonWriter.key("registrationStatus").value(listWorkflowTypesRequest.getRegistrationStatus()); + } + if (listWorkflowTypesRequest.getNextPageToken() != null) { + jsonWriter.key("nextPageToken").value(listWorkflowTypesRequest.getNextPageToken()); + } + if (listWorkflowTypesRequest.getMaximumPageSize() != null) { + jsonWriter.key("maximumPageSize").value(listWorkflowTypesRequest.getMaximumPageSize()); + } + if (listWorkflowTypesRequest.isReverseOrder() != null) { + jsonWriter.key("reverseOrder").value(listWorkflowTypesRequest.isReverseOrder()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/MarkerRecordedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/MarkerRecordedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..9c5a8b568853 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/MarkerRecordedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Marker Recorded Event Attributes JSON Unmarshaller + */ +public class MarkerRecordedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public MarkerRecordedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + MarkerRecordedEventAttributes markerRecordedEventAttributes = new MarkerRecordedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return markerRecordedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("markerName", targetDepth)) { + context.nextToken(); + markerRecordedEventAttributes.setMarkerName(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("details", targetDepth)) { + context.nextToken(); + markerRecordedEventAttributes.setDetails(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + markerRecordedEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return markerRecordedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static MarkerRecordedEventAttributesJsonUnmarshaller instance; + public static MarkerRecordedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new MarkerRecordedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/OperationNotPermittedExceptionUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/OperationNotPermittedExceptionUnmarshaller.java new file mode 100644 index 000000000000..25c6d48b2a94 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/OperationNotPermittedExceptionUnmarshaller.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + +import com.amazonaws.AmazonServiceException; +import com.amazonaws.transform.JsonErrorUnmarshaller; +import com.amazonaws.util.json.JSONObject; + +import com.amazonaws.services.simpleworkflow.model.OperationNotPermittedException; + +public class OperationNotPermittedExceptionUnmarshaller extends JsonErrorUnmarshaller { + + public OperationNotPermittedExceptionUnmarshaller() { + super(OperationNotPermittedException.class); + } + + public AmazonServiceException unmarshall(JSONObject json) throws Exception { + // Bail out if this isn't the right error code that this + // marshaller understands. + String errorCode = parseErrorCode(json); + if (errorCode == null || !errorCode.equals("OperationNotPermittedFault")) + return null; + + OperationNotPermittedException e = (OperationNotPermittedException)super.unmarshall(json); + + + + return e; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/PendingTaskCountJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/PendingTaskCountJsonUnmarshaller.java new file mode 100644 index 000000000000..7c2a1a03b6ff --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/PendingTaskCountJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Pending Task Count JSON Unmarshaller + */ +public class PendingTaskCountJsonUnmarshaller implements Unmarshaller { + + + + public PendingTaskCount unmarshall(JsonUnmarshallerContext context) throws Exception { + PendingTaskCount pendingTaskCount = new PendingTaskCount(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return pendingTaskCount; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("count", targetDepth)) { + context.nextToken(); + pendingTaskCount.setCount(IntegerJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("truncated", targetDepth)) { + context.nextToken(); + pendingTaskCount.setTruncated(BooleanJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return pendingTaskCount; + } + } + token = context.nextToken(); + } + } + + private static PendingTaskCountJsonUnmarshaller instance; + public static PendingTaskCountJsonUnmarshaller getInstance() { + if (instance == null) instance = new PendingTaskCountJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/PollForActivityTaskRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/PollForActivityTaskRequestMarshaller.java new file mode 100644 index 000000000000..3e3b6955c56b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/PollForActivityTaskRequestMarshaller.java @@ -0,0 +1,86 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Poll For Activity Task Request Marshaller + */ +public class PollForActivityTaskRequestMarshaller implements Marshaller, PollForActivityTaskRequest> { + + public Request marshall(PollForActivityTaskRequest pollForActivityTaskRequest) { + if (pollForActivityTaskRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(pollForActivityTaskRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.PollForActivityTask"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (pollForActivityTaskRequest.getDomain() != null) { + jsonWriter.key("domain").value(pollForActivityTaskRequest.getDomain()); + } + if (pollForActivityTaskRequest != null) { + TaskList taskListTaskList = pollForActivityTaskRequest.getTaskList(); + if (taskListTaskList != null) { + jsonWriter.key("taskList").object(); + if (taskListTaskList.getName() != null) { + jsonWriter.key("name").value(taskListTaskList.getName()); + } + jsonWriter.endObject(); + } + } + if (pollForActivityTaskRequest.getIdentity() != null) { + jsonWriter.key("identity").value(pollForActivityTaskRequest.getIdentity()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/PollForDecisionTaskRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/PollForDecisionTaskRequestMarshaller.java new file mode 100644 index 000000000000..cb3c56dc4171 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/PollForDecisionTaskRequestMarshaller.java @@ -0,0 +1,95 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Poll For Decision Task Request Marshaller + */ +public class PollForDecisionTaskRequestMarshaller implements Marshaller, PollForDecisionTaskRequest> { + + public Request marshall(PollForDecisionTaskRequest pollForDecisionTaskRequest) { + if (pollForDecisionTaskRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(pollForDecisionTaskRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.PollForDecisionTask"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (pollForDecisionTaskRequest.getDomain() != null) { + jsonWriter.key("domain").value(pollForDecisionTaskRequest.getDomain()); + } + if (pollForDecisionTaskRequest != null) { + TaskList taskListTaskList = pollForDecisionTaskRequest.getTaskList(); + if (taskListTaskList != null) { + jsonWriter.key("taskList").object(); + if (taskListTaskList.getName() != null) { + jsonWriter.key("name").value(taskListTaskList.getName()); + } + jsonWriter.endObject(); + } + } + if (pollForDecisionTaskRequest.getIdentity() != null) { + jsonWriter.key("identity").value(pollForDecisionTaskRequest.getIdentity()); + } + if (pollForDecisionTaskRequest.getNextPageToken() != null) { + jsonWriter.key("nextPageToken").value(pollForDecisionTaskRequest.getNextPageToken()); + } + if (pollForDecisionTaskRequest.getMaximumPageSize() != null) { + jsonWriter.key("maximumPageSize").value(pollForDecisionTaskRequest.getMaximumPageSize()); + } + if (pollForDecisionTaskRequest.isReverseOrder() != null) { + jsonWriter.key("reverseOrder").value(pollForDecisionTaskRequest.isReverseOrder()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RecordActivityTaskHeartbeatRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RecordActivityTaskHeartbeatRequestMarshaller.java new file mode 100644 index 000000000000..ddecf12c1f7f --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RecordActivityTaskHeartbeatRequestMarshaller.java @@ -0,0 +1,76 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Record Activity Task Heartbeat Request Marshaller + */ +public class RecordActivityTaskHeartbeatRequestMarshaller implements Marshaller, RecordActivityTaskHeartbeatRequest> { + + public Request marshall(RecordActivityTaskHeartbeatRequest recordActivityTaskHeartbeatRequest) { + if (recordActivityTaskHeartbeatRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(recordActivityTaskHeartbeatRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.RecordActivityTaskHeartbeat"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (recordActivityTaskHeartbeatRequest.getTaskToken() != null) { + jsonWriter.key("taskToken").value(recordActivityTaskHeartbeatRequest.getTaskToken()); + } + if (recordActivityTaskHeartbeatRequest.getDetails() != null) { + jsonWriter.key("details").value(recordActivityTaskHeartbeatRequest.getDetails()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RegisterActivityTypeRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RegisterActivityTypeRequestMarshaller.java new file mode 100644 index 000000000000..8901a86a3dcc --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RegisterActivityTypeRequestMarshaller.java @@ -0,0 +1,104 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Register Activity Type Request Marshaller + */ +public class RegisterActivityTypeRequestMarshaller implements Marshaller, RegisterActivityTypeRequest> { + + public Request marshall(RegisterActivityTypeRequest registerActivityTypeRequest) { + if (registerActivityTypeRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(registerActivityTypeRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.RegisterActivityType"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (registerActivityTypeRequest.getDomain() != null) { + jsonWriter.key("domain").value(registerActivityTypeRequest.getDomain()); + } + if (registerActivityTypeRequest.getName() != null) { + jsonWriter.key("name").value(registerActivityTypeRequest.getName()); + } + if (registerActivityTypeRequest.getVersion() != null) { + jsonWriter.key("version").value(registerActivityTypeRequest.getVersion()); + } + if (registerActivityTypeRequest.getDescription() != null) { + jsonWriter.key("description").value(registerActivityTypeRequest.getDescription()); + } + if (registerActivityTypeRequest.getDefaultTaskStartToCloseTimeout() != null) { + jsonWriter.key("defaultTaskStartToCloseTimeout").value(registerActivityTypeRequest.getDefaultTaskStartToCloseTimeout()); + } + if (registerActivityTypeRequest.getDefaultTaskHeartbeatTimeout() != null) { + jsonWriter.key("defaultTaskHeartbeatTimeout").value(registerActivityTypeRequest.getDefaultTaskHeartbeatTimeout()); + } + if (registerActivityTypeRequest != null) { + TaskList taskListDefaultTaskList = registerActivityTypeRequest.getDefaultTaskList(); + if (taskListDefaultTaskList != null) { + jsonWriter.key("defaultTaskList").object(); + if (taskListDefaultTaskList.getName() != null) { + jsonWriter.key("name").value(taskListDefaultTaskList.getName()); + } + jsonWriter.endObject(); + } + } + if (registerActivityTypeRequest.getDefaultTaskScheduleToStartTimeout() != null) { + jsonWriter.key("defaultTaskScheduleToStartTimeout").value(registerActivityTypeRequest.getDefaultTaskScheduleToStartTimeout()); + } + if (registerActivityTypeRequest.getDefaultTaskScheduleToCloseTimeout() != null) { + jsonWriter.key("defaultTaskScheduleToCloseTimeout").value(registerActivityTypeRequest.getDefaultTaskScheduleToCloseTimeout()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RegisterDomainRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RegisterDomainRequestMarshaller.java new file mode 100644 index 000000000000..37f1abfcbeb2 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RegisterDomainRequestMarshaller.java @@ -0,0 +1,79 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Register Domain Request Marshaller + */ +public class RegisterDomainRequestMarshaller implements Marshaller, RegisterDomainRequest> { + + public Request marshall(RegisterDomainRequest registerDomainRequest) { + if (registerDomainRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(registerDomainRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.RegisterDomain"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (registerDomainRequest.getName() != null) { + jsonWriter.key("name").value(registerDomainRequest.getName()); + } + if (registerDomainRequest.getDescription() != null) { + jsonWriter.key("description").value(registerDomainRequest.getDescription()); + } + if (registerDomainRequest.getWorkflowExecutionRetentionPeriodInDays() != null) { + jsonWriter.key("workflowExecutionRetentionPeriodInDays").value(registerDomainRequest.getWorkflowExecutionRetentionPeriodInDays()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RegisterWorkflowTypeRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RegisterWorkflowTypeRequestMarshaller.java new file mode 100644 index 000000000000..e8c9e60cf574 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RegisterWorkflowTypeRequestMarshaller.java @@ -0,0 +1,101 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Register Workflow Type Request Marshaller + */ +public class RegisterWorkflowTypeRequestMarshaller implements Marshaller, RegisterWorkflowTypeRequest> { + + public Request marshall(RegisterWorkflowTypeRequest registerWorkflowTypeRequest) { + if (registerWorkflowTypeRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(registerWorkflowTypeRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.RegisterWorkflowType"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (registerWorkflowTypeRequest.getDomain() != null) { + jsonWriter.key("domain").value(registerWorkflowTypeRequest.getDomain()); + } + if (registerWorkflowTypeRequest.getName() != null) { + jsonWriter.key("name").value(registerWorkflowTypeRequest.getName()); + } + if (registerWorkflowTypeRequest.getVersion() != null) { + jsonWriter.key("version").value(registerWorkflowTypeRequest.getVersion()); + } + if (registerWorkflowTypeRequest.getDescription() != null) { + jsonWriter.key("description").value(registerWorkflowTypeRequest.getDescription()); + } + if (registerWorkflowTypeRequest.getDefaultTaskStartToCloseTimeout() != null) { + jsonWriter.key("defaultTaskStartToCloseTimeout").value(registerWorkflowTypeRequest.getDefaultTaskStartToCloseTimeout()); + } + if (registerWorkflowTypeRequest.getDefaultExecutionStartToCloseTimeout() != null) { + jsonWriter.key("defaultExecutionStartToCloseTimeout").value(registerWorkflowTypeRequest.getDefaultExecutionStartToCloseTimeout()); + } + if (registerWorkflowTypeRequest != null) { + TaskList taskListDefaultTaskList = registerWorkflowTypeRequest.getDefaultTaskList(); + if (taskListDefaultTaskList != null) { + jsonWriter.key("defaultTaskList").object(); + if (taskListDefaultTaskList.getName() != null) { + jsonWriter.key("name").value(taskListDefaultTaskList.getName()); + } + jsonWriter.endObject(); + } + } + if (registerWorkflowTypeRequest.getDefaultChildPolicy() != null) { + jsonWriter.key("defaultChildPolicy").value(registerWorkflowTypeRequest.getDefaultChildPolicy()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RequestCancelActivityTaskFailedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RequestCancelActivityTaskFailedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..50c66f8d0be1 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RequestCancelActivityTaskFailedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Request Cancel Activity Task Failed Event Attributes JSON Unmarshaller + */ +public class RequestCancelActivityTaskFailedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public RequestCancelActivityTaskFailedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + RequestCancelActivityTaskFailedEventAttributes requestCancelActivityTaskFailedEventAttributes = new RequestCancelActivityTaskFailedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return requestCancelActivityTaskFailedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("activityId", targetDepth)) { + context.nextToken(); + requestCancelActivityTaskFailedEventAttributes.setActivityId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("cause", targetDepth)) { + context.nextToken(); + requestCancelActivityTaskFailedEventAttributes.setCause(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + requestCancelActivityTaskFailedEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return requestCancelActivityTaskFailedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static RequestCancelActivityTaskFailedEventAttributesJsonUnmarshaller instance; + public static RequestCancelActivityTaskFailedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new RequestCancelActivityTaskFailedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RequestCancelExternalWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RequestCancelExternalWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..7e5fafcde0ad --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RequestCancelExternalWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,86 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Request Cancel External Workflow Execution Failed Event Attributes JSON Unmarshaller + */ +public class RequestCancelExternalWorkflowExecutionFailedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public RequestCancelExternalWorkflowExecutionFailedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + RequestCancelExternalWorkflowExecutionFailedEventAttributes requestCancelExternalWorkflowExecutionFailedEventAttributes = new RequestCancelExternalWorkflowExecutionFailedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return requestCancelExternalWorkflowExecutionFailedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("workflowId", targetDepth)) { + context.nextToken(); + requestCancelExternalWorkflowExecutionFailedEventAttributes.setWorkflowId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("runId", targetDepth)) { + context.nextToken(); + requestCancelExternalWorkflowExecutionFailedEventAttributes.setRunId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("cause", targetDepth)) { + context.nextToken(); + requestCancelExternalWorkflowExecutionFailedEventAttributes.setCause(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("initiatedEventId", targetDepth)) { + context.nextToken(); + requestCancelExternalWorkflowExecutionFailedEventAttributes.setInitiatedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + requestCancelExternalWorkflowExecutionFailedEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("control", targetDepth)) { + context.nextToken(); + requestCancelExternalWorkflowExecutionFailedEventAttributes.setControl(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return requestCancelExternalWorkflowExecutionFailedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static RequestCancelExternalWorkflowExecutionFailedEventAttributesJsonUnmarshaller instance; + public static RequestCancelExternalWorkflowExecutionFailedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new RequestCancelExternalWorkflowExecutionFailedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RequestCancelExternalWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RequestCancelExternalWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..43a7898340e2 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RequestCancelExternalWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,78 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Request Cancel External Workflow Execution Initiated Event Attributes JSON Unmarshaller + */ +public class RequestCancelExternalWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public RequestCancelExternalWorkflowExecutionInitiatedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + RequestCancelExternalWorkflowExecutionInitiatedEventAttributes requestCancelExternalWorkflowExecutionInitiatedEventAttributes = new RequestCancelExternalWorkflowExecutionInitiatedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return requestCancelExternalWorkflowExecutionInitiatedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("workflowId", targetDepth)) { + context.nextToken(); + requestCancelExternalWorkflowExecutionInitiatedEventAttributes.setWorkflowId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("runId", targetDepth)) { + context.nextToken(); + requestCancelExternalWorkflowExecutionInitiatedEventAttributes.setRunId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + requestCancelExternalWorkflowExecutionInitiatedEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("control", targetDepth)) { + context.nextToken(); + requestCancelExternalWorkflowExecutionInitiatedEventAttributes.setControl(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return requestCancelExternalWorkflowExecutionInitiatedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static RequestCancelExternalWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller instance; + public static RequestCancelExternalWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new RequestCancelExternalWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RequestCancelWorkflowExecutionRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RequestCancelWorkflowExecutionRequestMarshaller.java new file mode 100644 index 000000000000..3748f97183b6 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RequestCancelWorkflowExecutionRequestMarshaller.java @@ -0,0 +1,79 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Request Cancel Workflow Execution Request Marshaller + */ +public class RequestCancelWorkflowExecutionRequestMarshaller implements Marshaller, RequestCancelWorkflowExecutionRequest> { + + public Request marshall(RequestCancelWorkflowExecutionRequest requestCancelWorkflowExecutionRequest) { + if (requestCancelWorkflowExecutionRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(requestCancelWorkflowExecutionRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.RequestCancelWorkflowExecution"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (requestCancelWorkflowExecutionRequest.getDomain() != null) { + jsonWriter.key("domain").value(requestCancelWorkflowExecutionRequest.getDomain()); + } + if (requestCancelWorkflowExecutionRequest.getWorkflowId() != null) { + jsonWriter.key("workflowId").value(requestCancelWorkflowExecutionRequest.getWorkflowId()); + } + if (requestCancelWorkflowExecutionRequest.getRunId() != null) { + jsonWriter.key("runId").value(requestCancelWorkflowExecutionRequest.getRunId()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RespondActivityTaskCanceledRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RespondActivityTaskCanceledRequestMarshaller.java new file mode 100644 index 000000000000..3f875febab1a --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RespondActivityTaskCanceledRequestMarshaller.java @@ -0,0 +1,76 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Respond Activity Task Canceled Request Marshaller + */ +public class RespondActivityTaskCanceledRequestMarshaller implements Marshaller, RespondActivityTaskCanceledRequest> { + + public Request marshall(RespondActivityTaskCanceledRequest respondActivityTaskCanceledRequest) { + if (respondActivityTaskCanceledRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(respondActivityTaskCanceledRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.RespondActivityTaskCanceled"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (respondActivityTaskCanceledRequest.getTaskToken() != null) { + jsonWriter.key("taskToken").value(respondActivityTaskCanceledRequest.getTaskToken()); + } + if (respondActivityTaskCanceledRequest.getDetails() != null) { + jsonWriter.key("details").value(respondActivityTaskCanceledRequest.getDetails()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RespondActivityTaskCompletedRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RespondActivityTaskCompletedRequestMarshaller.java new file mode 100644 index 000000000000..e578ea6c8e2f --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RespondActivityTaskCompletedRequestMarshaller.java @@ -0,0 +1,76 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Respond Activity Task Completed Request Marshaller + */ +public class RespondActivityTaskCompletedRequestMarshaller implements Marshaller, RespondActivityTaskCompletedRequest> { + + public Request marshall(RespondActivityTaskCompletedRequest respondActivityTaskCompletedRequest) { + if (respondActivityTaskCompletedRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(respondActivityTaskCompletedRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.RespondActivityTaskCompleted"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (respondActivityTaskCompletedRequest.getTaskToken() != null) { + jsonWriter.key("taskToken").value(respondActivityTaskCompletedRequest.getTaskToken()); + } + if (respondActivityTaskCompletedRequest.getResult() != null) { + jsonWriter.key("result").value(respondActivityTaskCompletedRequest.getResult()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RespondActivityTaskFailedRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RespondActivityTaskFailedRequestMarshaller.java new file mode 100644 index 000000000000..befd0d604953 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RespondActivityTaskFailedRequestMarshaller.java @@ -0,0 +1,79 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Respond Activity Task Failed Request Marshaller + */ +public class RespondActivityTaskFailedRequestMarshaller implements Marshaller, RespondActivityTaskFailedRequest> { + + public Request marshall(RespondActivityTaskFailedRequest respondActivityTaskFailedRequest) { + if (respondActivityTaskFailedRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(respondActivityTaskFailedRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.RespondActivityTaskFailed"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (respondActivityTaskFailedRequest.getTaskToken() != null) { + jsonWriter.key("taskToken").value(respondActivityTaskFailedRequest.getTaskToken()); + } + if (respondActivityTaskFailedRequest.getReason() != null) { + jsonWriter.key("reason").value(respondActivityTaskFailedRequest.getReason()); + } + if (respondActivityTaskFailedRequest.getDetails() != null) { + jsonWriter.key("details").value(respondActivityTaskFailedRequest.getDetails()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RespondDecisionTaskCompletedRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RespondDecisionTaskCompletedRequestMarshaller.java new file mode 100644 index 000000000000..f5da1711a54f --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RespondDecisionTaskCompletedRequestMarshaller.java @@ -0,0 +1,376 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Respond Decision Task Completed Request Marshaller + */ +public class RespondDecisionTaskCompletedRequestMarshaller implements Marshaller, RespondDecisionTaskCompletedRequest> { + + public Request marshall(RespondDecisionTaskCompletedRequest respondDecisionTaskCompletedRequest) { + if (respondDecisionTaskCompletedRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(respondDecisionTaskCompletedRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.RespondDecisionTaskCompleted"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (respondDecisionTaskCompletedRequest.getTaskToken() != null) { + jsonWriter.key("taskToken").value(respondDecisionTaskCompletedRequest.getTaskToken()); + } + + if (respondDecisionTaskCompletedRequest != null) { + java.util.List decisionsList = respondDecisionTaskCompletedRequest.getDecisions(); + if (decisionsList != null && decisionsList.size() > 0) { + int decisionsListIndex = 1; + jsonWriter.key("decisions").array(); + for (Decision decisionsListValue : decisionsList) { + + + + jsonWriter.object(); + if (decisionsListValue.getDecisionType() != null) { + jsonWriter.key("decisionType").value(decisionsListValue.getDecisionType()); + } + if (decisionsListValue != null) { + ScheduleActivityTaskDecisionAttributes scheduleActivityTaskDecisionAttributesScheduleActivityTaskDecisionAttributes = decisionsListValue.getScheduleActivityTaskDecisionAttributes(); + if (scheduleActivityTaskDecisionAttributesScheduleActivityTaskDecisionAttributes != null) { + jsonWriter.key("scheduleActivityTaskDecisionAttributes").object(); + if (scheduleActivityTaskDecisionAttributesScheduleActivityTaskDecisionAttributes != null) { + ActivityType activityTypeActivityType = scheduleActivityTaskDecisionAttributesScheduleActivityTaskDecisionAttributes.getActivityType(); + if (activityTypeActivityType != null) { + jsonWriter.key("activityType").object(); + if (activityTypeActivityType.getName() != null) { + jsonWriter.key("name").value(activityTypeActivityType.getName()); + } + if (activityTypeActivityType.getVersion() != null) { + jsonWriter.key("version").value(activityTypeActivityType.getVersion()); + } + jsonWriter.endObject(); + } + } + if (scheduleActivityTaskDecisionAttributesScheduleActivityTaskDecisionAttributes.getActivityId() != null) { + jsonWriter.key("activityId").value(scheduleActivityTaskDecisionAttributesScheduleActivityTaskDecisionAttributes.getActivityId()); + } + if (scheduleActivityTaskDecisionAttributesScheduleActivityTaskDecisionAttributes.getControl() != null) { + jsonWriter.key("control").value(scheduleActivityTaskDecisionAttributesScheduleActivityTaskDecisionAttributes.getControl()); + } + if (scheduleActivityTaskDecisionAttributesScheduleActivityTaskDecisionAttributes.getInput() != null) { + jsonWriter.key("input").value(scheduleActivityTaskDecisionAttributesScheduleActivityTaskDecisionAttributes.getInput()); + } + if (scheduleActivityTaskDecisionAttributesScheduleActivityTaskDecisionAttributes.getScheduleToCloseTimeout() != null) { + jsonWriter.key("scheduleToCloseTimeout").value(scheduleActivityTaskDecisionAttributesScheduleActivityTaskDecisionAttributes.getScheduleToCloseTimeout()); + } + if (scheduleActivityTaskDecisionAttributesScheduleActivityTaskDecisionAttributes != null) { + TaskList taskListTaskList = scheduleActivityTaskDecisionAttributesScheduleActivityTaskDecisionAttributes.getTaskList(); + if (taskListTaskList != null) { + jsonWriter.key("taskList").object(); + if (taskListTaskList.getName() != null) { + jsonWriter.key("name").value(taskListTaskList.getName()); + } + jsonWriter.endObject(); + } + } + if (scheduleActivityTaskDecisionAttributesScheduleActivityTaskDecisionAttributes.getScheduleToStartTimeout() != null) { + jsonWriter.key("scheduleToStartTimeout").value(scheduleActivityTaskDecisionAttributesScheduleActivityTaskDecisionAttributes.getScheduleToStartTimeout()); + } + if (scheduleActivityTaskDecisionAttributesScheduleActivityTaskDecisionAttributes.getStartToCloseTimeout() != null) { + jsonWriter.key("startToCloseTimeout").value(scheduleActivityTaskDecisionAttributesScheduleActivityTaskDecisionAttributes.getStartToCloseTimeout()); + } + if (scheduleActivityTaskDecisionAttributesScheduleActivityTaskDecisionAttributes.getHeartbeatTimeout() != null) { + jsonWriter.key("heartbeatTimeout").value(scheduleActivityTaskDecisionAttributesScheduleActivityTaskDecisionAttributes.getHeartbeatTimeout()); + } + jsonWriter.endObject(); + } + } + if (decisionsListValue != null) { + RequestCancelActivityTaskDecisionAttributes requestCancelActivityTaskDecisionAttributesRequestCancelActivityTaskDecisionAttributes = decisionsListValue.getRequestCancelActivityTaskDecisionAttributes(); + if (requestCancelActivityTaskDecisionAttributesRequestCancelActivityTaskDecisionAttributes != null) { + jsonWriter.key("requestCancelActivityTaskDecisionAttributes").object(); + if (requestCancelActivityTaskDecisionAttributesRequestCancelActivityTaskDecisionAttributes.getActivityId() != null) { + jsonWriter.key("activityId").value(requestCancelActivityTaskDecisionAttributesRequestCancelActivityTaskDecisionAttributes.getActivityId()); + } + jsonWriter.endObject(); + } + } + if (decisionsListValue != null) { + CompleteWorkflowExecutionDecisionAttributes completeWorkflowExecutionDecisionAttributesCompleteWorkflowExecutionDecisionAttributes = decisionsListValue.getCompleteWorkflowExecutionDecisionAttributes(); + if (completeWorkflowExecutionDecisionAttributesCompleteWorkflowExecutionDecisionAttributes != null) { + jsonWriter.key("completeWorkflowExecutionDecisionAttributes").object(); + if (completeWorkflowExecutionDecisionAttributesCompleteWorkflowExecutionDecisionAttributes.getResult() != null) { + jsonWriter.key("result").value(completeWorkflowExecutionDecisionAttributesCompleteWorkflowExecutionDecisionAttributes.getResult()); + } + jsonWriter.endObject(); + } + } + if (decisionsListValue != null) { + FailWorkflowExecutionDecisionAttributes failWorkflowExecutionDecisionAttributesFailWorkflowExecutionDecisionAttributes = decisionsListValue.getFailWorkflowExecutionDecisionAttributes(); + if (failWorkflowExecutionDecisionAttributesFailWorkflowExecutionDecisionAttributes != null) { + jsonWriter.key("failWorkflowExecutionDecisionAttributes").object(); + if (failWorkflowExecutionDecisionAttributesFailWorkflowExecutionDecisionAttributes.getReason() != null) { + jsonWriter.key("reason").value(failWorkflowExecutionDecisionAttributesFailWorkflowExecutionDecisionAttributes.getReason()); + } + if (failWorkflowExecutionDecisionAttributesFailWorkflowExecutionDecisionAttributes.getDetails() != null) { + jsonWriter.key("details").value(failWorkflowExecutionDecisionAttributesFailWorkflowExecutionDecisionAttributes.getDetails()); + } + jsonWriter.endObject(); + } + } + if (decisionsListValue != null) { + CancelWorkflowExecutionDecisionAttributes cancelWorkflowExecutionDecisionAttributesCancelWorkflowExecutionDecisionAttributes = decisionsListValue.getCancelWorkflowExecutionDecisionAttributes(); + if (cancelWorkflowExecutionDecisionAttributesCancelWorkflowExecutionDecisionAttributes != null) { + jsonWriter.key("cancelWorkflowExecutionDecisionAttributes").object(); + if (cancelWorkflowExecutionDecisionAttributesCancelWorkflowExecutionDecisionAttributes.getDetails() != null) { + jsonWriter.key("details").value(cancelWorkflowExecutionDecisionAttributesCancelWorkflowExecutionDecisionAttributes.getDetails()); + } + jsonWriter.endObject(); + } + } + if (decisionsListValue != null) { + ContinueAsNewWorkflowExecutionDecisionAttributes continueAsNewWorkflowExecutionDecisionAttributesContinueAsNewWorkflowExecutionDecisionAttributes = decisionsListValue.getContinueAsNewWorkflowExecutionDecisionAttributes(); + if (continueAsNewWorkflowExecutionDecisionAttributesContinueAsNewWorkflowExecutionDecisionAttributes != null) { + jsonWriter.key("continueAsNewWorkflowExecutionDecisionAttributes").object(); + if (continueAsNewWorkflowExecutionDecisionAttributesContinueAsNewWorkflowExecutionDecisionAttributes.getInput() != null) { + jsonWriter.key("input").value(continueAsNewWorkflowExecutionDecisionAttributesContinueAsNewWorkflowExecutionDecisionAttributes.getInput()); + } + if (continueAsNewWorkflowExecutionDecisionAttributesContinueAsNewWorkflowExecutionDecisionAttributes.getExecutionStartToCloseTimeout() != null) { + jsonWriter.key("executionStartToCloseTimeout").value(continueAsNewWorkflowExecutionDecisionAttributesContinueAsNewWorkflowExecutionDecisionAttributes.getExecutionStartToCloseTimeout()); + } + if (continueAsNewWorkflowExecutionDecisionAttributesContinueAsNewWorkflowExecutionDecisionAttributes != null) { + TaskList taskListTaskList = continueAsNewWorkflowExecutionDecisionAttributesContinueAsNewWorkflowExecutionDecisionAttributes.getTaskList(); + if (taskListTaskList != null) { + jsonWriter.key("taskList").object(); + if (taskListTaskList.getName() != null) { + jsonWriter.key("name").value(taskListTaskList.getName()); + } + jsonWriter.endObject(); + } + } + if (continueAsNewWorkflowExecutionDecisionAttributesContinueAsNewWorkflowExecutionDecisionAttributes.getTaskStartToCloseTimeout() != null) { + jsonWriter.key("taskStartToCloseTimeout").value(continueAsNewWorkflowExecutionDecisionAttributesContinueAsNewWorkflowExecutionDecisionAttributes.getTaskStartToCloseTimeout()); + } + if (continueAsNewWorkflowExecutionDecisionAttributesContinueAsNewWorkflowExecutionDecisionAttributes.getChildPolicy() != null) { + jsonWriter.key("childPolicy").value(continueAsNewWorkflowExecutionDecisionAttributesContinueAsNewWorkflowExecutionDecisionAttributes.getChildPolicy()); + } + if (continueAsNewWorkflowExecutionDecisionAttributesContinueAsNewWorkflowExecutionDecisionAttributes != null) { + java.util.List tagListList = continueAsNewWorkflowExecutionDecisionAttributesContinueAsNewWorkflowExecutionDecisionAttributes.getTagList(); + int tagListListIndex = 0; + if (tagListList != null && tagListList.size() > 0) { + jsonWriter.key("tagList").array(); + for (String tagListListValue : tagListList) { + if (tagListListValue != null) { + jsonWriter.value(tagListListValue); + } else jsonWriter.value(null); + tagListListIndex++; + } + jsonWriter.endArray(); + } + } + if (continueAsNewWorkflowExecutionDecisionAttributesContinueAsNewWorkflowExecutionDecisionAttributes.getWorkflowTypeVersion() != null) { + jsonWriter.key("workflowTypeVersion").value(continueAsNewWorkflowExecutionDecisionAttributesContinueAsNewWorkflowExecutionDecisionAttributes.getWorkflowTypeVersion()); + } + jsonWriter.endObject(); + } + } + if (decisionsListValue != null) { + RecordMarkerDecisionAttributes recordMarkerDecisionAttributesRecordMarkerDecisionAttributes = decisionsListValue.getRecordMarkerDecisionAttributes(); + if (recordMarkerDecisionAttributesRecordMarkerDecisionAttributes != null) { + jsonWriter.key("recordMarkerDecisionAttributes").object(); + if (recordMarkerDecisionAttributesRecordMarkerDecisionAttributes.getMarkerName() != null) { + jsonWriter.key("markerName").value(recordMarkerDecisionAttributesRecordMarkerDecisionAttributes.getMarkerName()); + } + if (recordMarkerDecisionAttributesRecordMarkerDecisionAttributes.getDetails() != null) { + jsonWriter.key("details").value(recordMarkerDecisionAttributesRecordMarkerDecisionAttributes.getDetails()); + } + jsonWriter.endObject(); + } + } + if (decisionsListValue != null) { + StartTimerDecisionAttributes startTimerDecisionAttributesStartTimerDecisionAttributes = decisionsListValue.getStartTimerDecisionAttributes(); + if (startTimerDecisionAttributesStartTimerDecisionAttributes != null) { + jsonWriter.key("startTimerDecisionAttributes").object(); + if (startTimerDecisionAttributesStartTimerDecisionAttributes.getTimerId() != null) { + jsonWriter.key("timerId").value(startTimerDecisionAttributesStartTimerDecisionAttributes.getTimerId()); + } + if (startTimerDecisionAttributesStartTimerDecisionAttributes.getControl() != null) { + jsonWriter.key("control").value(startTimerDecisionAttributesStartTimerDecisionAttributes.getControl()); + } + if (startTimerDecisionAttributesStartTimerDecisionAttributes.getStartToFireTimeout() != null) { + jsonWriter.key("startToFireTimeout").value(startTimerDecisionAttributesStartTimerDecisionAttributes.getStartToFireTimeout()); + } + jsonWriter.endObject(); + } + } + if (decisionsListValue != null) { + CancelTimerDecisionAttributes cancelTimerDecisionAttributesCancelTimerDecisionAttributes = decisionsListValue.getCancelTimerDecisionAttributes(); + if (cancelTimerDecisionAttributesCancelTimerDecisionAttributes != null) { + jsonWriter.key("cancelTimerDecisionAttributes").object(); + if (cancelTimerDecisionAttributesCancelTimerDecisionAttributes.getTimerId() != null) { + jsonWriter.key("timerId").value(cancelTimerDecisionAttributesCancelTimerDecisionAttributes.getTimerId()); + } + jsonWriter.endObject(); + } + } + if (decisionsListValue != null) { + SignalExternalWorkflowExecutionDecisionAttributes signalExternalWorkflowExecutionDecisionAttributesSignalExternalWorkflowExecutionDecisionAttributes = decisionsListValue.getSignalExternalWorkflowExecutionDecisionAttributes(); + if (signalExternalWorkflowExecutionDecisionAttributesSignalExternalWorkflowExecutionDecisionAttributes != null) { + jsonWriter.key("signalExternalWorkflowExecutionDecisionAttributes").object(); + if (signalExternalWorkflowExecutionDecisionAttributesSignalExternalWorkflowExecutionDecisionAttributes.getWorkflowId() != null) { + jsonWriter.key("workflowId").value(signalExternalWorkflowExecutionDecisionAttributesSignalExternalWorkflowExecutionDecisionAttributes.getWorkflowId()); + } + if (signalExternalWorkflowExecutionDecisionAttributesSignalExternalWorkflowExecutionDecisionAttributes.getRunId() != null) { + jsonWriter.key("runId").value(signalExternalWorkflowExecutionDecisionAttributesSignalExternalWorkflowExecutionDecisionAttributes.getRunId()); + } + if (signalExternalWorkflowExecutionDecisionAttributesSignalExternalWorkflowExecutionDecisionAttributes.getSignalName() != null) { + jsonWriter.key("signalName").value(signalExternalWorkflowExecutionDecisionAttributesSignalExternalWorkflowExecutionDecisionAttributes.getSignalName()); + } + if (signalExternalWorkflowExecutionDecisionAttributesSignalExternalWorkflowExecutionDecisionAttributes.getInput() != null) { + jsonWriter.key("input").value(signalExternalWorkflowExecutionDecisionAttributesSignalExternalWorkflowExecutionDecisionAttributes.getInput()); + } + if (signalExternalWorkflowExecutionDecisionAttributesSignalExternalWorkflowExecutionDecisionAttributes.getControl() != null) { + jsonWriter.key("control").value(signalExternalWorkflowExecutionDecisionAttributesSignalExternalWorkflowExecutionDecisionAttributes.getControl()); + } + jsonWriter.endObject(); + } + } + if (decisionsListValue != null) { + RequestCancelExternalWorkflowExecutionDecisionAttributes requestCancelExternalWorkflowExecutionDecisionAttributesRequestCancelExternalWorkflowExecutionDecisionAttributes = decisionsListValue.getRequestCancelExternalWorkflowExecutionDecisionAttributes(); + if (requestCancelExternalWorkflowExecutionDecisionAttributesRequestCancelExternalWorkflowExecutionDecisionAttributes != null) { + jsonWriter.key("requestCancelExternalWorkflowExecutionDecisionAttributes").object(); + if (requestCancelExternalWorkflowExecutionDecisionAttributesRequestCancelExternalWorkflowExecutionDecisionAttributes.getWorkflowId() != null) { + jsonWriter.key("workflowId").value(requestCancelExternalWorkflowExecutionDecisionAttributesRequestCancelExternalWorkflowExecutionDecisionAttributes.getWorkflowId()); + } + if (requestCancelExternalWorkflowExecutionDecisionAttributesRequestCancelExternalWorkflowExecutionDecisionAttributes.getRunId() != null) { + jsonWriter.key("runId").value(requestCancelExternalWorkflowExecutionDecisionAttributesRequestCancelExternalWorkflowExecutionDecisionAttributes.getRunId()); + } + if (requestCancelExternalWorkflowExecutionDecisionAttributesRequestCancelExternalWorkflowExecutionDecisionAttributes.getControl() != null) { + jsonWriter.key("control").value(requestCancelExternalWorkflowExecutionDecisionAttributesRequestCancelExternalWorkflowExecutionDecisionAttributes.getControl()); + } + jsonWriter.endObject(); + } + } + if (decisionsListValue != null) { + StartChildWorkflowExecutionDecisionAttributes startChildWorkflowExecutionDecisionAttributesStartChildWorkflowExecutionDecisionAttributes = decisionsListValue.getStartChildWorkflowExecutionDecisionAttributes(); + if (startChildWorkflowExecutionDecisionAttributesStartChildWorkflowExecutionDecisionAttributes != null) { + jsonWriter.key("startChildWorkflowExecutionDecisionAttributes").object(); + if (startChildWorkflowExecutionDecisionAttributesStartChildWorkflowExecutionDecisionAttributes != null) { + WorkflowType workflowTypeWorkflowType = startChildWorkflowExecutionDecisionAttributesStartChildWorkflowExecutionDecisionAttributes.getWorkflowType(); + if (workflowTypeWorkflowType != null) { + jsonWriter.key("workflowType").object(); + if (workflowTypeWorkflowType.getName() != null) { + jsonWriter.key("name").value(workflowTypeWorkflowType.getName()); + } + if (workflowTypeWorkflowType.getVersion() != null) { + jsonWriter.key("version").value(workflowTypeWorkflowType.getVersion()); + } + jsonWriter.endObject(); + } + } + if (startChildWorkflowExecutionDecisionAttributesStartChildWorkflowExecutionDecisionAttributes.getWorkflowId() != null) { + jsonWriter.key("workflowId").value(startChildWorkflowExecutionDecisionAttributesStartChildWorkflowExecutionDecisionAttributes.getWorkflowId()); + } + if (startChildWorkflowExecutionDecisionAttributesStartChildWorkflowExecutionDecisionAttributes.getControl() != null) { + jsonWriter.key("control").value(startChildWorkflowExecutionDecisionAttributesStartChildWorkflowExecutionDecisionAttributes.getControl()); + } + if (startChildWorkflowExecutionDecisionAttributesStartChildWorkflowExecutionDecisionAttributes.getInput() != null) { + jsonWriter.key("input").value(startChildWorkflowExecutionDecisionAttributesStartChildWorkflowExecutionDecisionAttributes.getInput()); + } + if (startChildWorkflowExecutionDecisionAttributesStartChildWorkflowExecutionDecisionAttributes.getExecutionStartToCloseTimeout() != null) { + jsonWriter.key("executionStartToCloseTimeout").value(startChildWorkflowExecutionDecisionAttributesStartChildWorkflowExecutionDecisionAttributes.getExecutionStartToCloseTimeout()); + } + if (startChildWorkflowExecutionDecisionAttributesStartChildWorkflowExecutionDecisionAttributes != null) { + TaskList taskListTaskList = startChildWorkflowExecutionDecisionAttributesStartChildWorkflowExecutionDecisionAttributes.getTaskList(); + if (taskListTaskList != null) { + jsonWriter.key("taskList").object(); + if (taskListTaskList.getName() != null) { + jsonWriter.key("name").value(taskListTaskList.getName()); + } + jsonWriter.endObject(); + } + } + if (startChildWorkflowExecutionDecisionAttributesStartChildWorkflowExecutionDecisionAttributes.getTaskStartToCloseTimeout() != null) { + jsonWriter.key("taskStartToCloseTimeout").value(startChildWorkflowExecutionDecisionAttributesStartChildWorkflowExecutionDecisionAttributes.getTaskStartToCloseTimeout()); + } + if (startChildWorkflowExecutionDecisionAttributesStartChildWorkflowExecutionDecisionAttributes.getChildPolicy() != null) { + jsonWriter.key("childPolicy").value(startChildWorkflowExecutionDecisionAttributesStartChildWorkflowExecutionDecisionAttributes.getChildPolicy()); + } + if (startChildWorkflowExecutionDecisionAttributesStartChildWorkflowExecutionDecisionAttributes != null) { + java.util.List tagListList = startChildWorkflowExecutionDecisionAttributesStartChildWorkflowExecutionDecisionAttributes.getTagList(); + int tagListListIndex = 0; + if (tagListList != null && tagListList.size() > 0) { + jsonWriter.key("tagList").array(); + for (String tagListListValue : tagListList) { + if (tagListListValue != null) { + jsonWriter.value(tagListListValue); + } else jsonWriter.value(null); + tagListListIndex++; + } + jsonWriter.endArray(); + } + } + jsonWriter.endObject(); + } + } + jsonWriter.endObject(); + + decisionsListIndex++; + } + jsonWriter.endArray(); + } + } + if (respondDecisionTaskCompletedRequest.getExecutionContext() != null) { + jsonWriter.key("executionContext").value(respondDecisionTaskCompletedRequest.getExecutionContext()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RunJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RunJsonUnmarshaller.java new file mode 100644 index 000000000000..3edae56d9578 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/RunJsonUnmarshaller.java @@ -0,0 +1,66 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Run JSON Unmarshaller + */ +public class RunJsonUnmarshaller implements Unmarshaller { + + + + public Run unmarshall(JsonUnmarshallerContext context) throws Exception { + Run run = new Run(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return run; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("runId", targetDepth)) { + context.nextToken(); + run.setRunId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return run; + } + } + token = context.nextToken(); + } + } + + private static RunJsonUnmarshaller instance; + public static RunJsonUnmarshaller getInstance() { + if (instance == null) instance = new RunJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ScheduleActivityTaskFailedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ScheduleActivityTaskFailedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..dbd11fcb49ca --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/ScheduleActivityTaskFailedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,78 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Schedule Activity Task Failed Event Attributes JSON Unmarshaller + */ +public class ScheduleActivityTaskFailedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public ScheduleActivityTaskFailedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + ScheduleActivityTaskFailedEventAttributes scheduleActivityTaskFailedEventAttributes = new ScheduleActivityTaskFailedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return scheduleActivityTaskFailedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("activityType", targetDepth)) { + context.nextToken(); + scheduleActivityTaskFailedEventAttributes.setActivityType(ActivityTypeJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("activityId", targetDepth)) { + context.nextToken(); + scheduleActivityTaskFailedEventAttributes.setActivityId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("cause", targetDepth)) { + context.nextToken(); + scheduleActivityTaskFailedEventAttributes.setCause(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + scheduleActivityTaskFailedEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return scheduleActivityTaskFailedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static ScheduleActivityTaskFailedEventAttributesJsonUnmarshaller instance; + public static ScheduleActivityTaskFailedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new ScheduleActivityTaskFailedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/SignalExternalWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/SignalExternalWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..4b89537d9748 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/SignalExternalWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,86 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Signal External Workflow Execution Failed Event Attributes JSON Unmarshaller + */ +public class SignalExternalWorkflowExecutionFailedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public SignalExternalWorkflowExecutionFailedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + SignalExternalWorkflowExecutionFailedEventAttributes signalExternalWorkflowExecutionFailedEventAttributes = new SignalExternalWorkflowExecutionFailedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return signalExternalWorkflowExecutionFailedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("workflowId", targetDepth)) { + context.nextToken(); + signalExternalWorkflowExecutionFailedEventAttributes.setWorkflowId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("runId", targetDepth)) { + context.nextToken(); + signalExternalWorkflowExecutionFailedEventAttributes.setRunId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("cause", targetDepth)) { + context.nextToken(); + signalExternalWorkflowExecutionFailedEventAttributes.setCause(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("initiatedEventId", targetDepth)) { + context.nextToken(); + signalExternalWorkflowExecutionFailedEventAttributes.setInitiatedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + signalExternalWorkflowExecutionFailedEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("control", targetDepth)) { + context.nextToken(); + signalExternalWorkflowExecutionFailedEventAttributes.setControl(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return signalExternalWorkflowExecutionFailedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static SignalExternalWorkflowExecutionFailedEventAttributesJsonUnmarshaller instance; + public static SignalExternalWorkflowExecutionFailedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new SignalExternalWorkflowExecutionFailedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/SignalExternalWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/SignalExternalWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..19aa85f4282c --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/SignalExternalWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,86 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Signal External Workflow Execution Initiated Event Attributes JSON Unmarshaller + */ +public class SignalExternalWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public SignalExternalWorkflowExecutionInitiatedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + SignalExternalWorkflowExecutionInitiatedEventAttributes signalExternalWorkflowExecutionInitiatedEventAttributes = new SignalExternalWorkflowExecutionInitiatedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return signalExternalWorkflowExecutionInitiatedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("workflowId", targetDepth)) { + context.nextToken(); + signalExternalWorkflowExecutionInitiatedEventAttributes.setWorkflowId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("runId", targetDepth)) { + context.nextToken(); + signalExternalWorkflowExecutionInitiatedEventAttributes.setRunId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("signalName", targetDepth)) { + context.nextToken(); + signalExternalWorkflowExecutionInitiatedEventAttributes.setSignalName(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("input", targetDepth)) { + context.nextToken(); + signalExternalWorkflowExecutionInitiatedEventAttributes.setInput(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + signalExternalWorkflowExecutionInitiatedEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("control", targetDepth)) { + context.nextToken(); + signalExternalWorkflowExecutionInitiatedEventAttributes.setControl(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return signalExternalWorkflowExecutionInitiatedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static SignalExternalWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller instance; + public static SignalExternalWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new SignalExternalWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/SignalWorkflowExecutionRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/SignalWorkflowExecutionRequestMarshaller.java new file mode 100644 index 000000000000..47e69ab353e1 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/SignalWorkflowExecutionRequestMarshaller.java @@ -0,0 +1,85 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Signal Workflow Execution Request Marshaller + */ +public class SignalWorkflowExecutionRequestMarshaller implements Marshaller, SignalWorkflowExecutionRequest> { + + public Request marshall(SignalWorkflowExecutionRequest signalWorkflowExecutionRequest) { + if (signalWorkflowExecutionRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(signalWorkflowExecutionRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.SignalWorkflowExecution"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (signalWorkflowExecutionRequest.getDomain() != null) { + jsonWriter.key("domain").value(signalWorkflowExecutionRequest.getDomain()); + } + if (signalWorkflowExecutionRequest.getWorkflowId() != null) { + jsonWriter.key("workflowId").value(signalWorkflowExecutionRequest.getWorkflowId()); + } + if (signalWorkflowExecutionRequest.getRunId() != null) { + jsonWriter.key("runId").value(signalWorkflowExecutionRequest.getRunId()); + } + if (signalWorkflowExecutionRequest.getSignalName() != null) { + jsonWriter.key("signalName").value(signalWorkflowExecutionRequest.getSignalName()); + } + if (signalWorkflowExecutionRequest.getInput() != null) { + jsonWriter.key("input").value(signalWorkflowExecutionRequest.getInput()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/StartChildWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/StartChildWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..661aef9b9b6f --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/StartChildWorkflowExecutionFailedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,86 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Start Child Workflow Execution Failed Event Attributes JSON Unmarshaller + */ +public class StartChildWorkflowExecutionFailedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public StartChildWorkflowExecutionFailedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + StartChildWorkflowExecutionFailedEventAttributes startChildWorkflowExecutionFailedEventAttributes = new StartChildWorkflowExecutionFailedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return startChildWorkflowExecutionFailedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("workflowType", targetDepth)) { + context.nextToken(); + startChildWorkflowExecutionFailedEventAttributes.setWorkflowType(WorkflowTypeJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("cause", targetDepth)) { + context.nextToken(); + startChildWorkflowExecutionFailedEventAttributes.setCause(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowId", targetDepth)) { + context.nextToken(); + startChildWorkflowExecutionFailedEventAttributes.setWorkflowId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("initiatedEventId", targetDepth)) { + context.nextToken(); + startChildWorkflowExecutionFailedEventAttributes.setInitiatedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + startChildWorkflowExecutionFailedEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("control", targetDepth)) { + context.nextToken(); + startChildWorkflowExecutionFailedEventAttributes.setControl(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return startChildWorkflowExecutionFailedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static StartChildWorkflowExecutionFailedEventAttributesJsonUnmarshaller instance; + public static StartChildWorkflowExecutionFailedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new StartChildWorkflowExecutionFailedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/StartChildWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/StartChildWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..1b227580362d --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/StartChildWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,101 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Start Child Workflow Execution Initiated Event Attributes JSON Unmarshaller + */ +public class StartChildWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public StartChildWorkflowExecutionInitiatedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + StartChildWorkflowExecutionInitiatedEventAttributes startChildWorkflowExecutionInitiatedEventAttributes = new StartChildWorkflowExecutionInitiatedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return startChildWorkflowExecutionInitiatedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("workflowId", targetDepth)) { + context.nextToken(); + startChildWorkflowExecutionInitiatedEventAttributes.setWorkflowId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowType", targetDepth)) { + context.nextToken(); + startChildWorkflowExecutionInitiatedEventAttributes.setWorkflowType(WorkflowTypeJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("control", targetDepth)) { + context.nextToken(); + startChildWorkflowExecutionInitiatedEventAttributes.setControl(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("input", targetDepth)) { + context.nextToken(); + startChildWorkflowExecutionInitiatedEventAttributes.setInput(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("executionStartToCloseTimeout", targetDepth)) { + context.nextToken(); + startChildWorkflowExecutionInitiatedEventAttributes.setExecutionStartToCloseTimeout(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("taskList", targetDepth)) { + context.nextToken(); + startChildWorkflowExecutionInitiatedEventAttributes.setTaskList(TaskListJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + startChildWorkflowExecutionInitiatedEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("childPolicy", targetDepth)) { + context.nextToken(); + startChildWorkflowExecutionInitiatedEventAttributes.setChildPolicy(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("taskStartToCloseTimeout", targetDepth)) { + context.nextToken(); + startChildWorkflowExecutionInitiatedEventAttributes.setTaskStartToCloseTimeout(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("tagList", targetDepth)) { + startChildWorkflowExecutionInitiatedEventAttributes.setTagList(new ListUnmarshaller(StringJsonUnmarshaller.getInstance()).unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return startChildWorkflowExecutionInitiatedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static StartChildWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller instance; + public static StartChildWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new StartChildWorkflowExecutionInitiatedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/StartTimerFailedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/StartTimerFailedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..9c155faf7142 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/StartTimerFailedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Start Timer Failed Event Attributes JSON Unmarshaller + */ +public class StartTimerFailedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public StartTimerFailedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + StartTimerFailedEventAttributes startTimerFailedEventAttributes = new StartTimerFailedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return startTimerFailedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("timerId", targetDepth)) { + context.nextToken(); + startTimerFailedEventAttributes.setTimerId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("cause", targetDepth)) { + context.nextToken(); + startTimerFailedEventAttributes.setCause(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + startTimerFailedEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return startTimerFailedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static StartTimerFailedEventAttributesJsonUnmarshaller instance; + public static StartTimerFailedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new StartTimerFailedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/StartWorkflowExecutionRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/StartWorkflowExecutionRequestMarshaller.java new file mode 100644 index 000000000000..702b46677e95 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/StartWorkflowExecutionRequestMarshaller.java @@ -0,0 +1,125 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Start Workflow Execution Request Marshaller + */ +public class StartWorkflowExecutionRequestMarshaller implements Marshaller, StartWorkflowExecutionRequest> { + + public Request marshall(StartWorkflowExecutionRequest startWorkflowExecutionRequest) { + if (startWorkflowExecutionRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(startWorkflowExecutionRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.StartWorkflowExecution"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (startWorkflowExecutionRequest.getDomain() != null) { + jsonWriter.key("domain").value(startWorkflowExecutionRequest.getDomain()); + } + if (startWorkflowExecutionRequest.getWorkflowId() != null) { + jsonWriter.key("workflowId").value(startWorkflowExecutionRequest.getWorkflowId()); + } + if (startWorkflowExecutionRequest != null) { + WorkflowType workflowTypeWorkflowType = startWorkflowExecutionRequest.getWorkflowType(); + if (workflowTypeWorkflowType != null) { + jsonWriter.key("workflowType").object(); + if (workflowTypeWorkflowType.getName() != null) { + jsonWriter.key("name").value(workflowTypeWorkflowType.getName()); + } + if (workflowTypeWorkflowType.getVersion() != null) { + jsonWriter.key("version").value(workflowTypeWorkflowType.getVersion()); + } + jsonWriter.endObject(); + } + } + if (startWorkflowExecutionRequest != null) { + TaskList taskListTaskList = startWorkflowExecutionRequest.getTaskList(); + if (taskListTaskList != null) { + jsonWriter.key("taskList").object(); + if (taskListTaskList.getName() != null) { + jsonWriter.key("name").value(taskListTaskList.getName()); + } + jsonWriter.endObject(); + } + } + if (startWorkflowExecutionRequest.getInput() != null) { + jsonWriter.key("input").value(startWorkflowExecutionRequest.getInput()); + } + if (startWorkflowExecutionRequest.getExecutionStartToCloseTimeout() != null) { + jsonWriter.key("executionStartToCloseTimeout").value(startWorkflowExecutionRequest.getExecutionStartToCloseTimeout()); + } + if (startWorkflowExecutionRequest != null) { + java.util.List tagListList = startWorkflowExecutionRequest.getTagList(); + int tagListListIndex = 0; + if (tagListList != null && tagListList.size() > 0) { + jsonWriter.key("tagList").array(); + for (String tagListListValue : tagListList) { + if (tagListListValue != null) { + jsonWriter.value(tagListListValue); + } else jsonWriter.value(null); + tagListListIndex++; + } + jsonWriter.endArray(); + } + } + if (startWorkflowExecutionRequest.getTaskStartToCloseTimeout() != null) { + jsonWriter.key("taskStartToCloseTimeout").value(startWorkflowExecutionRequest.getTaskStartToCloseTimeout()); + } + if (startWorkflowExecutionRequest.getChildPolicy() != null) { + jsonWriter.key("childPolicy").value(startWorkflowExecutionRequest.getChildPolicy()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TaskListJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TaskListJsonUnmarshaller.java new file mode 100644 index 000000000000..421aaaa04073 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TaskListJsonUnmarshaller.java @@ -0,0 +1,66 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Task List JSON Unmarshaller + */ +public class TaskListJsonUnmarshaller implements Unmarshaller { + + + + public TaskList unmarshall(JsonUnmarshallerContext context) throws Exception { + TaskList taskList = new TaskList(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return taskList; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("name", targetDepth)) { + context.nextToken(); + taskList.setName(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return taskList; + } + } + token = context.nextToken(); + } + } + + private static TaskListJsonUnmarshaller instance; + public static TaskListJsonUnmarshaller getInstance() { + if (instance == null) instance = new TaskListJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TerminateWorkflowExecutionRequestMarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TerminateWorkflowExecutionRequestMarshaller.java new file mode 100644 index 000000000000..8a96ef8d4ece --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TerminateWorkflowExecutionRequestMarshaller.java @@ -0,0 +1,88 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.List; + +import com.amazonaws.AmazonClientException; +import com.amazonaws.Request; +import com.amazonaws.DefaultRequest; +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.Marshaller; +import com.amazonaws.util.StringUtils; +import com.amazonaws.util.StringInputStream; +import com.amazonaws.util.json.*; + +import static com.amazonaws.http.HttpMethodName.POST; + +/** + * Terminate Workflow Execution Request Marshaller + */ +public class TerminateWorkflowExecutionRequestMarshaller implements Marshaller, TerminateWorkflowExecutionRequest> { + + public Request marshall(TerminateWorkflowExecutionRequest terminateWorkflowExecutionRequest) { + if (terminateWorkflowExecutionRequest == null) { + throw new AmazonClientException("Invalid argument passed to marshall(...)"); + } + + Request request = new DefaultRequest(terminateWorkflowExecutionRequest, "AmazonSimpleWorkflow"); + String target = "SimpleWorkflowService.TerminateWorkflowExecution"; + request.addHeader("X-Amz-Target", target); + request.addHeader("Content-Type", "application/x-amz-json-1.0"); + request.setHttpMethod(POST); + + try { + StringWriter stringWriter = new StringWriter(); + JSONWriter jsonWriter = new JSONWriter(stringWriter); + jsonWriter.object(); + + if (terminateWorkflowExecutionRequest.getDomain() != null) { + jsonWriter.key("domain").value(terminateWorkflowExecutionRequest.getDomain()); + } + if (terminateWorkflowExecutionRequest.getWorkflowId() != null) { + jsonWriter.key("workflowId").value(terminateWorkflowExecutionRequest.getWorkflowId()); + } + if (terminateWorkflowExecutionRequest.getRunId() != null) { + jsonWriter.key("runId").value(terminateWorkflowExecutionRequest.getRunId()); + } + if (terminateWorkflowExecutionRequest.getReason() != null) { + jsonWriter.key("reason").value(terminateWorkflowExecutionRequest.getReason()); + } + if (terminateWorkflowExecutionRequest.getDetails() != null) { + jsonWriter.key("details").value(terminateWorkflowExecutionRequest.getDetails()); + } + if (terminateWorkflowExecutionRequest.getChildPolicy() != null) { + jsonWriter.key("childPolicy").value(terminateWorkflowExecutionRequest.getChildPolicy()); + } + + jsonWriter.endObject(); + + String snippet = stringWriter.toString(); + byte[] content = snippet.getBytes("UTF-8"); + request.setContent(new StringInputStream(snippet)); + request.addHeader("Content-Length", Integer.toString(content.length)); + return request; + } catch(Throwable t) { + throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); + } + } +} diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TimerCanceledEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TimerCanceledEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..9842cd04699a --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TimerCanceledEventAttributesJsonUnmarshaller.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Timer Canceled Event Attributes JSON Unmarshaller + */ +public class TimerCanceledEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public TimerCanceledEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + TimerCanceledEventAttributes timerCanceledEventAttributes = new TimerCanceledEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return timerCanceledEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("timerId", targetDepth)) { + context.nextToken(); + timerCanceledEventAttributes.setTimerId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startedEventId", targetDepth)) { + context.nextToken(); + timerCanceledEventAttributes.setStartedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + timerCanceledEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return timerCanceledEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static TimerCanceledEventAttributesJsonUnmarshaller instance; + public static TimerCanceledEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new TimerCanceledEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TimerFiredEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TimerFiredEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..32e0570028a8 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TimerFiredEventAttributesJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Timer Fired Event Attributes JSON Unmarshaller + */ +public class TimerFiredEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public TimerFiredEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + TimerFiredEventAttributes timerFiredEventAttributes = new TimerFiredEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return timerFiredEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("timerId", targetDepth)) { + context.nextToken(); + timerFiredEventAttributes.setTimerId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startedEventId", targetDepth)) { + context.nextToken(); + timerFiredEventAttributes.setStartedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return timerFiredEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static TimerFiredEventAttributesJsonUnmarshaller instance; + public static TimerFiredEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new TimerFiredEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TimerStartedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TimerStartedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..1412bd960200 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TimerStartedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,78 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Timer Started Event Attributes JSON Unmarshaller + */ +public class TimerStartedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public TimerStartedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + TimerStartedEventAttributes timerStartedEventAttributes = new TimerStartedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return timerStartedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("timerId", targetDepth)) { + context.nextToken(); + timerStartedEventAttributes.setTimerId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("control", targetDepth)) { + context.nextToken(); + timerStartedEventAttributes.setControl(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startToFireTimeout", targetDepth)) { + context.nextToken(); + timerStartedEventAttributes.setStartToFireTimeout(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + timerStartedEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return timerStartedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static TimerStartedEventAttributesJsonUnmarshaller instance; + public static TimerStartedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new TimerStartedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TypeAlreadyExistsExceptionUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TypeAlreadyExistsExceptionUnmarshaller.java new file mode 100644 index 000000000000..73c3e7cbf316 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TypeAlreadyExistsExceptionUnmarshaller.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + +import com.amazonaws.AmazonServiceException; +import com.amazonaws.transform.JsonErrorUnmarshaller; +import com.amazonaws.util.json.JSONObject; + +import com.amazonaws.services.simpleworkflow.model.TypeAlreadyExistsException; + +public class TypeAlreadyExistsExceptionUnmarshaller extends JsonErrorUnmarshaller { + + public TypeAlreadyExistsExceptionUnmarshaller() { + super(TypeAlreadyExistsException.class); + } + + public AmazonServiceException unmarshall(JSONObject json) throws Exception { + // Bail out if this isn't the right error code that this + // marshaller understands. + String errorCode = parseErrorCode(json); + if (errorCode == null || !errorCode.equals("TypeAlreadyExistsFault")) + return null; + + TypeAlreadyExistsException e = (TypeAlreadyExistsException)super.unmarshall(json); + + + + return e; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TypeDeprecatedExceptionUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TypeDeprecatedExceptionUnmarshaller.java new file mode 100644 index 000000000000..6cb7094ead3e --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/TypeDeprecatedExceptionUnmarshaller.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + +import com.amazonaws.AmazonServiceException; +import com.amazonaws.transform.JsonErrorUnmarshaller; +import com.amazonaws.util.json.JSONObject; + +import com.amazonaws.services.simpleworkflow.model.TypeDeprecatedException; + +public class TypeDeprecatedExceptionUnmarshaller extends JsonErrorUnmarshaller { + + public TypeDeprecatedExceptionUnmarshaller() { + super(TypeDeprecatedException.class); + } + + public AmazonServiceException unmarshall(JSONObject json) throws Exception { + // Bail out if this isn't the right error code that this + // marshaller understands. + String errorCode = parseErrorCode(json); + if (errorCode == null || !errorCode.equals("TypeDeprecatedFault")) + return null; + + TypeDeprecatedException e = (TypeDeprecatedException)super.unmarshall(json); + + + + return e; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/UnknownResourceExceptionUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/UnknownResourceExceptionUnmarshaller.java new file mode 100644 index 000000000000..85c980fac291 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/UnknownResourceExceptionUnmarshaller.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + +import com.amazonaws.AmazonServiceException; +import com.amazonaws.transform.JsonErrorUnmarshaller; +import com.amazonaws.util.json.JSONObject; + +import com.amazonaws.services.simpleworkflow.model.UnknownResourceException; + +public class UnknownResourceExceptionUnmarshaller extends JsonErrorUnmarshaller { + + public UnknownResourceExceptionUnmarshaller() { + super(UnknownResourceException.class); + } + + public AmazonServiceException unmarshall(JSONObject json) throws Exception { + // Bail out if this isn't the right error code that this + // marshaller understands. + String errorCode = parseErrorCode(json); + if (errorCode == null || !errorCode.equals("UnknownResourceFault")) + return null; + + UnknownResourceException e = (UnknownResourceException)super.unmarshall(json); + + + + return e; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionAlreadyStartedExceptionUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionAlreadyStartedExceptionUnmarshaller.java new file mode 100644 index 000000000000..2b6629499ba1 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionAlreadyStartedExceptionUnmarshaller.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.model.transform; + +import com.amazonaws.AmazonServiceException; +import com.amazonaws.transform.JsonErrorUnmarshaller; +import com.amazonaws.util.json.JSONObject; + +import com.amazonaws.services.simpleworkflow.model.WorkflowExecutionAlreadyStartedException; + +public class WorkflowExecutionAlreadyStartedExceptionUnmarshaller extends JsonErrorUnmarshaller { + + public WorkflowExecutionAlreadyStartedExceptionUnmarshaller() { + super(WorkflowExecutionAlreadyStartedException.class); + } + + public AmazonServiceException unmarshall(JSONObject json) throws Exception { + // Bail out if this isn't the right error code that this + // marshaller understands. + String errorCode = parseErrorCode(json); + if (errorCode == null || !errorCode.equals("WorkflowExecutionAlreadyStartedFault")) + return null; + + WorkflowExecutionAlreadyStartedException e = (WorkflowExecutionAlreadyStartedException)super.unmarshall(json); + + + + return e; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionCancelRequestedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionCancelRequestedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..c0e874b3e411 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionCancelRequestedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Execution Cancel Requested Event Attributes JSON Unmarshaller + */ +public class WorkflowExecutionCancelRequestedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowExecutionCancelRequestedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowExecutionCancelRequestedEventAttributes workflowExecutionCancelRequestedEventAttributes = new WorkflowExecutionCancelRequestedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowExecutionCancelRequestedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("externalWorkflowExecution", targetDepth)) { + context.nextToken(); + workflowExecutionCancelRequestedEventAttributes.setExternalWorkflowExecution(WorkflowExecutionJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("externalInitiatedEventId", targetDepth)) { + context.nextToken(); + workflowExecutionCancelRequestedEventAttributes.setExternalInitiatedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("cause", targetDepth)) { + context.nextToken(); + workflowExecutionCancelRequestedEventAttributes.setCause(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowExecutionCancelRequestedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static WorkflowExecutionCancelRequestedEventAttributesJsonUnmarshaller instance; + public static WorkflowExecutionCancelRequestedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowExecutionCancelRequestedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionCanceledEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionCanceledEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..0450b9a59a2c --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionCanceledEventAttributesJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Execution Canceled Event Attributes JSON Unmarshaller + */ +public class WorkflowExecutionCanceledEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowExecutionCanceledEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowExecutionCanceledEventAttributes workflowExecutionCanceledEventAttributes = new WorkflowExecutionCanceledEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowExecutionCanceledEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("details", targetDepth)) { + context.nextToken(); + workflowExecutionCanceledEventAttributes.setDetails(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + workflowExecutionCanceledEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowExecutionCanceledEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static WorkflowExecutionCanceledEventAttributesJsonUnmarshaller instance; + public static WorkflowExecutionCanceledEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowExecutionCanceledEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionCompletedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionCompletedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..52d0b6ae7365 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionCompletedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Execution Completed Event Attributes JSON Unmarshaller + */ +public class WorkflowExecutionCompletedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowExecutionCompletedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowExecutionCompletedEventAttributes workflowExecutionCompletedEventAttributes = new WorkflowExecutionCompletedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowExecutionCompletedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("result", targetDepth)) { + context.nextToken(); + workflowExecutionCompletedEventAttributes.setResult(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + workflowExecutionCompletedEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowExecutionCompletedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static WorkflowExecutionCompletedEventAttributesJsonUnmarshaller instance; + public static WorkflowExecutionCompletedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowExecutionCompletedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionConfigurationJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionConfigurationJsonUnmarshaller.java new file mode 100644 index 000000000000..72c8f6d51d88 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionConfigurationJsonUnmarshaller.java @@ -0,0 +1,78 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Execution Configuration JSON Unmarshaller + */ +public class WorkflowExecutionConfigurationJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowExecutionConfiguration unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowExecutionConfiguration workflowExecutionConfiguration = new WorkflowExecutionConfiguration(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowExecutionConfiguration; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("taskStartToCloseTimeout", targetDepth)) { + context.nextToken(); + workflowExecutionConfiguration.setTaskStartToCloseTimeout(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("executionStartToCloseTimeout", targetDepth)) { + context.nextToken(); + workflowExecutionConfiguration.setExecutionStartToCloseTimeout(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("taskList", targetDepth)) { + context.nextToken(); + workflowExecutionConfiguration.setTaskList(TaskListJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("childPolicy", targetDepth)) { + context.nextToken(); + workflowExecutionConfiguration.setChildPolicy(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowExecutionConfiguration; + } + } + token = context.nextToken(); + } + } + + private static WorkflowExecutionConfigurationJsonUnmarshaller instance; + public static WorkflowExecutionConfigurationJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowExecutionConfigurationJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionContinuedAsNewEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionContinuedAsNewEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..5d30f562a61a --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionContinuedAsNewEventAttributesJsonUnmarshaller.java @@ -0,0 +1,97 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Execution Continued As New Event Attributes JSON Unmarshaller + */ +public class WorkflowExecutionContinuedAsNewEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowExecutionContinuedAsNewEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowExecutionContinuedAsNewEventAttributes workflowExecutionContinuedAsNewEventAttributes = new WorkflowExecutionContinuedAsNewEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowExecutionContinuedAsNewEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("input", targetDepth)) { + context.nextToken(); + workflowExecutionContinuedAsNewEventAttributes.setInput(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + workflowExecutionContinuedAsNewEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("newExecutionRunId", targetDepth)) { + context.nextToken(); + workflowExecutionContinuedAsNewEventAttributes.setNewExecutionRunId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("executionStartToCloseTimeout", targetDepth)) { + context.nextToken(); + workflowExecutionContinuedAsNewEventAttributes.setExecutionStartToCloseTimeout(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("taskList", targetDepth)) { + context.nextToken(); + workflowExecutionContinuedAsNewEventAttributes.setTaskList(TaskListJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("taskStartToCloseTimeout", targetDepth)) { + context.nextToken(); + workflowExecutionContinuedAsNewEventAttributes.setTaskStartToCloseTimeout(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("childPolicy", targetDepth)) { + context.nextToken(); + workflowExecutionContinuedAsNewEventAttributes.setChildPolicy(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("tagList", targetDepth)) { + workflowExecutionContinuedAsNewEventAttributes.setTagList(new ListUnmarshaller(StringJsonUnmarshaller.getInstance()).unmarshall(context)); + } + if (context.testExpression("workflowType", targetDepth)) { + context.nextToken(); + workflowExecutionContinuedAsNewEventAttributes.setWorkflowType(WorkflowTypeJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowExecutionContinuedAsNewEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static WorkflowExecutionContinuedAsNewEventAttributesJsonUnmarshaller instance; + public static WorkflowExecutionContinuedAsNewEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowExecutionContinuedAsNewEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionCountJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionCountJsonUnmarshaller.java new file mode 100644 index 000000000000..f24ca1b36f4f --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionCountJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Execution Count JSON Unmarshaller + */ +public class WorkflowExecutionCountJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowExecutionCount unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowExecutionCount workflowExecutionCount = new WorkflowExecutionCount(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowExecutionCount; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("count", targetDepth)) { + context.nextToken(); + workflowExecutionCount.setCount(IntegerJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("truncated", targetDepth)) { + context.nextToken(); + workflowExecutionCount.setTruncated(BooleanJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowExecutionCount; + } + } + token = context.nextToken(); + } + } + + private static WorkflowExecutionCountJsonUnmarshaller instance; + public static WorkflowExecutionCountJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowExecutionCountJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionDetailJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionDetailJsonUnmarshaller.java new file mode 100644 index 000000000000..1c33ca587d63 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionDetailJsonUnmarshaller.java @@ -0,0 +1,82 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Execution Detail JSON Unmarshaller + */ +public class WorkflowExecutionDetailJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowExecutionDetail unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowExecutionDetail workflowExecutionDetail = new WorkflowExecutionDetail(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowExecutionDetail; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("executionInfo", targetDepth)) { + context.nextToken(); + workflowExecutionDetail.setExecutionInfo(WorkflowExecutionInfoJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("executionConfiguration", targetDepth)) { + context.nextToken(); + workflowExecutionDetail.setExecutionConfiguration(WorkflowExecutionConfigurationJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("openCounts", targetDepth)) { + context.nextToken(); + workflowExecutionDetail.setOpenCounts(WorkflowExecutionOpenCountsJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("latestActivityTaskTimestamp", targetDepth)) { + context.nextToken(); + workflowExecutionDetail.setLatestActivityTaskTimestamp(DateJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("latestExecutionContext", targetDepth)) { + context.nextToken(); + workflowExecutionDetail.setLatestExecutionContext(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowExecutionDetail; + } + } + token = context.nextToken(); + } + } + + private static WorkflowExecutionDetailJsonUnmarshaller instance; + public static WorkflowExecutionDetailJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowExecutionDetailJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionFailedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionFailedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..2f7edf167aea --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionFailedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Execution Failed Event Attributes JSON Unmarshaller + */ +public class WorkflowExecutionFailedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowExecutionFailedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowExecutionFailedEventAttributes workflowExecutionFailedEventAttributes = new WorkflowExecutionFailedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowExecutionFailedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("reason", targetDepth)) { + context.nextToken(); + workflowExecutionFailedEventAttributes.setReason(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("details", targetDepth)) { + context.nextToken(); + workflowExecutionFailedEventAttributes.setDetails(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("decisionTaskCompletedEventId", targetDepth)) { + context.nextToken(); + workflowExecutionFailedEventAttributes.setDecisionTaskCompletedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowExecutionFailedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static WorkflowExecutionFailedEventAttributesJsonUnmarshaller instance; + public static WorkflowExecutionFailedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowExecutionFailedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionInfoJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionInfoJsonUnmarshaller.java new file mode 100644 index 000000000000..bfca9c0a75c6 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionInfoJsonUnmarshaller.java @@ -0,0 +1,97 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Execution Info JSON Unmarshaller + */ +public class WorkflowExecutionInfoJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowExecutionInfo unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowExecutionInfo workflowExecutionInfo = new WorkflowExecutionInfo(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowExecutionInfo; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("execution", targetDepth)) { + context.nextToken(); + workflowExecutionInfo.setExecution(WorkflowExecutionJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowType", targetDepth)) { + context.nextToken(); + workflowExecutionInfo.setWorkflowType(WorkflowTypeJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("startTimestamp", targetDepth)) { + context.nextToken(); + workflowExecutionInfo.setStartTimestamp(DateJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("closeTimestamp", targetDepth)) { + context.nextToken(); + workflowExecutionInfo.setCloseTimestamp(DateJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("executionStatus", targetDepth)) { + context.nextToken(); + workflowExecutionInfo.setExecutionStatus(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("closeStatus", targetDepth)) { + context.nextToken(); + workflowExecutionInfo.setCloseStatus(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("parent", targetDepth)) { + context.nextToken(); + workflowExecutionInfo.setParent(WorkflowExecutionJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("tagList", targetDepth)) { + workflowExecutionInfo.setTagList(new ListUnmarshaller(StringJsonUnmarshaller.getInstance()).unmarshall(context)); + } + if (context.testExpression("cancelRequested", targetDepth)) { + context.nextToken(); + workflowExecutionInfo.setCancelRequested(BooleanJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowExecutionInfo; + } + } + token = context.nextToken(); + } + } + + private static WorkflowExecutionInfoJsonUnmarshaller instance; + public static WorkflowExecutionInfoJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowExecutionInfoJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionInfosJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionInfosJsonUnmarshaller.java new file mode 100644 index 000000000000..613d69093704 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionInfosJsonUnmarshaller.java @@ -0,0 +1,69 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Execution Infos JSON Unmarshaller + */ +public class WorkflowExecutionInfosJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowExecutionInfos unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowExecutionInfos workflowExecutionInfos = new WorkflowExecutionInfos(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowExecutionInfos; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("executionInfos", targetDepth)) { + workflowExecutionInfos.setExecutionInfos(new ListUnmarshaller(WorkflowExecutionInfoJsonUnmarshaller.getInstance()).unmarshall(context)); + } + if (context.testExpression("nextPageToken", targetDepth)) { + context.nextToken(); + workflowExecutionInfos.setNextPageToken(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowExecutionInfos; + } + } + token = context.nextToken(); + } + } + + private static WorkflowExecutionInfosJsonUnmarshaller instance; + public static WorkflowExecutionInfosJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowExecutionInfosJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionJsonUnmarshaller.java new file mode 100644 index 000000000000..4c62e8c7f098 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Execution JSON Unmarshaller + */ +public class WorkflowExecutionJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowExecution unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowExecution workflowExecution = new WorkflowExecution(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowExecution; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("workflowId", targetDepth)) { + context.nextToken(); + workflowExecution.setWorkflowId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("runId", targetDepth)) { + context.nextToken(); + workflowExecution.setRunId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowExecution; + } + } + token = context.nextToken(); + } + } + + private static WorkflowExecutionJsonUnmarshaller instance; + public static WorkflowExecutionJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowExecutionJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionOpenCountsJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionOpenCountsJsonUnmarshaller.java new file mode 100644 index 000000000000..1cc675a0d56b --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionOpenCountsJsonUnmarshaller.java @@ -0,0 +1,78 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Execution Open Counts JSON Unmarshaller + */ +public class WorkflowExecutionOpenCountsJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowExecutionOpenCounts unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowExecutionOpenCounts workflowExecutionOpenCounts = new WorkflowExecutionOpenCounts(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowExecutionOpenCounts; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("openActivityTasks", targetDepth)) { + context.nextToken(); + workflowExecutionOpenCounts.setOpenActivityTasks(IntegerJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("openDecisionTasks", targetDepth)) { + context.nextToken(); + workflowExecutionOpenCounts.setOpenDecisionTasks(IntegerJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("openTimers", targetDepth)) { + context.nextToken(); + workflowExecutionOpenCounts.setOpenTimers(IntegerJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("openChildWorkflowExecutions", targetDepth)) { + context.nextToken(); + workflowExecutionOpenCounts.setOpenChildWorkflowExecutions(IntegerJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowExecutionOpenCounts; + } + } + token = context.nextToken(); + } + } + + private static WorkflowExecutionOpenCountsJsonUnmarshaller instance; + public static WorkflowExecutionOpenCountsJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowExecutionOpenCountsJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionSignaledEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionSignaledEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..28b9099c3d77 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionSignaledEventAttributesJsonUnmarshaller.java @@ -0,0 +1,78 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Execution Signaled Event Attributes JSON Unmarshaller + */ +public class WorkflowExecutionSignaledEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowExecutionSignaledEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowExecutionSignaledEventAttributes workflowExecutionSignaledEventAttributes = new WorkflowExecutionSignaledEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowExecutionSignaledEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("signalName", targetDepth)) { + context.nextToken(); + workflowExecutionSignaledEventAttributes.setSignalName(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("input", targetDepth)) { + context.nextToken(); + workflowExecutionSignaledEventAttributes.setInput(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("externalWorkflowExecution", targetDepth)) { + context.nextToken(); + workflowExecutionSignaledEventAttributes.setExternalWorkflowExecution(WorkflowExecutionJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("externalInitiatedEventId", targetDepth)) { + context.nextToken(); + workflowExecutionSignaledEventAttributes.setExternalInitiatedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowExecutionSignaledEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static WorkflowExecutionSignaledEventAttributesJsonUnmarshaller instance; + public static WorkflowExecutionSignaledEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowExecutionSignaledEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionStartedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionStartedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..692207a9460e --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionStartedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,101 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Execution Started Event Attributes JSON Unmarshaller + */ +public class WorkflowExecutionStartedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowExecutionStartedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowExecutionStartedEventAttributes workflowExecutionStartedEventAttributes = new WorkflowExecutionStartedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowExecutionStartedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("input", targetDepth)) { + context.nextToken(); + workflowExecutionStartedEventAttributes.setInput(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("executionStartToCloseTimeout", targetDepth)) { + context.nextToken(); + workflowExecutionStartedEventAttributes.setExecutionStartToCloseTimeout(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("taskStartToCloseTimeout", targetDepth)) { + context.nextToken(); + workflowExecutionStartedEventAttributes.setTaskStartToCloseTimeout(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("childPolicy", targetDepth)) { + context.nextToken(); + workflowExecutionStartedEventAttributes.setChildPolicy(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("taskList", targetDepth)) { + context.nextToken(); + workflowExecutionStartedEventAttributes.setTaskList(TaskListJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("workflowType", targetDepth)) { + context.nextToken(); + workflowExecutionStartedEventAttributes.setWorkflowType(WorkflowTypeJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("tagList", targetDepth)) { + workflowExecutionStartedEventAttributes.setTagList(new ListUnmarshaller(StringJsonUnmarshaller.getInstance()).unmarshall(context)); + } + if (context.testExpression("continuedExecutionRunId", targetDepth)) { + context.nextToken(); + workflowExecutionStartedEventAttributes.setContinuedExecutionRunId(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("parentWorkflowExecution", targetDepth)) { + context.nextToken(); + workflowExecutionStartedEventAttributes.setParentWorkflowExecution(WorkflowExecutionJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("parentInitiatedEventId", targetDepth)) { + context.nextToken(); + workflowExecutionStartedEventAttributes.setParentInitiatedEventId(LongJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowExecutionStartedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static WorkflowExecutionStartedEventAttributesJsonUnmarshaller instance; + public static WorkflowExecutionStartedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowExecutionStartedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionTerminatedEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionTerminatedEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..b6490b5f2070 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionTerminatedEventAttributesJsonUnmarshaller.java @@ -0,0 +1,78 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Execution Terminated Event Attributes JSON Unmarshaller + */ +public class WorkflowExecutionTerminatedEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowExecutionTerminatedEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowExecutionTerminatedEventAttributes workflowExecutionTerminatedEventAttributes = new WorkflowExecutionTerminatedEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowExecutionTerminatedEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("reason", targetDepth)) { + context.nextToken(); + workflowExecutionTerminatedEventAttributes.setReason(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("details", targetDepth)) { + context.nextToken(); + workflowExecutionTerminatedEventAttributes.setDetails(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("childPolicy", targetDepth)) { + context.nextToken(); + workflowExecutionTerminatedEventAttributes.setChildPolicy(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("cause", targetDepth)) { + context.nextToken(); + workflowExecutionTerminatedEventAttributes.setCause(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowExecutionTerminatedEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static WorkflowExecutionTerminatedEventAttributesJsonUnmarshaller instance; + public static WorkflowExecutionTerminatedEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowExecutionTerminatedEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionTimedOutEventAttributesJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionTimedOutEventAttributesJsonUnmarshaller.java new file mode 100644 index 000000000000..ac655b40ba1e --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowExecutionTimedOutEventAttributesJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Execution Timed Out Event Attributes JSON Unmarshaller + */ +public class WorkflowExecutionTimedOutEventAttributesJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowExecutionTimedOutEventAttributes unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowExecutionTimedOutEventAttributes workflowExecutionTimedOutEventAttributes = new WorkflowExecutionTimedOutEventAttributes(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowExecutionTimedOutEventAttributes; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("timeoutType", targetDepth)) { + context.nextToken(); + workflowExecutionTimedOutEventAttributes.setTimeoutType(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("childPolicy", targetDepth)) { + context.nextToken(); + workflowExecutionTimedOutEventAttributes.setChildPolicy(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowExecutionTimedOutEventAttributes; + } + } + token = context.nextToken(); + } + } + + private static WorkflowExecutionTimedOutEventAttributesJsonUnmarshaller instance; + public static WorkflowExecutionTimedOutEventAttributesJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowExecutionTimedOutEventAttributesJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowTypeConfigurationJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowTypeConfigurationJsonUnmarshaller.java new file mode 100644 index 000000000000..f260764f64f0 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowTypeConfigurationJsonUnmarshaller.java @@ -0,0 +1,78 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Type Configuration JSON Unmarshaller + */ +public class WorkflowTypeConfigurationJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowTypeConfiguration unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowTypeConfiguration workflowTypeConfiguration = new WorkflowTypeConfiguration(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowTypeConfiguration; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("defaultTaskStartToCloseTimeout", targetDepth)) { + context.nextToken(); + workflowTypeConfiguration.setDefaultTaskStartToCloseTimeout(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("defaultExecutionStartToCloseTimeout", targetDepth)) { + context.nextToken(); + workflowTypeConfiguration.setDefaultExecutionStartToCloseTimeout(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("defaultTaskList", targetDepth)) { + context.nextToken(); + workflowTypeConfiguration.setDefaultTaskList(TaskListJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("defaultChildPolicy", targetDepth)) { + context.nextToken(); + workflowTypeConfiguration.setDefaultChildPolicy(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowTypeConfiguration; + } + } + token = context.nextToken(); + } + } + + private static WorkflowTypeConfigurationJsonUnmarshaller instance; + public static WorkflowTypeConfigurationJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowTypeConfigurationJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowTypeDetailJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowTypeDetailJsonUnmarshaller.java new file mode 100644 index 000000000000..ed17f6bd03cb --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowTypeDetailJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Type Detail JSON Unmarshaller + */ +public class WorkflowTypeDetailJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowTypeDetail unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowTypeDetail workflowTypeDetail = new WorkflowTypeDetail(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowTypeDetail; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("typeInfo", targetDepth)) { + context.nextToken(); + workflowTypeDetail.setTypeInfo(WorkflowTypeInfoJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("configuration", targetDepth)) { + context.nextToken(); + workflowTypeDetail.setConfiguration(WorkflowTypeConfigurationJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowTypeDetail; + } + } + token = context.nextToken(); + } + } + + private static WorkflowTypeDetailJsonUnmarshaller instance; + public static WorkflowTypeDetailJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowTypeDetailJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowTypeInfoJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowTypeInfoJsonUnmarshaller.java new file mode 100644 index 000000000000..2bf76bd592dd --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowTypeInfoJsonUnmarshaller.java @@ -0,0 +1,82 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Type Info JSON Unmarshaller + */ +public class WorkflowTypeInfoJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowTypeInfo unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowTypeInfo workflowTypeInfo = new WorkflowTypeInfo(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowTypeInfo; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("workflowType", targetDepth)) { + context.nextToken(); + workflowTypeInfo.setWorkflowType(WorkflowTypeJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("status", targetDepth)) { + context.nextToken(); + workflowTypeInfo.setStatus(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("description", targetDepth)) { + context.nextToken(); + workflowTypeInfo.setDescription(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("creationDate", targetDepth)) { + context.nextToken(); + workflowTypeInfo.setCreationDate(DateJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("deprecationDate", targetDepth)) { + context.nextToken(); + workflowTypeInfo.setDeprecationDate(DateJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowTypeInfo; + } + } + token = context.nextToken(); + } + } + + private static WorkflowTypeInfoJsonUnmarshaller instance; + public static WorkflowTypeInfoJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowTypeInfoJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowTypeInfosJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowTypeInfosJsonUnmarshaller.java new file mode 100644 index 000000000000..54005166f2ad --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowTypeInfosJsonUnmarshaller.java @@ -0,0 +1,69 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Type Infos JSON Unmarshaller + */ +public class WorkflowTypeInfosJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowTypeInfos unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowTypeInfos workflowTypeInfos = new WorkflowTypeInfos(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowTypeInfos; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("typeInfos", targetDepth)) { + workflowTypeInfos.setTypeInfos(new ListUnmarshaller(WorkflowTypeInfoJsonUnmarshaller.getInstance()).unmarshall(context)); + } + if (context.testExpression("nextPageToken", targetDepth)) { + context.nextToken(); + workflowTypeInfos.setNextPageToken(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowTypeInfos; + } + } + token = context.nextToken(); + } + } + + private static WorkflowTypeInfosJsonUnmarshaller instance; + public static WorkflowTypeInfosJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowTypeInfosJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowTypeJsonUnmarshaller.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowTypeJsonUnmarshaller.java new file mode 100644 index 000000000000..18cfad2640c1 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/WorkflowTypeJsonUnmarshaller.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package com.amazonaws.services.simpleworkflow.model.transform; + +import java.util.Map; +import java.util.Map.Entry; + +import com.amazonaws.services.simpleworkflow.model.*; +import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*; +import com.amazonaws.transform.*; + +import org.codehaus.jackson.JsonToken; +import static org.codehaus.jackson.JsonToken.*; + +/** + * Workflow Type JSON Unmarshaller + */ +public class WorkflowTypeJsonUnmarshaller implements Unmarshaller { + + + + public WorkflowType unmarshall(JsonUnmarshallerContext context) throws Exception { + WorkflowType workflowType = new WorkflowType(); + int originalDepth = context.getCurrentDepth(); + int targetDepth = originalDepth + 1; + + JsonToken token = context.currentToken; + if (token == null) token = context.nextToken(); + + while (true) { + if (token == null) return workflowType; + + if (token == FIELD_NAME || token == START_OBJECT) { + if (context.testExpression("name", targetDepth)) { + context.nextToken(); + workflowType.setName(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + if (context.testExpression("version", targetDepth)) { + context.nextToken(); + workflowType.setVersion(StringJsonUnmarshaller.getInstance().unmarshall(context)); + } + } else if (token == END_ARRAY || token == END_OBJECT) { + if (context.getCurrentDepth() <= originalDepth) { + return workflowType; + } + } + token = context.nextToken(); + } + } + + private static WorkflowTypeJsonUnmarshaller instance; + public static WorkflowTypeJsonUnmarshaller getInstance() { + if (instance == null) instance = new WorkflowTypeJsonUnmarshaller(); + return instance; + } +} + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/package-info.java b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/package-info.java new file mode 100644 index 000000000000..79f0f783d3b4 --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/model/transform/package-info.java @@ -0,0 +1,6 @@ + +/** + * Marhsalling for the various types represented by AmazonSimpleWorkflow. + */ + package com.amazonaws.services.simpleworkflow.model.transform; + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/services/simpleworkflow/package-info.java b/src/main/java/com/amazonaws/services/simpleworkflow/package-info.java new file mode 100644 index 000000000000..55aa0f0bb0cd --- /dev/null +++ b/src/main/java/com/amazonaws/services/simpleworkflow/package-info.java @@ -0,0 +1,310 @@ + +/** + * Synchronous and asynchronous client classes for accessing AmazonSimpleWorkflow. + * + * Amazon Simple Workflow Service

+ * The Amazon Simple Workflow Service API Reference is intended for + * programmers who need detailed information about the Amazon SWF actions + * and data types. + *

+ *

+ * For an broader overview of the Amazon SWF programming model, please + * go to the + * Amazon SWF Developer Guide . + *

+ *

+ * This section provides an overview of Amazon SWF actions. + *

+ *

+ * Action Categories + *

+ *

+ * The Amazon SWF actions can be grouped into the following major + * categories. + *

+ * + *
    + *
  • + * Actions related to Activities + *

    + *
  • + *
  • + * Actions related to Deciders + *

    + *
  • + *
  • + * Actions related to Workflow Executions + *

    + *
  • + *
  • + * Actions related to Administration + *

    + *
  • + *
  • + * Actions related to Visibility + *

    + *
  • + * + *
+ *

+ * Actions related to Activities + *

+ *

+ * The following are actions that are performed by activity workers: + *

+ * + *
    + *
  • + * PollForActivityTask + *

    + *
  • + *
  • + * RespondActivityTaskCompleted + *

    + *
  • + *
  • + * RespondActivityTaskFailed + *

    + *
  • + *
  • + * RespondActivityTaskCanceled + *

    + *
  • + *
  • + * RecordActivityTaskHeartbeat + *

    + *
  • + * + *
+ *

+ * Activity workers use the PollForActivityTask to get new activity + * tasks. After a worker receives an activity task from Amazon SWF, it + * performs the task and responds using RespondActivityTaskCompleted if + * successful or RespondActivityTaskFailed if unsuccessful. + *

+ *

+ * Actions related to Deciders + *

+ *

+ * The following are actions that are performed by deciders: + *

+ * + *
    + *
  • + * PollForDecisionTask + *

    + *
  • + *
  • + * RespondDecisionTaskCompleted + *

    + *
  • + * + *
+ *

+ * Deciders use PollForDecisionTask to get decision tasks. After a + * decider receives a decision task from Amazon SWF, it examines its + * workflow execution history and decides what to do next. It calls + * RespondDecisionTaskCompletedto complete the decision task and provide + * zero or more next decisions. + *

+ *

+ * Actions related to Workflow Executions + *

+ *

+ * The following actions operate on a workflow execution: + *

+ * + *
    + *
  • + * RequestCancelWorkflowExecution + *

    + *
  • + *
  • + * StartWorkflowExecution + *

    + *
  • + *
  • + * SignalWorkflowExecution + *

    + *
  • + *
  • + * TerminateWorkflowExecution + *

    + *
  • + * + *
+ *

+ * Actions related to Administration + *

+ *

+ * Although you can perform administrative tasks from the Amazon SWF + * console, you can use the actions in this section to automate functions + * or build your own administrative tools. + *

+ *

+ * Activity Management + *

+ * + *
    + *
  • + * RegisterActivityType + *

    + *
  • + *
  • + * DeprecateActivityType + *

    + *
  • + * + *
+ *

+ * Workflow Management + *

+ * + *
    + *
  • + * RegisterWorkflowType + *

    + *
  • + *
  • + * DeprecateWorkflowType + *

    + *
  • + * + *
+ *

+ * Domain Management + *

+ * + *
    + *
  • + * RegisterDomain + *

    + *
  • + *
  • + * DeprecateDomain + *

    + *
  • + * + *
+ *

+ * Workflow Execution Management + *

+ * + *
    + *
  • + * RequestCancelWorkflowExecution + *

    + *
  • + *
  • + * TerminateWorkflowExecution + *

    + *
  • + * + *
+ *

+ * Visibility Actions + *

+ *

+ * Although you can perform visibility actions from the Amazon SWF + * console, you can use the actions in this section to build your own + * console or administrative tools. + *

+ * + *
    + * + *
+ *

+ * Activity Visibility + *

+ * + *
    + *
  • + * ListActivityTypes + *

    + *
  • + *
  • + * DescribeActivity + *

    + *
  • + * + *
+ *

+ * Workflow Visibility + *

+ * + *
    + *
  • + * ListWorkflowTypes + *

    + *
  • + *
  • + * DescribeWorkflowType + *

    + *
  • + * + *
+ *

+ * Workflow Execution Visibility + *

+ * + *
    + *
  • + * DescribeWorkflowExecution + *

    + *
  • + *
  • + * ListOpenWorkflowExecutions + *

    + *
  • + *
  • + * ListClosedWorkflowExecutions + *

    + *
  • + *
  • + * CountOpenWorkflowExecutions + *

    + *
  • + *
  • + * CountClosedWorkflowExecutions + *

    + *
  • + *
  • + * GetWorkflowExecutionHistory + *

    + *
  • + * + *
+ *

+ * Domain Visibility + *

+ * + *
    + *
  • + * ListDomains + *

    + *
  • + *
  • + * DescribeDomain + *

    + *
  • + * + *
+ *

+ * Task List Visibility + *

+ * + *
    + *
  • + * CountPendingActivityTasks + *

    + *
  • + *
  • + * CountPendingDecisionTasks + *

    + *
  • + * + *
+ */ + package com.amazonaws.services.simpleworkflow; + \ No newline at end of file diff --git a/src/main/java/com/amazonaws/transform/JsonUnmarshallerContext.java b/src/main/java/com/amazonaws/transform/JsonUnmarshallerContext.java index d0fc4e599f66..ca92d26c590f 100644 --- a/src/main/java/com/amazonaws/transform/JsonUnmarshallerContext.java +++ b/src/main/java/com/amazonaws/transform/JsonUnmarshallerContext.java @@ -43,7 +43,10 @@ public class JsonUnmarshallerContext { private Map metadata = new HashMap(); private List metadataExpressions = new ArrayList(); + public JsonToken currentToken; + private JsonToken nextToken; + public JsonUnmarshallerContext(JsonParser jsonParser) { this.jsonParser = jsonParser; @@ -62,6 +65,14 @@ public int getCurrentDepth() { return depth; } + /** + * Returns the text of the current token, or throws an exception if + * the current token does not contain text (ex: '{', '}', etc.). + * + * @return The text of the current token. + * + * @throws IOException + */ public String readText() throws IOException { switch (currentToken) { case VALUE_STRING: @@ -107,33 +118,48 @@ public boolean testExpression(String expression) { * * @param expression * The psuedo-xpath expression to test. - * @param startingStackDepth + * @param stackDepth * The depth in the stack representing where the expression must * start matching in order for this method to return true. * * @return True if the specified expression matches the current position in * the JSON document, starting from the specified depth. */ - public boolean testExpression(String expression, int startingStackDepth) { + public boolean testExpression(String expression, int stackDepth) { if (expression.equals(".")) return true; int index = -1; while ((index = expression.indexOf("/", index + 1)) > -1) { // Don't consider attributes a new depth level if (expression.charAt(index + 1) != '@') { - startingStackDepth++; + stackDepth++; } } - return stackString.endsWith("/" + expression); + return stackString.endsWith("/" + expression) && + stackDepth == getCurrentDepth(); } public JsonToken nextToken() throws IOException { - JsonToken token = jsonParser.nextToken(); - updateContext(token); + // Use the value from the nextToken field if + // we've already populated it to peek ahead. + JsonToken token = (nextToken != null) ? + nextToken : jsonParser.nextToken(); + + this.currentToken = token; + nextToken = null; + + updateContext(); return token; } + public JsonToken peek() throws IOException { + if (nextToken != null) return nextToken; + + nextToken = jsonParser.nextToken(); + return nextToken; + } + /** * Returns any metadata collected through metadata expressions while this * context was reading the JSON events from the JSON document. @@ -185,21 +211,20 @@ public MetadataExpression(String expression, int targetDepth, String key) { } } - private void updateContext(JsonToken token) throws IOException { - if (token == null) return; - this.currentToken = token; + private void updateContext() throws IOException { + if (currentToken == null) return; - if (token == START_OBJECT || token == START_ARRAY) { + if (currentToken == START_OBJECT || currentToken == START_ARRAY) { if (currentField != null) { stack.push(currentField); currentField = null; - } else { - stack.push(token.toString()); } - } else if (token == END_OBJECT || token == END_ARRAY) { - if (stack.isEmpty() == false) stack.pop(); - currentField = null; - } else if (token == FIELD_NAME) { + } else if (currentToken == END_OBJECT || currentToken == END_ARRAY) { + if (!stack.isEmpty()) { + stack.pop(); + } + currentField = null; + } else if (currentToken == FIELD_NAME) { String t = jsonParser.getText(); currentField = t; } @@ -213,7 +238,8 @@ public String toString() { } private void rebuildStackString() { - stackString = ""; + stackString = ""; + for (String s : stack) { stackString += "/" + s; } @@ -221,5 +247,7 @@ private void rebuildStackString() { if (currentField != null) { stackString += "/" + currentField; } + + if (stackString == "") stackString = "/"; } } diff --git a/src/main/java/com/amazonaws/transform/MapUnmarshaller.java b/src/main/java/com/amazonaws/transform/MapUnmarshaller.java index 676007e365be..af0d7de58fe4 100644 --- a/src/main/java/com/amazonaws/transform/MapUnmarshaller.java +++ b/src/main/java/com/amazonaws/transform/MapUnmarshaller.java @@ -37,7 +37,6 @@ public MapUnmarshaller(Unmarshaller keyUnmarshaller, public Map unmarshall(JsonUnmarshallerContext context) throws Exception { Map map = new HashMap(); int originalDepth = context.getCurrentDepth(); - int targetDepth = originalDepth + 1; while (true) { JsonToken token = context.nextToken(); @@ -48,7 +47,7 @@ public Map unmarshall(JsonUnmarshallerContext context) throws Exception { V v = valueUnmarshaller.unmarshall(context); map.put(k, v); } else if (token == END_ARRAY || token == END_OBJECT) { - if (context.getCurrentDepth() < originalDepth) return map; + if (context.getCurrentDepth() <= originalDepth) return map; } } } diff --git a/src/main/resources/com/amazonaws/sdk/versionInfo.properties b/src/main/resources/com/amazonaws/sdk/versionInfo.properties index 1fd90eade300..5eed8aa54a65 100644 --- a/src/main/resources/com/amazonaws/sdk/versionInfo.properties +++ b/src/main/resources/com/amazonaws/sdk/versionInfo.properties @@ -1,2 +1,2 @@ -version = 1.3.2 +version = 1.3.3 platform = java diff --git a/src/samples/AwsFlowFramework/README.html b/src/samples/AwsFlowFramework/README.html new file mode 100644 index 000000000000..60b7c5559772 --- /dev/null +++ b/src/samples/AwsFlowFramework/README.html @@ -0,0 +1,200 @@ + + + + +Readme: AWS Flow Framework for Java Samples + + + +

AWS Flow Framework Samples

+These samples demonstrate how to use AWS Flow Framework. The following samples are included: +
    +
  • HelloWorld � this sample includes a very simple workflow that calls an activity to print hello world to the console. It shows the basic usage of AWS Flow Framework, including defining contracts, implementation of activities and workflow coordination logic and worker programs to host them.
  • +
  • Booking � shows an example workflow for making a reservation, including flight and rental car.
  • +
  • FileProcessing � shows a workflow for media processing use case. The sample workflow downloads a file from an Amazon S3 bucket, creates a zip file and uploads that zip file back to S3. The sample uses the task routing feature.
  • +
  • PeriodicWorkflow � shows how to create a workflow that periodically executes an activity. The workflow can run for extended periods and hence it uses the continue as new execution feature.
  • +
  • SplitMerge � the workflow in this sample processes a large data set by splitting it up into smaller data sets. The sample calculates the average of a large set of numbers stored in a file in S3. The smaller data sets are assigned to workers and the results of processing are merged to produce the final result.
  • +
  • Deployment � the workflow in this sample shows deployment of interdependent components.
  • +
+

Prerequisites

+
    +
  • You must have a valid Amazon Web Services developer account.
  • +
  • Requires the AWS SDK for Java. For more information on the AWS SDK for Java, see http://aws.amazon.com/sdkforjava.
  • +
  • You must be signed up for the following services: + +
  • +
  • JUnit (version 4.7) is required to run the samples. The jar file must be in the classpath. For more information, see http://www.junit.org/
  • +
  • org.springframework.test (version 3.0) is required to run the samples. The jar file must be in the classpath. For more information, see http://www.springsource.org/
  • +
  • Log4j (version 1.2.15) is required to run the samples. The jar file must be in the classpath. For more information, see http://logging.apache.org/log4j/1.2/
  • +
+

Running the Samples

+

The steps for running the AWS Flow Framework samples are:

+
    +
  1. Create the Samples domain +
      +
    1. Go to the SWF Management Console (https://console.aws.amazon.com/swf/home).
    2. +
    3. Follow the on-screen instructions to log in.
    4. +
    5. Click Manage Domains and register a new domain with the name Samples.
    6. +
    + +
  2. +
  3. Open the access.properties in the samples folder.
  4. +
  5. Locate the following sections and fill in your Access Key ID and Secret Access Key. You can use the same values for SWF and S3:
    +
    + # Fill in your AWS Access Key ID and Secret Access Key for SWF +# http://aws.amazon.com/security-credentials
    +AWS.Access.ID=<Your AWS Access Key>
    +AWS.Secret.Key=<Your AWS Secret Key>
    +AWS.Account.ID=<Your AWS Account ID>
    +
    +# Fill in your AWS Access Key ID and Secret Access Key for S3
    +# http://aws.amazon.com/security-credentials
    +S3.Access.ID=<Your AWS Access Key>
    +S3.Secret.Key=<Your AWS Secret Key>
    +S3.Account.ID=<Your AWS Account ID>
    +

    +
  6. + +
  7. Some samples upload files to S3. Locate the following section and fill in the name of S3 bucket that you want the samples to use:
    +####### FileProcessing Sample Config Values ##########
    +Workflow.Input.TargetBucketName=<Your S3 bucket name>

    + +
  8. + +
  9. Save the file.
  10. +
  11. Set the environment variable AWS_SWF_SAMPLES_CONFIG to the full path of the directory containing the access.properties file. For example on windows run this command:
    + set AWS_SWF_SAMPLES_CONFIG=<Your SDK Directrory>/samples/AwsFlowFramework

    + and on linux use this command to set the environment variable:
    + export AWS_SWF_SAMPLES_CONFIG=<Your SDK Directrory>/samples/AwsFlowFramework + +
  12. +
  13. Compile the samples by using the Ant build.xml file. This will create binaries in bin directory under the samples directory.
  14. +
  15. To run the samples follow these instructions:
    +Hello World Sample:
    +The sample has three executables. You should run each in a separate terminal/console.
    +Run: ant -f build.xml -Dmain-class="com.amazonaws.services.simpleworkflow.flow.examples.helloworld.ActivityHost" run
    +Run: ant -f build.xml -Dmain-class="com.amazonaws.services.simpleworkflow.flow.examples.helloworld.WorkflowHost" run
    +Run: ant -f build.xml -Dmain-class="com.amazonaws.services.simpleworkflow.flow.examples.helloworld.WorkflowExecutionStarter" run
    +
    +Booking Sample:
    +The sample has three executables. You should run each in a separate terminal/console. From the samples folder,
    +Run: ant -f build.xml -Dmain-class="com.amazonaws.services.simpleworkflow.flow.examples.booking.ActivityHost" run
    +Run: ant -f build.xml -Dmain-class="com.amazonaws.services.simpleworkflow.flow.examples.booking.WorkflowHost" run
    +Run: ant -f build.xml -Dmain-class="com.amazonaws.services.simpleworkflow.flow.examples.booking.WorkflowExecutionStarter" run
    +
    +Split Merge Sample:
    +The sample has three executables. You should run each in a separate terminal/console. From the samples folder,
    +Run: ant -f build.xml -Dmain-class="com.amazonaws.services.simpleworkflow.flow.examples.splitmerge.ActivityHost" run
    +Run: ant -f build.xml -Dmain-class="com.amazonaws.services.simpleworkflow.flow.examples.splitmerge.WorkflowHost" run
    +Run: ant -f build.xml -Dmain-class="com.amazonaws.services.simpleworkflow.flow.examples.splitmerge.WorkflowExecutionStarter" run
    +
    +Periodic Workflow Sample:
    +The sample has three executables. You should run each in a separate terminal/console. From the samples folder,
    +Run: ant -f build.xml -Dmain-class="com.amazonaws.services.simpleworkflow.flow.examples.periodicworkflow.ActivityHost" run
    +Run: ant -f build.xml -Dmain-class="com.amazonaws.services.simpleworkflow.flow.examples.periodicworkflow.WorkflowHost" run
    +Run: ant -f build.xml -Dmain-class="com.amazonaws.services.simpleworkflow.flow.examples.periodicworkflow.WorkflowExecutionStarter" run
    +
    +File Processing Sample:
    +The sample has three executables. You should run each in a separate terminal/console. From the samples folder,
    +Run: ant -f build.xml -Dmain-class="com.amazonaws.services.simpleworkflow.flow.examples.fileprocessing.ActivityHost" run
    +Run: ant -f build.xml -Dmain-class="com.amazonaws.services.simpleworkflow.flow.examples.fileprocessing.WorkflowHost" run
    +Run: ant -f build.xml -Dmain-class="com.amazonaws.services.simpleworkflow.flow.examples.fileprocessing.WorkflowExecutionStarter" run
    +
    +
  16. +
+ + diff --git a/src/samples/AwsFlowFramework/access.properties b/src/samples/AwsFlowFramework/access.properties new file mode 100644 index 000000000000..f0e3d31ce338 --- /dev/null +++ b/src/samples/AwsFlowFramework/access.properties @@ -0,0 +1,44 @@ +####### SWF PROD ENDPOINT ####### +service.url=http://swf.us-east-1.amazonaws.com + +# Fill in your AWS Access Key ID and Secret Access Key for SWF +# http://aws.amazon.com/security-credentials +AWS.Access.ID= +AWS.Secret.Key= +AWS.Account.ID= + +# Fill in your AWS Access Key ID and Secret Access Key for S3 +# http://aws.amazon.com/security-credentials +S3.Access.ID= +S3.Secret.Key= +S3.Account.ID= + +######## COMMON CONFIG ########### +domain=Samples +domainRetentionPeriodInDays=1 + +####### FileProcessing Sample Config Values ########## +Activity.Worker.LocalFolder=tmp/ +Activity.Worker.CommonTaskList=fileProcessingSampleCommonTaskList +Workflow.Worker.Tasklist=fileProcessingSampleDecisionTaskList + +Workflow.Input.SourceFileName=test_image.jpg +Workflow.Input.SourceBucketName=swfconsole +Workflow.Input.TargetFileName=media-processing-sample/test_image.zip +# Fill in your S3 bucket name +Workflow.Input.TargetBucketName= + +####### Booking Sample Config Values ###### +Booking.Activity.Worker.TaskList=bookingSampleActivityTaskList +Booking.Workflow.Worker.TaskList=bookingSampleDecisionTaskList + +Booking.Input.RequestId=10 +Booking.Input.CustomerId=123 + +####### SplitMerge Sample Config Values ###### +SplitMerge.Activity.Worker.TaskList=SplitMergeSampleActivityTaskList +SplitMerge.Workflow.Worker.TaskList=SplitMergeSampleWorkflowTaskList + +SplitMerge.Input.BucketName=swf-private-beta-samples +SplitMerge.Input.FileName=split-merge-sample/input.txt +SplitMerge.Input.NumberOfWorkers=5 diff --git a/src/samples/AwsFlowFramework/build.xml b/src/samples/AwsFlowFramework/build.xml new file mode 100644 index 000000000000..5db06093e473 --- /dev/null +++ b/src/samples/AwsFlowFramework/build.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/samples/AwsFlowFramework/log4j.properties b/src/samples/AwsFlowFramework/log4j.properties new file mode 100644 index 000000000000..9b925ba3bba0 --- /dev/null +++ b/src/samples/AwsFlowFramework/log4j.properties @@ -0,0 +1,9 @@ +log4j.rootLogger=WARN, A1 +log4j.appender.A1=org.apache.log4j.ConsoleAppender +log4j.appender.A1.layout=org.apache.log4j.PatternLayout + +# Print the date in ISO 8601 format +log4j.appender.A1.layout.ConversionPattern=%d %-5p [%t] %c - %m%n + +log4j.logger.com.amazonaws.request=OFF + diff --git a/src/samples/AwsFlowFramework/src/META-INF/aop.xml b/src/samples/AwsFlowFramework/src/META-INF/aop.xml new file mode 100644 index 000000000000..b43927876202 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/META-INF/aop.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/ActivityHost.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/ActivityHost.java new file mode 100644 index 000000000000..4ada643aeed8 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/ActivityHost.java @@ -0,0 +1,121 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.booking; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.concurrent.TimeUnit; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.ActivityWorker; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; + +/** + * This is the process which hosts all Activities in this sample + */ +public class ActivityHost { + private static AmazonSimpleWorkflow swfService; + private static String domain; + private static long domainRetentionPeriodInDays; + private static ActivityWorker worker; + private static ActivityHost activityWorker; + + // ActivityWorker Factory method + public synchronized static ActivityHost getActivityHost() { + if (activityWorker == null) { + activityWorker = new ActivityHost(); + } + return activityWorker; + } + + public static void main(String[] args) throws Exception { + // load configuration + ConfigHelper configHelper = loadConfig(); + + // Start Activity Worker + getActivityHost().startWorker(configHelper); + + // Add a Shutdown hook to close ActivityWorker + addShutDownHook(); + + System.out.println("Please press any key to terminate service."); + + try { + System.in.read(); + } + catch (IOException e) { + e.printStackTrace(); + } + + System.exit(0); + + } + + private void startWorker(ConfigHelper configHelper) throws Exception { + // Create activity implementations + BookingActivities bookingActivitiesImpl = new BookingActivitiesImpl(); + + // Start worker to poll the common task list + String taskList = configHelper.getValueFromConfig(BookingConfigKeys.ACTIVITY_WORKER_TASKLIST); + worker = new ActivityWorker(swfService, domain, taskList); + worker.setDomainRetentionPeriodInDays(domainRetentionPeriodInDays); + worker.setRegisterDomain(true); + worker.addActivitiesImplementation(bookingActivitiesImpl); + worker.start(); + System.out.println("Worker Started for Activity Task List: " + taskList); + } + + private void stopWorker() throws InterruptedException { + System.out.println("Stopping Worker..."); + worker.shutdownAndAwaitTermination(10, TimeUnit.SECONDS); + System.out.println("Worker Stopped..."); + } + + + static ConfigHelper loadConfig() throws IllegalArgumentException, IOException{ + ConfigHelper configHelper = ConfigHelper.createConfig(); + swfService = configHelper.createSWFClient(); + domain = configHelper.getDomain(); + domainRetentionPeriodInDays = configHelper.getDomainRetentionPeriodInDays(); + + return configHelper; + } + + static void addShutDownHook(){ + Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { + + public void run() { + try { + getActivityHost().stopWorker(); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + } + })); + } + + static String getHostName() { + try { + InetAddress addr = InetAddress.getLocalHost(); + return addr.getHostName(); + } + catch (UnknownHostException e) { + throw new Error(e); + } + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingActivities.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingActivities.java new file mode 100644 index 000000000000..9adb2fa3e0e5 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingActivities.java @@ -0,0 +1,35 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.booking; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Activities; +import com.amazonaws.services.simpleworkflow.flow.annotations.ActivityRegistrationOptions; +import com.amazonaws.services.simpleworkflow.flow.common.FlowConstants; + +@Activities(version = "1.0") +@ActivityRegistrationOptions( + defaultTaskHeartbeatTimeoutSeconds = FlowConstants.NONE, + defaultTaskScheduleToCloseTimeoutSeconds = 300, + defaultTaskScheduleToStartTimeoutSeconds = 60, + defaultTaskStartToCloseTimeoutSeconds = 60) +public interface BookingActivities { + + void reserveCar(int requestId); + + void reserveAirline(int requestId); + + void sendConfirmationActivity(int customerId); + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingActivitiesImpl.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingActivitiesImpl.java new file mode 100644 index 000000000000..6900e481b260 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingActivitiesImpl.java @@ -0,0 +1,33 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.booking; + +public class BookingActivitiesImpl implements BookingActivities { + + @Override + public void reserveCar(int requestId) { + System.out.printf("Reserving car for Request ID: %d...\n", requestId); + } + + @Override + public void reserveAirline(int requestId) { + System.out.printf("Reserving airline for Request ID: %d...\n", requestId); + } + + @Override + public void sendConfirmationActivity(int customerId){ + System.out.printf("Sending notification to Customer '%d'...\n", customerId); + } +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingConfigKeys.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingConfigKeys.java new file mode 100644 index 000000000000..665c0b965b83 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingConfigKeys.java @@ -0,0 +1,24 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.booking; + +public class BookingConfigKeys { + public static final String ACTIVITY_WORKER_TASKLIST = "Booking.Activity.Worker.TaskList"; + public static final String WORKFLOW_WORKER_TASKLIST = "Booking.Workflow.Worker.TaskList"; + + public static final String WORKFLOW_INPUT_REQUESTID_KEY = "Booking.Input.RequestId"; + public static final String WORKFLOW_INPUT_CUSTOMERID_KEY = "Booking.Input.CustomerId"; + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingWorkflow.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingWorkflow.java new file mode 100644 index 000000000000..c170e6eefa08 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingWorkflow.java @@ -0,0 +1,28 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.booking; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Execute; +import com.amazonaws.services.simpleworkflow.flow.annotations.Workflow; +import com.amazonaws.services.simpleworkflow.flow.annotations.WorkflowRegistrationOptions; + +@Workflow +@WorkflowRegistrationOptions(defaultExecutionStartToCloseTimeoutSeconds = 600, defaultTaskStartToCloseTimeoutSeconds = 10) +public interface BookingWorkflow { + + @Execute(name = "MakeBooking", version = "1.0") + void makeBooking(int requestID, int customerID, boolean reserveAir, boolean reserveCar); + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingWorkflowImpl.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingWorkflowImpl.java new file mode 100644 index 000000000000..1c9ab6c535ba --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingWorkflowImpl.java @@ -0,0 +1,37 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.booking; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +public class BookingWorkflowImpl implements BookingWorkflow { + + private final BookingActivitiesClient client = new BookingActivitiesClientImpl(); + + @Override + public void makeBooking(int requestID, int customerID, boolean reserveAir, boolean reserveCar) { + Promise carReservation = null; + if (reserveCar) { + carReservation = client.reserveCar(requestID); + } + Promise airReservation = null; + if (reserveAir) { + airReservation = client.reserveAirline(requestID); + } + // Relies on null Promise parameter considered immediately ready + client.sendConfirmationActivity(customerID, carReservation, airReservation); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingWorklfowTest.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingWorklfowTest.java new file mode 100644 index 000000000000..4dc6b040260b --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/BookingWorklfowTest.java @@ -0,0 +1,112 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.booking; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.junit.AsyncAssert; +import com.amazonaws.services.simpleworkflow.flow.junit.FlowBlockJUnit4ClassRunner; +import com.amazonaws.services.simpleworkflow.flow.junit.WorkflowTest; + +@RunWith(FlowBlockJUnit4ClassRunner.class) +public class BookingWorklfowTest { + + @Rule + public WorkflowTest workflowTest = new WorkflowTest(); + + List trace; + + private BookingWorkflowClientFactory workflowFactory = new BookingWorkflowClientFactoryImpl(); + + @Before + public void setUp() throws Exception { + trace = new ArrayList(); + // Register activity implementaion to be used during test run + // In real life some mocking framework to be used + BookingActivities activities = new BookingActivities() { + + @Override + public void sendConfirmationActivity(int customerId) { + trace.add("sendConfirmation-" + customerId); + } + + @Override + public void reserveCar(int requestId) { + trace.add("reserveCar-" + requestId); + } + + @Override + public void reserveAirline(int requestId) { + trace.add("reserveAirline-" + requestId); + } + }; + workflowTest.addActivitiesImplementation(activities); + workflowTest.addWorkflowImplementationType(BookingWorkflowImpl.class); + } + + @After + public void tearDown() throws Exception { + trace = null; + } + + @Test + public void testReserveBoth() { + BookingWorkflowClient workflow = workflowFactory.getClient(); + Promise booked = workflow.makeBooking(123, 345, true, true); + List expected = new ArrayList(); + expected.add("reserveCar-123"); + expected.add("reserveAirline-123"); + expected.add("sendConfirmation-345"); + AsyncAssert.assertEqualsWaitFor(expected, trace, booked); + } + + @Test + public void testReserveAir() { + BookingWorkflowClient workflow = workflowFactory.getClient(); + Promise booked = workflow.makeBooking(123, 345, true, false); + List expected = new ArrayList(); + expected.add("reserveAirline-123"); + expected.add("sendConfirmation-345"); + AsyncAssert.assertEqualsWaitFor(expected, trace, booked); + } + + @Test + public void testReserveCar() { + BookingWorkflowClient workflow = workflowFactory.getClient(); + Promise booked = workflow.makeBooking(123, 345, false, true); + List expected = new ArrayList(); + expected.add("reserveCar-123"); + expected.add("sendConfirmation-345"); + AsyncAssert.assertEqualsWaitFor(expected, trace, booked); + } + + @Test + public void testReserveNone() { + BookingWorkflowClient workflow = workflowFactory.getClient(); + Promise booked = workflow.makeBooking(123, 345, false, false); + List expected = new ArrayList(); + expected.add("sendConfirmation-345"); + AsyncAssert.assertEqualsWaitFor(expected, trace, booked); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/WorkflowExecutionStarter.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/WorkflowExecutionStarter.java new file mode 100644 index 000000000000..c97680941fb0 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/WorkflowExecutionStarter.java @@ -0,0 +1,43 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.booking; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; + +public class WorkflowExecutionStarter { + private static AmazonSimpleWorkflow swfService; + private static String domain; + + public static void main(String[] args) throws Exception { + + // Load configuration + ConfigHelper configHelper = ConfigHelper.createConfig(); + + // Create the client for Simple Workflow Service + swfService = configHelper.createSWFClient(); + domain = configHelper.getDomain(); + + // Start Workflow instance + int requestId = Integer.parseInt(configHelper.getValueFromConfig(BookingConfigKeys.WORKFLOW_INPUT_REQUESTID_KEY)); + int customerId = Integer.parseInt(configHelper.getValueFromConfig(BookingConfigKeys.WORKFLOW_INPUT_CUSTOMERID_KEY)); + + BookingWorkflowClientExternalFactory clientFactory = new BookingWorkflowClientExternalFactoryImpl(swfService, domain); + BookingWorkflowClientExternal workflow = clientFactory.getClient(); + workflow.makeBooking(requestId, customerId, true, true); + + System.exit(0); + } +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/WorkflowHost.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/WorkflowHost.java new file mode 100644 index 000000000000..87f19708406d --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/booking/WorkflowHost.java @@ -0,0 +1,105 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.booking; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.WorkflowWorker; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; + +public class WorkflowHost { + private static AmazonSimpleWorkflow swfService; + private static String domain; + private static long domainRetentionPeriodInDays; + private static WorkflowWorker worker; + private static WorkflowHost host; + + // Factory method for Workflow Host + public synchronized static WorkflowHost getWorkflowHost() { + if (host == null) { + host = new WorkflowHost(); + } + return host; + } + + public static void main(String[] args) throws Exception { + ConfigHelper configHelper = loadConfiguration(); + + getWorkflowHost().startWorkflowWorker(configHelper); + + // Add a Shutdown hook to close WorkflowWorker + addShutDownHook(); + + System.out.println("Please press any key to terminate service."); + try { + System.in.read(); + } + catch (IOException e) { + e.printStackTrace(); + } + + System.exit(0); + } + + private void startWorkflowWorker(ConfigHelper configHelper) throws Exception { + System.out.println("Starting Workflow Host Service..."); + + String taskList = configHelper.getValueFromConfig(BookingConfigKeys.WORKFLOW_WORKER_TASKLIST); + worker = new WorkflowWorker(swfService, domain, taskList); + worker.setDomainRetentionPeriodInDays(domainRetentionPeriodInDays); + worker.setRegisterDomain(true); + worker.addWorkflowImplementationType(BookingWorkflowImpl.class); + // Start the worker threads + worker.start(); + + System.out.println("Workflow Host Service Started..."); + } + + private void stopHost() throws InterruptedException { + System.out.println("Stopping Workflow Host Service..."); + worker.shutdownNow(); + swfService.shutdown(); + worker.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); + System.out.println("Workflow Host Service Stopped..."); + } + + static ConfigHelper loadConfiguration() throws IllegalArgumentException, IOException{ + ConfigHelper configHelper = ConfigHelper.createConfig(); + + // Create the client for Simple Workflow Service and S3 Service + swfService = configHelper.createSWFClient(); + domain = configHelper.getDomain(); + domainRetentionPeriodInDays = configHelper.getDomainRetentionPeriodInDays(); + configHelper.createS3Client(); + + return configHelper; + } + + static void addShutDownHook(){ + Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { + + public void run() { + try { + getWorkflowHost().stopHost(); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + } + })); + } +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/ConfigHelper.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/ConfigHelper.java new file mode 100644 index 000000000000..5094002028c6 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/ConfigHelper.java @@ -0,0 +1,135 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.common; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Properties; + +import org.apache.log4j.BasicConfigurator; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; + +import com.amazonaws.ClientConfiguration; +import com.amazonaws.auth.AWSCredentials; +import com.amazonaws.auth.BasicAWSCredentials; +import com.amazonaws.services.s3.AmazonS3; +import com.amazonaws.services.s3.AmazonS3Client; +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflowClient; + + +/** + * Configuration Helper to used to create SWF and S3 clients + */ + +public class ConfigHelper { + private Properties sampleConfig; + + private String swfServiceUrl; + private String swfAccessId; + private String swfSecretKey; + private String s3AccessId; + private String s3SecretKey; + private String domain; + private long domainRetentionPeriodInDays; + + private ConfigHelper(File propertiesFile) throws IOException { + loadProperties(propertiesFile); + } + + private void loadProperties(File propertiesFile) throws IOException { + + FileInputStream inputStream = new FileInputStream(propertiesFile); + sampleConfig = new Properties(); + sampleConfig.load(inputStream); + + this.swfServiceUrl = sampleConfig.getProperty(ConfigKeys.SWF_SERVICE_URL_KEY); + this.swfAccessId = sampleConfig.getProperty(ConfigKeys.SWF_ACCESS_ID_KEY); + this.swfSecretKey = sampleConfig.getProperty(ConfigKeys.SWF_SECRET_KEY_KEY); + + this.s3AccessId = sampleConfig.getProperty(ConfigKeys.S3_ACCESS_ID_KEY); + this.s3SecretKey = sampleConfig.getProperty(ConfigKeys.S3_SECRET_KEY_KEY); + + this.domain = sampleConfig.getProperty(ConfigKeys.DOMAIN_KEY); + this.domainRetentionPeriodInDays = Long.parseLong(sampleConfig.getProperty(ConfigKeys.DOMAIN_RETENTION_PERIOD_KEY)); + } + + public static ConfigHelper createConfig() throws IOException, IllegalArgumentException { + + BasicConfigurator.configure(); + Logger.getRootLogger().setLevel(Level.INFO); + +// Logger.getLogger("org.apache.http").setLevel(Level.INFO); + + ConfigHelper configHelper = null; + + boolean envVariableExists = false; + //first check the existence of environment variable + String sampleConfigPath = System.getenv(SampleConstants.ACCESS_PROPERTIES_ENVIRONMENT_VARIABLE); + if (sampleConfigPath != null && sampleConfigPath.length() > 0) { + envVariableExists = true; + } + File accessProperties = new File(System.getProperty(SampleConstants.HOME_DIRECTORY_PROPERTY), SampleConstants.HOME_DIRECTORY_FILENAME); + + if(accessProperties.exists()){ + configHelper = new ConfigHelper(accessProperties); + } + else if (envVariableExists) { + accessProperties = new File(sampleConfigPath, SampleConstants.ACCESS_PROPERTIES_FILENAME); + configHelper = new ConfigHelper(accessProperties); + } + else { + //try checking the existence of file on relative path. + try { + accessProperties = new File(SampleConstants.ACCESS_PROPERTIES_RELATIVE_PATH, SampleConstants.ACCESS_PROPERTIES_FILENAME); + configHelper = new ConfigHelper(accessProperties); + } + catch (Exception e) { + throw new FileNotFoundException("Cannot find AWS_SWF_SAMPLES_CONFIG environment variable, Exiting!!!"); + } + } + + return configHelper; + } + + public AmazonSimpleWorkflow createSWFClient() { + ClientConfiguration config = new ClientConfiguration().withSocketTimeout(70 * 1000); + AWSCredentials awsCredentials = new BasicAWSCredentials(this.swfAccessId, this.swfSecretKey); + AmazonSimpleWorkflow client = new AmazonSimpleWorkflowClient(awsCredentials, config); + client.setEndpoint(this.swfServiceUrl); + return client; + } + + public AmazonS3 createS3Client() { + AWSCredentials s3AWSCredentials = new BasicAWSCredentials(this.s3AccessId, this.s3SecretKey); + AmazonS3 client = new AmazonS3Client(s3AWSCredentials); + return client; + } + + public String getDomain() { + return domain; + } + + public long getDomainRetentionPeriodInDays() { + return domainRetentionPeriodInDays; + } + + public String getValueFromConfig(String key) { + return sampleConfig.getProperty(key); + } +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/ConfigKeys.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/ConfigKeys.java new file mode 100644 index 000000000000..dab2b3854eee --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/ConfigKeys.java @@ -0,0 +1,29 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.common; + +public class ConfigKeys { + + public static final String SWF_SERVICE_URL_KEY = "service.url"; + public static final String SWF_ACCESS_ID_KEY = "AWS.Access.ID"; + public static final String SWF_SECRET_KEY_KEY = "AWS.Secret.Key"; + + public static final String S3_ACCESS_ID_KEY = "S3.Access.ID"; + public static final String S3_SECRET_KEY_KEY = "S3.Secret.Key"; + + public static final String DOMAIN_KEY = "domain"; + public static final String DOMAIN_RETENTION_PERIOD_KEY = "domainRetentionPeriodInDays"; + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/RegistrationDefaults.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/RegistrationDefaults.java new file mode 100644 index 000000000000..c8b3fa193201 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/RegistrationDefaults.java @@ -0,0 +1,32 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.common; + +import com.amazonaws.services.simpleworkflow.flow.common.FlowConstants; + +public final class RegistrationDefaults { + private static final long SECONDS_IN_MINUTE = 60; + //private static final long SECONDS_IN_HOUR = 60 * SECONDS_IN_MINUTE; + //private static final long SECONDS_IN_DAY = 24 * SECONDS_IN_HOUR; + + public static final long ACTIVITY_REGISTRATION_OPTIONS_DEFAULT_TASK_SCHEDULE_TO_START_TIMEOUT_SECONDS = FlowConstants.NONE; + public static final long ACTIVITY_REGISTRATION_OPTIONS_DEFAULT_TASK_HEARTBEAT_TIMEOUT_SECONDS = FlowConstants.NONE; + public static final long ACTIVITY_REGISTRATION_OPTIONS_DEFAULT_TASK_SCHEDULE_TO_CLOSE_TIMEOUT_SECONDS = 5 * SECONDS_IN_MINUTE; + public static final long ACTIVITY_REGISTRATION_OPTIONS_DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_SECONDS = 5 * SECONDS_IN_MINUTE; + + public static final long WORKFLOW_REGISTRATION_OPTIONS_DEFAULT_EXECUTION_START_TO_CLOSE_TIMEOUT_SECONDS = 10 * SECONDS_IN_MINUTE; + public static final long WORKFLOW_REGISTRATION_OPTIONS_DEFAULT_TASK_START_TO_CLOSE_TIMEOUT_SECONDS = 1 * SECONDS_IN_MINUTE; + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/SampleConstants.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/SampleConstants.java new file mode 100644 index 000000000000..4dccf64b11fa --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/SampleConstants.java @@ -0,0 +1,23 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.common; + +public class SampleConstants { + public static final String HOME_DIRECTORY_PROPERTY = "user.home"; + public static final String HOME_DIRECTORY_FILENAME = ".swf-flow-samples.properties"; + public static final String ACCESS_PROPERTIES_FILENAME = "access.properties"; + public static final String ACCESS_PROPERTIES_RELATIVE_PATH = "../../../common"; + public static final String ACCESS_PROPERTIES_ENVIRONMENT_VARIABLE = "AWS_SWF_SAMPLES_CONFIG"; +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/WorkflowExecutionFlowThreadDumper.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/WorkflowExecutionFlowThreadDumper.java new file mode 100644 index 000000000000..51251a4a896e --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/WorkflowExecutionFlowThreadDumper.java @@ -0,0 +1,62 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.common; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.WorkflowException; +import com.amazonaws.services.simpleworkflow.flow.WorkflowReplayer; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +/** + * Simple example utility to pretty print workflow execution history. + * + * @author fateev + */ +public class WorkflowExecutionFlowThreadDumper { + + public static void main(String[] args) throws Exception { + if (args.length < 3) { + System.err.println("Usage: java " + WorkflowExecutionFlowThreadDumper.class.getName() + + " "); + System.exit(1); + } + ConfigHelper configHelper = ConfigHelper.createConfig(); + AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); + String domain = configHelper.getDomain(); + + WorkflowExecution workflowExecution = new WorkflowExecution(); + String workflowId = args[1]; + workflowExecution.setWorkflowId(workflowId); + String runId = args[2]; + workflowExecution.setRunId(runId); + + String implementationTypeName = args[0]; + @SuppressWarnings("unchecked") + Class workflowImplementationType = (Class) Class.forName(implementationTypeName); + WorkflowReplayer replayer = new WorkflowReplayer(swfService, domain, workflowExecution, + workflowImplementationType); + + System.out.println("Beginning workflow replay for " + workflowExecution); + try { + String flowThreadDump = replayer.getAsynchronousThreadDumpAsString(); + System.out.println("Workflow asynchronous thread dump:"); + System.out.println(flowThreadDump); + } + catch (WorkflowException e) { + System.out.println("No asynchronous thread dump available as workflow has failed: " + e); + } + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/WorkflowExecutionGetState.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/WorkflowExecutionGetState.java new file mode 100644 index 000000000000..874fd455154e --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/WorkflowExecutionGetState.java @@ -0,0 +1,53 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.common; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.generic.GenericWorkflowClientExternal; +import com.amazonaws.services.simpleworkflow.flow.worker.GenericWorkflowClientExternalImpl; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +/** + * Simple example utility to pretty print workflow execution history. + * + * @author fateev + */ +public class WorkflowExecutionGetState { + + public static void main(String[] args) throws Exception { + if (args.length < 2) { + System.err.println("Usage: java " + WorkflowExecutionGetState.class.getName() + " "); + System.exit(1); + } + ConfigHelper configHelper = ConfigHelper.createConfig(); + AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); + String domain = configHelper.getDomain(); + + + WorkflowExecution workflowExecution = new WorkflowExecution(); + String workflowId = args[1]; + workflowExecution.setWorkflowId(workflowId); + String runId = args[2]; + workflowExecution.setRunId(runId); + + GenericWorkflowClientExternal client = new GenericWorkflowClientExternalImpl(swfService, domain); + + String state = client.getWorkflowState(workflowExecution); + + System.out.println("Current state of " + workflowExecution + ":"); + System.out.println(state); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/WorkflowExecutionHistoryPrinter.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/WorkflowExecutionHistoryPrinter.java new file mode 100644 index 000000000000..ad72735ddf39 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/WorkflowExecutionHistoryPrinter.java @@ -0,0 +1,46 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.common; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.common.WorkflowExecutionUtils; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +/** + * Simple example utility to pretty print workflow execution history. + * + * @author fateev + */ +public class WorkflowExecutionHistoryPrinter { + + public static void main(String[] args) throws Exception { + if (args.length < 2) { + System.err.println("Usage: java " + WorkflowExecutionHistoryPrinter.class.getName() + " "); + System.exit(1); + } + ConfigHelper configHelper = ConfigHelper.createConfig(); + AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); + String domain = configHelper.getDomain(); + + + WorkflowExecution workflowExecution = new WorkflowExecution(); + String workflowId = args[0]; + workflowExecution.setWorkflowId(workflowId); + String runId = args[1]; + workflowExecution.setRunId(runId); + System.out.println(WorkflowExecutionUtils.prettyPrintHistory(swfService, domain, workflowExecution, true)); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/WorkflowExecutionReplayer.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/WorkflowExecutionReplayer.java new file mode 100644 index 000000000000..c7851d8e3f86 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/common/WorkflowExecutionReplayer.java @@ -0,0 +1,58 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.common; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.WorkflowReplayer; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +/** + * Simple example utility to pretty print workflow execution history. + * + * @author fateev + */ +public class WorkflowExecutionReplayer { + + public static void main(String[] args) throws Exception { + if (args.length < 3) { + System.err.println("Usage: java " + WorkflowExecutionReplayer.class.getName() + + " "); + System.exit(1); + } + ConfigHelper configHelper = ConfigHelper.createConfig(); + AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); + String domain = configHelper.getDomain(); + + WorkflowExecution workflowExecution = new WorkflowExecution(); + String workflowId = args[1]; + workflowExecution.setWorkflowId(workflowId); + String runId = args[2]; + workflowExecution.setRunId(runId); + + String implementationTypeName = args[0]; + @SuppressWarnings("unchecked") + Class workflowImplementationType = (Class) Class.forName(implementationTypeName); + WorkflowReplayer replayer = new WorkflowReplayer(swfService, domain, workflowExecution, + workflowImplementationType); + + System.out.println("Beginning workflow replay for " + workflowExecution); + Object workflow = replayer.loadWorkflow(); + System.out.println("Workflow implementation object:"); + System.out.println(workflow); + + System.out.println("Done workflow replay for " + workflowExecution); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/AppServer.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/AppServer.java new file mode 100644 index 000000000000..b0a98b4c8fe9 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/AppServer.java @@ -0,0 +1,62 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.deployment; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.PostConstruct; + +import org.springframework.beans.factory.annotation.Autowired; + +import com.amazonaws.services.simpleworkflow.flow.ActivitySchedulingOptions; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + + +public class AppServer extends DeployableBase { + + private List databases; + + @Autowired + private DeploymentActivitiesClient activities; + + public List getDatabases() { + return databases; + } + + public void setDatabases(List databases) { + this.databases = databases; + } + + @PostConstruct + public void init() { + addDependsOn(databases); + } + + @Override + protected Promise deploySelf() { + List dataSources = new ArrayList(); + for (Database db : databases) { + // It is safe to call Promise.get() here as deploySelf is called after + // all Databases AppServer depends on are already deployed + dataSources.add(db.getUrl().get()); + } + // Use host name as taskList to route request to appropriate host + ActivitySchedulingOptions options = new ActivitySchedulingOptions(); + options.setTaskList(getHost()); + return activities.deployAppServer(dataSources, options); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/AppStack1.xml b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/AppStack1.xml new file mode 100644 index 000000000000..c0b0c95ebab4 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/AppStack1.xml @@ -0,0 +1,135 @@ + + + + + + + + host1 + + + + + + host2 + + + + + + host3 + + + + + + + + + + + host2 + + + + + + + + + + + host3 + + + + + + + + + + + + host1 + + + + + + + + + + + + + + + + + + host2 + + + + + + + + + + + + + + + + + host2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/ApplicationStack.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/ApplicationStack.java new file mode 100644 index 000000000000..b7f4665f60a4 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/ApplicationStack.java @@ -0,0 +1,56 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.deployment; + +import java.util.List; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +public class ApplicationStack { + + private List components; + + private Deployable frontendComponent; + + public List getComponents() { + return components; + } + + public void setComponents(List components) { + this.components = components; + } + + public Deployable getFrontendComponent() { + return frontendComponent; + } + + public void setFrontendComponent(Deployable frontendComponent) { + this.frontendComponent = frontendComponent; + } + + public void deploy() { + // Note that order in which components are iterated doesn't matter. + // The component.deploy() initiates deployment but actual component deployment + // happens only when all downstream dependencies are satisfied. + for (Deployable component : components) { + component.deploy(); + } + } + + public Promise getUrl() { + return frontendComponent.getUrl(); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/Database.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/Database.java new file mode 100644 index 000000000000..c58cc268d89c --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/Database.java @@ -0,0 +1,35 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.deployment; + +import org.springframework.beans.factory.annotation.Autowired; + +import com.amazonaws.services.simpleworkflow.flow.ActivitySchedulingOptions; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +public class Database extends DeployableBase { + + @Autowired + private DeploymentActivitiesClient activities; + + @Override + protected Promise deploySelf() { + // Use host name as taskList to route request to appropriate host + ActivitySchedulingOptions options = new ActivitySchedulingOptions(); + options.setTaskList(getHost()); + return activities.deployDatabase(options); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/Deployable.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/Deployable.java new file mode 100644 index 000000000000..a30decc68ed6 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/Deployable.java @@ -0,0 +1,38 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.deployment; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +public interface Deployable { + + /** + * @return Destination host. + */ + public String getHost(); + + /** + * Initiate deployment. Actual deployment is expected to happen after all + * dependencies of the current Deployable are deployed. + */ + public void deploy(); + + /** + * Url used to access deployed component + * @return promise the Url which becomes ready after successful deployment. + */ + public Promise getUrl(); + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeployableBase.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeployableBase.java new file mode 100644 index 000000000000..36359b5cd9db --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeployableBase.java @@ -0,0 +1,73 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.deployment; + +import java.util.ArrayList; +import java.util.List; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Asynchronous; +import com.amazonaws.services.simpleworkflow.flow.annotations.Wait; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.core.Settable; + +public abstract class DeployableBase implements Deployable { + + private String host; + + List dependsOn = new ArrayList(); + + + @Override + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + protected void addDependsOn(List deployable) { + dependsOn.addAll(deployable); + } + + private Settable url = new Settable(); + + @Override + public void deploy() { + List> dependsOnPromises = new ArrayList>(); + for (Deployable deployable : dependsOn) { + dependsOnPromises.add(deployable.getUrl()); + } + deploy(dependsOnPromises); + } + + @Asynchronous + private void deploy(@Wait List> dependsOnPromises) { + // chain links one promise to the result of the other one + url.chain(deploySelf()); + } + + @Override + public Promise getUrl() { + return url; + } + + /** + * Perform actual deployment. + * @return Url used to access this Deployable + */ + protected abstract Promise deploySelf(); + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentActivities.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentActivities.java new file mode 100644 index 000000000000..997075a614f2 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentActivities.java @@ -0,0 +1,56 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.deployment; + +import java.util.List; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Activities; +import com.amazonaws.services.simpleworkflow.flow.annotations.ActivityRegistrationOptions; +import com.amazonaws.services.simpleworkflow.flow.common.FlowConstants; + +@Activities(version = "1.0") +// NO_DEFAULT_TASK_LIST mandates that task list is specified when activity is called +@ActivityRegistrationOptions(defaultTaskList = FlowConstants.NO_DEFAULT_TASK_LIST, + defaultTaskScheduleToStartTimeoutSeconds = 300, defaultTaskStartToCloseTimeoutSeconds = 300) +public interface DeploymentActivities { + + /** + * @return dataSource + */ + public String deployDatabase(); + + /** + * @param dataSources + * used to access database + * @return URL used to access appserver + */ + public String deployAppServer(List dataSources); + + /** + * @param dataSource + * dataSources used to access database + * @param appServerUrls + * URLs used to access appservers + * @return URL used to access webserver + */ + public String deployWebServer(List appServerUrls, List dataSources); + + /** + * @param frontendUrls URLs used to acccess frontends + * @return URL for the load balancer + */ + public String deployLoadBalancer(List frontendUrls); + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentActivitiesImpl.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentActivitiesImpl.java new file mode 100644 index 000000000000..afd665036b5f --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentActivitiesImpl.java @@ -0,0 +1,41 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.deployment; + +import java.util.List; + +public class DeploymentActivitiesImpl implements DeploymentActivities { + + @Override + public String deployDatabase() { + return "jdbc:foo/bar"; + } + + @Override + public String deployAppServer(List dataSources) { + return "http://baz"; + } + + @Override + public String deployWebServer(List appServerUrls, List dataSources) { + return "http://webserver"; + } + + @Override + public String deployLoadBalancer(List frontendUrls) { + return "http://myweb.com"; + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentCommon-context.xml b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentCommon-context.xml new file mode 100644 index 000000000000..e259ce1db0bc --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentCommon-context.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentHost-context.xml b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentHost-context.xml new file mode 100644 index 000000000000..f8f862c8219e --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentHost-context.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentHost.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentHost.java new file mode 100644 index 000000000000..d83f54446dc7 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentHost.java @@ -0,0 +1,30 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.deployment; + +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class DeploymentHost { + + /** + * @param args + * @throws MalformedURLException + */ + public static void main(String[] args) { + new ClassPathXmlApplicationContext( + "/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentHost-context.xml"); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentInitiator-context.xml b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentInitiator-context.xml new file mode 100644 index 000000000000..ea0f4877936f --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentInitiator-context.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentInitiator.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentInitiator.java new file mode 100644 index 000000000000..5fd889d028cf --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentInitiator.java @@ -0,0 +1,67 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.deployment; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.net.URL; + +import org.apache.log4j.PropertyConfigurator; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class DeploymentInitiator { + + /** + * @param args + * @throws IOException + */ + public static void main(String[] args) throws IOException { + URL pUrl = DeploymentHost.class.getResource("/com/amazonaws/services/simpleworkflow/flow/examples/log4j.properties"); + PropertyConfigurator.configure(pUrl); + + ApplicationContext appContext = new ClassPathXmlApplicationContext( + "/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentInitiator-context.xml"); + + DeploymentWorkflowClientExternalFactory workflowFactory = appContext.getBean("workflowFactory", + DeploymentWorkflowClientExternalFactory.class); + + String applicationStackConfigFile = args[0]; + // Use applicationStackConfig as workflowId to prohibit running multiple deployments of the same stack in parallel + String workflowId = new File(applicationStackConfigFile).getName(); + DeploymentWorkflowClientExternal worklfowClient = workflowFactory.getClient(workflowId); + String template = loadFile(applicationStackConfigFile); + worklfowClient.deploy(template); + System.out.println("Initiated deployment from " + applicationStackConfigFile); + } + + public static String loadFile(String fileName) throws IOException { + int length = (int) new File(fileName).length(); + byte[] buffer = new byte[length]; + BufferedInputStream is = null; + try { + is = new BufferedInputStream(new FileInputStream(fileName)); + is.read(buffer); + } + finally { + if (is != null) { + is.close(); + } + } + return new String(buffer); + } +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentTest-context.xml b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentTest-context.xml new file mode 100644 index 000000000000..ffa1c1ec804d --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentTest-context.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + host1 + + + + + + host2 + + + + + + host3 + + + + + + + + + + + + + + host1 + + + + + + host2 + + + + + + host3 + + + + + + + + + + diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentTest.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentTest.java new file mode 100644 index 000000000000..58fa0228080a --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentTest.java @@ -0,0 +1,128 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.deployment; + +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +import junit.framework.Assert; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; + +import com.amazonaws.services.simpleworkflow.flow.core.TryCatchFinally; +import com.amazonaws.services.simpleworkflow.flow.junit.WorkflowTestBase; +import com.amazonaws.services.simpleworkflow.flow.junit.spring.FlowSpringJUnit4ClassRunner; + +@RunWith(FlowSpringJUnit4ClassRunner.class) +@ContextConfiguration("DeploymentTest-context.xml") +public class DeploymentTest { + + public static class TestDeploymentActivities implements DeploymentActivities { + + private final String host; + + public TestDeploymentActivities(String host) { + this.host = host; + } + + @Override + public String deployDatabase() { + trace.add("Database-" + host); + return "dbUrl-" + host; + } + + @Override + public String deployAppServer(List dataSources) { + trace.add("appServer-" + host); + return "appServerUrl-" + host; + } + + @Override + public String deployWebServer(List appServerUrls, List dataSources) { + trace.add("WebServer-" + host); + return "webServerUrl-" + host; + } + + @Override + public String deployLoadBalancer(List frontendUrls) { + trace.add("LoadBalancer-" + host); + return "loadBalancerUrl-" + host; + } + + } + + @Rule + @Autowired + public WorkflowTestBase workflowTest; + + @Autowired + public DeploymentWorkflowClientFactory workflowClientFactory; + + private static final List trace = new ArrayList(); + + @Test + public void test() throws IOException { + new TryCatchFinally() { + + Throwable failure; + + @Override + protected void doTry() throws Throwable { + String template = getTemplate("AppStack1.xml"); + DeploymentWorkflowClient workflow = workflowClientFactory.getClient("AppStack1"); + workflow.deploy(template); + } + + @Override + protected void doCatch(Throwable e) throws Throwable { + failure = e; + throw e; + } + + @Override + protected void doFinally() throws Throwable { + // Without this check assertEquals fails overwriting + // original exception + if (failure == null) { + List expected = new ArrayList(); + expected.add("Database-host1"); + expected.add("Database-host2"); + expected.add("appServer-host3"); + expected.add("appServer-host2"); + expected.add("appServer-host3"); + expected.add("WebServer-host2"); + expected.add("WebServer-host1"); + expected.add("LoadBalancer-host2"); + Assert.assertEquals(expected, trace); + } + } + + }; + } + + private String getTemplate(String resourceName) throws IOException { + URL resource = DeploymentTest.class.getResource(resourceName); + String template = new Scanner(resource.openStream()).useDelimiter("\\A").next(); + return template; + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentWorkflow.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentWorkflow.java new file mode 100644 index 000000000000..6884e1ddcb86 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentWorkflow.java @@ -0,0 +1,33 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.deployment; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Execute; +import com.amazonaws.services.simpleworkflow.flow.annotations.Workflow; +import com.amazonaws.services.simpleworkflow.flow.annotations.WorkflowRegistrationOptions; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +@Workflow +@WorkflowRegistrationOptions(defaultExecutionStartToCloseTimeoutSeconds = 3600) +public interface DeploymentWorkflow { + + /** + * deploy the whole stack + * @return Url of the stack webserver + */ + @Execute(version="1.0") + public Promise deploy(String springTemplate); + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentWorkflowImpl.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentWorkflowImpl.java new file mode 100644 index 000000000000..8da3863d330f --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentWorkflowImpl.java @@ -0,0 +1,42 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.deployment; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.GenericXmlApplicationContext; +import org.springframework.core.io.ByteArrayResource; +import org.springframework.core.io.Resource; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +public class DeploymentWorkflowImpl implements DeploymentWorkflow { + + @Autowired + private ApplicationContext applicationContext; + + @Override + public Promise deploy(String springTemplate) { + Resource templateResource = new ByteArrayResource(springTemplate.getBytes()); + GenericXmlApplicationContext appContext = new GenericXmlApplicationContext(); + appContext.setParent(applicationContext); + appContext.load(templateResource); + appContext.refresh(); + ApplicationStack applicationStack = appContext.getBean("applicationStack", ApplicationStack.class); + applicationStack.deploy(); + return applicationStack.getUrl(); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/LoadBalancer.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/LoadBalancer.java new file mode 100644 index 000000000000..afeef6a74433 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/LoadBalancer.java @@ -0,0 +1,61 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.deployment; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.PostConstruct; + +import org.springframework.beans.factory.annotation.Autowired; + +import com.amazonaws.services.simpleworkflow.flow.ActivitySchedulingOptions; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +public class LoadBalancer extends DeployableBase { + + private List webServers; + + @Autowired + private DeploymentActivitiesClient activities; + + public List getWebServers() { + return webServers; + } + + public void setWebServers(List webServers) { + this.webServers = webServers; + } + + @PostConstruct + public void init() { + addDependsOn(webServers); + } + + @Override + protected Promise deploySelf() { + List urls = new ArrayList(); + for (WebServer webServer : webServers) { + // It is safe to call Promise.get() here as deploySelf is called after + // all components WebServer depends on are already deployed + urls.add(webServer.getUrl().get()); + } + // Use host name as taskList to route request to appropriate host + ActivitySchedulingOptions options = new ActivitySchedulingOptions(); + options.setTaskList(getHost()); + return activities.deployLoadBalancer(urls, options); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/WebServer.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/WebServer.java new file mode 100644 index 000000000000..c68a4c68caa6 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/deployment/WebServer.java @@ -0,0 +1,83 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.deployment; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.PostConstruct; + +import org.springframework.beans.factory.annotation.Autowired; + +import com.amazonaws.services.simpleworkflow.flow.ActivitySchedulingOptions; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +/** + * For the sake of the example WebServer depends on both AppServers and Databases. + * + * @author fateev + */ +public class WebServer extends DeployableBase { + + private List databases; + + private List appServers; + + @Autowired + private DeploymentActivitiesClient activities; + + public List getDatabases() { + return databases; + } + + public void setDatabases(List databases) { + this.databases = databases; + } + + public List getAppServers() { + return appServers; + } + + public void setAppServers(List appServers) { + this.appServers = appServers; + } + + @PostConstruct + public void init() { + addDependsOn(databases); + addDependsOn(appServers); + } + + @Override + protected Promise deploySelf() { + List dataSources = new ArrayList(); + for (Database db : databases) { + // It is safe to call Promise.get() here as deploySelf is called after + // all components WebServer depends on are already deployed + dataSources.add(db.getUrl().get()); + } + List appServerUrls = new ArrayList(); + for (AppServer appServer : appServers) { + // It is safe to call Promise.get() here as deploySelf is called after + // all components WebServer depends on are already deployed + appServerUrls.add(appServer.getUrl().get()); + } + // Use host name as taskList to route request to appropriate host + ActivitySchedulingOptions options = new ActivitySchedulingOptions(); + options.setTaskList(getHost()); + return activities.deployWebServer(appServerUrls, dataSources, options); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/ActivityHost.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/ActivityHost.java new file mode 100644 index 000000000000..8c97808995ad --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/ActivityHost.java @@ -0,0 +1,95 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.fileprocessing; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.concurrent.TimeUnit; + +import com.amazonaws.services.s3.AmazonS3; +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.ActivityWorker; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; + +/** + * This is the process which hosts all Activities in this sample + */ +public class ActivityHost { + + private static final String ACTIVITIES_TASK_LIST = "FileProcessing"; + + public static void main(String[] args) throws Exception { + ConfigHelper configHelper = ConfigHelper.createConfig(); + AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); + AmazonS3 s3Client = configHelper.createS3Client(); + String domain = configHelper.getDomain(); + + String localFolder = configHelper.getValueFromConfig(FileProcessingConfigKeys.ACTIVITY_WORKER_LOCALFOLDER); + + // Start worker to poll the common task list + final ActivityWorker workerForCommonTaskList = new ActivityWorker(swfService, domain, ACTIVITIES_TASK_LIST); + SimpleStoreActivitiesS3Impl storeActivityImpl = new SimpleStoreActivitiesS3Impl(s3Client, localFolder, getHostName()); + workerForCommonTaskList.addActivitiesImplementation(storeActivityImpl); + workerForCommonTaskList.start(); + System.out.println("Host Service Started for Task List: " + ACTIVITIES_TASK_LIST); + + // Start worker to poll the host specific task list + final ActivityWorker workerForHostSpecificTaskList = new ActivityWorker(swfService, domain, getHostName()); + workerForHostSpecificTaskList.addActivitiesImplementation(storeActivityImpl); + FileProcessingActivitiesZipImpl processorActivityImpl = new FileProcessingActivitiesZipImpl(localFolder); + workerForHostSpecificTaskList.addActivitiesImplementation(processorActivityImpl); + workerForHostSpecificTaskList.start(); + System.out.println("Worker Started for Activity Task List: " + getHostName()); + + Runtime.getRuntime().addShutdownHook(new Thread() { + + public void run() { + try { + workerForCommonTaskList.shutdown(); + workerForHostSpecificTaskList.shutdown(); + workerForCommonTaskList.awaitTermination(1, TimeUnit.MINUTES); + workerForHostSpecificTaskList.awaitTermination(1, TimeUnit.MINUTES); + System.out.println("Activity Workers Exited."); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + } + }); + + System.out.println("Please press any key to terminate service."); + + try { + System.in.read(); + } + catch (IOException e) { + e.printStackTrace(); + } + System.exit(0); + + } + + static String getHostName() { + try { + InetAddress addr = InetAddress.getLocalHost(); + return addr.getHostName(); + } + catch (UnknownHostException e) { + throw new Error(e); + } + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/FileProcessingActivities.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/FileProcessingActivities.java new file mode 100644 index 000000000000..90e8b9e9aede --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/FileProcessingActivities.java @@ -0,0 +1,29 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.fileprocessing; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Activities; +import com.amazonaws.services.simpleworkflow.flow.annotations.ActivityRegistrationOptions; + +/** + * Contract for file processing activities + */ +@Activities(version="1.0") +@ActivityRegistrationOptions(defaultTaskScheduleToStartTimeoutSeconds = 60, defaultTaskStartToCloseTimeoutSeconds = 60) +public interface FileProcessingActivities { + + public void processFile(String inputFileName, String outputFileName) throws Exception; + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/FileProcessingActivitiesZipImpl.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/FileProcessingActivitiesZipImpl.java new file mode 100644 index 000000000000..61bce01106ff --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/FileProcessingActivitiesZipImpl.java @@ -0,0 +1,78 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.fileprocessing; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +/** + * This implementation of FileProcessingActivities zips the file + */ +public class FileProcessingActivitiesZipImpl implements FileProcessingActivities { + + private final String localDirectory; + + public FileProcessingActivitiesZipImpl(String localDirectory) { + this.localDirectory = localDirectory; + } + + /** + * This is the Activity implementation that does the zip of a file + * + * @param localDirectory + * Path to the local directory containing the file to zip + * @param fileName + * Name of file to zip + * @param zipFileName + * Filename after zip + */ + @Override + public void processFile(String fileName, String zipFileName) throws Exception { + String fileNameFullPath = localDirectory + fileName; + String zipFileNameFullPath = localDirectory + zipFileName; + + System.out.println("processFile activity begin. fileName= " + fileNameFullPath + ", zipFileName= " + zipFileNameFullPath); + final int BUFFER = 1024; + BufferedInputStream origin = null; + ZipOutputStream out = null; + + try { + FileOutputStream dest = new FileOutputStream(zipFileNameFullPath); + out = new ZipOutputStream(new BufferedOutputStream(dest)); + byte data[] = new byte[BUFFER]; + + FileInputStream fi = new FileInputStream(fileNameFullPath); + origin = new BufferedInputStream(fi, BUFFER); + ZipEntry entry = new ZipEntry(fileName); + out.putNextEntry(entry); + int count; + while ((count = origin.read(data, 0, BUFFER)) != -1) { + out.write(data, 0, count); + } + } + finally { + if (origin != null) + origin.close(); + if (out != null) + out.close(); + } + + System.out.println("zipFileActivity done."); + } +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/FileProcessingConfigKeys.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/FileProcessingConfigKeys.java new file mode 100644 index 000000000000..153e7ba8d140 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/FileProcessingConfigKeys.java @@ -0,0 +1,29 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.fileprocessing; + +public class FileProcessingConfigKeys { + + public static final String ACTIVITY_WORKER_LOCALFOLDER = "Activity.Worker.LocalFolder"; + + public static final String WORKFLOW_INPUT_SOURCEFILENAME_KEY = "Workflow.Input.SourceFileName"; + + public static final String WORKFLOW_INPUT_SOURCEBUCKETNAME_KEY = "Workflow.Input.SourceBucketName"; + + public static final String WORKFLOW_INPUT_TARGETFILENAME_KEY = "Workflow.Input.TargetFileName"; + + public static final String WORKFLOW_INPUT_TARGETBUCKETNAME_KEY = "Workflow.Input.TargetBucketName"; + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/FileProcessingWorkflow.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/FileProcessingWorkflow.java new file mode 100644 index 000000000000..c28d1b35fe9a --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/FileProcessingWorkflow.java @@ -0,0 +1,38 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.fileprocessing; + +import java.io.IOException; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Execute; +import com.amazonaws.services.simpleworkflow.flow.annotations.GetState; +import com.amazonaws.services.simpleworkflow.flow.annotations.Workflow; +import com.amazonaws.services.simpleworkflow.flow.annotations.WorkflowRegistrationOptions; + +/** + * Contract for file processing workflow + */ +@Workflow +@WorkflowRegistrationOptions(defaultExecutionStartToCloseTimeoutSeconds = 300, defaultTaskStartToCloseTimeoutSeconds = 10) +public interface FileProcessingWorkflow { + + @Execute(name = "ProcessFile", version = "1.0") + public void processFile(String sourceBucketName, String sourceFilename, String targetBucketName, String targetFilename) + throws IOException; + + @GetState + public String getState(); + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/FileProcessingWorkflowZipImpl.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/FileProcessingWorkflowZipImpl.java new file mode 100644 index 000000000000..88a65e0b8b82 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/FileProcessingWorkflowZipImpl.java @@ -0,0 +1,131 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.fileprocessing; + +import java.io.File; +import java.io.IOException; + +import com.amazonaws.services.simpleworkflow.flow.ActivitySchedulingOptions; +import com.amazonaws.services.simpleworkflow.flow.DecisionContextProviderImpl; +import com.amazonaws.services.simpleworkflow.flow.WorkflowContext; +import com.amazonaws.services.simpleworkflow.flow.annotations.Asynchronous; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.core.Settable; +import com.amazonaws.services.simpleworkflow.flow.core.TryCatchFinally; + +/** + * This implementation of FileProcessingWorkflow downloads the file, zips it and + * uploads it back to S3 + */ +public class FileProcessingWorkflowZipImpl implements FileProcessingWorkflow { + + private final SimpleStoreActivitiesClient store; + + private final FileProcessingActivitiesClient processor; + + private final WorkflowContext workflowContext; + + private String state = "Started"; + + public FileProcessingWorkflowZipImpl() { + // Create activity clients + this.store = new SimpleStoreActivitiesClientImpl(); + processor = new FileProcessingActivitiesClientImpl(); + workflowContext = (new DecisionContextProviderImpl()).getDecisionContext().getWorkflowContext(); + } + + /** + * Constructor used for unit testing or when Spring is used to configure + * workflow + */ + public FileProcessingWorkflowZipImpl(SimpleStoreActivitiesClient store, FileProcessingActivitiesClient processor, + WorkflowContext workflowContext) { + this.store = store; + this.processor = processor; + this.workflowContext = workflowContext; + } + + @Override + public void processFile(final String sourceBucketName, final String sourceFilename, final String targetBucketName, + final String targetFilename) throws IOException { + // Settable to store the worker specific task list returned by the activity + final Settable taskList = new Settable(); + + // Use runId as a way to ensure that downloaded files do not get name collisions + String workflowRunId = workflowContext.getWorkflowExecution().getRunId(); + File localSource = new File(sourceFilename); + final String localSourceFilename = workflowRunId + "_" + localSource.getName(); + File localTarget = new File(targetFilename); + final String localTargetFilename = workflowRunId + "_" + localTarget.getName(); + new TryCatchFinally() { + + @Override + protected void doTry() throws Throwable { + Promise activityWorkerTaskList = store.download(sourceBucketName, sourceFilename, localSourceFilename); + // chaining is a way for one promise get assigned value of another + taskList.chain(activityWorkerTaskList); + // Call processFile activity to zip the file + Promise fileProcessed = processFileOnHost(localSourceFilename, localTargetFilename, activityWorkerTaskList); + // Call upload activity to upload zipped file + upload(targetBucketName, targetFilename, localTargetFilename, taskList, fileProcessed); + } + + @Override + protected void doCatch(Throwable e) throws Throwable { + state = "Failed: " + e.getMessage(); + throw e; + } + + @Override + protected void doFinally() throws Throwable { + if (taskList.isReady()) { // File was downloaded + + // Set option to schedule activity in worker specific task list + ActivitySchedulingOptions options = new ActivitySchedulingOptions().withTaskList(taskList.get()); + + // Call deleteLocalFile activity using the host specific task list + store.deleteLocalFile(localSourceFilename, options); + store.deleteLocalFile(localTargetFilename, options); + } + if (!state.startsWith("Failed:")) { + state = "Completed"; + } + } + + }; + } + + @Asynchronous + private Promise processFileOnHost(String fileToProcess, String fileToUpload, Promise taskList) { + state = "Downloaded to " + taskList.get(); + // Call the activity to process the file using worker specific task list + ActivitySchedulingOptions options = new ActivitySchedulingOptions().withTaskList(taskList.get()); + return processor.processFile(fileToProcess, fileToUpload, options); + } + + @Asynchronous + private void upload(final String targetBucketName, final String targetFilename, final String localTargetFilename, + Promise taskList, Promise fileProcessed) { + state = "Processed at " + taskList.get(); + ActivitySchedulingOptions options = new ActivitySchedulingOptions().withTaskList(taskList.get()); + store.upload(targetBucketName, localTargetFilename, targetFilename, options); + } + + @Override + public String getState() { + return state; + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/SimpleStoreActivities.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/SimpleStoreActivities.java new file mode 100644 index 000000000000..e71e8fbab6af --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/SimpleStoreActivities.java @@ -0,0 +1,60 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.fileprocessing; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Activities; +import com.amazonaws.services.simpleworkflow.flow.annotations.ActivityRegistrationOptions; +import com.amazonaws.services.simpleworkflow.flow.annotations.ExponentialRetry; + +@Activities(version = "1.0") +@ActivityRegistrationOptions(defaultTaskScheduleToStartTimeoutSeconds = 60, defaultTaskStartToCloseTimeoutSeconds = 120) +public interface SimpleStoreActivities { + + /** + * + * @param localName + * Name of the file to upload from temporary directory + * @param remoteName + * Name of the file to use on S3 bucket after upload + * @param fromBox + * Machine name which has the file that needs to be uploaded + * @return + */ + @ExponentialRetry(initialRetryIntervalSeconds = 10, maximumAttempts = 10) + public void upload(String bucketName, String localName, String targetName); + /** + * + * @param remoteName + * Name of the file to download from S3 bucket + * @param localName + * Name of the file used locally after download + * @param toBox + * This is an output parameter here. + * Used to communicate the name of the box that runs download activity + */ + @ExponentialRetry(initialRetryIntervalSeconds = 10, maximumAttempts = 10) + public String download(String bucketName, String remoteName, String localName) throws Exception; + /** + * + * @param fileName + * Name of file to delete from temporary folder + * @param machineName + * Machine which has the file locally + * @return + */ + @ExponentialRetry(initialRetryIntervalSeconds=10) + public void deleteLocalFile(String fileName); + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/SimpleStoreActivitiesS3Impl.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/SimpleStoreActivitiesS3Impl.java new file mode 100644 index 000000000000..b8168f4bffde --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/SimpleStoreActivitiesS3Impl.java @@ -0,0 +1,173 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.fileprocessing; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; + +import com.amazonaws.services.s3.AmazonS3; +import com.amazonaws.services.s3.model.S3Object; +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContextProvider; +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContextProviderImpl; + +/** + * This is an S3 Store implementation which provides Activities to + * download/upload files from S3 + * + */ +public class SimpleStoreActivitiesS3Impl implements SimpleStoreActivities { + + private static final int HEARTBEAT_INTERVAL = 60000; + + private final ActivityExecutionContextProvider contextProvider = new ActivityExecutionContextProviderImpl(); + + private final AmazonS3 s3Client; + + private final String localDirectory; + + private final String hostSpecificTaskList; + + public SimpleStoreActivitiesS3Impl(AmazonS3 s3Client, String localDirectory, String taskList) { + this.s3Client = s3Client; + this.localDirectory = localDirectory; + this.hostSpecificTaskList = taskList; + } + + @Override + public void upload(String bucketName, String localName, String targetName) { + uploadFileToS3(bucketName, localDirectory + localName, targetName); + } + + /** + * + * @param bucket + * Name of S3 bucket + * @param localName + * Name of the file to upload + * @param remoteName + * Key for the S3 object + * @param fromBox + * The value for this parameter is used to control the scheduling + * of this Activity at runtime. In this case it is putting + * requirement to run this activity on the machine name passed + * in. We want to run this activity on the same box that ran the + * download. + * @return A Value object + */ + + private void uploadFileToS3(String bucket, String localName, String remoteName) { + System.out.println("uploadToS3 begin remoteName=" + remoteName + ", localName=" + localName); + File f = new File(localName); + s3Client.putObject(bucket, remoteName, f); + System.out.println("uploadToS3 done"); + } + + @Override + public String download(String bucketName, String remoteName, String localName) throws Exception { + return downloadFileFromS3(bucketName, remoteName, localDirectory + localName); + } + + /** + * + * @param bucketName + * Name of S3 bucket + * @param remoteName + * Key to use for uploaded S3 object + * @param localName + * Name of the file locally + * @param toBox + * This is an output parameter here. Used to communicate the name + * of the box that runs download activity + * @return A Value object + * @throws IOException + */ + + private String downloadFileFromS3(String bucketName, String remoteName, String localName) throws IOException { + System.out.println("downloadFileFromS3 begin remoteName=" + remoteName + ", localName=" + localName); + FileOutputStream f = new FileOutputStream(localName); + try { + S3Object obj = s3Client.getObject(bucketName, remoteName); + InputStream inputStream = obj.getObjectContent(); + long totalSize = obj.getObjectMetadata().getContentLength(); + + try { + long totalRead = 0; + int read = 0; + byte[] bytes = new byte[1024]; + long lastHeartbeatTime = System.currentTimeMillis(); + while ((read = inputStream.read(bytes)) != -1) { + totalRead += read; + f.write(bytes, 0, read); + int progress = (int) (totalRead / totalSize * 100); + lastHeartbeatTime = heartbeat(lastHeartbeatTime, progress); + } + } + finally { + inputStream.close(); + } + } + finally { + f.close(); + } + // Return hostname file was downloaded to + System.out.println("downloadFileFromS3 done"); + return hostSpecificTaskList; + } + + @Override + public void deleteLocalFile(String fileName) { + deleteLocalFiles(localDirectory + fileName); + } + + /** + * + * @param fileName + * Filename to delete locally + * @param machineName + * The value for this parameter is used to control the scheduling + * of this Activity at runtime. In this case it is putting + * requirement to run this activity on the machine name passed + * in. + * @return + */ + + private void deleteLocalFiles(String fileName) { + System.out.println("deleteLocalActivity begin fileName=" + fileName); + File f = new File(fileName); + f.delete(); + + System.out.println("deleteLocalActivity done"); + } + + /** + * Heartbeat every 5 minutes. It is not a good idea to heartbeat too + * frequently as each noteActivityProgress event ends up eating history + * events count. + * + * @return time of the last heartbeat + */ + private long heartbeat(long lastHeartbeatTime, int progress) { + if (System.currentTimeMillis() - lastHeartbeatTime > HEARTBEAT_INTERVAL) { + ActivityExecutionContext context = contextProvider.getActivityExecutionContext(); + context.recordActivityHeartbeat(Integer.toString((progress))); + lastHeartbeatTime = System.currentTimeMillis(); + } + return lastHeartbeatTime; + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/WorkflowExecutionStarter.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/WorkflowExecutionStarter.java new file mode 100644 index 000000000000..1e0662fb6065 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/WorkflowExecutionStarter.java @@ -0,0 +1,55 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.fileprocessing; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +/** + * This is used for launching a Workflow instance of FileProcessingWorkflowExample + */ +public class WorkflowExecutionStarter { + + private static AmazonSimpleWorkflow swfService; + private static String domain; + + public static void main(String[] args) throws Exception { + + // Load configuration + ConfigHelper configHelper = ConfigHelper.createConfig(); + + // Create the client for Simple Workflow Service + swfService = configHelper.createSWFClient(); + domain = configHelper.getDomain(); + + // Start Workflow instance + String sourceBucketName = configHelper.getValueFromConfig(FileProcessingConfigKeys.WORKFLOW_INPUT_SOURCEBUCKETNAME_KEY); + String sourceFilename = configHelper.getValueFromConfig(FileProcessingConfigKeys.WORKFLOW_INPUT_SOURCEFILENAME_KEY); + String targetBucketName = configHelper.getValueFromConfig(FileProcessingConfigKeys.WORKFLOW_INPUT_TARGETBUCKETNAME_KEY); + String targetFilename = configHelper.getValueFromConfig(FileProcessingConfigKeys.WORKFLOW_INPUT_TARGETFILENAME_KEY); + + FileProcessingWorkflowClientExternalFactory clientFactory = new FileProcessingWorkflowClientExternalFactoryImpl(swfService, domain); + FileProcessingWorkflowClientExternal workflow = clientFactory.getClient(); + workflow.processFile(sourceBucketName, sourceFilename, targetBucketName, targetFilename); + + // WorkflowExecution is available after workflow creation + WorkflowExecution workflowExecution = workflow.getWorkflowExecution(); + System.out.println("Started periodic workflow with workflowId=\"" + workflowExecution.getWorkflowId() + + "\" and runId=\"" + workflowExecution.getRunId() + "\""); + + System.exit(0); + } +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/WorkflowHost.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/WorkflowHost.java new file mode 100644 index 000000000000..e0a176cb4beb --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/fileprocessing/WorkflowHost.java @@ -0,0 +1,70 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.fileprocessing; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.WorkflowWorker; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; + +/** + * This is the process which hosts all SWF Deciders and Activities specified in + * this package + */ + +public class WorkflowHost { + + private static final String DECISION_TASK_LIST = "FileProcessing"; + + public static void main(String[] args) throws Exception { + ConfigHelper configHelper = ConfigHelper.createConfig(); + AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); + String domain = configHelper.getDomain(); + + final WorkflowWorker worker = new WorkflowWorker(swfService, domain, DECISION_TASK_LIST); + worker.addWorkflowImplementationType(FileProcessingWorkflowZipImpl.class); + worker.start(); + + System.out.println("Workflow Host Service Started..."); + + Runtime.getRuntime().addShutdownHook(new Thread() { + + public void run() { + try { + worker.shutdownAndAwaitTermination(1, TimeUnit.MINUTES); + System.out.println("Workflow Host Service Terminated..."); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + } + }); + + System.out.println("Please press any key to terminate service."); + + try { + System.in.read(); + } + catch (IOException e) { + e.printStackTrace(); + } + + System.exit(0); + + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/ActivityHost.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/ActivityHost.java new file mode 100644 index 000000000000..53b7fd4b3a7b --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/ActivityHost.java @@ -0,0 +1,71 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.helloworld; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.ActivityWorker; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; + +/** + * This is the process which hosts all Activities in this sample + */ +public class ActivityHost { + + private static final String ACTIVITIES_TASK_LIST = "HelloWorld"; + + public static void main(String[] args) throws Exception { + ConfigHelper configHelper = ConfigHelper.createConfig(); + AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); + String domain = configHelper.getDomain(); + + final ActivityWorker worker = new ActivityWorker(swfService, domain, ACTIVITIES_TASK_LIST); + + // Create activity implementations + HelloWorldActivities helloWorldActivitiesImpl = new HelloWorldActivitiesImpl(); + worker.addActivitiesImplementation(helloWorldActivitiesImpl); + + worker.start(); + + System.out.println("Activity Worker Started for Task List: " + worker.getTaskListToPoll()); + + Runtime.getRuntime().addShutdownHook(new Thread() { + + public void run() { + try { + worker.shutdownAndAwaitTermination(1, TimeUnit.MINUTES); + System.out.println("Activity Worker Exited."); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + } + }); + + System.out.println("Please press any key to terminate service."); + + try { + System.in.read(); + } + catch (IOException e) { + e.printStackTrace(); + } + System.exit(0); + + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/HelloWorldActivities.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/HelloWorldActivities.java new file mode 100644 index 000000000000..d76452c11d20 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/HelloWorldActivities.java @@ -0,0 +1,31 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.helloworld; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Activities; +import com.amazonaws.services.simpleworkflow.flow.annotations.Activity; +import com.amazonaws.services.simpleworkflow.flow.annotations.ActivityRegistrationOptions; + +/** + * Contract of the hello world activities + */ +@Activities +public interface HelloWorldActivities { + + @Activity(name = "PrintHello", version = "1.0") + @ActivityRegistrationOptions(defaultTaskScheduleToStartTimeoutSeconds = 30, defaultTaskStartToCloseTimeoutSeconds = 10) + void printHello(String name); + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/HelloWorldActivitiesImpl.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/HelloWorldActivitiesImpl.java new file mode 100644 index 000000000000..12a5892f690e --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/HelloWorldActivitiesImpl.java @@ -0,0 +1,27 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.helloworld; + +/** + * Implementation of the hello world activities + */ +public class HelloWorldActivitiesImpl implements HelloWorldActivities { + + @Override + public void printHello(String name) { + System.out.println("Hello " + name + "!"); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/HelloWorldTest.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/HelloWorldTest.java new file mode 100644 index 000000000000..06b1dc547165 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/HelloWorldTest.java @@ -0,0 +1,114 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.helloworld; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Asynchronous; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.core.Task; +import com.amazonaws.services.simpleworkflow.flow.core.TryFinally; +import com.amazonaws.services.simpleworkflow.flow.junit.FlowBlockJUnit4ClassRunner; +import com.amazonaws.services.simpleworkflow.flow.junit.WorkflowTest; + +@RunWith(FlowBlockJUnit4ClassRunner.class) +public class HelloWorldTest { + + private final class TestHelloWorldActivities implements HelloWorldActivities { + + private String greeting; + + @Override + public void printHello(String name) { + greeting = "Hello " + name + "!"; + } + + public String getGreeting() { + return greeting; + } + + } + + @Rule + public WorkflowTest workflowTest = new WorkflowTest(); + + private final HelloWorldWorkflowClientFactory workflowFactory = new HelloWorldWorkflowClientFactoryImpl(); + + private TestHelloWorldActivities activitiesImplementation; + + @Before + public void setUp() throws Exception { + workflowTest.addWorkflowImplementationType(HelloWorldWorkflowImpl.class); + activitiesImplementation = new TestHelloWorldActivities(); + workflowTest.addActivitiesImplementation(activitiesImplementation); + } + + /** + * Test through generated workflow client. As workflow unit tests run in + * dummy workflow context the same client that is used for creation of child + * workflows is used. + */ + @Test + public void testThroughClient() throws Exception { + HelloWorldWorkflowClient workflow = workflowFactory.getClient(); + Promise done = workflow.helloWorld("World"); + assertGreeting(done); + } + + @Asynchronous + private void assertGreeting(Promise done) { + Assert.assertEquals("Hello World!", activitiesImplementation.getGreeting()); + } + + @Test + public void testThroughClientAssertWithTask() throws Exception { + HelloWorldWorkflowClient workflow = workflowFactory.getClient(); + Promise done = workflow.helloWorld("AWS"); + new Task(done) { + + @Override + protected void doExecute() throws Throwable { + Assert.assertEquals("Hello AWS!", activitiesImplementation.getGreeting()); + } + }; + } + + /** + * Instantiate workflow implementation object directly. Note that any object + * that is part of workflow can be unit tested through direct instantiation. + */ + @Test + public void directTest() { + final HelloWorldWorkflow workflow = new HelloWorldWorkflowImpl(); + new TryFinally() { + + @Override + protected void doTry() throws Throwable { + // helloWorld returns void so we use TryFinally + // to wait for its completion + workflow.helloWorld("SWF"); + } + + @Override + protected void doFinally() throws Throwable { + Assert.assertEquals("Hello SWF!", activitiesImplementation.getGreeting()); + } + }; + } +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/HelloWorldWorkflow.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/HelloWorldWorkflow.java new file mode 100644 index 000000000000..57116e775d4b --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/HelloWorldWorkflow.java @@ -0,0 +1,31 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.helloworld; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Execute; +import com.amazonaws.services.simpleworkflow.flow.annotations.Workflow; +import com.amazonaws.services.simpleworkflow.flow.annotations.WorkflowRegistrationOptions; + +/** + * Contract of the hello world workflow + */ +@Workflow +@WorkflowRegistrationOptions(defaultExecutionStartToCloseTimeoutSeconds = 60) +public interface HelloWorldWorkflow { + + @Execute(version = "1.0") + void helloWorld(String name); + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/HelloWorldWorkflowImpl.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/HelloWorldWorkflowImpl.java new file mode 100644 index 000000000000..fd2a67518da5 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/HelloWorldWorkflowImpl.java @@ -0,0 +1,30 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.helloworld; + + +/** + * Implementation of the hello world workflow + */ +public class HelloWorldWorkflowImpl implements HelloWorldWorkflow{ + + HelloWorldActivitiesClient client = new HelloWorldActivitiesClientImpl(); + + @Override + public void helloWorld(String name) { + client.printHello(name); + } + +} \ No newline at end of file diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/WorkflowExecutionStarter.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/WorkflowExecutionStarter.java new file mode 100644 index 000000000000..a514c336546a --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/WorkflowExecutionStarter.java @@ -0,0 +1,41 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.helloworld; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +public class WorkflowExecutionStarter { + + public static void main(String[] args) throws Exception { + ConfigHelper configHelper = ConfigHelper.createConfig(); + AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); + String domain = configHelper.getDomain(); + + HelloWorldWorkflowClientExternalFactory clientFactory = new HelloWorldWorkflowClientExternalFactoryImpl(swfService, + domain); + HelloWorldWorkflowClientExternal workflow = clientFactory.getClient(); + + // Start Wrokflow Execution + workflow.helloWorld("User"); + + // WorkflowExecution is available after workflow creation + WorkflowExecution workflowExecution = workflow.getWorkflowExecution(); + System.out.println("Started helloWorld workflow with workflowId=\"" + workflowExecution.getWorkflowId() + + "\" and runId=\"" + workflowExecution.getRunId() + "\""); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/WorkflowHost.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/WorkflowHost.java new file mode 100644 index 000000000000..2d43284ce9a4 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/helloworld/WorkflowHost.java @@ -0,0 +1,65 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.helloworld; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.WorkflowWorker; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; + +public class WorkflowHost { + + private static final String DECISION_TASK_LIST = "HelloWorldWorkflow"; + + public static void main(String[] args) throws Exception { + ConfigHelper configHelper = ConfigHelper.createConfig(); + AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); + String domain = configHelper.getDomain(); + + final WorkflowWorker worker = new WorkflowWorker(swfService, domain, DECISION_TASK_LIST); + worker.addWorkflowImplementationType(HelloWorldWorkflowImpl.class); + worker.start(); + + System.out.println("Workflow Host Service Started..."); + + Runtime.getRuntime().addShutdownHook(new Thread() { + + public void run() { + try { + worker.shutdownAndAwaitTermination(1, TimeUnit.MINUTES); + System.out.println("Workflow Host Service Terminated..."); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + } + }); + + System.out.println("Please press any key to terminate service."); + + try { + System.in.read(); + } + catch (IOException e) { + e.printStackTrace(); + } + + System.exit(0); + + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/ActivityHost.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/ActivityHost.java new file mode 100644 index 000000000000..55af6d6fdc8f --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/ActivityHost.java @@ -0,0 +1,73 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.periodicworkflow; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.ActivityWorker; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; + +/** + * This is the process which hosts all Activities in this sample + */ +public class ActivityHost { + + private static final String ACTIVITIES_TASK_LIST = "Periodic"; + + public static void main(String[] args) throws Exception { + ConfigHelper configHelper = ConfigHelper.createConfig(); + AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); + String domain = configHelper.getDomain(); + + final ActivityWorker worker = new ActivityWorker(swfService, domain, ACTIVITIES_TASK_LIST); + + // Create activity implementations + PeriodicWorkflowActivities periodicActivitiesImpl = new PeriodicWorkflowActivitiesImpl(); + worker.addActivitiesImplementation(periodicActivitiesImpl); + + worker.start(); + + System.out.println("Activity Worker Started for Task List: " + worker.getTaskListToPoll()); + + Runtime.getRuntime().addShutdownHook(new Thread() { + + public void run() { + try { + worker.shutdownAndAwaitTermination(1, TimeUnit.MINUTES); + System.out.println("Activity Worker Exited."); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + } + }); + + System.out.println("Please press any key to terminate service."); + + try { + System.in.read(); + } + catch (IOException e) { + e.printStackTrace(); + } + System.exit(0); + + } + +} + + diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/ErrorReportingActivities.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/ErrorReportingActivities.java new file mode 100644 index 000000000000..659eddad61e0 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/ErrorReportingActivities.java @@ -0,0 +1,28 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.periodicworkflow; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Activities; +import com.amazonaws.services.simpleworkflow.flow.annotations.ActivityRegistrationOptions; + +@Activities(version="1.0") +@ActivityRegistrationOptions( + defaultTaskScheduleToStartTimeoutSeconds = 100, + defaultTaskStartToCloseTimeoutSeconds = 10) +public interface ErrorReportingActivities { + + void reportFailure(Throwable e); + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/ErrorReportingActivitiesImpl.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/ErrorReportingActivitiesImpl.java new file mode 100644 index 000000000000..96fbf29c4e47 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/ErrorReportingActivitiesImpl.java @@ -0,0 +1,42 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.periodicworkflow; + +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContextProvider; +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContextProviderImpl; + +public class ErrorReportingActivitiesImpl implements ErrorReportingActivities { + + private final ActivityExecutionContextProvider contextProvider; + + public ErrorReportingActivitiesImpl() { + this.contextProvider = new ActivityExecutionContextProviderImpl(); + } + + /** + * For unit testing or IoC + */ + public ErrorReportingActivitiesImpl(ActivityExecutionContextProvider contextProvider) { + this.contextProvider = contextProvider; + } + + @Override + public void reportFailure(Throwable e) { + String runId = contextProvider.getActivityExecutionContext().getTask().getWorkflowExecution().getRunId(); + System.err.println("Run Id: " + runId + ", Failure in periodic task:"); + e.printStackTrace(); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflow.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflow.java new file mode 100644 index 000000000000..575c47ebb302 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflow.java @@ -0,0 +1,37 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.periodicworkflow; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Execute; +import com.amazonaws.services.simpleworkflow.flow.annotations.Workflow; +import com.amazonaws.services.simpleworkflow.flow.annotations.WorkflowRegistrationOptions; +import com.amazonaws.services.simpleworkflow.model.ActivityType; + +@Workflow +@WorkflowRegistrationOptions(defaultExecutionStartToCloseTimeoutSeconds = 300, defaultTaskStartToCloseTimeoutSeconds = 10) +public interface PeriodicWorkflow { + + /** + * Start workflow that executes activity according to options. + * + * @param activity + * activity type to execute + * @param options + * define the schedule of the execution. + */ + @Execute(name = "PeriodicWorkflow", version = "1.0") + void startPeriodicWorkflow(ActivityType activity, Object[] activityArguments, PeriodicWorkflowOptions options); + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflowActivities.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflowActivities.java new file mode 100644 index 000000000000..757e0642b421 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflowActivities.java @@ -0,0 +1,28 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.periodicworkflow; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Activities; +import com.amazonaws.services.simpleworkflow.flow.annotations.ActivityRegistrationOptions; + +@Activities(version="1.0") +@ActivityRegistrationOptions( + defaultTaskScheduleToStartTimeoutSeconds = 100, + defaultTaskStartToCloseTimeoutSeconds = 10) +public interface PeriodicWorkflowActivities { + + void doSomeWork(String parameter); + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflowActivitiesImpl.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflowActivitiesImpl.java new file mode 100644 index 000000000000..a4c98457cc00 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflowActivitiesImpl.java @@ -0,0 +1,54 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.periodicworkflow; + +import java.util.Random; + +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContextProvider; +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContextProviderImpl; + +public class PeriodicWorkflowActivitiesImpl implements PeriodicWorkflowActivities { + + private final ActivityExecutionContextProvider contextProvider; + + public PeriodicWorkflowActivitiesImpl() { + this.contextProvider = new ActivityExecutionContextProviderImpl(); + } + + /** + * For unit testing or IoC + */ + public PeriodicWorkflowActivitiesImpl(ActivityExecutionContextProvider contextProvider) { + this.contextProvider = contextProvider; + } + + @Override + // Activity takes random time to execute to show that it is waited if workflow parameter waitForActivityCompletion + // is set to true + public void doSomeWork(String parameter) { + String runId = contextProvider.getActivityExecutionContext().getTask().getWorkflowExecution().getRunId(); + Random r = new Random(); + long delay = r.nextInt(3000); + System.out.println("Run Id: " + runId + ", Do some periodic task here for " + delay + " milliseconds with parameter=" + + parameter); + try { + Thread.sleep(delay); + } + catch (InterruptedException e) { + } + + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflowImpl.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflowImpl.java new file mode 100644 index 000000000000..7351b02309bb --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflowImpl.java @@ -0,0 +1,135 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.periodicworkflow; + +import com.amazonaws.services.simpleworkflow.flow.DecisionContextProvider; +import com.amazonaws.services.simpleworkflow.flow.DecisionContextProviderImpl; +import com.amazonaws.services.simpleworkflow.flow.DynamicActivitiesClient; +import com.amazonaws.services.simpleworkflow.flow.DynamicActivitiesClientImpl; +import com.amazonaws.services.simpleworkflow.flow.WorkflowClock; +import com.amazonaws.services.simpleworkflow.flow.annotations.Asynchronous; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; +import com.amazonaws.services.simpleworkflow.flow.core.TryCatchFinally; +import com.amazonaws.services.simpleworkflow.model.ActivityType; + +public class PeriodicWorkflowImpl implements PeriodicWorkflow { + + private static final int SECOND = 1000; + + /** + * This is needed to keep the decider logic deterministic as using + * System.currentTimeMillis() in your decider logic is not. + * WorkflowClock.currentTimeMillis() should be used instead. + */ + private final WorkflowClock clock; + + private final DynamicActivitiesClient activities; + + private final ErrorReportingActivitiesClient errorReporting; + + /** + * Used to create new run of the periodic workflow to reset history. This + * allows "infinite" workflows. + */ + private final PeriodicWorkflowSelfClient selfClient; + + private ActivityType activityType; + + private PeriodicWorkflowOptions options; + + private Object[] activityArguments; + + public PeriodicWorkflowImpl() { + DecisionContextProvider contextProvider = new DecisionContextProviderImpl(); + clock = contextProvider.getDecisionContext().getWorkflowClock(); + activities = new DynamicActivitiesClientImpl(); + errorReporting = new ErrorReportingActivitiesClientImpl(); + selfClient = new PeriodicWorkflowSelfClientImpl(); + } + + /** + * Constructor used for unit testing or configuration through IOC container + */ + public PeriodicWorkflowImpl(WorkflowClock clock, DynamicActivitiesClient activities, + ErrorReportingActivitiesClient errorReporting, PeriodicWorkflowSelfClient selfClient) { + this.clock = clock; + this.activities = activities; + this.errorReporting = errorReporting; + this.selfClient = selfClient; + } + + @Override + public void startPeriodicWorkflow(final ActivityType activity, final Object[] activityArguments, + final PeriodicWorkflowOptions options) { + final long startTime = clock.currentTimeMillis(); + this.activityType = activity; + this.activityArguments = activityArguments; + this.options = options; + + // Use TryCatch to ensure that workflow is not going to fail as it causes new run not being created + new TryCatchFinally() { + + @Override + protected void doTry() throws Throwable { + long startTime = clock.currentTimeMillis(); + callPeriodicActivity(startTime, Promise.Void(), Promise.Void()); + } + + @Override + protected void doCatch(Throwable e) throws Throwable { + errorReporting.reportFailure(e); + } + + @Override + protected void doFinally() throws Throwable { + long secondsLeft = options.getCompleteAfterSeconds() - (clock.currentTimeMillis() - startTime) / SECOND; + PeriodicWorkflowOptions nextRunOptions = new PeriodicWorkflowOptions(); + nextRunOptions.setCompleteAfterSeconds(secondsLeft); + nextRunOptions.setContinueAsNewAfterSeconds(options.getContinueAsNewAfterSeconds()); + nextRunOptions.setExecutionPeriodSeconds(options.getExecutionPeriodSeconds()); + nextRunOptions.setWaitForActivityCompletion(options.isWaitForActivityCompletion()); + options.setCompleteAfterSeconds(secondsLeft); + if (secondsLeft > 0) { + // Request new run of the current workflow instance. + selfClient.startPeriodicWorkflow(activity, activityArguments, nextRunOptions); + } + } + }; + } + + @Asynchronous + public void callPeriodicActivity(long startTime, Promise... waitFor) { + long currentTime = clock.currentTimeMillis(); + if ((currentTime - startTime) < options.getContinueAsNewAfterSeconds() * SECOND) { + + // Call activity using dynamic client. Return type is specified as Void as it is not used, but activity that + // returns some other type can be called this way. + Promise activityCompletion = activities.scheduleActivity(activityType, activityArguments, null, Void.class); + + if (!options.isWaitForActivityCompletion()) { + // Promise.Void() returns already ready promise of type Void + activityCompletion = Promise.Void(); + } + // Create a timer to re-run your periodic activity after activity completion, + // but not earlier then after delay of executionPeriodSeconds. + // However in real cron workflows, delay should be calculated everytime to run activity at + // a predefined time. + Promise timer = clock.createTimer(options.getExecutionPeriodSeconds()); + + callPeriodicActivity(startTime, timer, activityCompletion); + } + } + +} \ No newline at end of file diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflowOptions.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflowOptions.java new file mode 100644 index 000000000000..b7fd93da1360 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflowOptions.java @@ -0,0 +1,74 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.periodicworkflow; + +public class PeriodicWorkflowOptions { + + private long executionPeriodSeconds; + + private boolean waitForActivityCompletion; + + private long continueAsNewAfterSeconds; + + private long completeAfterSeconds; + + public long getExecutionPeriodSeconds() { + return executionPeriodSeconds; + } + + /** + * Interval between activity executions + */ + public void setExecutionPeriodSeconds(long executionPeriodSeconds) { + this.executionPeriodSeconds = executionPeriodSeconds; + } + + public boolean isWaitForActivityCompletion() { + return waitForActivityCompletion; + } + + /** + * Should the new activity execution be delayed until the previous one + * completion? + */ + public void setWaitForActivityCompletion(boolean waitForActivityCompletion) { + this.waitForActivityCompletion = waitForActivityCompletion; + } + + public long getContinueAsNewAfterSeconds() { + return continueAsNewAfterSeconds; + } + + /** + * how frequently the new run of the workflow (whith an empty history) + * should be created. + */ + public void setContinueAsNewAfterSeconds(long continueAsNewAfterSeconds) { + this.continueAsNewAfterSeconds = continueAsNewAfterSeconds; + } + + public long getCompleteAfterSeconds() { + return completeAfterSeconds; + } + + /** + * Complete the workflow without creating a new run after the specified + * interval. + */ + public void setCompleteAfterSeconds(long completeAfterSeconds) { + this.completeAfterSeconds = completeAfterSeconds; + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflowTest.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflowTest.java new file mode 100644 index 000000000000..83379ec2d28a --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/PeriodicWorkflowTest.java @@ -0,0 +1,154 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.periodicworkflow; + +import junit.framework.Assert; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContext; +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContextProvider; +import com.amazonaws.services.simpleworkflow.flow.ActivityExecutionContextProviderImpl; +import com.amazonaws.services.simpleworkflow.flow.core.TryFinally; +import com.amazonaws.services.simpleworkflow.flow.junit.FlowBlockJUnit4ClassRunner; +import com.amazonaws.services.simpleworkflow.flow.junit.WorkflowTest; +import com.amazonaws.services.simpleworkflow.model.ActivityType; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +//Have to use Flow JUnit runner if timeout is specified on any @Test +//annotation. +@RunWith(FlowBlockJUnit4ClassRunner.class) +public class PeriodicWorkflowTest { + + private final class TestPeriodicWorkflowActivities implements + PeriodicWorkflowActivities { + + private final ActivityExecutionContextProvider contextProvider = new ActivityExecutionContextProviderImpl(); + + private int workCount; + + private int currentRunWorkCount; + + private String runId; + + @Override + public void doSomeWork(String parameter) { + // Reset counter on the new run which changes when workflow + // continues as new + ActivityExecutionContext activityExecutionContext = contextProvider + .getActivityExecutionContext(); + WorkflowExecution workflowExecution = activityExecutionContext + .getWorkflowExecution(); + String runId = workflowExecution.getRunId(); + if (this.runId != null && !runId.equals(this.runId)) { + currentRunWorkCount = 0; + } + this.runId = runId; + workCount++; + currentRunWorkCount++; + } + + public int getWorkCount() { + return workCount; + } + + public int getCurrentRunWorkCount() { + return currentRunWorkCount; + } + } + + private final class TestErrorReportingActivities implements + ErrorReportingActivities { + + private Throwable failure; + + @Override + public void reportFailure(Throwable e) { + failure = e; + } + + public Throwable getFailure() { + return failure; + } + } + + @Rule + public WorkflowTest workflowTest = new WorkflowTest(); + + private PeriodicWorkflowClientFactory workflowClientFactory = new PeriodicWorkflowClientFactoryImpl(); + + private TestPeriodicWorkflowActivities periodicActivitiesImplementation; + + private TestErrorReportingActivities errorReportingActivitiesImplementation; + + @Before + public void setUp() throws Exception { + periodicActivitiesImplementation = new TestPeriodicWorkflowActivities(); + workflowTest + .addActivitiesImplementation(periodicActivitiesImplementation); + errorReportingActivitiesImplementation = new TestErrorReportingActivities(); + workflowTest + .addActivitiesImplementation(errorReportingActivitiesImplementation); + workflowTest.addWorkflowImplementationType(PeriodicWorkflowImpl.class); + workflowTest.setDisableOutstandingTasksCheck(true); + } + + @After + public void tearDown() throws Exception { + } + + @Test(timeout = 2000) + public void testPeriodic() { + workflowTest.setClockAccelerationCoefficient(100); + workflowTest.setDisableOutstandingTasksCheck(true); + final PeriodicWorkflowClient workflow = workflowClientFactory + .getClient(); + + final PeriodicWorkflowOptions options = new PeriodicWorkflowOptions(); + options.setExecutionPeriodSeconds(10); + options.setContinueAsNewAfterSeconds(30); + options.setCompleteAfterSeconds(120); + options.setWaitForActivityCompletion(true); + + final ActivityType activityType = new ActivityType(); + activityType.setName("PeriodicWorkflowActivities.doSomeWork"); + activityType.setVersion("1.0"); + final Object[] parameters = new Object[] { "parameter1" }; + + new TryFinally() { + + @Override + protected void doTry() throws Throwable { + workflow.startPeriodicWorkflow(activityType, parameters, + options); + } + + @Override + protected void doFinally() throws Throwable { + Assert.assertEquals(120 / 10, + periodicActivitiesImplementation.getWorkCount()); + Assert.assertEquals(30 / 10, periodicActivitiesImplementation + .getCurrentRunWorkCount()); + Assert.assertNull(errorReportingActivitiesImplementation + .getFailure()); + } + }; + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/WorkflowExecutionStarter.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/WorkflowExecutionStarter.java new file mode 100644 index 000000000000..5bf2ddc40f84 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/WorkflowExecutionStarter.java @@ -0,0 +1,75 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.periodicworkflow; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; +import com.amazonaws.services.simpleworkflow.model.ActivityType; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecutionAlreadyStartedException; + +public class WorkflowExecutionStarter { + + private static AmazonSimpleWorkflow swfService; + + private static String domain; + + public static void main(String[] args) throws Exception { + + // Load configuration + ConfigHelper configHelper = ConfigHelper.createConfig(); + + // Create the client for Simple Workflow Service + swfService = configHelper.createSWFClient(); + domain = configHelper.getDomain(); + + // Start Workflow execution + PeriodicWorkflowClientExternalFactory clientFactory = new PeriodicWorkflowClientExternalFactoryImpl(swfService, domain); + + // Passing instance id to ensure that only one periodic workflow can be active at a time. + // Use different id for each schedule. + PeriodicWorkflowClientExternal workflow = clientFactory.getClient("periodic1"); + + // Execute activity every two 10 seconds, wait for it to complete before starting the new one, + // create new run every 30 seconds and stop the workflow after two minutes. + // Obviously these periods are so low to make example run fast enough to not be boring. + // In production case there is no need to create new runs so frequently. + PeriodicWorkflowOptions options = new PeriodicWorkflowOptions(); + options.setExecutionPeriodSeconds(10); + options.setContinueAsNewAfterSeconds(30); + options.setCompleteAfterSeconds(120); + options.setWaitForActivityCompletion(true); + + ActivityType activityType = new ActivityType(); + activityType.setName("PeriodicWorkflowActivities.doSomeWork"); + activityType.setVersion("1.0"); + Object[] parameters = new Object[] { "parameter1" }; + + try { + workflow.startPeriodicWorkflow(activityType, parameters, options); + // WorkflowExecution is available after workflow creation + WorkflowExecution workflowExecution = workflow.getWorkflowExecution(); + System.out.println("Started periodic workflow with workflowId=\"" + workflowExecution.getWorkflowId() + + "\" and runId=\"" + workflowExecution.getRunId() + "\""); + } + catch (WorkflowExecutionAlreadyStartedException e) { + // It is expected to get this exception if start is called before workflow run is completed. + System.out.println("Periodic workflow with workflowId=\"" + workflow.getWorkflowExecution().getWorkflowId() + + " is already running"); + } + + System.exit(0); + } +} \ No newline at end of file diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/WorkflowHost.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/WorkflowHost.java new file mode 100644 index 000000000000..6bfb9095e1ae --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/periodicworkflow/WorkflowHost.java @@ -0,0 +1,64 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.periodicworkflow; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.WorkflowWorker; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; + +public class WorkflowHost { + + private static final String DECISION_TASK_LIST = "PeriodicWorkflow"; + + public static void main(String[] args) throws Exception { + ConfigHelper configHelper = ConfigHelper.createConfig(); + AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); + String domain = configHelper.getDomain(); + + final WorkflowWorker worker = new WorkflowWorker(swfService, domain, DECISION_TASK_LIST); + worker.addWorkflowImplementationType(PeriodicWorkflowImpl.class); + worker.start(); + + System.out.println("Workflow Host Service Started..."); + + Runtime.getRuntime().addShutdownHook(new Thread() { + + public void run() { + try { + worker.shutdownAndAwaitTermination(1, TimeUnit.MINUTES); + System.out.println("Workflow Host Service Terminated..."); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + } + }); + + System.out.println("Please press any key to terminate service."); + + try { + System.in.read(); + } + catch (IOException e) { + e.printStackTrace(); + } + + System.exit(0); + + } +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/ActivityHost.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/ActivityHost.java new file mode 100644 index 000000000000..6d034fdefd4e --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/ActivityHost.java @@ -0,0 +1,73 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.splitmerge; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +import com.amazonaws.services.s3.AmazonS3; +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.ActivityWorker; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; + +/** + * This is the process which hosts all Activities in this sample + */ +public class ActivityHost { + + private static final String ACTIVITIES_TASK_LIST = "AverageCalculator"; + + public static void main(String[] args) throws Exception { + ConfigHelper configHelper = ConfigHelper.createConfig(); + AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); + AmazonS3 s3Client = configHelper.createS3Client(); + String domain = configHelper.getDomain(); + + final ActivityWorker worker = new ActivityWorker(swfService, domain, ACTIVITIES_TASK_LIST); + + // Create activity implementations + AverageCalculatorActivitiesImpl avgCalcActivitiesImpl = new AverageCalculatorActivitiesImpl(s3Client); + worker.addActivitiesImplementation(avgCalcActivitiesImpl); + + worker.start(); + + System.out.println("Activity Worker Started for Task List: " + worker.getTaskListToPoll()); + + Runtime.getRuntime().addShutdownHook(new Thread() { + + public void run() { + try { + worker.shutdownAndAwaitTermination(1, TimeUnit.MINUTES); + System.out.println("Activity Worker Exited."); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + } + }); + + System.out.println("Please press any key to terminate service."); + + try { + System.in.read(); + } + catch (IOException e) { + e.printStackTrace(); + } + System.exit(0); + + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/AverageCalculatorActivities.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/AverageCalculatorActivities.java new file mode 100644 index 000000000000..7a55ca1ad484 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/AverageCalculatorActivities.java @@ -0,0 +1,36 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.splitmerge; + +import java.io.IOException; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Activities; +import com.amazonaws.services.simpleworkflow.flow.annotations.Activity; +import com.amazonaws.services.simpleworkflow.flow.annotations.ActivityRegistrationOptions; +import com.amazonaws.services.simpleworkflow.flow.annotations.ExponentialRetry; + +@Activities(version = "1.0") +@ActivityRegistrationOptions(defaultTaskScheduleToStartTimeoutSeconds = 30, defaultTaskStartToCloseTimeoutSeconds = 30) +public interface AverageCalculatorActivities { + + @Activity(name = "computeDataSize") + int computeDataSizeForInputData(String bucketName, String filename); + + @ExponentialRetry(initialRetryIntervalSeconds = 10, maximumAttempts = 10) + int computeSumForChunk(String bucketName, String filename, int chunkNumber, int chunkSize) throws IOException; + + void reportResult(double average); + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/AverageCalculatorActivitiesImpl.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/AverageCalculatorActivitiesImpl.java new file mode 100644 index 000000000000..d82f2513d57a --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/AverageCalculatorActivitiesImpl.java @@ -0,0 +1,90 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.splitmerge; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +import com.amazonaws.services.s3.AmazonS3; +import com.amazonaws.services.s3.model.GetObjectRequest; +import com.amazonaws.services.s3.model.ObjectMetadata; +import com.amazonaws.services.s3.model.S3Object; + +public class AverageCalculatorActivitiesImpl implements AverageCalculatorActivities { + + private static final int ROW_SIZE = 7; + + private final AmazonS3 storage; + + public AverageCalculatorActivitiesImpl(AmazonS3 storage) { + this.storage = storage; + } + + @Override + public int computeDataSizeForInputData(String bucketName, String filename) { + ObjectMetadata metadata = storage.getObjectMetadata(bucketName, filename); + long size = metadata.getContentLength(); + return (int) size / ROW_SIZE; + } + + @Override + public int computeSumForChunk(String bucketName, String filename, int chunkNumber, int chunkSize) throws IOException { + int sum = 0; + int from = chunkNumber * chunkSize; + int to = from + chunkSize; + + int offset = chunkNumber * chunkSize * ROW_SIZE; + int bytesToRead = chunkSize * ROW_SIZE; + + // Create a request to download content for computing the sum for this chunk + GetObjectRequest getRequest = new GetObjectRequest(bucketName, filename); + getRequest.setRange(offset, offset + bytesToRead - 1); + + // Download content + S3Object obj = storage.getObject(getRequest); + InputStream inputStream = obj.getObjectContent(); + InputStreamReader inputStreamReader = null; + BufferedReader reader = null; + try { + String line = null; + inputStreamReader = new InputStreamReader(inputStream); + reader = new BufferedReader(inputStreamReader); + + // Compute sum for downloaded content + while ((line = reader.readLine()) != null) { + sum += Integer.parseInt(line); + } + } + finally { + if (reader != null) + reader.close(); + if (inputStreamReader != null) + inputStreamReader.close(); + if (inputStream != null) + inputStream.close(); + } + + System.out.printf("Sum from '%d' to '%d' is: '%d'\n", from + 1, to, sum); + return sum; + } + + @Override + public void reportResult(double average) { + System.out.printf("Average is: %6.2f.\n", average); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/AverageCalculatorWorkflow.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/AverageCalculatorWorkflow.java new file mode 100644 index 000000000000..75c742d3330c --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/AverageCalculatorWorkflow.java @@ -0,0 +1,29 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.splitmerge; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Execute; +import com.amazonaws.services.simpleworkflow.flow.annotations.Workflow; +import com.amazonaws.services.simpleworkflow.flow.annotations.WorkflowRegistrationOptions; + +@Workflow +@WorkflowRegistrationOptions( + defaultExecutionStartToCloseTimeoutSeconds = 300, + defaultTaskStartToCloseTimeoutSeconds = 10) +public interface AverageCalculatorWorkflow { + + @Execute(name = "SplitMergeWorkflowExample", version = "1.0") + void average(String bucketName, String fileName, final int numberOfWorkers); +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/AverageCalculatorWorkflowImpl.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/AverageCalculatorWorkflowImpl.java new file mode 100644 index 000000000000..b720139d7e0d --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/AverageCalculatorWorkflowImpl.java @@ -0,0 +1,28 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.splitmerge; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +public class AverageCalculatorWorkflowImpl implements AverageCalculatorWorkflow { + + @Override + public void average(String bucketName, String fileName, int numberOfWorkers) { + PartitionedAverageCalculator calculator = new PartitionedAverageCalculatorImpl(numberOfWorkers, bucketName); + Promise result = calculator.computeAverage(fileName); + calculator.reportResult(result); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/PartitionedAverageCalculator.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/PartitionedAverageCalculator.java new file mode 100644 index 000000000000..3b114ae6a8cb --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/PartitionedAverageCalculator.java @@ -0,0 +1,25 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.splitmerge; + +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +public interface PartitionedAverageCalculator { + + public abstract Promise computeAverage(String inputFile); + + public abstract void reportResult(Promise result); + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/PartitionedAverageCalculatorImpl.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/PartitionedAverageCalculatorImpl.java new file mode 100644 index 000000000000..8ec1b50676db --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/PartitionedAverageCalculatorImpl.java @@ -0,0 +1,72 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.splitmerge; + +import java.util.ArrayList; +import java.util.List; + +import com.amazonaws.services.simpleworkflow.flow.annotations.Asynchronous; +import com.amazonaws.services.simpleworkflow.flow.annotations.Wait; +import com.amazonaws.services.simpleworkflow.flow.core.Promise; + +public class PartitionedAverageCalculatorImpl implements PartitionedAverageCalculator { + + private final AverageCalculatorActivitiesClient client = new AverageCalculatorActivitiesClientImpl(); + + private final int numberOfWorkers; + + private final String bucketName; + + public PartitionedAverageCalculatorImpl(int numberOfWorkers, String bucketName) { + this.numberOfWorkers = numberOfWorkers; + this.bucketName = bucketName; + } + + @Override + public Promise computeAverage(String inputFile) { + Promise dataSize = client.computeDataSizeForInputData(bucketName, inputFile); + return computeAverageDistributed(inputFile, dataSize); + } + + @Asynchronous + private Promise computeAverageDistributed(String inputFile, Promise dataSize) { + int chunkSize = dataSize.get() / numberOfWorkers; + + // Create an array list to hold the result returned by each worker + List> results = new ArrayList>(); + for (int chunkNumber = 0; chunkNumber < numberOfWorkers; chunkNumber++) { + // Splitting computation for each chunk as separate activity + results.add(client.computeSumForChunk(bucketName, inputFile, chunkNumber, chunkSize)); + } + // Merge phase + return mergeSumAndComputeAverage(results, dataSize.get()); + } + + @Asynchronous + private Promise mergeSumAndComputeAverage(@Wait List> results, int dataSize){ + int totalSum = 0; + for(Promise workerSum: results){ + totalSum += workerSum.get(); + } + return Promise.asPromise((double) totalSum / (double) dataSize); + } + + @Override + @Asynchronous + public void reportResult(Promise result){ + client.reportResult(result); + } + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/SplitMergeConfigKeys.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/SplitMergeConfigKeys.java new file mode 100644 index 000000000000..d9c916368150 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/SplitMergeConfigKeys.java @@ -0,0 +1,23 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.splitmerge; + +public class SplitMergeConfigKeys { + + static final String S3_BUCKET_NAME = "SplitMerge.Input.BucketName"; + static final String S3_INPUT_FILENAME = "SplitMerge.Input.FileName"; + static final String NUMBER_OF_WORKERS = "SplitMerge.Input.NumberOfWorkers"; + +} diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/WorkflowExecutionStarter.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/WorkflowExecutionStarter.java new file mode 100644 index 000000000000..0e2aaa86852f --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/WorkflowExecutionStarter.java @@ -0,0 +1,51 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.splitmerge; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; +import com.amazonaws.services.simpleworkflow.model.WorkflowExecution; + +public class WorkflowExecutionStarter { + private static AmazonSimpleWorkflow swfService; + private static String domain; + + public static void main(String[] args) throws Exception { + + // Load configuration + ConfigHelper configHelper = ConfigHelper.createConfig(); + + // Create the client for Simple Workflow Service + swfService = configHelper.createSWFClient(); + domain = configHelper.getDomain(); + + // Start Workflow execution + String bucketName = configHelper.getValueFromConfig(SplitMergeConfigKeys.S3_BUCKET_NAME); + String fileName = configHelper.getValueFromConfig(SplitMergeConfigKeys.S3_INPUT_FILENAME); + String val = configHelper.getValueFromConfig(SplitMergeConfigKeys.NUMBER_OF_WORKERS); + int numberOfWorkers = Integer.parseInt(val); + + AverageCalculatorWorkflowClientExternalFactory clientFactory = new AverageCalculatorWorkflowClientExternalFactoryImpl(swfService, domain); + AverageCalculatorWorkflowClientExternal workflow = clientFactory.getClient(); + workflow.average(bucketName, fileName, numberOfWorkers); + + // WorkflowExecution is available after workflow creation + WorkflowExecution workflowExecution = workflow.getWorkflowExecution(); + System.out.println("Started periodic workflow with workflowId=\"" + workflowExecution.getWorkflowId() + + "\" and runId=\"" + workflowExecution.getRunId() + "\""); + + System.exit(0); + } +} \ No newline at end of file diff --git a/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/WorkflowHost.java b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/WorkflowHost.java new file mode 100644 index 000000000000..dbb0b3bb53a4 --- /dev/null +++ b/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/splitmerge/WorkflowHost.java @@ -0,0 +1,66 @@ +/* + * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +package com.amazonaws.services.simpleworkflow.flow.examples.splitmerge; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +import com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflow; +import com.amazonaws.services.simpleworkflow.flow.WorkflowWorker; +import com.amazonaws.services.simpleworkflow.flow.examples.common.ConfigHelper; + +public class WorkflowHost { + + private static final String DECISION_TASK_LIST = "AverageCalculatorWorkflow"; + + public static void main(String[] args) throws Exception { + ConfigHelper configHelper = ConfigHelper.createConfig(); + AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); + String domain = configHelper.getDomain(); + + final WorkflowWorker worker = new WorkflowWorker(swfService, domain, DECISION_TASK_LIST); + worker.addWorkflowImplementationType(AverageCalculatorWorkflowImpl.class); + worker.start(); + + System.out.println("Workflow Host Service Started..."); + + Runtime.getRuntime().addShutdownHook(new Thread() { + + public void run() { + try { + worker.shutdownAndAwaitTermination(1, TimeUnit.MINUTES); + System.out.println("Workflow Host Service Terminated..."); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + } + }); + + System.out.println("Please press any key to terminate service."); + + try { + System.in.read(); + } + catch (IOException e) { + e.printStackTrace(); + } + + System.exit(0); + + } + +} +