List of usage examples for com.amazonaws.services.simpleworkflow.model WorkflowExecution WorkflowExecution
WorkflowExecution
From source file:com.eucalyptus.cloudformation.CloudFormationService.java
License:Open Source License
public DeleteStackResponseType deleteStack(final DeleteStackType request) throws CloudFormationException { DeleteStackResponseType reply = request.getReply(); try {//from w ww . j av a2 s . com final Context ctx = Contexts.lookup(); final User user = ctx.getUser(); final String userId = user.getUserId(); final String accountId = ctx.getAccountNumber(); final String accountAlias = ctx.getAccountAlias(); final String stackName = request.getStackName(); if (stackName == null) throw new ValidationErrorException("Stack name is null"); StackEntity stackEntity = StackEntityManager.getNonDeletedStackByNameOrId(stackName, accountId); if (stackEntity == null && ctx.isAdministrator() && stackName.startsWith(STACK_ID_PREFIX)) { stackEntity = StackEntityManager.getNonDeletedStackByNameOrId(stackName, null); } if (stackEntity != null) { if (!RestrictedTypes.filterPrivileged().apply(stackEntity)) { throw new AccessDeniedException("Not authorized."); } final String stackAccountId = stackEntity.getAccountId(); // check to see if there has been a delete workflow. If one exists and is still going on, just quit: boolean existingOpenDeleteWorkflow = false; List<StackWorkflowEntity> deleteWorkflows = StackWorkflowEntityManager.getStackWorkflowEntities( stackEntity.getStackId(), StackWorkflowEntity.WorkflowType.DELETE_STACK_WORKFLOW); if (deleteWorkflows != null && !deleteWorkflows.isEmpty()) { if (deleteWorkflows.size() > 1) { throw new ValidationErrorException( "More than one delete workflow exists for " + stackEntity.getStackId()); // TODO: InternalFailureException (?) } // see if the workflow is open try { AmazonSimpleWorkflow simpleWorkflowClient = WorkflowClientManager.getSimpleWorkflowClient(); StackWorkflowEntity deleteStackWorkflowEntity = deleteWorkflows.get(0); DescribeWorkflowExecutionRequest describeWorkflowExecutionRequest = new DescribeWorkflowExecutionRequest(); describeWorkflowExecutionRequest.setDomain(deleteStackWorkflowEntity.getDomain()); WorkflowExecution execution = new WorkflowExecution(); execution.setRunId(deleteStackWorkflowEntity.getRunId()); execution.setWorkflowId(deleteStackWorkflowEntity.getWorkflowId()); describeWorkflowExecutionRequest.setExecution(execution); WorkflowExecutionDetail workflowExecutionDetail = simpleWorkflowClient .describeWorkflowExecution(describeWorkflowExecutionRequest); if ("OPEN".equals(workflowExecutionDetail.getExecutionInfo().getExecutionStatus())) { existingOpenDeleteWorkflow = true; } } catch (Exception ex) { LOG.error("Unable to get status of delete workflow for " + stackEntity.getStackId() + ", assuming not open"); LOG.debug(ex); } } if (!existingOpenDeleteWorkflow) { String stackId = stackEntity.getStackId(); StackWorkflowTags stackWorkflowTags = new StackWorkflowTags(stackId, stackName, stackAccountId, accountAlias); WorkflowClientFactory workflowClientFactory = new WorkflowClientFactory( WorkflowClientManager.getSimpleWorkflowClient(), CloudFormationProperties.SWF_DOMAIN, CloudFormationProperties.SWF_TASKLIST); WorkflowDescriptionTemplate workflowDescriptionTemplate = new DeleteStackWorkflowDescriptionTemplate(); InterfaceBasedWorkflowClient<DeleteStackWorkflow> client = workflowClientFactory .getNewWorkflowClient(DeleteStackWorkflow.class, workflowDescriptionTemplate, stackWorkflowTags); DeleteStackWorkflow deleteStackWorkflow = new DeleteStackWorkflowClient(client); deleteStackWorkflow.deleteStack(stackId, stackAccountId, stackEntity.getResourceDependencyManagerJson(), userId); StackWorkflowEntityManager.addOrUpdateStackWorkflowEntity(stackEntity.getStackId(), StackWorkflowEntity.WorkflowType.DELETE_STACK_WORKFLOW, CloudFormationProperties.SWF_DOMAIN, client.getWorkflowExecution().getWorkflowId(), client.getWorkflowExecution().getRunId()); } } } catch (Exception ex) { handleException(ex); } return reply; }
From source file:com.swf.common.WorkflowExecutionFlowThreadDumper.java
License:Open Source License
public static void main(String[] args) throws Exception { if (args.length < 3) { System.err.println("Usage: java " + WorkflowExecutionFlowThreadDumper.class.getName() + "<workflow implementation class> <workflowId> <runId>"); System.exit(1);/*w w w .j a v a2 s.c o m*/ } ConfigHelper configHelper = ConfigHelper.createConfig(); AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); String domain = configHelper.getDomain(); WorkflowExecution workflowExecution = new WorkflowExecution(); String workflowId = args[1]; workflowExecution.setWorkflowId(workflowId); String runId = args[2]; workflowExecution.setRunId(runId); String implementationTypeName = args[0]; @SuppressWarnings("unchecked") Class<Object> workflowImplementationType = (Class<Object>) Class.forName(implementationTypeName); WorkflowReplayer<Object> replayer = new WorkflowReplayer<Object>(swfService, domain, workflowExecution, workflowImplementationType); System.out.println("Beginning workflow replay for " + workflowExecution); try { String flowThreadDump = replayer.getAsynchronousThreadDumpAsString(); System.out.println("Workflow asynchronous thread dump:"); System.out.println(flowThreadDump); } catch (WorkflowException e) { System.out.println("No asynchronous thread dump available as workflow has failed: " + e); } }
From source file:com.swf.common.WorkflowExecutionGetState.java
License:Open Source License
public static void main(String[] args) throws Exception { if (args.length < 2) { System.err//from w ww .ja va 2 s.c o m .println("Usage: java " + WorkflowExecutionGetState.class.getName() + " <workflowId> <runId>"); System.exit(1); } ConfigHelper configHelper = ConfigHelper.createConfig(); AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); String domain = configHelper.getDomain(); WorkflowExecution workflowExecution = new WorkflowExecution(); String workflowId = args[1]; workflowExecution.setWorkflowId(workflowId); String runId = args[2]; workflowExecution.setRunId(runId); GenericWorkflowClientExternal client = new GenericWorkflowClientExternalImpl(swfService, domain); String state = client.getWorkflowState(workflowExecution); System.out.println("Current state of " + workflowExecution + ":"); System.out.println(state); }
From source file:com.swf.common.WorkflowExecutionHistoryPrinter.java
License:Open Source License
public static void main(String[] args) throws Exception { if (args.length < 2) { System.err.println(//from w w w. java 2s .co m "Usage: java " + WorkflowExecutionHistoryPrinter.class.getName() + " <workflowId> <runId>"); System.exit(1); } ConfigHelper configHelper = ConfigHelper.createConfig(); AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); String domain = configHelper.getDomain(); WorkflowExecution workflowExecution = new WorkflowExecution(); String workflowId = args[0]; workflowExecution.setWorkflowId(workflowId); String runId = args[1]; workflowExecution.setRunId(runId); System.out.println(WorkflowExecutionUtils.prettyPrintHistory(swfService, domain, workflowExecution, true)); }
From source file:com.swf.common.WorkflowExecutionReplayer.java
License:Open Source License
public static void main(String[] args) throws Exception { if (args.length < 3) { System.err.println("Usage: java " + WorkflowExecutionReplayer.class.getName() + "<workflow implementation class> <workflowId> <runId>"); System.exit(1);/*from w ww .jav a2s. c o m*/ } ConfigHelper configHelper = ConfigHelper.createConfig(); AmazonSimpleWorkflow swfService = configHelper.createSWFClient(); String domain = configHelper.getDomain(); WorkflowExecution workflowExecution = new WorkflowExecution(); String workflowId = args[1]; workflowExecution.setWorkflowId(workflowId); String runId = args[2]; workflowExecution.setRunId(runId); String implementationTypeName = args[0]; @SuppressWarnings("unchecked") Class<Object> workflowImplementationType = (Class<Object>) Class.forName(implementationTypeName); WorkflowReplayer<Object> replayer = new WorkflowReplayer<Object>(swfService, domain, workflowExecution, workflowImplementationType); System.out.println("Beginning workflow replay for " + workflowExecution); Object workflow = replayer.loadWorkflow(); System.out.println("Workflow implementation object:"); System.out.println(workflow); System.out.println("Done workflow replay for " + workflowExecution); }
From source file:org.apache.camel.component.aws.swf.CamelSWFWorkflowClient.java
License:Apache License
public Map<String, Object> describeWorkflowInstance(String workflowId, String runId) { DescribeWorkflowExecutionRequest describeRequest = new DescribeWorkflowExecutionRequest(); describeRequest.setDomain(configuration.getDomainName()); describeRequest.setExecution(new WorkflowExecution().withWorkflowId(workflowId).withRunId(runId)); WorkflowExecutionDetail executionDetail = endpoint.getSWClient().describeWorkflowExecution(describeRequest); WorkflowExecutionInfo instanceMetadata = executionDetail.getExecutionInfo(); Map<String, Object> info = new HashMap<String, Object>(); info.put("closeStatus", instanceMetadata.getCloseStatus()); info.put("closeTimestamp", instanceMetadata.getCloseTimestamp()); info.put("executionStatus", instanceMetadata.getExecutionStatus()); info.put("tagList", instanceMetadata.getTagList()); info.put("executionDetail", executionDetail); return info;//from w w w .j ava 2 s . co m }
From source file:org.apache.camel.component.aws.swf.CamelSWFWorkflowClient.java
License:Apache License
public List<HistoryEvent> getWorkflowExecutionHistory(String workflowId, String runId) { return WorkflowExecutionUtils.getHistory(endpoint.getSWClient(), configuration.getDomainName(), new WorkflowExecution().withWorkflowId(workflowId).withRunId(runId)); }
From source file:org.apache.camel.component.aws.swf.CamelSWFWorkflowClient.java
License:Apache License
DynamicWorkflowClientExternal getDynamicWorkflowClient(String workflowId, String runId) { GenericWorkflowClientExternalImpl genericClient = new GenericWorkflowClientExternalImpl( endpoint.getSWClient(), configuration.getDomainName()); WorkflowExecution workflowExecution = new WorkflowExecution(); workflowExecution.setWorkflowId(workflowId != null ? workflowId : genericClient.generateUniqueId()); workflowExecution.setRunId(runId);//from w ww. j av a 2 s . c om return new DynamicWorkflowClientExternalImpl(workflowExecution, null, endpoint.getStartWorkflowOptions(), null, genericClient); }