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; } } }
private static boolean populate(Step step, NodeType nodeInstance, KevoreeDeployPhase phase) { for (AdaptationPrimitive adapt : step.getAdaptations()) { PrimitiveCommand cmd = nodeInstance.getPrimitive(adapt); if (cmd != null) { Log.trace("Populate primitive command = {}", cmd); phase.populate(cmd); } else { Log.warn("Unable to find a primitive command for primitive adaptation {}", adapt); return false; } } return true; }