Search in sources :

Example 1 with NetworkDump

use of org.openkilda.messaging.ctrl.state.NetworkDump in project open-kilda by telstra.

the class CacheTopologyTest method cacheReceivesInfoDataBeforeNetworkDump.

@Test
public void cacheReceivesInfoDataBeforeNetworkDump() throws Exception {
    System.out.println("Cache receives InfoData before NetworkDump Test");
    sendClearState();
    waitDumpRequest();
    // Send switchUpdate info to not initialized bolt
    sendData(sw);
    // Bolt must fail that tuple
    sendNetworkDumpRequest();
    NetworkDump networkDump = getNetworkDump(ctrlConsumer.pollMessage());
    assertTrue(CollectionUtils.isEmpty(networkDump.getSwitches()));
    // Init bolt with dump from TE
    sendNetworkDump(dump);
    // Check if SwitchInfoData is ok
    sendNetworkDumpRequest();
    networkDump = getNetworkDump(ctrlConsumer.pollMessage());
    assertFalse(CollectionUtils.isEmpty(networkDump.getSwitches()));
    Set<String> flowIds = new HashSet<>(Arrays.asList(firstFlowId, secondFlowId));
    ConsumerRecord<String, String> firstRecord = flowConsumer.pollMessage();
    assertNotNull(firstRecord);
    assertNotNull(firstRecord.value());
    CommandMessage commandMessage = objectMapper.readValue(firstRecord.value(), CommandMessage.class);
    FlowRestoreRequest commandData = (FlowRestoreRequest) commandMessage.getData();
    assertNotNull(commandData);
    assertTrue(flowIds.contains(commandData.getPayload().getLeft().getFlowId()));
    ConsumerRecord<String, String> secondRecord = flowConsumer.pollMessage();
    assertNotNull(secondRecord);
    assertNotNull(secondRecord.value());
    commandMessage = objectMapper.readValue(secondRecord.value(), CommandMessage.class);
    commandData = (FlowRestoreRequest) commandMessage.getData();
    assertNotNull(commandData);
    assertTrue(flowIds.contains(commandData.getPayload().getLeft().getFlowId()));
}
Also used : NetworkDump(org.openkilda.messaging.ctrl.state.NetworkDump) FlowRestoreRequest(org.openkilda.messaging.command.flow.FlowRestoreRequest) HashSet(java.util.HashSet) CommandMessage(org.openkilda.messaging.command.CommandMessage) AbstractStormTest(org.openkilda.wfm.AbstractStormTest)

Example 2 with NetworkDump

use of org.openkilda.messaging.ctrl.state.NetworkDump in project open-kilda by telstra.

the class CacheBolt method dumpState.

@Override
public AbstractDumpState dumpState() {
    NetworkDump networkDump = new NetworkDump(networkCache.dumpSwitches(), networkCache.dumpIsls());
    FlowDump flowDump = new FlowDump(flowCache.dumpFlows());
    return new CacheBoltState(networkDump, flowDump);
}
Also used : CacheBoltState(org.openkilda.messaging.ctrl.state.CacheBoltState) NetworkDump(org.openkilda.messaging.ctrl.state.NetworkDump) FlowDump(org.openkilda.messaging.ctrl.state.FlowDump)

Aggregations

NetworkDump (org.openkilda.messaging.ctrl.state.NetworkDump)2 HashSet (java.util.HashSet)1 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 FlowRestoreRequest (org.openkilda.messaging.command.flow.FlowRestoreRequest)1 CacheBoltState (org.openkilda.messaging.ctrl.state.CacheBoltState)1 FlowDump (org.openkilda.messaging.ctrl.state.FlowDump)1 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)1