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 Object

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


Constructor Summary
WorkflowExecutionUtils()
           
 
Method Summary
static WorkflowExecutionInfo describeWorkflowInstance(AmazonSimpleWorkflow service, String domain, WorkflowExecution workflowExecution)
           
static String getFailureCause(HistoryEvent historyEvent)
           
static List<HistoryEvent> getHistory(AmazonSimpleWorkflow service, String domain, WorkflowExecution workflowExecution)
           
static History getHistoryPage(String nextPageToken, AmazonSimpleWorkflow service, String domain, WorkflowExecution workflowExecution)
           
static String getId(HistoryEvent historyEvent)
           
static HistoryEvent getInstanceCloseEvent(AmazonSimpleWorkflow service, String domain, WorkflowExecution workflowExecution)
           
static WorkflowExecutionCompletedEventAttributes getWorkflowExecutionResult(AmazonSimpleWorkflow service, 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 String prettyPrintDecision(Decision decision)
          Returns single decision in a human readable format
static String prettyPrintDecisions(Iterable<Decision> decisions)
           
static String prettyPrintHistory(AmazonSimpleWorkflow service, String domain, WorkflowExecution workflowExecution)
          Returns workflow instance history in a human readable format.
static String prettyPrintHistory(AmazonSimpleWorkflow service, String domain, WorkflowExecution workflowExecution, boolean showWorkflowTasks)
          Returns workflow instance history in a human readable format.
static String prettyPrintHistory(History history, boolean showWorkflowTasks)
          Returns workflow instance history in a human readable format.
static String prettyPrintHistory(Iterable<HistoryEvent> events, boolean showWorkflowTasks)
           
static String prettyPrintHistoryEvent(HistoryEvent event)
          Returns single event in a human readable format
static String printDetails(String details)
           
static String truncateDetails(String details)
           
static String truncateReason(String reason)
          Simple Workflow limits length of the reason field.
static WorkflowExecutionCompletedEventAttributes waitForWorkflowExecutionResult(AmazonSimpleWorkflow service, String domain, WorkflowExecution workflowExecution)
          Blocks until workflow instance completes and returns its result.
static WorkflowExecutionCompletedEventAttributes waitForWorkflowExecutionResult(AmazonSimpleWorkflow service, String domain, WorkflowExecution workflowExecution, long timeoutSeconds)
          Waits up to specified timeout until workflow instance completes and returns its result.
static String waitForWorkflowInstanceCompletion(AmazonSimpleWorkflow service, String domain, WorkflowExecution workflowExecution)
          Blocks until workflow instance completes.
static String waitForWorkflowInstanceCompletion(AmazonSimpleWorkflow service, String domain, WorkflowExecution workflowExecution, long timeoutSeconds)
          Waits up to specified timeout for workflow instance completion.
static String waitForWorkflowInstanceCompletionAcrossGenerations(AmazonSimpleWorkflow service, String domain, WorkflowExecution workflowExecution)
          Like waitForWorkflowInstanceCompletionAcrossGenerations(AmazonSimpleWorkflow, String, WorkflowExecution, long) , but with no timeout.
static String waitForWorkflowInstanceCompletionAcrossGenerations(AmazonSimpleWorkflow service, 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,
                                                                                       String domain,
                                                                                       WorkflowExecution workflowExecution)
                                                                                throws 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:
InterruptedException - if thread is interrupted
RuntimeException - if workflow instance ended up in any state but completed

waitForWorkflowExecutionResult

public static WorkflowExecutionCompletedEventAttributes waitForWorkflowExecutionResult(AmazonSimpleWorkflow service,
                                                                                       String domain,
                                                                                       WorkflowExecution workflowExecution,
                                                                                       long timeoutSeconds)
                                                                                throws InterruptedException,
                                                                                       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:
InterruptedException - if thread is interrupted
TimeoutException - if instance is not complete after specified timeout
RuntimeException - if workflow instance ended up in any state but completed

getWorkflowExecutionResult

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

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

getInstanceCloseEvent

public static HistoryEvent getInstanceCloseEvent(AmazonSimpleWorkflow service,
                                                 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 String getId(HistoryEvent historyEvent)

getFailureCause

public static String getFailureCause(HistoryEvent historyEvent)

waitForWorkflowInstanceCompletion

public static String waitForWorkflowInstanceCompletion(AmazonSimpleWorkflow service,
                                                       String domain,
                                                       WorkflowExecution workflowExecution)
                                                throws 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:
InterruptedException

waitForWorkflowInstanceCompletion

public static String waitForWorkflowInstanceCompletion(AmazonSimpleWorkflow service,
                                                       String domain,
                                                       WorkflowExecution workflowExecution,
                                                       long timeoutSeconds)
                                                throws InterruptedException,
                                                       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:
TimeoutException
InterruptedException

waitForWorkflowInstanceCompletionAcrossGenerations

public static String waitForWorkflowInstanceCompletionAcrossGenerations(AmazonSimpleWorkflow service,
                                                                        String domain,
                                                                        WorkflowExecution workflowExecution,
                                                                        long timeoutSeconds)
                                                                 throws InterruptedException,
                                                                        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:
InterruptedException
TimeoutException
See Also:
waitForWorkflowInstanceCompletion(AmazonSimpleWorkflow, String, WorkflowExecution, long)

waitForWorkflowInstanceCompletionAcrossGenerations

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

Parameters:
service -
domain -
workflowExecution -
Returns:
Throws:
InterruptedException

describeWorkflowInstance

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

prettyPrintHistory

public static String prettyPrintHistory(AmazonSimpleWorkflow service,
                                        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 String prettyPrintHistory(AmazonSimpleWorkflow service,
                                        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 List<HistoryEvent> getHistory(AmazonSimpleWorkflow service,
                                            String domain,
                                            WorkflowExecution workflowExecution)

getHistoryPage

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

prettyPrintHistory

public static 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 String prettyPrintHistory(Iterable<HistoryEvent> events,
                                        boolean showWorkflowTasks)

prettyPrintDecisions

public static String prettyPrintDecisions(Iterable<Decision> decisions)

prettyPrintHistoryEvent

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

Parameters:
event - event to pretty print

prettyPrintDecision

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

Parameters:
event - event to pretty print

printDetails

public static String printDetails(String details)

truncateReason

public static String truncateReason(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 String truncateDetails(String details)


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