@Test public void discovery() { NetworkWatcherService w = makeService(); w.addWatch(Endpoint.of(new SwitchId(1), 1), 1); w.addWatch(Endpoint.of(new SwitchId(1), 2), 1); w.addWatch(Endpoint.of(new SwitchId(2), 1), 2); w.addWatch(Endpoint.of(new SwitchId(2), 1), 2); w.addWatch(Endpoint.of(new SwitchId(2), 2), 3); assertThat(w.getConfirmedPackets().size(), is(0)); assertThat(w.getTimeouts().size(), is(3)); verify(carrier, times(5)).sendDiscovery(any(DiscoverIslCommandData.class)); w.confirmation(Endpoint.of(new SwitchId(1), 1), 0); w.confirmation(Endpoint.of(new SwitchId(2), 1), 2); assertThat(w.getConfirmedPackets().size(), is(2)); PathNode source = new PathNode(new SwitchId(1), 1, 0); PathNode destination = new PathNode(new SwitchId(2), 1, 0); IslInfoData islAlphaBeta = IslInfoData.builder().source(source).destination(destination).packetId(0L).build(); IslInfoData islBetaAlpha = IslInfoData.builder().source(destination).destination(source).packetId(2L).build(); w.discovery(islAlphaBeta); w.discovery(islBetaAlpha); w.tick(100); assertThat(w.getConfirmedPackets().size(), is(0)); verify(carrier).discoveryReceived(eq(new Endpoint(islAlphaBeta.getSource())), eq(0L), eq(islAlphaBeta), anyLong()); verify(carrier).discoveryReceived(eq(new Endpoint(islBetaAlpha.getSource())), eq(2L), eq(islBetaAlpha), anyLong()); verify(carrier, times(2)).discoveryReceived(any(Endpoint.class), anyLong(), any(IslInfoData.class), anyLong()); assertThat(w.getTimeouts().size(), is(0)); }
public void discovery(IslInfoData discoveryEvent) { Endpoint source = new Endpoint(discoveryEvent.getSource()); Long packetId = discoveryEvent.getPacketId(); if (packetId == null) { log.error("Got corrupted discovery packet into {} - packetId field is empty", source); } else { discovery(discoveryEvent, Packet.of(source, packetId)); } }
NetworkWatcherService { public void discovery(IslInfoData discoveryEvent) { Endpoint source = new Endpoint(discoveryEvent.getSource()); Long packetId = discoveryEvent.getPacketId(); if (packetId == null) { log.error("Got corrupted discovery packet into {} - packetId field is empty", source); } else { discovery(discoveryEvent, Packet.of(source, packetId)); } } }
NetworkWatcherService { public void discovery(IslInfoData discoveryEvent) { Endpoint source = new Endpoint(discoveryEvent.getSource()); Long packetId = discoveryEvent.getPacketId(); if (packetId == null) { log.error("Got corrupted discovery packet into {} - packetId field is empty", source); } else { discovery(discoveryEvent, Packet.of(source, packetId)); } } NetworkWatcherService(
            IWatcherCarrier carrier, Duration roundTripNotificationPeriod, long awaitTime, Integer taskId); @VisibleForTesting  NetworkWatcherService(
            Clock clock, IWatcherCarrier carrier, Duration roundTripNotificationPeriod, long awaitTime,
            Integer taskId); }
NetworkWatcherService { public void discovery(IslInfoData discoveryEvent) { Endpoint source = new Endpoint(discoveryEvent.getSource()); Long packetId = discoveryEvent.getPacketId(); if (packetId == null) { log.error("Got corrupted discovery packet into {} - packetId field is empty", source); } else { discovery(discoveryEvent, Packet.of(source, packetId)); } } NetworkWatcherService(
            IWatcherCarrier carrier, Duration roundTripNotificationPeriod, long awaitTime, Integer taskId); @VisibleForTesting  NetworkWatcherService(
            Clock clock, IWatcherCarrier carrier, Duration roundTripNotificationPeriod, long awaitTime,
            Integer taskId); void addWatch(Endpoint endpoint); void removeWatch(Endpoint endpoint); void tick(); void confirmation(Endpoint endpoint, long packetNo); void discovery(IslInfoData discoveryEvent); void roundTripDiscovery(Endpoint endpoint, long packetId); }
NetworkWatcherService { public void discovery(IslInfoData discoveryEvent) { Endpoint source = new Endpoint(discoveryEvent.getSource()); Long packetId = discoveryEvent.getPacketId(); if (packetId == null) { log.error("Got corrupted discovery packet into {} - packetId field is empty", source); } else { discovery(discoveryEvent, Packet.of(source, packetId)); } } NetworkWatcherService(
            IWatcherCarrier carrier, Duration roundTripNotificationPeriod, long awaitTime, Integer taskId); @VisibleForTesting  NetworkWatcherService(
            Clock clock, IWatcherCarrier carrier, Duration roundTripNotificationPeriod, long awaitTime,
            Integer taskId); void addWatch(Endpoint endpoint); void removeWatch(Endpoint endpoint); void tick(); void confirmation(Endpoint endpoint, long packetNo); void discovery(IslInfoData discoveryEvent); void roundTripDiscovery(Endpoint endpoint, long packetId);  }