public StartBranchDataContainer(Long startPosition, Long executionPlanId, Map<String, Serializable> contexts, SystemContext systemContext) { Validate.notNull(startPosition); Validate.notNull(executionPlanId); Validate.notNull(contexts); Validate.notNull(systemContext); this.startPosition = startPosition; this.executionPlanId = executionPlanId; this.systemContext = new SystemContext(systemContext); this.contexts = new HashMap<>(); for (String name : contexts.keySet()) { this.contexts.put(name, contexts.get(name)); } }
public StartBranchDataContainer(Long startPosition, Long executionPlanId, Map<String, Serializable> contexts, SystemContext systemContext) { Validate.notNull(startPosition); Validate.notNull(executionPlanId); Validate.notNull(contexts); Validate.notNull(systemContext); this.startPosition = startPosition; this.executionPlanId = executionPlanId; this.systemContext = new SystemContext(systemContext); this.contexts = new HashMap<>(); for (String name : contexts.keySet()) { this.contexts.put(name, contexts.get(name)); } }
protected void addBranch(Long startPosition, Long executionPlanId, Map<String, Serializable> context, ExecutionRuntimeServices executionRuntimeServices) { if (!contextMap.containsKey(BRANCH_DATA)) { contextMap.put(BRANCH_DATA, new ArrayList<StartBranchDataContainer>()); } List<StartBranchDataContainer> branchesData = getFromMap(BRANCH_DATA); Map<String, Serializable> contextMapForBranch = new HashMap<>(executionRuntimeServices.contextMap); contextMapForBranch.remove(BRANCH_DATA); contextMapForBranch.put(SCORE_EVENTS_QUEUE, (ArrayDeque) new ArrayDeque<>()); branchesData.add(new StartBranchDataContainer(startPosition, executionPlanId, context, new SystemContext(contextMapForBranch))); }
protected void addBranch(Long startPosition, Long executionPlanId, Map<String, Serializable> context, ExecutionRuntimeServices executionRuntimeServices) { if (!contextMap.containsKey(BRANCH_DATA)) { contextMap.put(BRANCH_DATA, new ArrayList<StartBranchDataContainer>()); } List<StartBranchDataContainer> branchesData = getFromMap(BRANCH_DATA); Map<String, Serializable> contextMapForBranch = new HashMap<>(executionRuntimeServices.contextMap); contextMapForBranch.remove(BRANCH_DATA); contextMapForBranch.put(SCORE_EVENTS_QUEUE, (ArrayDeque) new ArrayDeque<>()); branchesData.add(new StartBranchDataContainer(startPosition, executionPlanId, context, new SystemContext(contextMapForBranch))); }
private void checkExceptionInBranch(EndBranchDataContainer branch) { //first we check that no exception was thrown during the execution of the branch String branchException = branch.getException(); if (StringUtils.isNotEmpty(branchException)) { Map<String, Serializable> systemContextMap = branch.getSystemContext(); String branchId = null; if (MapUtils.isNotEmpty(systemContextMap)) { ExecutionRuntimeServices branchExecutionRuntimeServices = new SystemContext(systemContextMap); branchId = branchExecutionRuntimeServices.getBranchId(); } logger.error("There was an error running branch: " + branchId + " Error is: " + branchException); throw new RuntimeException(BRANCH_EXCEPTION_PREFIX + ": \n" + branchException); } }
private void checkExceptionInBranch(EndBranchDataContainer branch) { //first we check that no exception was thrown during the execution of the branch String branchException = branch.getException(); if (StringUtils.isNotEmpty(branchException)) { Map<String, Serializable> systemContextMap = branch.getSystemContext(); String branchId = null; if (MapUtils.isNotEmpty(systemContextMap)) { ExecutionRuntimeServices branchExecutionRuntimeServices = new SystemContext(systemContextMap); branchId = branchExecutionRuntimeServices.getBranchId(); } logger.error("There was an error running branch: " + branchId + " Error is: " + branchException); throw new RuntimeException(BRANCH_EXCEPTION_PREFIX + ": \n" + branchException); } }
@Override public Long trigger(Long executionId, TriggeringProperties triggeringProperties) { SystemContext scoreSystemContext = new SystemContext(triggeringProperties.getRuntimeValues()); Long runningExecutionPlanId = saveRunningExecutionPlans(triggeringProperties.getExecutionPlan(), triggeringProperties.getDependencies(), scoreSystemContext, String.valueOf(executionId)); scoreSystemContext.setExecutionId(executionId); Map<String,Serializable> executionMetadata = createMetadata(triggeringProperties); scoreSystemContext.putMetaData(executionMetadata); Execution execution = new Execution(executionId, runningExecutionPlanId, triggeringProperties.getStartStep(), triggeringProperties.getContext(), scoreSystemContext); // create execution record in ExecutionSummary table executionStateService.createParentExecution(execution.getExecutionId()); // create execution message ExecutionMessage message = createExecutionMessage(execution); enqueue(message); return executionId; }
@Override public Long trigger(Long executionId, TriggeringProperties triggeringProperties) { SystemContext scoreSystemContext = new SystemContext(triggeringProperties.getRuntimeValues()); Long runningExecutionPlanId = saveRunningExecutionPlans(triggeringProperties.getExecutionPlan(), triggeringProperties.getDependencies(), scoreSystemContext, String.valueOf(executionId)); scoreSystemContext.setExecutionId(executionId); Map<String,Serializable> executionMetadata = createMetadata(triggeringProperties); scoreSystemContext.putMetaData(executionMetadata); Execution execution = new Execution(executionId, runningExecutionPlanId, triggeringProperties.getStartStep(), triggeringProperties.getContext(), scoreSystemContext); // create execution record in ExecutionSummary table executionStateService.createParentExecution(execution.getExecutionId()); // create execution message ExecutionMessage message = createExecutionMessage(execution); enqueue(message); return executionId; }