Search in sources :

Example 21 with Pipeline

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"));
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Pipeline(loghub.Pipeline) Test(org.junit.Test)

Example 22 with Pipeline

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());
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Map(java.util.Map) Pipeline(loghub.Pipeline) Test(org.junit.Test)

Example 23 with Pipeline

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;
}
Also used : Processor(loghub.Processor) NamedSubPipeline(loghub.processors.NamedSubPipeline) AnonymousSubPipeline(loghub.processors.AnonymousSubPipeline) Pipeline(loghub.Pipeline) NamedSubPipeline(loghub.processors.NamedSubPipeline) AnonymousSubPipeline(loghub.processors.AnonymousSubPipeline)

Aggregations

Pipeline (loghub.Pipeline)23 Event (loghub.Event)21 Properties (loghub.configuration.Properties)20 Test (org.junit.Test)17 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)8 HashMap (java.util.HashMap)6 IOException (java.io.IOException)4 Map (java.util.Map)4 File (java.io.File)2 InputStream (java.io.InputStream)2 Reader (java.io.Reader)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 MalformedURLException (java.net.MalformedURLException)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 URL (java.net.URL)2 URLClassLoader (java.net.URLClassLoader)2 Files (java.nio.file.Files)2 Path (java.nio.file.Path)2 Paths (java.nio.file.Paths)2