@Override public Map<String, Object> getGlobalConfig() { return config.getGlobalConfig(); }
private List<FieldValidator> getFailedValidators(JSONObject message, ParserConfigurations parserConfigurations) { List<FieldValidator> fieldValidations = parserConfigurations.getFieldValidations(); List<FieldValidator> failedValidators = new ArrayList<>(); for(FieldValidator validator : fieldValidations) { if(!validator.isValid(message, parserConfigurations.getGlobalConfig(), stellarContext)) { failedValidators.add(validator); } } return failedValidators; } }
protected Context initializeStellar() { Map<String, Object> cacheConfig = new HashMap<>(); for (String sensorType: this.parserRunner.getSensorTypes()) { SensorParserConfig config = getSensorParserConfig(sensorType); if (config != null) { cacheConfig.putAll(config.getCacheConfig()); } } Cache<CachingStellarProcessor.Key, Object> cache = CachingStellarProcessor.createCache(cacheConfig); Context.Builder builder = new Context.Builder() .with(Context.Capabilities.ZOOKEEPER_CLIENT, () -> client) .with(Context.Capabilities.GLOBAL_CONFIG, () -> getConfigurations().getGlobalConfig()) .with(Context.Capabilities.STELLAR_CONFIG, () -> getConfigurations().getGlobalConfig()) ; if(cache != null) { builder = builder.with(Context.Capabilities.CACHE, () -> cache); } Context stellarContext = builder.build(); StellarFunctions.initialize(stellarContext); return stellarContext; }
errorTopic = (String) configs.getGlobalConfig().get(Constants.PARSER_ERROR_TOPIC_GLOBALS_KEY);
Map<String, Object> sampleGlobalConfig = sampleConfigurations.getGlobalConfig(); sampleGlobalConfig.put("newGlobalField", "newGlobalValue"); ConfigurationsUtils.writeGlobalConfigToZookeeper(sampleGlobalConfig, zookeeperUrl); waitForConfigUpdate(ConfigurationType.GLOBAL.getTypeName()); Assert.assertEquals("Add global config field", sampleConfigurations.getGlobalConfig(), configuredBolt.getConfigurations().getGlobalConfig());
ParserConfigurations config = cache.get( ParserConfigurations.class); assertEventually(() -> Assert.assertEquals(expectedConfig, config.getSensorParserConfig("bro"))); assertEventually(() -> Assert.assertEquals(expectedGlobalConfig, config.getGlobalConfig())); assertEventually(() -> Assert.assertNull(config.getSensorParserConfig("notthere")));
assertEventually(() -> Assert.assertNull(config.getGlobalConfig(false)));