use of org.openkilda.model.YFlow 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.YFlow in project open-kilda by telstra.
the class StartRemovingYFlowAction method perform.
@Override
protected void perform(State from, State to, Event event, YFlowDeleteContext context, YFlowDeleteFsm stateMachine) {
String yFlowId = stateMachine.getYFlowId();
YFlow yFlow = getYFlow(yFlowId);
stateMachine.setDeleteOldYFlowCommands(buildYFlowDeleteCommands(yFlow, stateMachine.getCommandContext()));
}
use of org.openkilda.model.YFlow 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.YFlow in project open-kilda by telstra.
the class OnSubFlowRemovedAction method perform.
@Override
protected void perform(State from, State to, Event event, YFlowDeleteContext context, YFlowDeleteFsm stateMachine) {
String subFlowId = context.getSubFlowId();
if (!stateMachine.isDeletingSubFlow(subFlowId)) {
throw new IllegalStateException("Received an event for non-pending sub-flow " + subFlowId);
}
String yFlowId = stateMachine.getYFlowId();
stateMachine.saveActionToHistory("Removed a sub-flow", format("Removed sub-flow %s of y-flow %s", subFlowId, yFlowId));
stateMachine.removeDeletingSubFlow(subFlowId);
stateMachine.notifyEventListeners(listener -> listener.onSubFlowProcessingFinished(yFlowId, subFlowId));
// TODO: refactor to concurrent deleting once https://github.com/telstra/open-kilda/issues/3411 is fixed.
YFlow yFlow = getYFlow(yFlowId);
yFlow.getSubFlows().stream().filter(subFlow -> !stateMachine.getSubFlows().contains(subFlow.getSubFlowId())).findFirst().ifPresent(subFlow -> {
String nextSubFlowId = subFlow.getSubFlowId();
stateMachine.addSubFlow(nextSubFlowId);
stateMachine.addDeletingSubFlow(nextSubFlowId);
stateMachine.notifyEventListeners(listener -> listener.onSubFlowProcessingStart(yFlowId, nextSubFlowId));
CommandContext flowContext = stateMachine.getCommandContext().fork(nextSubFlowId);
flowDeleteService.startFlowDeletion(flowContext, nextSubFlowId);
});
if (stateMachine.getDeletingSubFlows().isEmpty()) {
stateMachine.fire(Event.ALL_SUB_FLOWS_REMOVED);
}
}
use of org.openkilda.model.YFlow 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