private static String getConfigZKPath(ConfigurationType configType, Optional<String> configName) { String pathSuffix = configName.isPresent() && configType != GLOBAL ? "/" + configName.get() : ""; return configType.getZookeeperRoot() + pathSuffix; }
public static byte[] readSensorEnrichmentConfigBytesFromZookeeper(String sensorType, CuratorFramework client) throws Exception { return readFromZookeeper(ENRICHMENT.getZookeeperRoot() + "/" + sensorType, client); }
public static byte[] readGlobalConfigBytesFromZookeeper(CuratorFramework client) throws Exception { return readFromZookeeper(GLOBAL.getZookeeperRoot(), client); }
private ProfilerConfig readFromZookeeper(CuratorFramework client) throws Exception { byte[] raw = client.getData().forPath(PROFILER.getZookeeperRoot()); return JSONUtils.INSTANCE.load(new ByteArrayInputStream(raw), ProfilerConfig.class); }
public static byte[] readSensorIndexingConfigBytesFromZookeeper(String sensorType, CuratorFramework client) throws Exception { return readFromZookeeper(INDEXING.getZookeeperRoot() + "/" + sensorType, client); }
public static byte[] readProfilerConfigBytesFromZookeeper(CuratorFramework client) throws Exception { return readFromZookeeper(PROFILER.getZookeeperRoot(), client); }
public static byte[] readSensorParserConfigBytesFromZookeeper(String sensorType, CuratorFramework client) throws Exception { return readFromZookeeper(PARSER.getZookeeperRoot() + "/" + sensorType, client); }
@Override public boolean delete() throws RestException { try { client.delete().forPath(ConfigurationType.GLOBAL.getZookeeperRoot()); } catch (KeeperException.NoNodeException e) { return false; } catch (Exception e) { throw new RestException(e); } return true; } }
@Override public boolean delete(String name) throws RestException { try { client.delete().forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/" + name); } catch (KeeperException.NoNodeException e) { return false; } catch (Exception e) { throw new RestException(e); } return true; }
@Override public boolean delete(String name) throws RestException { try { client.delete().forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot() + "/" + name); } catch (KeeperException.NoNodeException e) { return false; } catch (Exception e) { throw new RestException(e); } return true; }
@Override public boolean delete(String name) throws RestException { try { client.delete().forPath(ConfigurationType.INDEXING.getZookeeperRoot() + "/" + name); } catch (KeeperException.NoNodeException e) { return false; } catch (Exception e) { throw new RestException(e); } return true; }
public static void writeProfilerConfigToZookeeper(byte[] config, CuratorFramework client) throws Exception { PROFILER.deserialize(new String(config)); writeToZookeeper(PROFILER.getZookeeperRoot(), config, client); }
public static void writeGlobalConfigToZookeeper(byte[] globalConfig, CuratorFramework client) throws Exception { GLOBAL.deserialize(new String(globalConfig)); writeToZookeeper(GLOBAL.getZookeeperRoot(), globalConfig, client); }
/** * Reads the Profiler configuration from Zookeeper. * * @param client The Zookeeper client. * @return THe Profiler configuration. * @throws Exception */ public static ProfilerConfig readProfilerConfigFromZookeeper(CuratorFramework client) throws Exception { ProfilerConfig config = null; Optional<byte[]> bytes = readFromZookeeperSafely(PROFILER.getZookeeperRoot(), client); if(bytes.isPresent()) { config = ProfilerConfig.fromBytes(bytes.get()); } return config; }
/** * Reads the global configuration stored in Zookeeper. * * @param client The Zookeeper client. * @return The global configuration, if one exists. Otherwise, null. * @throws Exception */ public static Map<String, Object> readGlobalConfigFromZookeeper(CuratorFramework client) throws Exception { Map<String, Object> config = null; Optional<byte[]> bytes = readFromZookeeperSafely(GLOBAL.getZookeeperRoot(), client); if(bytes.isPresent()) { InputStream in = new ByteArrayInputStream(bytes.get()); config = JSONUtils.INSTANCE.load(in, JSONUtils.MAP_SUPPLIER); } return config; }
public static void writeSensorEnrichmentConfigToZookeeper(String sensorType, byte[] configData, CuratorFramework client) throws Exception { ENRICHMENT.deserialize(new String(configData)); writeToZookeeper(ENRICHMENT.getZookeeperRoot() + "/" + sensorType, configData, client); }
/** * Reads the Indexing configuration from Zookeeper. * * @param sensorType The type of sensor. * @param client The Zookeeper client. * @return The indexing configuration for the given sensor type, if one exists. Otherwise, null. * @throws Exception */ public static Map<String, Object> readSensorIndexingConfigFromZookeeper(String sensorType, CuratorFramework client) throws Exception { Map<String, Object> config = null; Optional<byte[]> bytes = readFromZookeeperSafely(INDEXING.getZookeeperRoot() + "/" + sensorType, client); if(bytes.isPresent()) { InputStream in = new ByteArrayInputStream(bytes.get()); config = JSONUtils.INSTANCE.load(in, JSONUtils.MAP_SUPPLIER); } return config; }
public static void writeSensorIndexingConfigToZookeeper(String sensorType, byte[] configData, CuratorFramework client) throws Exception { INDEXING.deserialize(new String(configData)); writeToZookeeper(INDEXING.getZookeeperRoot() + "/" + sensorType, configData, client); }
/** * Reads the Parser configuration from Zookeeper. * * @param sensorType The type of sensor. * @param client The Zookeeper client. * @return The Parser configuration for the given sensor type, if one exists. Otherwise, null. * @throws Exception */ public static SensorParserConfig readSensorParserConfigFromZookeeper(String sensorType, CuratorFramework client) throws Exception { SensorParserConfig config = null; Optional<byte[]> bytes = readFromZookeeperSafely(PARSER.getZookeeperRoot() + "/" + sensorType, client); if(bytes.isPresent()) { config = SensorParserConfig.fromBytes(bytes.get()); } return config; }
public static void writeSensorParserConfigToZookeeper(String sensorType, byte[] configData, CuratorFramework client) throws Exception { SensorParserConfig c = (SensorParserConfig) PARSER.deserialize(new String(configData)); c.init(); writeToZookeeper(PARSER.getZookeeperRoot() + "/" + sensorType, configData, client); }