use of org.openkilda.model.FlowStatus in project open-kilda by telstra.
the class RevertYFlowAction method perform.
@Override
protected void perform(State from, State to, Event event, YFlowUpdateContext context, YFlowUpdateFsm stateMachine) {
YFlowRequest originalFlow = stateMachine.getOriginalFlow();
YFlowResources resources = stateMachine.getOldResources();
FlowStatus flowStatus = transactionManager.doInTransaction(() -> {
YFlow yFlow = getYFlow(originalFlow.getYFlowId());
revertFlow(yFlow, YFlowRequestMapper.INSTANCE.toYFlow(originalFlow), resources);
return yFlow.getStatus();
});
stateMachine.saveActionToHistory(format("The y-flow was reverted. The status %s", flowStatus));
}
use of org.openkilda.model.FlowStatus in project open-kilda by telstra.
the class CompleteYFlowUpdatingAction method perform.
@Override
protected void perform(State from, State to, Event event, YFlowUpdateContext context, YFlowUpdateFsm stateMachine) {
String yFlowId = stateMachine.getYFlowId();
FlowStatus flowStatus = transactionManager.doInTransaction(() -> {
YFlow yFlow = getYFlow(yFlowId);
yFlow.recalculateStatus();
return yFlow.getStatus();
});
dashboardLogger.onYFlowStatusUpdate(yFlowId, flowStatus);
stateMachine.saveActionToHistory(format("The y-flow status was set to %s", flowStatus));
}
use of org.openkilda.model.FlowStatus in project open-kilda by telstra.
the class CompleteYFlowReroutingAction method perform.
@Override
protected void perform(State from, State to, Event event, YFlowRerouteContext context, YFlowRerouteFsm stateMachine) {
String yFlowId = stateMachine.getYFlowId();
FlowStatus flowStatus = transactionManager.doInTransaction(() -> {
YFlow yFlow = getYFlow(yFlowId);
yFlow.recalculateStatus();
return yFlow.getStatus();
});
dashboardLogger.onYFlowStatusUpdate(yFlowId, flowStatus);
stateMachine.saveActionToHistory(format("The y-flow status was set to %s", flowStatus));
if (stateMachine.getErrorReason() == null) {
stateMachine.fire(Event.YFLOW_REROUTE_FINISHED);
} else {
stateMachine.fire(Event.ERROR);
}
}
use of org.openkilda.model.FlowStatus in project open-kilda by telstra.
the class RevertYFlowStatusAction method perform.
@Override
protected void perform(S from, S to, E event, C context, T stateMachine) {
String yFlowId = stateMachine.getYFlowId();
FlowStatus originalStatus = stateMachine.getOriginalYFlowStatus();
if (originalStatus != null) {
log.debug("Reverting the y-flow status of {} to {}", yFlowId, originalStatus);
transactionManager.doInTransaction(() -> {
YFlow flow = getYFlow(yFlowId);
flow.setStatus(originalStatus);
});
dashboardLogger.onYFlowStatusUpdate(yFlowId, originalStatus);
stateMachine.saveActionToHistory(format("The y-flow status was reverted to %s", originalStatus));
}
}
use of org.openkilda.model.FlowStatus 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));
}
Aggregations