List of usage examples for com.amazonaws.services.simpleworkflow AmazonSimpleWorkflowClient setEndpoint
@Deprecated public void setEndpoint(String endpoint) throws IllegalArgumentException
From source file:com.eucalyptus.simpleworkflow.common.client.Config.java
License:Open Source License
public static AmazonSimpleWorkflow buildClient(final Supplier<User> user, final String text) throws AuthException { final AWSCredentialsProvider credentialsProvider = new SecurityTokenAWSCredentialsProvider(user); final AmazonSimpleWorkflowClient client = new AmazonSimpleWorkflowClient(credentialsProvider, buildConfiguration(text));//w w w.java2 s . c om client.setEndpoint(ServiceUris.remote(Topology.lookup(SimpleWorkflow.class)).toString()); client.addRequestHandler(new RequestHandler2() { @Override public void beforeRequest(final Request<?> request) { // Add nonce to ensure unique request signature request.addHeader("Euca-Nonce", UUID.randomUUID().toString()); } @Override public void afterResponse(final Request<?> request, final Response<?> response) { } @Override public void afterError(final Request<?> request, final Response<?> response, final Exception e) { final String errorMessage = Strings.nullToEmpty(e.getMessage()); boolean resetEndpoint = false; if (Exceptions.isCausedBy(e, JSONException.class) && (errorMessage.contains("Response Code: 404") || errorMessage.contains("Response Code: 503"))) { resetEndpoint = true; } else if (Exceptions.isCausedBy(e, ConnectException.class)) { resetEndpoint = true; } else if (Exceptions.isCausedBy(e, NoHttpResponseException.class)) { resetEndpoint = true; } if (resetEndpoint) { try { client.setEndpoint(ServiceUris.remote(Topology.lookup(SimpleWorkflow.class)).toString()); } catch (final Exception e2) { // retry on next failure } } if (e instanceof AmazonServiceException) { final int status = ((AmazonServiceException) e).getStatusCode(); if (status == 403) { credentialsProvider.refresh(); } } } }); return client; }
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 w w w . j ava 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 void listActivitiesInWEI(SchedulerConfig schedulerConfig, List<WorkflowExecutionInfo> listWorkflowExecutionInfo) { AmazonSimpleWorkflowClient amazonSimpleWorkflowClient = new AmazonSimpleWorkflowClient( DyDBUtils.getAwsCredentials()); amazonSimpleWorkflowClient.setEndpoint(schedulerConfig.getEndPoint()); for (int cnt2 = 0; cnt2 < listWorkflowExecutionInfo.size(); cnt2++) { WorkflowExecutionInfo workflowExecutionInfo = listWorkflowExecutionInfo.get(cnt2); WorkflowExecution workflowExecution = workflowExecutionInfo.getExecution(); // System.out.println(workflowExecution); GetWorkflowExecutionHistoryRequest getWorkflowExecutionHistoryRequest = new GetWorkflowExecutionHistoryRequest() .withDomain(schedulerConfig.getDomain()).withExecution(workflowExecution); History history = amazonSimpleWorkflowClient .getWorkflowExecutionHistory(getWorkflowExecutionHistoryRequest); List<HistoryEvent> historyEvents; String nextPageToken;// w w w . ja va 2s . c o m do { historyEvents = history.getEvents(); for (int cnt3 = 0; cnt3 < historyEvents.size(); cnt3++) { // , , , , , , HistoryEvent he = historyEvents.get(cnt3); String eventType = historyEvents.get(cnt3).getEventType(); if (eventType.equals("ActivityTaskStarted") || eventType.equals("ActivityTaskCompleted") || eventType.equals("ActivityTaskFailed") || eventType.equals("ActivityTaskTimedOut") || eventType.equals("ActivityTaskCanceled") || eventType.equals("ActivityTaskCancelRequested") ) { if (he.getEventType().equals("ActivityTaskCompleted")) System.out.format("\n %30s %20s ", he.getEventType(), he.getEventTimestamp()); } } nextPageToken = history.getNextPageToken(); history.setNextPageToken(nextPageToken); } while (nextPageToken != null); } }
From source file:org.diksha.common.dyutils.SchedulerUDE.java
License:Apache License
public static int countOpenExecutionsFromSWF(String config) { SchedulerConfig schedulerConfig = DyDBUtils.getSchedulerConfig(config); AmazonSimpleWorkflowClient amazonSimpleWorkflowClient = new AmazonSimpleWorkflowClient( DyDBUtils.getAwsCredentials()); amazonSimpleWorkflowClient.setEndpoint(schedulerConfig.getEndPoint()); CountOpenWorkflowExecutionsRequest countOpenWorkflowExecutionsRequest = new CountOpenWorkflowExecutionsRequest() .withDomain(schedulerConfig.getDomain()); countOpenWorkflowExecutionsRequest/* ww w .jav a 2 s. c om*/ .setStartTimeFilter(new ExecutionTimeFilter().withOldestDate(new Date(0L))); WorkflowExecutionCount workflowExecutionCount = amazonSimpleWorkflowClient .countOpenWorkflowExecutions(countOpenWorkflowExecutionsRequest); return workflowExecutionCount.getCount(); }
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;//from w ww .j av a2 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; }