public static String getKey(String sensorType) { return ConfigurationType.INDEXING.getTypeName() + "." + sensorType; }
public static String getKey(String sensorType) { return ConfigurationType.PARSER.getTypeName() + "." + sensorType; } }
public static String getKey(String sensorType) { return ConfigurationType.ENRICHMENT.getTypeName() + "." + sensorType; }
public static String getKey() { return ConfigurationType.PROFILER.getTypeName(); }
public static byte[] readGlobalConfigFromFile(String rootPath) throws IOException { byte[] globalConfig = new byte[0]; File configPath = new File(rootPath, GLOBAL.getTypeName() + ".json"); if (configPath.exists()) { globalConfig = Files.readAllBytes(configPath.toPath()); } return globalConfig; }
/** * Read the Profiler configuration from a file. There is only a single profiler configuration. * @param rootPath Path to the Profiler configuration. */ public static byte[] readProfilerConfigFromFile(String rootPath) throws IOException { byte[] config = new byte[0]; File configPath = new File(rootPath, PROFILER.getTypeName() + ".json"); if (configPath.exists()) { config = Files.readAllBytes(configPath.toPath()); } return config; }
public List<String> getTypes() { List<String> ret = new ArrayList<>(); for(String keyedSensor : getConfigurations().keySet()) { if(!keyedSensor.isEmpty() && keyedSensor.startsWith(ConfigurationType.INDEXING.getTypeName())) { ret.add(keyedSensor.substring(ConfigurationType.INDEXING.getTypeName().length() + 1)); } } return ret; }
public List<String> getTypes() { List<String> ret = new ArrayList<>(); for(String keyedSensor : getConfigurations().keySet()) { if(!keyedSensor.isEmpty() && keyedSensor.startsWith(ConfigurationType.PARSER.getTypeName())) { ret.add(keyedSensor.substring(ConfigurationType.PARSER.getTypeName().length() + 1)); } } return ret; }
public List<String> getTypes() { List<String> ret = new ArrayList<>(); for(String keyedSensor : getConfigurations().keySet()) { if(!keyedSensor.isEmpty() && keyedSensor.startsWith(ConfigurationType.ENRICHMENT.getTypeName())) { ret.add(keyedSensor.substring(ConfigurationType.ENRICHMENT.getTypeName().length() + 1)); } } return ret; }
public void deleteGlobalConfig() { getConfigurations().remove(ConfigurationType.GLOBAL.getTypeName()); }
public Map<String, Object> getGlobalConfig(boolean emptyMapOnNonExistent) { return (Map<String, Object>) getConfigurations().getOrDefault(ConfigurationType.GLOBAL.getTypeName(), emptyMapOnNonExistent?new HashMap():null); }
public void updateGlobalConfig(Map<String, Object> globalConfig) { if(globalConfig != null) { getConfigurations().put(ConfigurationType.GLOBAL.getTypeName(), globalConfig); validations = FieldValidator.readValidations(getGlobalConfig()); } }
@Before public void setupConfiguration() throws Exception { TestingServer testZkServer = new TestingServer(true); this.zookeeperUrl = testZkServer.getConnectString(); byte[] globalConfig = ConfigurationsUtils.readGlobalConfigFromFile(TestConstants.SAMPLE_CONFIG_PATH); ConfigurationsUtils.writeGlobalConfigToZookeeper(globalConfig, zookeeperUrl); parserConfigurationTypes.add(ConfigurationType.GLOBAL.getTypeName()); Map<String, byte[]> sensorEnrichmentConfigs = ConfigurationsUtils.readSensorEnrichmentConfigsFromFile(TestConstants.ENRICHMENTS_CONFIGS_PATH); for (String sensorType : sensorEnrichmentConfigs.keySet()) { ConfigurationsUtils.writeSensorEnrichmentConfigToZookeeper(sensorType, sensorEnrichmentConfigs.get(sensorType), zookeeperUrl); } Map<String, byte[]> sensorParserConfigs = ConfigurationsUtils.readSensorParserConfigsFromFile(TestConstants.PARSER_CONFIGS_PATH); for (String sensorType : sensorParserConfigs.keySet()) { ConfigurationsUtils.writeSensorParserConfigToZookeeper(sensorType, sensorParserConfigs.get(sensorType), zookeeperUrl); parserConfigurationTypes.add(sensorType); } }
@Before public void setupConfiguration() throws Exception { TestingServer testZkServer = new TestingServer(true); this.zookeeperUrl = testZkServer.getConnectString(); byte[] globalConfig = ConfigurationsUtils.readGlobalConfigFromFile(TestConstants.SAMPLE_CONFIG_PATH); ConfigurationsUtils.writeGlobalConfigToZookeeper(globalConfig, zookeeperUrl); enrichmentConfigurationTypes.add(ConfigurationType.GLOBAL.getTypeName()); Map<String, byte[]> sensorEnrichmentConfigs = ConfigurationsUtils.readSensorEnrichmentConfigsFromFile(TestConstants.ENRICHMENTS_CONFIGS_PATH); for (String sensorType : sensorEnrichmentConfigs.keySet()) { ConfigurationsUtils.writeSensorEnrichmentConfigToZookeeper(sensorType, sensorEnrichmentConfigs.get(sensorType), zookeeperUrl); enrichmentConfigurationTypes.add(sensorType); } Map<String, byte[]> sensorParserConfigs = ConfigurationsUtils.readSensorParserConfigsFromFile(TestConstants.PARSER_CONFIGS_PATH); for (String sensorType : sensorParserConfigs.keySet()) { ConfigurationsUtils.writeSensorParserConfigToZookeeper(sensorType, sensorParserConfigs.get(sensorType), zookeeperUrl); } }
sampleGlobalConfig.put("newGlobalField", "newGlobalValue"); ConfigurationsUtils.writeGlobalConfigToZookeeper(sampleGlobalConfig, zookeeperUrl); waitForConfigUpdate(ConfigurationType.GLOBAL.getTypeName()); Assert.assertEquals("Add global config field", sampleConfigurations.getGlobalConfig(), configuredBolt.getConfigurations().getGlobalConfig()); sampleGlobalConfig.remove("newGlobalField"); ConfigurationsUtils.writeGlobalConfigToZookeeper(sampleGlobalConfig, zookeeperUrl); waitForConfigUpdate(ConfigurationType.GLOBAL.getTypeName()); Assert.assertEquals("Remove global config field", sampleConfigurations, configuredBolt.getConfigurations());
sampleGlobalConfig.put("newGlobalField", "newGlobalValue"); ConfigurationsUtils.writeGlobalConfigToZookeeper(sampleGlobalConfig, zookeeperUrl); waitForConfigUpdate(ConfigurationType.GLOBAL.getTypeName()); Assert.assertEquals("Add global config field", sampleConfigurations.getGlobalConfig(), configuredBolt.getConfigurations().getGlobalConfig()); sampleGlobalConfig.remove("newGlobalField"); ConfigurationsUtils.writeGlobalConfigToZookeeper(sampleGlobalConfig, zookeeperUrl); waitForConfigUpdate(ConfigurationType.GLOBAL.getTypeName()); Assert.assertEquals("Remove global config field", sampleConfigurations, configuredBolt.getConfigurations());