Did this page help you?

   Yes   No   Tell us about it...

com.amazonaws.services.simpleworkflow.flow.common
Class WorkflowExecutionUtils

java.lang.Object
  extended by com.amazonaws.services.simpleworkflow.flow.common.WorkflowExecutionUtils

public class WorkflowExecutionUtils
extends java.lang.Object

Convenience methods to be used by unit tests and during development.


Constructor Summary
WorkflowExecutionUtils()
           
 
Method Summary
static WorkflowExecutionInfo describeWorkflowInstance(AmazonSimpleWorkflow service, java.lang.String domain, WorkflowExecution workflowExecution)
           
static java.lang.String getFailureCause(HistoryEvent historyEvent)
           
static java.util.List<HistoryEvent> getHistory(AmazonSimpleWorkflow service, java.lang.String domain, WorkflowExecution workflowExecution)
           
static History getHistoryPage(java.lang.String nextPageToken, AmazonSimpleWorkflow service, java.lang.String domain, WorkflowExecution workflowExecution)
           
static java.lang.String getId(HistoryEvent historyEvent)
           
static HistoryEvent getInstanceCloseEvent(AmazonSimpleWorkflow service, java.lang.String domain, WorkflowExecution workflowExecution)
           
static WorkflowExecutionCompletedEventAttributes getWorkflowExecutionResult(AmazonSimpleWorkflow service, java.lang.String domain, WorkflowExecution workflowExecution)
          Returns result of workflow instance execution.
static WorkflowExecution getWorkflowIdFromExternalWorkflowCompletedEvent(HistoryEvent event)
           
static boolean isActivityTaskClosedEvent(HistoryEvent event)
           
static boolean isExternalWorkflowClosedEvent(HistoryEvent event)
           
static boolean isWorkflowExecutionCompletedEvent(HistoryEvent event)
           
static java.lang.String prettyPrintDecision(Decision decision)
          Returns single decision in a human readable format
static java.lang.String prettyPrintDecisions(java.lang.Iterable<Decision> decisions)
           
static java.lang.String prettyPrintHistory(AmazonSimpleWorkflow service, java.lang.String domain, WorkflowExecution workflowExecution)
          Returns workflow instance history in a human readable format.
static java.lang.String prettyPrintHistory(AmazonSimpleWorkflow service, java.lang.String domain, WorkflowExecution workflowExecution, boolean showWorkflowTasks)
          Returns workflow instance history in a human readable format.
static java.lang.String prettyPrintHistory(History history, boolean showWorkflowTasks)
          Returns workflow instance history in a human readable format.
static java.lang.String prettyPrintHistory(java.lang.Iterable<HistoryEvent> events, boolean showWorkflowTasks)
           
static java.lang.String prettyPrintHistoryEvent(HistoryEvent event)
          Returns single event in a human readable format
static java.lang.String printDetails(java.lang.String details)
           
static java.lang.String truncateDetails(java.lang.String details)
           
static java.lang.String truncateReason(java.lang.String reason)
          Simple Workflow limits length of the reason field.
static WorkflowExecutionCompletedEventAttributes waitForWorkflowExecutionResult(AmazonSimpleWorkflow service, java.lang.String domain, WorkflowExecution workflowExecution)
          Blocks until workflow instance completes and returns its result.
static WorkflowExecutionCompletedEventAttributes waitForWorkflowExecutionResult(AmazonSimpleWorkflow service, java.lang.String domain, WorkflowExecution workflowExecution, long timeoutSeconds)
          Waits up to specified timeout until workflow instance completes and returns its result.
static java.lang.String waitForWorkflowInstanceCompletion(AmazonSimpleWorkflow service, java.lang.String domain, WorkflowExecution workflowExecution)
          Blocks until workflow instance completes.
static java.lang.String waitForWorkflowInstanceCompletion(AmazonSimpleWorkflow service, java.lang.String domain, WorkflowExecution workflowExecution, long timeoutSeconds)
          Waits up to specified timeout for workflow instance completion.
static java.lang.String waitForWorkflowInstanceCompletionAcrossGenerations(AmazonSimpleWorkflow service, java.lang.String domain, WorkflowExecution workflowExecution)
          Like waitForWorkflowInstanceCompletionAcrossGenerations(AmazonSimpleWorkflow, String, WorkflowExecution, long) , but with no timeout.
static java.lang.String waitForWorkflowInstanceCompletionAcrossGenerations(AmazonSimpleWorkflow service, java.lang.String domain, WorkflowExecution workflowExecution, long timeoutSeconds)
          Like waitForWorkflowInstanceCompletion(AmazonSimpleWorkflow, String, WorkflowExecution, long) , except will wait for continued generations of the original workflow execution too.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkflowExecutionUtils

