public PollResult poll(boolean b, Object o) throws Exception { Map<String, Object> configurations = new LinkedHashMap<>(); for (ConfigModel configModel : configModels) { configurations.putAll(YAMLUtil.retrieveItems("", configModel.getConfig())); } return PollResult.createFull(configurations); } }
/** * Create a full result that represents the complete content of the configuration source. * @param complete map that contains all the properties */ public static PollResult createFull(Map<String, Object> complete) { return new PollResult(complete); }
if (result == null || !result.hasChanges()) { return; if (!result.isIncremental()) { Map<String, Object> props = result.getComplete(); if (props == null) { return; Map<String, Object> props = result.getAdded(); if (props != null) { for (Entry<String, Object> entry: props.entrySet()) { props = result.getChanged(); if (props != null) { for (Entry<String, Object> entry: props.entrySet()) { props = result.getDeleted(); if (props != null) { for (String name: props.keySet()) {
throw new RuntimeException("The lastResult is null, probably the eagle service is dead! ", exception); Map<String, Object> added = lastResult.getAdded(); Map<String, Object> changed = lastResult.getChanged(); Map<String, Object> deleted = lastResult.getDeleted(); for(Map.Entry<String, List<PolicyLifecycleMethods<T>>> entry : policyChangeListeners.entrySet()){ String alertExecutorId = entry.getKey();
public void run() { log.debug("Polling started"); PollResult result = null; try { result = source.poll(false, getNextCheckPoint(checkPoint)); checkPoint = result.getCheckPoint(); fireEvent(EventType.POLL_SUCCESS, result, null); } catch (Throwable e) { log.error("Error getting result from polling source", e); fireEvent(EventType.POLL_FAILURE, null, e); return; } try { populateProperties(result, config); } catch (Throwable e) { log.error("Error occured applying properties", e); } }
if (result == null || !result.hasChanges()) { return; if (!result.isIncremental()) { Map<String, Object> props = result.getComplete(); if (props == null) { return; Map<String, Object> props = result.getAdded(); if (props != null) { for (Entry<String, Object> entry: props.entrySet()) { props = result.getChanged(); if (props != null) { for (Entry<String, Object> entry: props.entrySet()) { props = result.getDeleted(); if (props != null) { for (String name: props.keySet()) {
public void run() { log.debug("Polling started"); PollResult result = null; try { result = source.poll(false, getNextCheckPoint(checkPoint)); checkPoint = result.getCheckPoint(); fireEvent(EventType.POLL_SUCCESS, result, null); } catch (Throwable e) { log.error("Error getting result from polling source", e); fireEvent(EventType.POLL_FAILURE, null, e); return; } try { populateProperties(result, config); } catch (Throwable e) { log.error("Error occured applying properties", e); } }
public class XMLPolledConfigurationSource implements PolledConfigurationSource { @SuppressWarnings("static-access") @Override public PollResult poll(boolean inital, Object checkPoint) throws Exception { PollResult pollResult = null; Map<String, Object> map = new HashMap<>(); // Code to read content from the resource return pollResult.createFull(map); } }
/** * Create a full result that represents the complete content of the configuration source. * @param complete map that contains all the properties */ public static PollResult createFull(Map<String, Object> complete) { return new PollResult(complete); }
/** * Do an initial poll from the source and apply the result to the configuration. * * @param source source of the configuration * @param config Configuration to apply the polling result * @throws RuntimeException if any error occurs in polling the configuration source */ protected synchronized void initialLoad(final PolledConfigurationSource source, final Configuration config) { PollResult result = null; try { result = source.poll(true, null); checkPoint = result.getCheckPoint(); fireEvent(EventType.POLL_SUCCESS, result, null); } catch (Throwable e) { throw new RuntimeException("Unable to load Properties source from " + source, e); } try { populateProperties(result, config); } catch (Throwable e) { throw new RuntimeException("Unable to load Properties", e); } }
@Override public PollResult poll(boolean initial, Object checkPoint) throws Exception { // implement logic to retrieve properties from DB Map<String, Object> map = load(); return PollResult.createFull(map); }
/** * Create a result that represents incremental changes from the configuration * source. * * @param added properties added * @param changed properties changed * @param deleted properties deleted, in which case the value in the map will be ignored * @param checkPoint Object that served as a marker for this incremental change, for example, a time stamp * of the last change. */ public static PollResult createIncremental(Map<String, Object> added, Map<String, Object> changed, Map<String, Object> deleted, Object checkPoint) { return new PollResult(added, changed, deleted, checkPoint); }
/** * Do an initial poll from the source and apply the result to the configuration. * * @param source source of the configuration * @param config Configuration to apply the polling result * @throws RuntimeException if any error occurs in polling the configuration source */ protected synchronized void initialLoad(final PolledConfigurationSource source, final Configuration config) { PollResult result = null; try { result = source.poll(true, null); checkPoint = result.getCheckPoint(); fireEvent(EventType.POLL_SUCCESS, result, null); } catch (Throwable e) { throw new RuntimeException("Unable to load Properties source from " + source, e); } try { populateProperties(result, config); } catch (Throwable e) { throw new RuntimeException("Unable to load Properties", e); } }
@Override public PollResult poll(boolean initial, Object checkPoint) throws Exception { // implement logic to retrieve properties from DB Map<String, Object> map = load(); return PollResult.createFull(map); }
/** * Create a result that represents incremental changes from the configuration * source. * * @param added properties added * @param changed properties changed * @param deleted properties deleted, in which case the value in the map will be ignored * @param checkPoint Object that served as a marker for this incremental change, for example, a time stamp * of the last change. */ public static PollResult createIncremental(Map<String, Object> added, Map<String, Object> changed, Map<String, Object> deleted, Object checkPoint) { return new PollResult(added, changed, deleted, checkPoint); }
/** * Retrieve the content of the property files. For each poll, it always * returns the complete union of properties defined in all URLs. If one * property is defined in content of more than one URL, the value in file later on the * list will override the value in the previous one. * * @param initial this parameter is ignored by the implementation * @param checkPoint this parameter is ignored by the implementation * @throws IOException IOException occurred in file operation */ @Override public PollResult poll(boolean initial, Object checkPoint) throws IOException { if (configUrls == null || configUrls.length == 0) { return PollResult.createFull(null); } Map<String, Object> map = new HashMap<String, Object>(); for (URL url: configUrls) { Properties props = new Properties(); InputStream fin = url.openStream(); props.load(fin); fin.close(); for (Entry<Object, Object> entry: props.entrySet()) { map.put((String) entry.getKey(), entry.getValue()); } } return PollResult.createFull(map); }
/** * Retrieve the content of the property files. For each poll, it always * returns the complete union of properties defined in all URLs. If one * property is defined in content of more than one URL, the value in file later on the * list will override the value in the previous one. * * @param initial this parameter is ignored by the implementation * @param checkPoint this parameter is ignored by the implementation * @throws IOException IOException occurred in file operation */ @Override public PollResult poll(boolean initial, Object checkPoint) throws IOException { if (configUrls == null || configUrls.length == 0) { return PollResult.createFull(null); } Map<String, Object> map = new HashMap<String, Object>(); for (URL url: configUrls) { InputStream fin = url.openStream(); Properties props = ConfigurationUtils.loadPropertiesFromInputStream(fin); for (Entry<Object, Object> entry: props.entrySet()) { map.put((String) entry.getKey(), entry.getValue()); } } return PollResult.createFull(map); }
public PollResult poll(boolean b, Object o) throws Exception { Map<String, Object> configurations = new LinkedHashMap<>(); for (ConfigModel configModel : configModels) { configurations.putAll(YAMLUtil.retrieveItems("", configModel.getConfig())); } return PollResult.createFull(configurations); } }
@Override public PollResult poll(boolean initial, Object checkPoint) throws Exception { String table = tableName.get(); Map<String, Object> map = loadPropertiesFromTable(table); log.info("Successfully polled Dynamo for a new configuration based on table:" + table); return PollResult.createFull(map); } }
/** {@inheritDoc} */ @Override public PollResult poll(boolean check, Object arg1) throws Exception { if (getFf4jStore() == null) { throw new IllegalStateException("PropertyStore should not be null (to poll it !)"); } // Cannot convert to Map < String, Object > Map < String, Object > properties = new HashMap<String, Object>(); for(Map.Entry<String, Property<?>> property : getFf4jStore().readAllProperties().entrySet()) { // All properties are String in commons-configuration properties.put(property.getKey(), property.getValue().asString()); } return PollResult.createFull(properties); }