use of loghub.Pipeline in project LogHub by fbacchella.
the class TestMapper method test3.
@Test
public void test3() throws ProcessorException, InterruptedException, ConfigException, IOException {
Properties conf = Tools.loadConf("map.conf");
for (Pipeline pipe : conf.pipelines) {
Assert.assertTrue("configuration failed", pipe.configure(conf));
}
Event sent = Tools.getEvent();
sent.put("a", 3);
Tools.runProcessing(sent, conf.namedPipeLine.get("mapper2"), conf);
Assert.assertEquals("conversion not expected", 3, sent.get("a"));
}
use of loghub.Pipeline in project LogHub by fbacchella.
the class TestScanBinary method testConfigFile.
@Test
public void testConfigFile() throws ProcessorException, InterruptedException, ConfigException, IOException {
Properties conf = Tools.loadConf("scanbinary.conf");
for (Pipeline pipe : conf.pipelines) {
Assert.assertTrue("configuration failed", pipe.configure(conf));
}
Event sent = Tools.getEvent();
sent.put("binary", 0b110101);
Tools.runProcessing(sent, conf.namedPipeLine.get("main"), conf);
@SuppressWarnings("unchecked") Map<String, Number> value = (Map<String, Number>) sent.get("binary");
Assert.assertEquals(0b101, value.get("a").intValue());
Assert.assertEquals(0b10, value.get("b").intValue());
Assert.assertEquals(0b1, value.get("c").intValue());
}
use of loghub.Pipeline in project LogHub by fbacchella.
the class Configuration method getProcessor.
private Processor getProcessor(ConfigListener.Pipenode i, String currentPipeLineName, int depth, AtomicInteger subPipeLine) throws ConfigException {
Processor t;
if (i instanceof ConfigListener.PipeRef) {
ConfigListener.PipeRef cpr = (ConfigListener.PipeRef) i;
NamedSubPipeline pr = new NamedSubPipeline();
pr.setPipeRef(cpr.pipename);
t = pr;
} else if (i instanceof ConfigListener.PipenodesList) {
subPipeLine.incrementAndGet();
AnonymousSubPipeline subpipe = new AnonymousSubPipeline();
Pipeline p = parsePipeline((ConfigListener.PipenodesList) i, currentPipeLineName, depth + 1, subPipeLine);
subpipe.setPipeline(p);
t = subpipe;
} else if (i instanceof ConfigListener.ProcessorInstance) {
ConfigListener.ProcessorInstance ti = (ConfigListener.ProcessorInstance) i;
t = (Processor) parseObjectDescription(ti, emptyConstructor, currentPipeLineName, depth, subPipeLine);
} else {
throw new RuntimeException("Unreachable code for " + i);
}
return t;
}
Aggregations