@Override public void event(DriverEvent event) { String driverName = event.subject().name(); driverHandlers.entrySet().stream() .filter(e -> driverName.equals(e.getValue().driver().name())) .map(Map.Entry::getKey) .distinct() .forEach(FlowObjectiveManager.this::invalidatePipeliner); } }
private DomainIntentConfigurable initDomainIntentDriver(DeviceId deviceId) { // Attempt to lookup the handler in the cache DriverHandler handler = driverHandlers.get(deviceId); if (handler == null) { try { // Otherwise create it and if it has DomainIntentConfig behaviour, cache it handler = driverService.createHandler(deviceId); if (!handler.driver().hasBehaviour(DomainIntentConfigurable.class)) { log.warn("DomainIntentConfig behaviour not supported for device {}", deviceId); return null; } } catch (ItemNotFoundException e) { log.warn("No applicable driver for device {}", deviceId); return null; } driverHandlers.put(deviceId, handler); } // Always (re)initialize the pipeline behaviour log.info("Driver {} bound to device {} ... initializing driver", handler.driver().name(), deviceId); return handler.behaviour(DomainIntentConfigurable.class); } }
private void setupPipelineHandler(DeviceId deviceId) { // Attempt to lookup the handler in the cache DriverHandler handler = driverHandlers.get(deviceId); if (handler == null) { try { // Otherwise create it and if it has pipeline behaviour, cache it handler = driverService.createHandler(deviceId); if (!handler.driver().hasBehaviour(Pipeliner.class)) { log.warn("Pipeline behaviour not supported for device {}", deviceId); return; } } catch (ItemNotFoundException e) { log.warn("No applicable driver for device {}", deviceId); return; } driverHandlers.put(deviceId, handler); } // Always (re)initialize the pipeline behaviour log.info("Driver {} bound to device {} ... initializing driver", handler.driver().name(), deviceId); Pipeliner pipeliner = handler.behaviour(Pipeliner.class); pipeliner.init(deviceId, context); pipeliners.putIfAbsent(deviceId, pipeliner); }
private void invalidatePipelinerIfNecessary(Device device) { DriverHandler handler = driverHandlers.get(device.id()); if (handler != null && !Objects.equals(handler.driver().name(), device.annotations().value(DRIVER))) { invalidatePipeliner(device.id()); } }