private synchronized void updateSchema(Watcher<Schema> watcher) throws Exception { Schema schema = assembleSchema(currentAddressSpacePlans, currentAddressPlans, currentStandardInfraConfigs, currentBrokeredInfraConfigs); if (schema != null) { watcher.onUpdate(Collections.singletonList(schema)); } }
void doWork() { synchronized (monitor) { try { monitor.wait(recheckInterval.toMillis()); log.debug("Woke up from monitor"); if (synced) { watcher.onUpdate(resourceCache.getItems()); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (Exception e) { log.warn("Exception in checker task", e); } } }
@Override public Watch watchStandardInfraConfigs(Watcher<StandardInfraConfig> watcher, Duration resyncInterval) { WorkQueue<StandardInfraConfig> queue = new EventCache<>(new HasMetadataFieldExtractor<>()); Reflector.Config<StandardInfraConfig, StandardInfraConfigList> config = new Reflector.Config<>(); config.setClock(Clock.systemUTC()); config.setExpectedType(StandardInfraConfig.class); config.setListerWatcher(this); config.setResyncInterval(resyncInterval); config.setWorkQueue(queue); config.setProcessor(map -> { if (queue.hasSynced()) { watcher.onUpdate(new ArrayList<>(queue.list())); } }); Reflector<StandardInfraConfig, StandardInfraConfigList> reflector = new Reflector<>(config); Controller controller = new Controller(reflector); controller.start(); return controller; } }
@Override public Watch watchAddressSpacePlans(Watcher<AddressSpacePlan> watcher, Duration resyncInterval) { WorkQueue<AddressSpacePlan> queue = new EventCache<>(new HasMetadataFieldExtractor<>()); Reflector.Config<AddressSpacePlan, AddressSpacePlanList> config = new Reflector.Config<>(); config.setClock(Clock.systemUTC()); config.setExpectedType(AddressSpacePlan.class); config.setListerWatcher(this); config.setResyncInterval(resyncInterval); config.setWorkQueue(queue); config.setProcessor(map -> { if (queue.hasSynced()) { watcher.onUpdate(new ArrayList<>(queue.list())); } }); Reflector<AddressSpacePlan, AddressSpacePlanList> reflector = new Reflector<>(config); Controller controller = new Controller(reflector); controller.start(); return controller; } }
@Override public Watch watchAddressPlans(Watcher<AddressPlan> watcher, Duration resyncInterval) { WorkQueue<AddressPlan> queue = new EventCache<>(new HasMetadataFieldExtractor<>()); Reflector.Config<AddressPlan, AddressPlanList> config = new Reflector.Config<>(); config.setClock(Clock.systemUTC()); config.setExpectedType(AddressPlan.class); config.setListerWatcher(this); config.setResyncInterval(resyncInterval); config.setWorkQueue(queue); config.setProcessor(map -> { if (queue.hasSynced()) { watcher.onUpdate(new ArrayList<>(queue.list())); } }); Reflector<AddressPlan, AddressPlanList> reflector = new Reflector<>(config); Controller controller = new Controller(reflector); controller.start(); return controller; } }
@Override public Watch watchBrokeredInfraConfigs(Watcher<BrokeredInfraConfig> watcher, Duration resyncInterval) { WorkQueue<BrokeredInfraConfig> queue = new EventCache<>(new HasMetadataFieldExtractor<>()); Reflector.Config<BrokeredInfraConfig, BrokeredInfraConfigList> config = new Reflector.Config<>(); config.setClock(Clock.systemUTC()); config.setExpectedType(BrokeredInfraConfig.class); config.setListerWatcher(this); config.setResyncInterval(resyncInterval); config.setWorkQueue(queue); config.setProcessor(map -> { if (queue.hasSynced()) { watcher.onUpdate(new ArrayList<>(queue.list())); } }); Reflector<BrokeredInfraConfig, BrokeredInfraConfigList> reflector = new Reflector<>(config); Controller controller = new Controller(reflector); controller.start(); return controller; } }