public WorkflowExecutionUtils()
Method Detail

waitForWorkflowExecutionResult

public static WorkflowExecutionCompletedEventAttributes waitForWorkflowExecutionResult(AmazonSimpleWorkflow service,
                                                                                       java.lang.String domain,
                                                                                       WorkflowExecution workflowExecution)
                                                                                throws java.lang.InterruptedException
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.

Parameters:
workflowExecution - result of AmazonSimpleWorkflow#startWorkflowInstance(com.amazonaws.services.simpleworkflow.model.StartWorkflowInstanceRequest)
Returns:
workflow instance result.
Throws:
java.lang.InterruptedException - if thread is interrupted
java.lang.RuntimeException - if workflow instance ended up in any state but completed

waitForWorkflowExecutionResult

public static WorkflowExecutionCompletedEventAttributes waitForWorkflowExecutionResult(AmazonSimpleWorkflow service,
                                                                                       java.lang.String domain,
                                                                                       WorkflowExecution workflowExecution,
                                                                                       long timeoutSeconds)
                                                                                throws java.lang.InterruptedException,
                                                                                       java.util.concurrent.TimeoutException
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.

Parameters:
workflowExecution - result of AmazonSimpleWorkflow#startWorkflowInstance(com.amazonaws.services.simpleworkflow.model.StartWorkflowInstanceRequest)
Returns:
workflow instance result.
Throws:
java.lang.InterruptedException - if thread is interrupted
java.util.concurrent.TimeoutException - if instance is not complete after specified timeout
java.lang.RuntimeException - if workflow instance ended up in any state but completed

getWorkflowExecutionResult

public static WorkflowExecutionCompletedEventAttributes getWorkflowExecutionResult(AmazonSimpleWorkflow service,
                                                                                   java.lang.String domain,
                                                                                   WorkflowExecution workflowExecution)
Returns result of workflow instance execution. result of AmazonSimpleWorkflow#startWorkflowInstance(com.amazonaws.services.simpleworkflow.model.StartWorkflowInstanceRequest)

Throws:
java.lang.IllegalStateException - if workflow is still running
java.lang.RuntimeException - if workflow instance ended up in any state but completed

getInstanceCloseEvent

public static HistoryEvent getInstanceCloseEvent(AmazonSimpleWorkflow service,
                                                 java.lang.String domain,
                                                 WorkflowExecution workflowExecution)

isWorkflowExecutionCompletedEvent

public static boolean isWorkflowExecutionCompletedEvent(HistoryEvent event)

isActivityTaskClosedEvent

public static boolean isActivityTaskClosedEvent(HistoryEvent event)

isExternalWorkflowClosedEvent

public static boolean isExternalWorkflowClosedEvent(HistoryEvent event)

getWorkflowIdFromExternalWorkflowCompletedEvent

public static WorkflowExecution getWorkflowIdFromExternalWorkflowCompletedEvent(HistoryEvent event)

getId

public static java.lang.String getId(HistoryEvent historyEvent)

getFailureCause

public static java.lang.String getFailureCause(HistoryEvent historyEvent)

waitForWorkflowInstanceCompletion

public static java.lang.String waitForWorkflowInstanceCompletion(AmazonSimpleWorkflow service,
                                                                 java.lang.String domain,
                                                                 WorkflowExecution workflowExecution)
                                                          throws java.lang.InterruptedException
Blocks until workflow instance completes. Never use in production setting as polling for worklow instance status is an expensive operation.

Parameters:
workflowExecution - result of AmazonSimpleWorkflow#startWorkflowInstance(com.amazonaws.services.simpleworkflow.model.StartWorkflowInstanceRequest)
Returns:
instance close status
Throws:
java.lang.InterruptedException

waitForWorkflowInstanceCompletion

public static java.lang.String waitForWorkflowInstanceCompletion(AmazonSimpleWorkflow service,
                                                                 java.lang.String domain,
                                                                 WorkflowExecution workflowExecution,
                                                                 long timeoutSeconds)
                                                          throws java.lang.InterruptedException,
                                                                 java.util.concurrent.TimeoutException
Waits up to specified timeout for workflow instance completion. Never use in production setting as polling for worklow instance status is an expensive operation.

Parameters:
workflowExecution - result of AmazonSimpleWorkflow#startWorkflowInstance(com.amazonaws.services.simpleworkflow.model.StartWorkflowInstanceRequest)
timeoutSeconds - maximum time to wait for completion. 0 means wait forever.
Returns:
instance close status
Throws:
java.util.concurrent.TimeoutException
java.lang.InterruptedException

