use of org.openkilda.model.FlowStatus in project open-kilda by telstra.
the class UpdateFlowStatusAction method perform.
@TimedExecution("fsm.update_flow_status")
@Override
protected void perform(State from, State to, Event event, FlowRerouteContext context, FlowRerouteFsm stateMachine) {
String flowId = stateMachine.getFlowId();
FlowStatus resultStatus = transactionManager.doInTransaction(() -> {
Flow flow = getFlow(flowId);
FlowStatus flowStatus = flow.computeFlowStatus();
if (flowStatus != flow.getStatus()) {
dashboardLogger.onFlowStatusUpdate(flowId, flowStatus);
flow.setStatus(flowStatus);
flow.setStatusInfo(getFlowStatusInfo(flow, flowStatus, stateMachine));
} else if (FlowStatus.DEGRADED.equals(flowStatus)) {
flow.setStatusInfo(getDegradedFlowStatusInfo(flow, stateMachine));
}
stateMachine.setNewFlowStatus(flowStatus);
return flowStatus;
});
stateMachine.saveActionToHistory(format("The flow status was set to %s", resultStatus));
}
use of org.openkilda.model.FlowStatus in project open-kilda by telstra.
the class OnNoPathFoundAction method perform.
@Override
protected void perform(State from, State to, Event event, FlowRerouteContext context, FlowRerouteFsm stateMachine) {
String flowId = stateMachine.getFlowId();
log.debug("Updating the flow status of {} after 'no path found' event", flowId);
FlowStatus flowStatus = transactionManager.doInTransaction(() -> {
stateMachine.setOriginalFlowStatus(null);
Flow flow = getFlow(flowId);
if (primaryPathNotFound && stateMachine.isReroutePrimary() && stateMachine.getNewPrimaryForwardPath() == null && stateMachine.getNewPrimaryReversePath() == null) {
if (flow.getForwardPathId() == null && flow.getReversePathId() == null) {
log.debug("Skip marking flow path statuses as inactive: flow {} doesn't have main paths", flowId);
} else {
log.debug("Set the flow path status of {}/{} to inactive", flow.getForwardPathId(), flow.getReversePathId());
if (flow.getForwardPathId() != null) {
flow.getForwardPath().setStatus(FlowPathStatus.INACTIVE);
}
if (flow.getReversePathId() != null) {
flow.getReversePath().setStatus(FlowPathStatus.INACTIVE);
}
}
}
if (stateMachine.isRerouteProtected() && stateMachine.getNewProtectedForwardPath() == null && stateMachine.getNewProtectedReversePath() == null) {
if (flow.getProtectedForwardPathId() == null && flow.getProtectedReversePathId() == null) {
log.debug("Skip marking flow path statuses as inactive: flow {} doesn't have protected paths", flowId);
} else {
log.debug("Set the flow path status of {}/{} to inactive", flow.getProtectedForwardPathId(), flow.getProtectedReversePathId());
if (flow.getProtectedForwardPathId() != null) {
flow.getProtectedForwardPath().setStatus(FlowPathStatus.INACTIVE);
}
if (flow.getProtectedReversePathId() != null) {
flow.getProtectedReversePath().setStatus(FlowPathStatus.INACTIVE);
}
}
}
FlowStatus newFlowStatus = flow.computeFlowStatus();
if (newFlowStatus != FlowStatus.DOWN && newFlowStatus != FlowStatus.DEGRADED) {
log.error("Computed unexpected status {} of flow {} after 'no path found' event", newFlowStatus, flow);
newFlowStatus = FlowStatus.DOWN;
}
log.debug("Setting the flow status of {} to {}", flowId, newFlowStatus);
dashboardLogger.onFlowStatusUpdate(flowId, newFlowStatus);
flow.setStatus(newFlowStatus);
flow.setStatusInfo(stateMachine.getErrorReason());
stateMachine.setNewFlowStatus(newFlowStatus);
return newFlowStatus;
});
stateMachine.saveActionToHistory(String.format("The flow status was set to %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 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));
}
Aggregations