List of usage examples for com.amazonaws.services.simpleworkflow AmazonSimpleWorkflow shutdown
void shutdown();
From source file:com.eucalyptus.cloudformation.StackAdminUtils.java
License:Open Source License
public static void cancelWorkflows(String stackId) throws CloudFormationException, AuthException { StackEntity stackEntity = StackEntityManager.getNonDeletedStackById(stackId); if (stackEntity == null) { throw new ValidationErrorException("Can not find undeleted stack " + stackId); }/*from ww w. j a va 2 s .c o m*/ String stackAccountId = stackEntity.getAccountId(); AmazonSimpleWorkflow simpleWorkflowClient = Config .buildClient(CloudFormationAWSCredentialsProvider.CloudFormationUserSupplier.INSTANCE); try { // first cancel all outstanding workflows for (StackWorkflowEntity stackWorkflowEntity : StackWorkflowEntityManager .getStackWorkflowEntities(stackId)) { try { RequestCancelWorkflowExecutionRequest requestCancelWorkflowExecutionRequest = new RequestCancelWorkflowExecutionRequest(); requestCancelWorkflowExecutionRequest.setWorkflowId(stackWorkflowEntity.getWorkflowId()); requestCancelWorkflowExecutionRequest.setRunId(stackWorkflowEntity.getRunId()); requestCancelWorkflowExecutionRequest.setDomain(stackWorkflowEntity.getDomain()); simpleWorkflowClient.requestCancelWorkflowExecution(requestCancelWorkflowExecutionRequest); } catch (UnknownResourceException ex) { ; // don't bother } } } finally { simpleWorkflowClient.shutdown(); } }
From source file:com.eucalyptus.simpleworkflow.common.client.WorkflowClientStandalone.java
License:Open Source License
private static void addShutdownHook(final AmazonSimpleWorkflow swfClient) { Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { public void run() { LOG.debug("Shutting down existing SWF clients"); final WorkflowClientStandalone instance = WorkflowClientStandalone.getInstance(); for (final WorkflowClient client : instance.clients) { try { client.stop();//from w w w .j a v a2 s .c om } catch (final InterruptedException ex) { ; } } swfClient.shutdown(); } })); }