/** * Retrieves the Parser configuration. * * @param args The function arguments. * @return The Parser configuration. * @throws Exception */ private String getParserConfig(List<Object> args) throws Exception { // retrieve the enrichment config for the given sensor String sensor = getArg(1, String.class, args); SensorParserConfig sensorConfig = readSensorParserConfigFromZookeeper(sensor, zkClient); // provide empty/default config if one is not present? if(sensorConfig == null && emptyIfNotPresent(args)) { sensorConfig = new SensorParserConfig(); } return toJSON(sensorConfig); }
public SensorParserConfig getSensorParserConfig(String sensorType) { SensorParserConfig sensorParserConfig = new SensorParserConfig(); CuratorFramework client = getClient(topologyProperties.getProperty(ZKServerComponent.ZOOKEEPER_PROPERTY)); client.start(); try { sensorParserConfig = readSensorParserConfigFromZookeeper(sensorType, client); } catch (Exception e) { e.printStackTrace(); } finally { client.close(); } return sensorParserConfig; }
private SensorParserConfig readFromZookeeper(Context context, String sensorType) throws ParseException { SensorParserConfig config; try { CuratorFramework zkClient = getZookeeperClient(context); config = readSensorParserConfigFromZookeeper(sensorType, zkClient); } catch(Exception e) { throw new ParseException(ExceptionUtils.getRootCauseMessage(e), e); } if(config == null) { throw new ParseException("Unable to read configuration from Zookeeper; sensorType = " + sensorType); } return config; }