Search in sources :

Example 16 with FlowStatus

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);
    }
}
Also used : FlowStatus(org.openkilda.model.FlowStatus)

Example 17 with FlowStatus

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));
    }
}
Also used : FlowStatus(org.openkilda.model.FlowStatus) Flow(org.openkilda.model.Flow)

Example 18 with FlowStatus

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));
}
Also used : YFlow(org.openkilda.model.YFlow) FlowStatus(org.openkilda.model.FlowStatus)

Example 19 with 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;
}
Also used : FlowStatus(org.openkilda.model.FlowStatus) Flow(org.openkilda.model.Flow)

Example 20 with 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());
            }
        }
    }
}
Also used : FlowRepository(org.openkilda.persistence.repositories.FlowRepository) YFlowRepository(org.openkilda.persistence.repositories.YFlowRepository) FlowPathRepository(org.openkilda.persistence.repositories.FlowPathRepository) PathSegmentRepository(org.openkilda.persistence.repositories.PathSegmentRepository) PersistenceManager(org.openkilda.persistence.PersistenceManager) MessageSender(org.openkilda.wfm.topology.reroute.bolts.MessageSender) TransactionManager(org.openkilda.persistence.tx.TransactionManager) PathSegment(org.openkilda.model.PathSegment) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) FlowPath(org.openkilda.model.FlowPath) FlowStatus(org.openkilda.model.FlowStatus) Test(org.junit.Test)

Aggregations

FlowStatus (org.openkilda.model.FlowStatus)22 YFlow (org.openkilda.model.YFlow)11 Flow (org.openkilda.model.Flow)9 FlowPath (org.openkilda.model.FlowPath)4 FlowPathStatus (org.openkilda.model.FlowPathStatus)3 TimedExecution (org.openkilda.wfm.share.metrics.TimedExecution)3 YFlowRequest (org.openkilda.messaging.command.yflow.YFlowRequest)2 PathNode (org.openkilda.messaging.info.event.PathNode)2 IslEndpoint (org.openkilda.model.IslEndpoint)2 PathSegment (org.openkilda.model.PathSegment)2 SwitchId (org.openkilda.model.SwitchId)2 YSubFlow (org.openkilda.model.YSubFlow)2 FlowThrottlingData (org.openkilda.wfm.topology.reroute.model.FlowThrottlingData)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 Test (org.junit.Test)1 PersistenceManager (org.openkilda.persistence.PersistenceManager)1