@Test public void testDeactivate() { this.addDevice(); provider.deactivate(null); assertAfter(500, () -> assertNull("Device should be removed", controller.getDevice(deviceId))); assertNull("Network config factory not removed", cfgFactory); assertFalse("Network config listener not removed", netCfgListeners.contains(provider.cfgLister)); assertFalse("Provider not unregistered", providerRegistry.getProviders().contains(provider.id())); assertNull("Provider registry not removed", provider.providerService); }
@Deactivate public void deactivate(ComponentContext context) { try { controller.getDevices().stream().forEach(device -> { deviceBuilderExecutor.execute(new DeviceFactory(device, false)); }); deviceBuilderExecutor.awaitTermination(1000, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { log.error("Device builder did not terminate"); } deviceBuilderExecutor.shutdownNow(); netCfgService.unregisterConfigFactory(factory); netCfgService.removeListener(cfgLister); providerRegistry.unregister(this); providerService = null; log.info("Stopped"); }
SnmpDeviceProvider extends AbstractProvider implements DeviceProvider { @Deactivate public void deactivate(ComponentContext context) { try { controller.getDevices().stream().forEach(device -> { deviceBuilderExecutor.execute(new DeviceFactory(device, false)); }); deviceBuilderExecutor.awaitTermination(1000, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { log.error("Device builder did not terminate"); } deviceBuilderExecutor.shutdownNow(); netCfgService.unregisterConfigFactory(factory); netCfgService.removeListener(cfgLister); providerRegistry.unregister(this); providerService = null; log.info("Stopped"); } }
SnmpDeviceProvider extends AbstractProvider implements DeviceProvider { @Deactivate public void deactivate(ComponentContext context) { try { controller.getDevices().stream().forEach(device -> { deviceBuilderExecutor.execute(new DeviceFactory(device, false)); }); deviceBuilderExecutor.awaitTermination(1000, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { log.error("Device builder did not terminate"); } deviceBuilderExecutor.shutdownNow(); netCfgService.unregisterConfigFactory(factory); netCfgService.removeListener(cfgLister); providerRegistry.unregister(this); providerService = null; log.info("Stopped"); } SnmpDeviceProvider(); }
SnmpDeviceProvider extends AbstractProvider implements DeviceProvider { @Deactivate public void deactivate(ComponentContext context) { try { controller.getDevices().stream().forEach(device -> { deviceBuilderExecutor.execute(new DeviceFactory(device, false)); }); deviceBuilderExecutor.awaitTermination(1000, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { log.error("Device builder did not terminate"); } deviceBuilderExecutor.shutdownNow(); netCfgService.unregisterConfigFactory(factory); netCfgService.removeListener(cfgLister); providerRegistry.unregister(this); providerService = null; log.info("Stopped"); } SnmpDeviceProvider(); @Activate void activate(ComponentContext context); @Deactivate void deactivate(ComponentContext context); @Modified void modified(ComponentContext context); @Override void triggerProbe(DeviceId deviceId); @Override void roleChanged(DeviceId deviceId, MastershipRole newRole); @Override boolean isReachable(DeviceId deviceId); @Override void changePortState(DeviceId deviceId, PortNumber portNumber,
                                boolean enable); }
SnmpDeviceProvider extends AbstractProvider implements DeviceProvider { @Deactivate public void deactivate(ComponentContext context) { try { controller.getDevices().stream().forEach(device -> { deviceBuilderExecutor.execute(new DeviceFactory(device, false)); }); deviceBuilderExecutor.awaitTermination(1000, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { log.error("Device builder did not terminate"); } deviceBuilderExecutor.shutdownNow(); netCfgService.unregisterConfigFactory(factory); netCfgService.removeListener(cfgLister); providerRegistry.unregister(this); providerService = null; log.info("Stopped"); } SnmpDeviceProvider(); @Activate void activate(ComponentContext context); @Deactivate void deactivate(ComponentContext context); @Modified void modified(ComponentContext context); @Override void triggerProbe(DeviceId deviceId); @Override void roleChanged(DeviceId deviceId, MastershipRole newRole); @Override boolean isReachable(DeviceId deviceId); @Override void changePortState(DeviceId deviceId, PortNumber portNumber,
                                boolean enable);  }