Search in sources :

Example 1 with SwitchStateChanged

use of org.openkilda.messaging.info.reroute.SwitchStateChanged in project open-kilda by telstra.

the class RerouteBolt method handleInfoMessage.

private void handleInfoMessage(Message message) {
    if (message instanceof InfoMessage) {
        InfoData infoData = ((InfoMessage) message).getData();
        if (infoData instanceof RerouteResultInfoData) {
            RerouteResultInfoData rerouteResultInfoData = (RerouteResultInfoData) infoData;
            emitWithContext(STREAM_OPERATION_QUEUE_ID, getCurrentTuple(), new Values(rerouteResultInfoData.getFlowId(), rerouteResultInfoData));
        } else if (infoData instanceof PathSwapResult) {
            PathSwapResult pathSwapResult = (PathSwapResult) infoData;
            emitWithContext(STREAM_OPERATION_QUEUE_ID, getCurrentTuple(), new Values(pathSwapResult.getFlowId(), pathSwapResult));
        } else if (infoData instanceof SwitchStateChanged) {
            if (active) {
                rerouteService.processSingleSwitchFlowStatusUpdate((SwitchStateChanged) infoData);
            }
        } else {
            unhandledInput(getCurrentTuple());
        }
    } else {
        unhandledInput(getCurrentTuple());
    }
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) RerouteResultInfoData(org.openkilda.messaging.info.reroute.RerouteResultInfoData) InfoData(org.openkilda.messaging.info.InfoData) Values(org.apache.storm.tuple.Values) RerouteResultInfoData(org.openkilda.messaging.info.reroute.RerouteResultInfoData) SwitchStateChanged(org.openkilda.messaging.info.reroute.SwitchStateChanged) PathSwapResult(org.openkilda.messaging.info.reroute.PathSwapResult)

Example 2 with SwitchStateChanged

use of org.openkilda.messaging.info.reroute.SwitchStateChanged in project open-kilda by telstra.

the class RerouteServiceTest method handleUpdateSingleSwitchFlows.

@Test
public void handleUpdateSingleSwitchFlows() {
    FlowRepository flowRepository = mock(FlowRepository.class);
    when(flowRepository.findOneSwitchFlows(oneSwitchFlow.getSrcSwitch().getSwitchId())).thenReturn(Collections.singletonList(oneSwitchFlow));
    FlowPathRepository flowPathRepository = mock(FlowPathRepository.class);
    RepositoryFactory repositoryFactory = mock(RepositoryFactory.class);
    when(repositoryFactory.createFlowRepository()).thenReturn(flowRepository);
    when(repositoryFactory.createFlowPathRepository()).thenReturn(flowPathRepository);
    PersistenceManager persistenceManager = mock(PersistenceManager.class);
    when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
    when(persistenceManager.getTransactionManager()).thenReturn(transactionManager);
    RerouteService rerouteService = new RerouteService(persistenceManager);
    rerouteService.processSingleSwitchFlowStatusUpdate(new SwitchStateChanged(oneSwitchFlow.getSrcSwitchId(), SwitchStatus.INACTIVE));
    assertEquals(format("Switch %s is inactive", oneSwitchFlow.getSrcSwitchId()), FlowStatus.DOWN, oneSwitchFlow.getStatus());
}
Also used : FlowRepository(org.openkilda.persistence.repositories.FlowRepository) YFlowRepository(org.openkilda.persistence.repositories.YFlowRepository) FlowPathRepository(org.openkilda.persistence.repositories.FlowPathRepository) PersistenceManager(org.openkilda.persistence.PersistenceManager) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) SwitchStateChanged(org.openkilda.messaging.info.reroute.SwitchStateChanged) Test(org.junit.Test)

Aggregations

SwitchStateChanged (org.openkilda.messaging.info.reroute.SwitchStateChanged)2 Values (org.apache.storm.tuple.Values)1 Test (org.junit.Test)1 InfoData (org.openkilda.messaging.info.InfoData)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1 PathSwapResult (org.openkilda.messaging.info.reroute.PathSwapResult)1 RerouteResultInfoData (org.openkilda.messaging.info.reroute.RerouteResultInfoData)1 PersistenceManager (org.openkilda.persistence.PersistenceManager)1 FlowPathRepository (org.openkilda.persistence.repositories.FlowPathRepository)1 FlowRepository (org.openkilda.persistence.repositories.FlowRepository)1 RepositoryFactory (org.openkilda.persistence.repositories.RepositoryFactory)1 YFlowRepository (org.openkilda.persistence.repositories.YFlowRepository)1