@Override public void eventReceived(Action action, ConfigMap configMap) { offer(WatchedUpdateResult.createFull(asObjectMap(configMap.getData()))); }
@Nullable @Override public Void apply(@Nullable WatchedUpdateListener watchedUpdateListener) { watchedUpdateListener.updateConfiguration(WatchedUpdateResult.createFull(new HashMap<String, Object>())); return null; } });
@Override public void eventReceived(Action action, ConfigMap configMap) { offer(WatchedUpdateResult.createFull(asObjectMap(configMap.getData()))); }
@Override public void eventReceived(Action action, ConfigMap configMap) { offer(WatchedUpdateResult.createFull(asObjectMap(configMap.getData()))); }
public void runOnce() throws InterruptedException { try { Response<List<GetValue>> kvals = updateIndex(getRaw(watchParams())); ImmutableMap<String, Object> full = convertToMap(kvals); final WatchedUpdateResult result; if (lastState.get() == null) { result = WatchedUpdateResult.createFull(full); } else { result = incrementalResult(full, lastState.get()); } lastState.set(full); fireEvent(result); } catch (Exception e) { LOGGER.error("Error watching path, waiting to retry", e); Thread.sleep(5000); } }
/** * Create an instance of the WatchedConfigurationSource, add listeners, and wait for the update callbacks. * * @param source * PolledConfigurationSource to poll */ public DynamicWatchedConfiguration(WatchedConfigurationSource source, boolean ignoreDeletesFromSource, DynamicPropertyUpdater updater) { this.source = source; this.ignoreDeletesFromSource = ignoreDeletesFromSource; this.updater = updater; // get a current snapshot of the config source data try { Map<String, Object> currentData = source.getCurrentData(); WatchedUpdateResult result = WatchedUpdateResult.createFull(currentData); updateConfiguration(result); } catch (final Exception exc) { logger.error("could not getCurrentData() from the WatchedConfigurationSource", exc); } // add a listener for subsequent config updates this.source.addUpdateListener(this); }
/** * Create an instance of the WatchedConfigurationSource, add listeners, and wait for the update callbacks. * * @param source * PolledConfigurationSource to poll */ public DynamicWatchedConfiguration(WatchedConfigurationSource source, boolean ignoreDeletesFromSource, DynamicPropertyUpdater updater) { this.source = source; this.ignoreDeletesFromSource = ignoreDeletesFromSource; this.updater = updater; // get a current snapshot of the config source data try { Map<String, Object> currentData = source.getCurrentData(); WatchedUpdateResult result = WatchedUpdateResult.createFull(currentData); updateConfiguration(result); } catch (final Exception exc) { logger.error("could not getCurrentData() from the WatchedConfigurationSource", exc); } // add a listener for subsequent config updates this.source.addUpdateListener(this); }