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());
}
}
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());
}
Aggregations