use of org.openkilda.model.FlowPathStatus in project open-kilda by telstra.
the class CompleteFlowCreateAction method perform.
@Override
protected void perform(State from, State to, Event event, FlowCreateContext context, FlowCreateFsm stateMachine) {
String flowId = stateMachine.getFlowId();
if (!flowRepository.exists(flowId)) {
throw new FlowProcessingException(ErrorType.NOT_FOUND, "Couldn't complete flow creation. The flow was deleted");
}
FlowStatus flowStatus = transactionManager.doInTransaction(() -> {
FlowStatus status = FlowStatus.UP;
FlowPathStatus primaryPathStatus;
if (stateMachine.isBackUpPrimaryPathComputationWayUsed()) {
primaryPathStatus = FlowPathStatus.DEGRADED;
status = FlowStatus.DEGRADED;
} else {
primaryPathStatus = FlowPathStatus.ACTIVE;
}
flowPathRepository.updateStatus(stateMachine.getForwardPathId(), primaryPathStatus);
flowPathRepository.updateStatus(stateMachine.getReversePathId(), primaryPathStatus);
if (stateMachine.getProtectedForwardPathId() != null && stateMachine.getProtectedReversePathId() != null) {
FlowPathStatus protectedPathStatus;
if (stateMachine.isBackUpProtectedPathComputationWayUsed()) {
protectedPathStatus = FlowPathStatus.DEGRADED;
status = FlowStatus.DEGRADED;
} else {
protectedPathStatus = FlowPathStatus.ACTIVE;
}
flowPathRepository.updateStatus(stateMachine.getProtectedForwardPathId(), protectedPathStatus);
flowPathRepository.updateStatus(stateMachine.getProtectedReversePathId(), protectedPathStatus);
}
flowRepository.updateStatus(flowId, status);
if (FlowStatus.DEGRADED.equals(status)) {
flowRepository.updateStatusInfo(flowId, "An alternative way " + "(back up strategy or max_latency_tier2 value) of building the path was used");
}
return status;
});
dashboardLogger.onFlowStatusUpdate(flowId, flowStatus);
stateMachine.saveActionToHistory(format("The flow status was set to %s", flowStatus));
}
use of org.openkilda.model.FlowPathStatus in project open-kilda by telstra.
the class CompleteFlowPathInstallationAction method perform.
@TimedExecution("fsm.complete_flow_path_install")
@Override
protected void perform(State from, State to, Event event, FlowRerouteContext context, FlowRerouteFsm stateMachine) {
if (stateMachine.getNewPrimaryForwardPath() != null && stateMachine.getNewPrimaryReversePath() != null) {
PathId newForward = stateMachine.getNewPrimaryForwardPath();
PathId newReverse = stateMachine.getNewPrimaryReversePath();
log.debug("Completing installation of the flow primary path {} / {}", newForward, newReverse);
FlowPathStatus primaryPathStatus;
if (stateMachine.isIgnoreBandwidth() || stateMachine.isBackUpPrimaryPathComputationWayUsed()) {
primaryPathStatus = FlowPathStatus.DEGRADED;
} else {
primaryPathStatus = FlowPathStatus.ACTIVE;
}
transactionManager.doInTransaction(() -> {
flowPathRepository.updateStatus(newForward, primaryPathStatus);
flowPathRepository.updateStatus(newReverse, primaryPathStatus);
});
stateMachine.saveActionToHistory("Flow paths were installed", format("The flow paths %s / %s were installed", newForward, newReverse));
}
if (stateMachine.getNewProtectedForwardPath() != null && stateMachine.getNewProtectedReversePath() != null) {
PathId newForward = stateMachine.getNewProtectedForwardPath();
PathId newReverse = stateMachine.getNewProtectedReversePath();
FlowPathStatus protectedPathStatus;
if (stateMachine.isIgnoreBandwidth() || stateMachine.isBackUpProtectedPathComputationWayUsed()) {
protectedPathStatus = FlowPathStatus.DEGRADED;
} else {
protectedPathStatus = FlowPathStatus.ACTIVE;
}
log.debug("Completing installation of the flow protected path {} / {}", newForward, newReverse);
transactionManager.doInTransaction(() -> {
flowPathRepository.updateStatus(newForward, protectedPathStatus);
flowPathRepository.updateStatus(newReverse, protectedPathStatus);
});
stateMachine.saveActionToHistory("Flow paths were installed", format("The flow paths %s / %s were installed", newForward, newReverse));
}
}
use of org.openkilda.model.FlowPathStatus in project open-kilda by telstra.
the class RecalculateFlowStatusAction method perform.
@Override
protected void perform(State from, State to, Event event, FlowPathSwapContext context, FlowPathSwapFsm stateMachine) {
String flowId = stateMachine.getFlowId();
FlowStatus resultStatus = transactionManager.doInTransaction(() -> {
Flow flow = getFlow(flowId);
FlowPathStatus pathStatus = stateMachine.getFailedCommands().isEmpty() ? FlowPathStatus.ACTIVE : FlowPathStatus.INACTIVE;
flow.getPaths().forEach(flowPath -> {
flowPath.setStatus(pathStatus);
});
FlowStatus status = flow.computeFlowStatus();
flow.setStatus(status);
return status;
});
stateMachine.saveActionToHistory(format("The flow status was set to %s", resultStatus));
}
use of org.openkilda.model.FlowPathStatus in project open-kilda by telstra.
the class CompleteFlowPathInstallationAction method perform.
@Override
protected void perform(State from, State to, Event event, FlowUpdateContext context, FlowUpdateFsm stateMachine) {
PathId newPrimaryForward = stateMachine.getNewPrimaryForwardPath();
PathId newPrimaryReverse = stateMachine.getNewPrimaryReversePath();
FlowPathStatus primaryPathStatus;
if (stateMachine.isBackUpPrimaryPathComputationWayUsed()) {
primaryPathStatus = FlowPathStatus.DEGRADED;
} else {
primaryPathStatus = FlowPathStatus.ACTIVE;
}
log.debug("Completing installation of the flow primary path {} / {}", newPrimaryForward, newPrimaryReverse);
transactionManager.doInTransaction(() -> {
flowPathRepository.updateStatus(newPrimaryForward, primaryPathStatus);
flowPathRepository.updateStatus(newPrimaryReverse, primaryPathStatus);
});
stateMachine.saveActionToHistory("Flow paths were installed", format("The flow paths %s / %s were installed", newPrimaryForward, newPrimaryReverse));
if (stateMachine.getNewProtectedForwardPath() != null && stateMachine.getNewProtectedReversePath() != null) {
PathId newForward = stateMachine.getNewProtectedForwardPath();
PathId newReverse = stateMachine.getNewProtectedReversePath();
FlowPathStatus protectedPathStatus;
if (stateMachine.isBackUpProtectedPathComputationWayUsed()) {
protectedPathStatus = FlowPathStatus.DEGRADED;
} else {
protectedPathStatus = FlowPathStatus.ACTIVE;
}
log.debug("Completing installation of the flow protected path {} / {}", newForward, newReverse);
transactionManager.doInTransaction(() -> {
flowPathRepository.updateStatus(newForward, protectedPathStatus);
flowPathRepository.updateStatus(newReverse, protectedPathStatus);
});
stateMachine.saveActionToHistory("Flow paths were installed", format("The flow paths %s / %s were installed", newForward, newReverse));
}
}
use of org.openkilda.model.FlowPathStatus in project open-kilda by telstra.
the class RerouteService method processSingleSwitchFlowStatusUpdate.
/**
* Handles request to update single switch flow status.
*/
public void processSingleSwitchFlowStatusUpdate(SwitchStateChanged request) {
transactionManager.doInTransaction(() -> {
Collection<Flow> affectedFlows = flowRepository.findOneSwitchFlows(request.getSwitchId());
FlowStatus newFlowStatus = request.getStatus() == SwitchStatus.ACTIVE ? FlowStatus.UP : FlowStatus.DOWN;
String newFlowStatusInfo = request.getStatus() == SwitchStatus.ACTIVE ? null : format("Switch %s is inactive", request.getSwitchId());
FlowPathStatus newFlowPathStatus = request.getStatus() == SwitchStatus.ACTIVE ? FlowPathStatus.ACTIVE : FlowPathStatus.INACTIVE;
for (Flow flow : affectedFlows) {
log.info("Updating flow and path statuses for flow {} to {}, {}", flow.getFlowId(), newFlowStatus, newFlowPathStatus);
flowDashboardLogger.onFlowStatusUpdate(flow.getFlowId(), newFlowStatus);
flow.setStatus(newFlowStatus);
flow.setStatusInfo(newFlowStatusInfo);
flow.getForwardPath().setStatus(newFlowPathStatus);
flow.getReversePath().setStatus(newFlowPathStatus);
}
});
}
Aggregations