public SensorParserConfig getSensorParserConfig() { if (sensorParserConfig == null) { return new SensorParserConfig(); } return sensorParserConfig; }
/** * 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; }
@Override public ParserConfigurations getConfigurations() { ParserConfigurations configurations = new ParserConfigurations(); SensorParserConfig sensorParserConfig = new SensorParserConfig(); sensorParserConfig.setParserConfig(new HashMap<String, Object>() {{ put(IndexingConfigurations.BATCH_SIZE_CONF, 10); }}); configurations.updateSensorParserConfig("yaf", sensorParserConfig); return configurations; } };
parserConfigurations.updateSensorParserConfig("yaf", new SensorParserConfig()); doThrow(new IllegalStateException("parserRunner.execute failed")).when(parserRunner).execute(eq("yaf"), any(), eq(parserConfigurations));
MockParserRunner mockParserRunner = new MockParserRunner(new HashSet<String>() {{ add("yaf"); }}); ParserConfigurations parserConfigurations = new ParserConfigurations(); parserConfigurations.updateSensorParserConfig("yaf", new SensorParserConfig()); doThrow(new IllegalStateException("write failed")).when(writerHandler).write(any(), any(), any(), any(), any());
MockParserRunner mockParserRunner = new MockParserRunner(new HashSet<String>() {{ add("yaf"); }}); ParserConfigurations parserConfigurations = new ParserConfigurations(); parserConfigurations.updateSensorParserConfig("yaf", new SensorParserConfig());
mockParserRunner.setInvalid(true); ParserConfigurations parserConfigurations = new ParserConfigurations(); parserConfigurations.updateSensorParserConfig("yaf", new SensorParserConfig());
SensorParserConfig testSensorConfig = new SensorParserConfig(); testSensorConfig.setParserClassName("className"); testSensorConfig.setSensorTopic("sensorTopic");