waitForWorkflowInstanceCompletionAcrossGenerations

public static java.lang.String waitForWorkflowInstanceCompletionAcrossGenerations(AmazonSimpleWorkflow service,
                                                                                  java.lang.String domain,
                                                                                  WorkflowExecution workflowExecution,
                                                                                  long timeoutSeconds)
                                                                           throws java.lang.InterruptedException,
                                                                                  java.util.concurrent.TimeoutException
Like waitForWorkflowInstanceCompletion(AmazonSimpleWorkflow, String, WorkflowExecution, long) , except will wait for continued generations of the original workflow execution too.

Parameters:
service -
domain -
workflowExecution -
timeoutSeconds -
Returns:
Throws:
java.lang.InterruptedException
java.util.concurrent.TimeoutException
See Also:
waitForWorkflowInstanceCompletion(AmazonSimpleWorkflow, String, WorkflowExecution, long)

waitForWorkflowInstanceCompletionAcrossGenerations

public static java.lang.String waitForWorkflowInstanceCompletionAcrossGenerations(AmazonSimpleWorkflow service,
                                                                                  java.lang.String domain,
                                                                                  WorkflowExecution workflowExecution)
                                                                           throws java.lang.InterruptedException
Like waitForWorkflowInstanceCompletionAcrossGenerations(AmazonSimpleWorkflow, String, WorkflowExecution, long) , but with no timeout.

Parameters:
service -
domain -
workflowExecution -
Returns:
Throws:
java.lang.InterruptedException

describeWorkflowInstance

public static WorkflowExecutionInfo describeWorkflowInstance(AmazonSimpleWorkflow service,
                                                             java.lang.String domain,
                                                             WorkflowExecution workflowExecution)

prettyPrintHistory

public static java.lang.String prettyPrintHistory(AmazonSimpleWorkflow service,
                                                  java.lang.String domain,
                                                  WorkflowExecution workflowExecution)
Returns workflow instance history in a human readable format.

Parameters:
workflowExecution - result of AmazonSimpleWorkflow#startWorkflowInstance(com.amazonaws.services.simpleworkflow.model.StartWorkflowInstanceRequest)

prettyPrintHistory

public static java.lang.String prettyPrintHistory(AmazonSimpleWorkflow service,
                                                  java.lang.String domain,
                                                  WorkflowExecution workflowExecution,
                                                  boolean showWorkflowTasks)
Returns workflow instance history in a human readable format.

Parameters:
workflowExecution - result of AmazonSimpleWorkflow#startWorkflowInstance(com.amazonaws.services.simpleworkflow.model.StartWorkflowInstanceRequest)
showWorkflowTasks - when set to false workflow task events (decider events) are not included

getHistory

public static java.util.List<HistoryEvent> getHistory(AmazonSimpleWorkflow service,
                                                      java.lang.String domain,
                                                      WorkflowExecution workflowExecution)

getHistoryPage

public static History getHistoryPage(java.lang.String nextPageToken,
                                     AmazonSimpleWorkflow service,
                                     java.lang.String domain,
                                     WorkflowExecution workflowExecution)

prettyPrintHistory

public static java.lang.String prettyPrintHistory(History history,
                                                  boolean showWorkflowTasks)
Returns workflow instance history in a human readable format.

Parameters:
showWorkflowTasks - when set to false workflow task events (decider events) are not included

prettyPrintHistory

public static java.lang.String prettyPrintHistory(java.lang.Iterable<HistoryEvent> events,
                                                  boolean showWorkflowTasks)

prettyPrintDecisions

public static java.lang.String prettyPrintDecisions(java.lang.Iterable<Decision> decisions)

prettyPrintHistoryEvent

public static java.lang.String prettyPrintHistoryEvent(HistoryEvent event)
Returns single event in a human readable format

Parameters:
event - event to pretty print

prettyPrintDecision

public static java.lang.String prettyPrintDecision(Decision decision)
Returns single decision in a human readable format

Parameters:
event - event to pretty print

printDetails

public static java.lang.String printDetails(java.lang.String details)

truncateReason

public static java.lang.String truncateReason(java.lang.String reason)
Simple Workflow limits length of the reason field. This method truncates the passed argument to the maximum length.

Parameters:
reason - string value to truncate
Returns:
truncated value

truncateDetails

public static java.lang.String truncateDetails(java.lang.String details)


Copyright © 2010 Amazon Web Services, Inc. All Rights Reserved.