Example usage for com.amazonaws.services.simpleworkflow AmazonSimpleWorkflowClient listOpenWorkflowExecutions

List of usage examples for com.amazonaws.services.simpleworkflow AmazonSimpleWorkflowClient listOpenWorkflowExecutions

Introduction

In this page you can find the example usage for com.amazonaws.services.simpleworkflow AmazonSimpleWorkflowClient listOpenWorkflowExecutions.

Prototype

@Override
public WorkflowExecutionInfos listOpenWorkflowExecutions(ListOpenWorkflowExecutionsRequest request) 

Source Link

Document

Returns a list of open workflow executions in the specified domain that meet the filtering criteria.

Usage

From source file:org.diksha.common.dyutils.SchedulerUDE.java

License:Apache License

public void listStatus(String clientId, SchedulerConfig schedulerConfig) {

    DynamoDBMapper mapper = DyDBUtils.getDynamoDBMapper();
    SchedulerWorkflowState schedulerWorkflowState = mapper.load(SchedulerWorkflowState.class, clientId);

    System.out.println("clientID : " + clientId);
    System.out.println("     Launch Parameters");
    System.out/*from  ww  w . j a v  a 2  s. co m*/
            .println("           Function: (" + this.functionName + ") with context = " + this.functionContext);
    System.out.println("                 CronExpression  : " + this.cronExpression);
    System.out.println("                 RepeatTimes     : " + this.repeatTimes);
    System.out.println("                 StartTimeDate   : " + this.startTimeDate);
    System.out.println("                 EndTimeDate     : " + this.endTimeDate);
    System.out.println("      Current State");

    int cnt = schedulerWorkflowState.loopCount - 1;

    System.out.println("            status of loop       : " + schedulerWorkflowState.getLoopState());

    System.out.println("            # of times executed  : " + cnt);

    System.out.println("            Last Executed @      : " + schedulerWorkflowState.lastExecutionTimeDate);
    System.out.println("            Next Proposed Time @ : " + schedulerWorkflowState.lastProposedTimeDate);

    AmazonSimpleWorkflowClient amazonSimpleWorkflowClient = new AmazonSimpleWorkflowClient(
            DyDBUtils.getAwsCredentials());
    amazonSimpleWorkflowClient.setEndpoint(schedulerConfig.getEndPoint());

    ListOpenWorkflowExecutionsRequest listOpenWorkflowExecutionsRequest = new ListOpenWorkflowExecutionsRequest()
            .withDomain(schedulerConfig.getDomain())
            .withExecutionFilter(new WorkflowExecutionFilter().withWorkflowId(clientId))
            .withReverseOrder(new Boolean("true"))
            .withStartTimeFilter(new ExecutionTimeFilter().withOldestDate(new Date(0L)));

    WorkflowExecutionInfos openWorkflowExecutionInfos = amazonSimpleWorkflowClient
            .listOpenWorkflowExecutions(listOpenWorkflowExecutionsRequest);

    List<WorkflowExecutionInfo> listOpenWorkflowExecutionInfo = openWorkflowExecutionInfos.getExecutionInfos();

    ListClosedWorkflowExecutionsRequest listClosedWorkflowExecutionsRequest = new ListClosedWorkflowExecutionsRequest()
            .withDomain(schedulerConfig.getDomain())
            .withExecutionFilter(new WorkflowExecutionFilter().withWorkflowId(clientId))
            .withReverseOrder(new Boolean("true"))
            .withStartTimeFilter(new ExecutionTimeFilter().withOldestDate(new Date(0L)));

    WorkflowExecutionInfos closedWorkflowExecutionInfos = amazonSimpleWorkflowClient
            .listClosedWorkflowExecutions(listClosedWorkflowExecutionsRequest);

    List<WorkflowExecutionInfo> listClosedWorkflowExecutionInfo = closedWorkflowExecutionInfos
            .getExecutionInfos();

    listActivitiesInWEI(schedulerConfig, listOpenWorkflowExecutionInfo);
    listActivitiesInWEI(schedulerConfig, listClosedWorkflowExecutionInfo);

    System.out.println("\n");

}

From source file:org.diksha.common.dyutils.SchedulerUDE.java

License:Apache License

public static ArrayList<String> listOpenExecutionsFromSWF(String config) {
    ArrayList<String> retValue = new ArrayList<String>();

    SchedulerConfig schedulerConfig = DyDBUtils.getSchedulerConfig(config);

    AmazonSimpleWorkflowClient amazonSimpleWorkflowClient = new AmazonSimpleWorkflowClient(
            DyDBUtils.getAwsCredentials());
    amazonSimpleWorkflowClient.setEndpoint(schedulerConfig.getEndPoint());

    ListOpenWorkflowExecutionsRequest listOpenWorkflowExecutionsRequest = new ListOpenWorkflowExecutionsRequest()
            .withDomain(schedulerConfig.getDomain())
            .withStartTimeFilter(new ExecutionTimeFilter().withOldestDate(new Date(0L)));

    WorkflowExecutionInfos workflowExecutionInfos = amazonSimpleWorkflowClient
            .listOpenWorkflowExecutions(listOpenWorkflowExecutionsRequest);

    String nextPageToken;/*w w  w  .  j  a v a 2 s .co  m*/

    do {
        java.util.List<WorkflowExecutionInfo> listWorkflowExecutionInfos = workflowExecutionInfos
                .getExecutionInfos();
        for (int cnt = 0; cnt < listWorkflowExecutionInfos.size(); cnt++) {
            retValue.add(listWorkflowExecutionInfos.get(cnt).getExecution().getWorkflowId());
        }

        nextPageToken = workflowExecutionInfos.getNextPageToken();
    } while (nextPageToken != null);

    return retValue;
}