org.onosproject.net.device.DeviceEvent Java Examples
The following examples show how to use
org.onosproject.net.device.DeviceEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OpenstackSwitchingPhysicalHandler.java From onos with Apache License 2.0 | 6 votes |
@Override public boolean isRelevant(DeviceEvent event) { Port port = event.port(); if (port == null) { return false; } OpenstackNode osNode = osNodeService.node(event.subject().id()); if (osNode == null) { return false; } Set<String> intPatchPorts = osNode.phyIntfs().stream() .map(pi -> structurePortName(INTEGRATION_TO_PHYSICAL_PREFIX + pi.network())).collect(Collectors.toSet()); String portName = port.annotations().value(PORT_NAME); return intPatchPorts.contains(portName); }
Example #2
Source File: LldpLinkProviderTest.java From onos with Apache License 2.0 | 6 votes |
/** * Checks that links on a reconfigured switch are properly removed. */ @Test public void switchSuppressedByAnnotation() { // add device to stub DeviceService deviceService.putDevice(device(DID3)); deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID3)); assertFalse("Device not added", provider.discoverers.isEmpty()); // update device in stub DeviceService with suppression config deviceService.putDevice(device(DID3, DefaultAnnotations.builder() .set(LldpLinkProvider.NO_LLDP, "true") .build())); deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_UPDATED, DID3)); // discovery on device is expected to be gone or stopped LinkDiscovery linkDiscovery = provider.discoverers.get(DID3); if (linkDiscovery != null) { assertTrue("Discovery expected to be stopped", linkDiscovery.isStopped()); } }
Example #3
Source File: LldpLinkProviderTest.java From onos with Apache License 2.0 | 6 votes |
@Test public void switchSuppressByBlacklist() { // add device in stub DeviceService deviceService.putDevice(device(DID3)); deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID3)); // add deviveId to device blacklist deviceBlacklist.add(DID3); configListener.event(new NetworkConfigEvent(Type.CONFIG_ADDED, DID3, LinkDiscoveryFromDevice.class)); assertAfter(EVENT_MS, () -> { // discovery helper for device is expected to be gone or stopped LinkDiscovery linkDiscovery = provider.discoverers.get(DID3); if (linkDiscovery != null) { assertTrue("Discovery expected to be stopped", linkDiscovery.isStopped()); } }); }
Example #4
Source File: DeviceManager.java From onos with Apache License 2.0 | 6 votes |
@Override public void removeDevicePorts(DeviceId deviceId) { checkNotNull(deviceId, DEVICE_ID_NULL); if (isAvailable(deviceId)) { log.debug("Cannot remove ports of device {} while it is available.", deviceId); return; } List<PortDescription> portDescriptions = ImmutableList.of(); List<DeviceEvent> events = store.updatePorts(getProvider(deviceId).id(), deviceId, portDescriptions); if (events != null) { for (DeviceEvent event : events) { post(event); } } }
Example #5
Source File: HostLocationProviderTest.java From onos with Apache License 2.0 | 6 votes |
@Test public void removeHostByDevicePortDown() { provider.modified(CTX_FOR_REMOVE); testProcessor.process(new TestArpPacketContext(DEV1)); testProcessor.process(new TestArpPacketContext(DEV4)); Device device = new DefaultDevice(ProviderId.NONE, deviceId(DEV1), SWITCH, "m", "h", "s", "n", new ChassisId(0L)); deviceService.listener.event(new DeviceEvent(PORT_UPDATED, device, new DefaultPort(device, portNumber(INPORT), false))); assertEquals("incorrect remove count", 1, providerService.locationRemoveCount); device = new DefaultDevice(ProviderId.NONE, deviceId(DEV4), SWITCH, "m", "h", "s", "n", new ChassisId(0L)); deviceService.listener.event(new DeviceEvent(PORT_UPDATED, device, new DefaultPort(device, portNumber(INPORT), false))); assertEquals("incorrect remove count", 2, providerService.locationRemoveCount); }
Example #6
Source File: HostLocationProviderTest.java From onos with Apache License 2.0 | 6 votes |
@Test public void removeHostByDeviceOffline() { provider.modified(CTX_FOR_REMOVE); testProcessor.process(new TestArpPacketContext(DEV1)); testProcessor.process(new TestArpPacketContext(DEV4)); Device device = new DefaultDevice(ProviderId.NONE, deviceId(DEV1), SWITCH, "m", "h", "s", "n", new ChassisId(0L)); deviceService.listener.event(new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device)); assertEquals("incorrect remove count", 2, providerService.locationRemoveCount); device = new DefaultDevice(ProviderId.NONE, deviceId(DEV4), SWITCH, "m", "h", "s", "n", new ChassisId(0L)); deviceService.listener.event(new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device)); assertEquals("incorrect remove count", 3, providerService.locationRemoveCount); }
Example #7
Source File: ControlPlaneRedirectManagerTest.java From onos with Apache License 2.0 | 6 votes |
/** * Tests adding new Device to a openflow router. */ @Test public void testAddDevice() { ConnectPoint sw1eth4 = new ConnectPoint(DEVICE_ID, PortNumber.portNumber(4)); List<InterfaceIpAddress> interfaceIpAddresses = new ArrayList<>(); interfaceIpAddresses.add( new InterfaceIpAddress(IpAddress.valueOf("192.168.40.101"), IpPrefix.valueOf("192.168.40.0/24")) ); interfaceIpAddresses.add( new InterfaceIpAddress(IpAddress.valueOf("2000::ff"), IpPrefix.valueOf("2000::ff/120")) ); Interface sw1Eth4 = new Interface(sw1eth4.deviceId().toString(), sw1eth4, interfaceIpAddresses, MacAddress.valueOf("00:00:00:00:00:04"), VlanId.NONE); interfaces.add(sw1Eth4); EasyMock.reset(flowObjectiveService); setUpFlowObjectiveService(); deviceListener.event(new DeviceEvent(DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED, dev3)); verify(flowObjectiveService); }
Example #8
Source File: HostLocationProviderTest.java From onos with Apache License 2.0 | 6 votes |
@Test public void removeHostByDeviceRemove() { provider.modified(CTX_FOR_REMOVE); testProcessor.process(new TestArpPacketContext(DEV1)); testProcessor.process(new TestNaPacketContext(DEV4)); Device device = new DefaultDevice(ProviderId.NONE, deviceId(DEV1), SWITCH, "m", "h", "s", "n", new ChassisId(0L)); deviceService.listener.event(new DeviceEvent(DEVICE_REMOVED, device)); assertEquals("incorrect remove count", 2, providerService.locationRemoveCount); device = new DefaultDevice(ProviderId.NONE, deviceId(DEV4), SWITCH, "m", "h", "s", "n", new ChassisId(0L)); deviceService.listener.event(new DeviceEvent(DEVICE_REMOVED, device)); assertEquals("incorrect remove count", 3, providerService.locationRemoveCount); }
Example #9
Source File: SimpleDeviceStoreTest.java From onos with Apache License 2.0 | 6 votes |
@Test public final void testCreateOrUpdateDevice() { DeviceDescription description = new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, HW, SW1, SN, CID); DeviceEvent event = deviceStore.createOrUpdateDevice(PID, DID1, description); assertEquals(DEVICE_ADDED, event.type()); assertDevice(DID1, SW1, event.subject()); DeviceDescription description2 = new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, HW, SW2, SN, CID); DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2); assertEquals(DEVICE_UPDATED, event2.type()); assertDevice(DID1, SW2, event2.subject()); assertNull("No change expected", deviceStore.createOrUpdateDevice(PID, DID1, description2)); }
Example #10
Source File: RoadmManager.java From onos with Apache License 2.0 | 6 votes |
@Override public void event(DeviceEvent deviceEvent) { Device device = deviceEvent.subject(); switch (deviceEvent.type()) { case DEVICE_ADDED: case DEVICE_UPDATED: initDevice(device.id()); break; case PORT_ADDED: case PORT_UPDATED: //FIXME // As roadm application is a optional tool for now. // The target power initialization will be enhanced later, // hopefully using an formal optical subsystem. // setInitialTargetPortPower(device.id(), deviceEvent.port().number()); break; default: break; } }
Example #11
Source File: LldpLinkProviderTest.java From onos with Apache License 2.0 | 6 votes |
/** * Checks that discovery on reconfigured port are properly restarted. */ @Test public void portSuppressedByPortConfig() { // add device in stub DeviceService without suppression configured deviceService.putDevice(device(DID3)); deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID3)); // suppressed port added to non-suppressed device final long portno3 = 3L; final Port port3 = port(DID3, portno3, true, DefaultAnnotations.builder() .set(LldpLinkProvider.NO_LLDP, "true") .build()); deviceService.putPorts(DID3, port3); deviceListener.event(portEvent(DeviceEvent.Type.PORT_ADDED, DID3, port3)); // discovery helper should be there turned on assertFalse("Discoverer is expected to start", provider.discoverers.get(DID3).isStopped()); assertFalse("Discoverer should not contain the port there", provider.discoverers.get(DID3).containsPort(portno3)); }
Example #12
Source File: ObjectiveTrackerTest.java From onos with Apache License 2.0 | 6 votes |
/** * Tests an event for a host becoming available that matches an intent. * * @throws InterruptedException if the latch wait fails. */ @Test public void testEventHostAvailableNoMatch() throws Exception { final Device host = device("host1"); final DeviceEvent deviceEvent = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, host); reasons.add(deviceEvent); deviceListener.event(deviceEvent); assertThat( delegate.latch.await(WAIT_TIMEOUT_SECONDS, TimeUnit.SECONDS), is(true)); assertThat(delegate.intentIdsFromEvent, hasSize(0)); assertThat(delegate.compileAllFailedFromEvent, is(true)); }
Example #13
Source File: Ovs.java From onos with Apache License 2.0 | 6 votes |
@Override public boolean isCompleted(WorkflowContext context, Event event) throws WorkflowException { if (!(event instanceof DeviceEvent)) { return false; } DeviceEvent deviceEvent = (DeviceEvent) event; Device device = deviceEvent.subject(); switch (deviceEvent.type()) { case DEVICE_ADDED: case DEVICE_AVAILABILITY_CHANGED: case DEVICE_UPDATED: return context.getService(DeviceService.class).isAvailable(device.id()); default: return false; } }
Example #14
Source File: GossipDeviceStore.java From onos with Apache License 2.0 | 5 votes |
@Override public synchronized DeviceEvent updatePortStatus(ProviderId providerId, DeviceId deviceId, PortDescription portDescription) { final Timestamp newTimestamp; try { newTimestamp = deviceClockService.getTimestamp(deviceId); } catch (IllegalStateException e) { log.info("Timestamp was not available for device {}", deviceId); log.debug(" discarding {}", portDescription); // Failed to generate timestamp. Ignoring. // See updatePorts comment return null; } final Timestamped<PortDescription> deltaDesc = new Timestamped<>(portDescription, newTimestamp); final DeviceEvent event; final Timestamped<PortDescription> mergedDesc; final Map<ProviderId, DeviceDescriptions> device = getOrCreateDeviceDescriptionsMap(deviceId); synchronized (device) { event = updatePortStatusInternal(providerId, deviceId, deltaDesc); mergedDesc = device.get(providerId) .getPortDesc(portDescription.portNumber()); } if (event != null) { log.debug("Notifying peers of a port status update topology event for providerId: {} and deviceId: {}", providerId, deviceId); notifyPeers(new InternalPortStatusEvent(providerId, deviceId, mergedDesc)); } return event; }
Example #15
Source File: OpenstackSwitchingHostProvider.java From onos with Apache License 2.0 | 5 votes |
/** * A helper method which logs the port addition event and performs port * addition action. * * @param event device event */ void portAddedHelper(DeviceEvent event) { log.debug("Instance port {} is detected from {}", event.port().annotations().value(PORT_NAME), event.subject().id()); processPortAdded(event.port()); }
Example #16
Source File: DeviceManager.java From onos with Apache License 2.0 | 5 votes |
@Deactivate public void deactivate() { backgroundService.shutdown(); networkConfigService.removeListener(networkConfigListener); store.unsetDelegate(delegate); mastershipService.removeListener(mastershipListener); eventDispatcher.removeSink(DeviceEvent.class); communicationService.removeSubscriber(PORT_UPDOWN_SUBJECT); portReqeustExecutor.shutdown(); log.info("Stopped"); }
Example #17
Source File: DeviceEventConverter.java From onos with Apache License 2.0 | 5 votes |
@Override public byte[] convertToProtoMessage(Event<?, ?> event) { DeviceEvent deviceEvent = (DeviceEvent) event; if (!deviceEventTypeSupported(deviceEvent)) { log.error("Unsupported Onos Device Event {}. There is no matching" + "proto Device Event type", deviceEvent.type().toString()); return null; } return ((GeneratedMessageV3) buildDeviceProtoMessage(deviceEvent)).toByteArray(); }
Example #18
Source File: DeviceManager.java From onos with Apache License 2.0 | 5 votes |
@Override @SafeVarargs public final void registerPortConfigOperator(PortConfigOperator portOp, Class<? extends Config<ConnectPoint>>... configs) { checkNotNull(portOp); portOp.bindService(networkConfigService); // update both portOpsIndex and portOps synchronized (portOpsIndex) { for (Class<? extends Config<ConnectPoint>> config : configs) { portOpsIndex.put(config, portOp); } portOps.add(portOp); } // TODO: Should we be applying to all existing Ports? Tools.stream(store.getAvailableDevices()) .map(Device::id) .filter(mastershipService::isLocalMaster) // for each locally managed Device, update all port descriptions .map(did -> { ProviderId pid = Optional.ofNullable(getProvider(did)) .map(Provider::id) .orElse(null); if (pid == null) { log.warn("Provider not found for {}", did); return ImmutableList.<DeviceEvent>of(); } List<PortDescription> pds = store.getPortDescriptions(pid, did) .map(pdesc -> applyAllPortOps(did, pdesc)) .collect(Collectors.toList()); return store.updatePorts(pid, did, pds); }) // ..and port port update event if necessary .forEach(evts -> evts.forEach(this::post)); }
Example #19
Source File: SimpleDeviceStoreTest.java From onos with Apache License 2.0 | 5 votes |
@Test public final void testRemoveDevice() { putDevice(DID1, SW1, A1); List<PortDescription> pds = Arrays.asList( DefaultPortDescription.builder().withPortNumber(P1).isEnabled(true).annotations(A2).build() ); deviceStore.updatePorts(PID, DID1, pds); putDevice(DID2, SW1); assertEquals(2, deviceStore.getDeviceCount()); assertEquals(1, deviceStore.getPorts(DID1).size()); assertAnnotationsEquals(deviceStore.getDevice(DID1).annotations(), A1); assertAnnotationsEquals(deviceStore.getPort(DID1, P1).annotations(), A2); DeviceEvent event = deviceStore.removeDevice(DID1); assertEquals(DEVICE_REMOVED, event.type()); assertDevice(DID1, SW1, event.subject()); assertEquals(1, deviceStore.getDeviceCount()); assertEquals(0, deviceStore.getPorts(DID1).size()); // putBack Device, Port w/o annotation putDevice(DID1, SW1); List<PortDescription> pds2 = Arrays.asList( DefaultPortDescription.builder().withPortNumber(P1).isEnabled(true).build() ); deviceStore.updatePorts(PID, DID1, pds2); // annotations should not survive assertEquals(2, deviceStore.getDeviceCount()); assertEquals(1, deviceStore.getPorts(DID1).size()); assertAnnotationsEquals(deviceStore.getDevice(DID1).annotations()); assertAnnotationsEquals(deviceStore.getPort(DID1, P1).annotations()); }
Example #20
Source File: OpenstackSwitchingHostProviderTest.java From onos with Apache License 2.0 | 5 votes |
@Test public void testProcessPortRemoved() { org.onosproject.net.Port addedPort = new DefaultPort(DEV1, P1, true, ANNOTATIONS); DeviceEvent addedEvent = new DeviceEvent(DeviceEvent.Type.PORT_ADDED, DEV1, addedPort); target.portAddedHelper(addedEvent); org.onosproject.net.Port removedPort = new DefaultPort(DEV2, P1, true, ANNOTATIONS); DeviceEvent removedEvent = new DeviceEvent(DeviceEvent.Type.PORT_REMOVED, DEV2, removedPort); target.portRemovedHelper(removedEvent); assertNull(target.hostService.getHost(HostId.hostId(HOST_MAC))); }
Example #21
Source File: K8sSwitchingHostProvider.java From onos with Apache License 2.0 | 5 votes |
private void processPortRemoval(DeviceEvent event) { if (!isRelevantHelper(event)) { return; } log.debug("K8s port {} is removed from {}", event.port().annotations().value(PORT_NAME), event.subject().id()); processPortRemoved(event.port()); }
Example #22
Source File: K8sSwitchingHostProvider.java From onos with Apache License 2.0 | 5 votes |
private void processPortAddition(DeviceEvent event) { if (!isRelevantHelper(event)) { return; } log.debug("K8s port {} is detected from {}", event.port().annotations().value(PORT_NAME), event.subject().id()); processPortAdded(event.port()); }
Example #23
Source File: OpenstackSwitchingHostProvider.java From onos with Apache License 2.0 | 5 votes |
private void processPortUpdate(DeviceEvent event) { if (!isRelevantHelper(event)) { return; } if (!event.port().isEnabled()) { portRemovedHelper(event); } else if (event.port().isEnabled()) { portAddedHelper(event); } }
Example #24
Source File: DhcpRelayManagerTest.java From onos with Apache License 2.0 | 5 votes |
/** * Should try install ignore rules when device comes up. */ @Test public void testInstallIgnoreRuleWhenDeviceComesUp() throws IOException { ObjectMapper om = new ObjectMapper(); JsonNode json = om.readTree(Resources.getResource(CONFIG_FILE_PATH)); IgnoreDhcpConfig config = new IgnoreDhcpConfig(); json = json.path("apps").path(DHCP_RELAY_APP).path(IgnoreDhcpConfig.KEY); config.init(APP_ID, IgnoreDhcpConfig.KEY, json, om, null); reset(manager.cfgService, flowObjectiveService, manager.deviceService); expect(manager.cfgService.getConfig(APP_ID, IgnoreDhcpConfig.class)) .andReturn(config).anyTimes(); Device device = createNiceMock(Device.class); expect(device.is(Pipeliner.class)).andReturn(true).anyTimes(); expect(device.id()).andReturn(DEV_1_ID).anyTimes(); expect(manager.deviceService.getDevice(DEV_1_ID)).andReturn(device).anyTimes(); DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device); Capture<Objective> capturedFromDev1 = newCapture(CaptureType.ALL); flowObjectiveService.apply(eq(DEV_1_ID), capture(capturedFromDev1)); expectLastCall().times(DHCP_SELECTORS.size()); replay(manager.cfgService, flowObjectiveService, manager.deviceService, device); manager.deviceListener.event(event); // Wait until all flow objective events are captured before triggering onSuccess int expectFlowObjCount = Dhcp4HandlerImpl.DHCP_SELECTORS.size() + Dhcp6HandlerImpl.DHCP_SELECTORS.size(); assertAfter(EVENT_PROCESSING_MS, () -> assertEquals(expectFlowObjCount, capturedFromDev1.getValues().size())); capturedFromDev1.getValues().forEach(obj -> obj.context().ifPresent(ctx -> ctx.onSuccess(obj))); assertAfter(EVENT_PROCESSING_MS, () -> assertEquals(1, v4Handler.ignoredVlans.size())); assertAfter(EVENT_PROCESSING_MS, () -> assertEquals(1, v6Handler.ignoredVlans.size())); }
Example #25
Source File: SimpleDeviceStoreTest.java From onos with Apache License 2.0 | 5 votes |
@Test public final void testCreateOrUpdateDeviceAncillary() { DeviceDescription description = new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, HW, SW1, SN, CID, A2); DeviceEvent event = deviceStore.createOrUpdateDevice(PIDA, DID1, description); assertEquals(DEVICE_ADDED, event.type()); assertDevice(DID1, SW1, event.subject()); assertEquals(PIDA, event.subject().providerId()); assertAnnotationsEquals(event.subject().annotations(), A2); assertFalse("Ancillary will not bring device up", deviceStore.isAvailable(DID1)); DeviceDescription description2 = new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, HW, SW2, SN, CID, A1); DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2); assertEquals(DEVICE_UPDATED, event2.type()); assertDevice(DID1, SW2, event2.subject()); assertEquals(PID, event2.subject().providerId()); assertAnnotationsEquals(event2.subject().annotations(), A1, A2); assertTrue(deviceStore.isAvailable(DID1)); assertNull("No change expected", deviceStore.createOrUpdateDevice(PID, DID1, description2)); // For now, Ancillary is ignored once primary appears assertNull("No change expected", deviceStore.createOrUpdateDevice(PIDA, DID1, description)); // But, Ancillary annotations will be in effect DeviceDescription description3 = new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR, HW, SW1, SN, CID, A2_2); DeviceEvent event3 = deviceStore.createOrUpdateDevice(PIDA, DID1, description3); assertEquals(DEVICE_UPDATED, event3.type()); // basic information will be the one from Primary assertDevice(DID1, SW2, event3.subject()); assertEquals(PID, event3.subject().providerId()); // but annotation from Ancillary will be merged assertAnnotationsEquals(event3.subject().annotations(), A1, A2, A2_2); assertTrue(deviceStore.isAvailable(DID1)); }
Example #26
Source File: SimpleDeviceStore.java From onos with Apache License 2.0 | 5 votes |
private DeviceEvent updatePort(Device device, Port oldPort, Port newPort, Map<PortNumber, Port> ports) { if (oldPort.isEnabled() != newPort.isEnabled() || oldPort.type() != newPort.type() || oldPort.portSpeed() != newPort.portSpeed() || !AnnotationsUtil.isEqual(oldPort.annotations(), newPort.annotations())) { ports.put(oldPort.number(), newPort); return new DeviceEvent(PORT_UPDATED, device, newPort); } return null; }
Example #27
Source File: NdpReplyComponent.java From ngsdn-tutorial with Apache License 2.0 | 5 votes |
@Override public boolean isRelevant(DeviceEvent event) { switch (event.type()) { case DEVICE_ADDED: case DEVICE_AVAILABILITY_CHANGED: break; default: // Ignore other events. return false; } // Process only if this controller instance is the master. final DeviceId deviceId = event.subject().id(); return mastershipService.isLocalMaster(deviceId); }
Example #28
Source File: NetworkConfigLinksProviderTest.java From onos with Apache License 2.0 | 5 votes |
/** * Tests removing a device via an event. */ @Test public void testRemoveDevice() { assertThat(provider.discoverers.entrySet(), hasSize(2)); deviceListener.event(new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, dev3)); assertThat(provider.discoverers.entrySet(), hasSize(3)); deviceListener.event(new DeviceEvent(DeviceEvent.Type.DEVICE_REMOVED, dev3)); assertThat(provider.discoverers.entrySet(), hasSize(2)); }
Example #29
Source File: GossipDeviceStore.java From onos with Apache License 2.0 | 5 votes |
private void handleRemoveRequest(DeviceId did) { try { DeviceEvent event = removeDevice(did); notifyDelegateIfNotNull(event); } catch (Exception e) { log.warn("Exception thrown handling device remove", e); } }
Example #30
Source File: FlowObjectiveManagerTest.java From onos with Apache License 2.0 | 5 votes |
/** * Tests receipt of a device up event. * * @throws TestUtilsException if lookup of a field fails */ @Test public void deviceUpEvent() throws TestUtilsException { TrafficSelector selector = DefaultTrafficSelector.emptySelector(); TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment(); DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, d2); DeviceListener listener = TestUtils.getField(manager, "deviceListener"); assertThat(listener, notNullValue()); listener.event(event); ForwardingObjective forward = DefaultForwardingObjective.builder() .fromApp(NetTestTools.APP_ID) .withFlag(ForwardingObjective.Flag.SPECIFIC) .withSelector(selector) .withTreatment(treatment) .makePermanent() .add(); manager.forward(id2, forward); // new device should have an objective now TestTools.assertAfter(RETRY_MS, () -> assertThat(forwardingObjectives, hasSize(1))); assertThat(forwardingObjectives, hasItem("of:d2")); assertThat(filteringObjectives, hasSize(0)); assertThat(nextObjectives, hasSize(0)); }