public static boolean execute( KevoreeCoreBean core, ContainerNode rootNode, AdaptationModel adaptionModel, NodeType nodeInstance, PrimitiveExecute afterUpdateFunc, PrimitiveExecute preRollBack, PrimitiveExecute postRollback) { Step orderedPrimitiveSet = adaptionModel.getOrderedPrimitiveSet(); if (orderedPrimitiveSet != null) { KevoreeDeployPhase phase = new KevoreeSeqDeployPhase(core); boolean result = PrimitiveCommandExecutionHelper.executeStep( core, rootNode, orderedPrimitiveSet, nodeInstance, phase, preRollBack); if (result) { if (!afterUpdateFunc.exec()) { preRollBack.exec(); phase.rollback(); postRollback.exec(); } } else { postRollback.exec(); } return result; } else { return afterUpdateFunc.exec(); } }
private static boolean executeStep( KevoreeCoreBean core, ContainerNode rootNode, Step step, NodeType nodeInstance, KevoreeDeployPhase phase, PrimitiveExecute preRollBack) { if (step == null) { return true; } else { if (core.isAnyTelemetryListener()) { core.broadcastTelemetry( TelemetryEvent.Type.DEPLOYMENT_STEP, step.getAdaptationType().name(), null); } boolean populateResult = PrimitiveCommandExecutionHelper.populate(step, nodeInstance, phase); if (populateResult) { boolean phaseResult = phase.execute(); if (phaseResult) { Step nextStep = step.getNextStep(); boolean subResult; if (nextStep != null) { KevoreeDeployPhase nextPhase = new KevoreeSeqDeployPhase(core); phase.successor = nextPhase; subResult = executeStep(core, rootNode, nextStep, nodeInstance, nextPhase, preRollBack); } else { subResult = true; } if (!subResult) { preRollBack.exec(); phase.rollback(); return false; } else { return true; } } else { preRollBack.exec(); phase.rollback(); return false; } } else { Log.error("Adaptation primitives must all be mapped by a primitive command"); return false; } } }