@Override public void writeSensorConfigToZookeeper(String sensorType, byte[] configData, CuratorFramework client) throws Exception { ConfigurationsUtils.writeSensorParserConfigToZookeeper(sensorType, configData, client); }
@Override public SensorParserConfig save(String name, SensorParserConfig sensorParserConfig) throws RestException { try { ConfigurationsUtils.writeSensorParserConfigToZookeeper(name, objectMapper.writeValueAsString(sensorParserConfig).getBytes(), client); } catch (Exception e) { throw new RestException(e); } return sensorParserConfig; }
public static void writeSensorParserConfigToZookeeper(String sensorType, byte[] configData, String zookeeperUrl) throws Exception { try(CuratorFramework client = getClient(zookeeperUrl)) { client.start(); writeSensorParserConfigToZookeeper(sensorType, configData, client); } }
public static void writeSensorParserConfigToZookeeper(String sensorType, SensorParserConfig sensorParserConfig, String zookeeperUrl) throws Exception { writeSensorParserConfigToZookeeper(sensorType, JSONUtils.INSTANCE.toJSONPretty(sensorParserConfig), zookeeperUrl); }
writeSensorParserConfigToZookeeper(sensor, value.getBytes(), client);
Map<String, byte[]> sensorParserConfigs = readSensorParserConfigsFromFile(parsersConfigPath); for (String sensorType : sensorParserConfigs.keySet()) { ConfigurationsUtils.writeSensorParserConfigToZookeeper(sensorType, sensorParserConfigs.get(sensorType), client);
public void update() throws UnableToStartException { try { final String zookeeperUrl = connectionString == null?topologyProperties.getProperty(ZKServerComponent.ZOOKEEPER_PROPERTY):connectionString; if(globalConfigPath != null || parserConfigsPath != null || enrichmentConfigsPath != null || indexingConfigsPath != null || profilerConfigPath != null ) { uploadConfigsToZookeeper(globalConfigPath, parserConfigsPath, enrichmentConfigsPath, indexingConfigsPath, profilerConfigPath, zookeeperUrl); } for(Map.Entry<String, SensorParserConfig> kv : parserSensorConfigs.entrySet()) { writeSensorParserConfigToZookeeper(kv.getKey(), kv.getValue(), zookeeperUrl); } if(globalConfig.isPresent()) { writeGlobalConfigToZookeeper(globalConfig.get().getBytes(), zookeeperUrl); } if(postStartCallback.isPresent()) { postStartCallback.get().accept(this); } } catch (Exception e) { throw new UnableToStartException(e.getMessage(), e); } }
@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); } }
ConfigurationsUtils.writeSensorParserConfigToZookeeper("bro", config, client);
@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); } }
@Test public void test() throws Exception { Assert.assertTrue(expectedGlobalConfig.length > 0); ConfigurationsUtils.writeGlobalConfigToZookeeper(expectedGlobalConfig, zookeeperUrl); byte[] actualGlobalConfigBytes = ConfigurationsUtils.readGlobalConfigBytesFromZookeeper(client); Assert.assertTrue(Arrays.equals(expectedGlobalConfig, actualGlobalConfigBytes)); Assert.assertTrue(expectedSensorParserConfigMap.size() > 0); String testSensorType = "yaf"; byte[] expectedSensorParserConfigBytes = expectedSensorParserConfigMap.get(testSensorType); ConfigurationsUtils.writeSensorParserConfigToZookeeper(testSensorType, expectedSensorParserConfigBytes, zookeeperUrl); byte[] actualSensorParserConfigBytes = ConfigurationsUtils.readSensorParserConfigBytesFromZookeeper(testSensorType, client); Assert.assertTrue(Arrays.equals(expectedSensorParserConfigBytes, actualSensorParserConfigBytes)); Assert.assertTrue(expectedSensorEnrichmentConfigMap.size() > 0); byte[] expectedSensorEnrichmentConfigBytes = expectedSensorEnrichmentConfigMap.get(testSensorType); ConfigurationsUtils.writeSensorEnrichmentConfigToZookeeper(testSensorType, expectedSensorEnrichmentConfigBytes, zookeeperUrl); byte[] actualSensorEnrichmentConfigBytes = ConfigurationsUtils.readSensorEnrichmentConfigBytesFromZookeeper(testSensorType, client); Assert.assertTrue(Arrays.equals(expectedSensorEnrichmentConfigBytes, actualSensorEnrichmentConfigBytes)); String name = "testConfig"; Map<String, Object> testConfig = new HashMap<>(); testConfig.put("stringField", "value"); testConfig.put("intField", 1); testConfig.put("doubleField", 1.1); ConfigurationsUtils.writeConfigToZookeeper(name, testConfig, zookeeperUrl); byte[] readConfigBytes = ConfigurationsUtils.readConfigBytesFromZookeeper(name, client); Assert.assertTrue(Arrays.equals(JSONUtils.INSTANCE.toJSONPretty(testConfig), readConfigBytes)); }
}}); sampleConfigurations.updateSensorParserConfig(sensorType, testSensorConfig); ConfigurationsUtils.writeSensorParserConfigToZookeeper(sensorType, testSensorConfig, zookeeperUrl); waitForConfigUpdate(sensorType); ParserConfigurations configuredBoltConfigs = configuredBolt.getConfigurations();
ConfigurationsUtils.writeGlobalConfigToZookeeper(globalConfig.getBytes(), client); ConfigurationsUtils.writeSensorEnrichmentConfigToZookeeper("test", testEnrichmentConfig.getBytes(), client); ConfigurationsUtils.writeSensorParserConfigToZookeeper("bro", testParserConfig.getBytes(), client); ConfigurationsUtils.writeProfilerConfigToZookeeper( profilerConfig.getBytes(), client);