use of org.openkilda.model.FlowStatus in project open-kilda by telstra.
the class RevertFlowStatusAction method perform.
@Override
protected void perform(State from, State to, Event event, FlowUpdateContext context, FlowUpdateFsm stateMachine) {
String flowId = stateMachine.getFlowId();
FlowStatus originalFlowStatus = stateMachine.getOriginalFlowStatus();
FlowStatus newFlowStatus = stateMachine.getNewFlowStatus();
if (originalFlowStatus != null) {
log.debug("Reverting the flow status of {} to {}", flowId, originalFlowStatus);
String flowStatusInfo = FlowStatus.DEGRADED.equals(originalFlowStatus) ? "Couldn't find non overlapping protected path" : stateMachine.getOriginalFlowStatusInfo();
flowRepository.updateStatus(flowId, originalFlowStatus, flowStatusInfo);
stateMachine.saveActionToHistory(format("The flow status was reverted to %s", originalFlowStatus));
} else {
String flowStatusInfo = !FlowStatus.UP.equals(newFlowStatus) ? stateMachine.getErrorReason() : null;
flowRepository.updateStatusInfo(flowId, flowStatusInfo);
}
}
use of org.openkilda.model.FlowStatus in project open-kilda by telstra.
the class UpdateFlowStatusAction method perform.
@Override
protected void perform(State from, State to, Event event, FlowUpdateContext context, FlowUpdateFsm stateMachine) {
String flowId = stateMachine.getFlowId();
FlowStatus resultStatus = transactionManager.doInTransaction(() -> {
Flow flow = getFlow(flowId);
FlowStatus flowStatus = Optional.ofNullable(stateMachine.getNewFlowStatus()).orElse(flow.computeFlowStatus());
if (flowStatus != flow.getStatus() && stateMachine.getBulkUpdateFlowIds().isEmpty()) {
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;
});
if (stateMachine.getBulkUpdateFlowIds().isEmpty()) {
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 CompleteYFlowInstallationAction method perform.
@Override
protected void perform(State from, State to, Event event, YFlowCreateContext context, YFlowCreateFsm 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 OnFinishedNbTrackableAction method updateFlowStatus.
private FlowStatus updateFlowStatus(String flowId) {
Flow flow = getFlow(flowId);
FlowStatus flowStatus = flow.computeFlowStatus();
if (flowStatus != flow.getStatus()) {
dashboardLogger.onFlowStatusUpdate(flowId, flowStatus);
flow.setStatus(flowStatus);
}
return flowStatus;
}
use of org.openkilda.model.FlowStatus in project open-kilda by telstra.
the class RerouteServiceTest method testRerouteInactivePinnedFlowsOneFailedSegment.
@Test
public void testRerouteInactivePinnedFlowsOneFailedSegment() throws Throwable {
pinnedFlow.setStatus(FlowStatus.DOWN);
for (FlowPath flowPath : pinnedFlow.getPaths()) {
flowPath.setStatus(FlowPathStatus.INACTIVE);
for (PathSegment pathSegment : flowPath.getSegments()) {
if (pathSegment.containsNode(SWITCH_ID_A, PORT)) {
pathSegment.setFailed(true);
}
}
}
RepositoryFactory repositoryFactory = mock(RepositoryFactory.class);
FlowRepository flowRepository = mock(FlowRepository.class);
when(flowRepository.findInactiveFlows()).thenReturn(Collections.singletonList(pinnedFlow));
doAnswer(invocation -> {
FlowStatus status = invocation.getArgument(1);
pinnedFlow.setStatus(status);
return null;
}).when(flowRepository).updateStatusSafe(eq(pinnedFlow), any(), any());
when(repositoryFactory.createFlowRepository()).thenReturn(flowRepository);
FlowPathRepository pathRepository = mock(FlowPathRepository.class);
when(repositoryFactory.createFlowPathRepository()).thenReturn(pathRepository);
PathSegmentRepository pathSegmentRepository = mock(PathSegmentRepository.class);
when(repositoryFactory.createPathSegmentRepository()).thenReturn(pathSegmentRepository);
MessageSender messageSender = mock(MessageSender.class);
PersistenceManager persistenceManager = mock(PersistenceManager.class);
when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
TransactionManager transactionManager = mock(TransactionManager.class);
doAnswer(invocation -> {
TransactionCallback<?, ?> arg = invocation.getArgument(0);
return arg.doInTransaction();
}).when(transactionManager).doInTransaction(Mockito.<TransactionCallback<?, ?>>any());
when(persistenceManager.getTransactionManager()).thenReturn(transactionManager);
RerouteService rerouteService = new RerouteService(persistenceManager);
rerouteService.rerouteInactiveFlows(messageSender, CORRELATION_ID, REROUTE_INACTIVE_FLOWS_COMMAND);
assertEquals(FlowStatus.UP, pinnedFlow.getStatus());
for (FlowPath fp : pinnedFlow.getPaths()) {
assertEquals(FlowPathStatus.ACTIVE, fp.getStatus());
for (PathSegment ps : fp.getSegments()) {
if (ps.containsNode(SWITCH_ID_A, PORT)) {
assertFalse(ps.isFailed());
}
}
}
}
Aggregations