use of org.openkilda.messaging.info.discovery.NetworkDumpSwitchData in project open-kilda by telstra.
the class SwitchMonitorServiceTest method testSerialUpdate.
@Test
public void testSerialUpdate() {
SwitchMonitorService subject = makeSubject();
Instant t0 = clock.instant();
SwitchInfoData swAlphaActivate = makeSwitchActivateNotification(SWITCH_ALPHA, 1);
subject.handleStatusUpdateNotification(swAlphaActivate, REGION_ALPHA);
verify(carrier).regionUpdateNotification(eq(new RegionMappingSet(swAlphaActivate.getSwitchId(), REGION_ALPHA, true)));
verify(carrier).sendSwitchConnectNotification(eq(swAlphaActivate.getSwitchId()), eq(swAlphaActivate.getSwitchView()), any(SwitchAvailabilityData.class));
verifyNoMoreInteractions(carrier);
reset(carrier);
NetworkDumpSwitchData dump = new NetworkDumpSwitchData(swAlphaActivate.getSwitchView(), NETWORK_DUMP_CORRELATION_ID, true);
for (int i = 0; i < 5; i++) {
clock.adjust(Duration.ofSeconds(60));
subject.handleNetworkDumpResponse(dump, REGION_ALPHA);
verify(carrier, times(i + 1)).sendOtherNotification(eq(dump.getSwitchId()), eq(dump));
verifyNoMoreInteractions(carrier);
}
reset(carrier);
// to ensure correct value of connectedAt field for REGION_ALPHA force sending of
// SwitchAvailabilityUpdateNotification
Instant t1 = clock.instant();
SwitchInfoData swBetaActivate = makeSwitchActivateNotification(swAlphaActivate.getSwitchId(), 2);
subject.handleStatusUpdateNotification(swBetaActivate, REGION_BETA);
verify(carrier).sendSwitchAvailabilityUpdateNotification(eq(swBetaActivate.getSwitchId()), argThat(arg -> matchAvailabilityData(SwitchAvailabilityData.builder().connection(SwitchAvailabilityEntry.builder().regionName(REGION_ALPHA).connectMode(SwitchConnectMode.READ_WRITE).master(true).connectedAt(t0).switchAddress(swAlphaActivate.getSwitchView().getSwitchSocketAddress()).speakerAddress(swAlphaActivate.getSwitchView().getSpeakerSocketAddress()).build()).connection(SwitchAvailabilityEntry.builder().regionName(REGION_BETA).connectMode(SwitchConnectMode.READ_WRITE).master(false).connectedAt(t1).switchAddress(swBetaActivate.getSwitchView().getSwitchSocketAddress()).speakerAddress(swBetaActivate.getSwitchView().getSpeakerSocketAddress()).build()).build(), arg)));
}
use of org.openkilda.messaging.info.discovery.NetworkDumpSwitchData in project open-kilda by telstra.
the class SwitchTrackingService method dumpAllSwitchesAction.
private void dumpAllSwitchesAction(String dumpId) {
Collection<IOFSwitch> iofSwitches = switchManager.getAllSwitchMap(true).values();
for (IOFSwitch sw : iofSwitches) {
NetworkDumpSwitchData payload = null;
try {
payload = new NetworkDumpSwitchData(buildSwitch(sw), dumpId, sw.getControllerRole() != OFControllerRole.ROLE_SLAVE);
emitDiscoveryEvent(sw.getId(), payload);
} catch (SwitchOperationException e) {
log.error("Exclude {} from dump switches response - {}", sw.getId(), e.getMessage(), e);
}
}
}
Aggregations