use of loghub.EventsProcessor in project LogHub by fbacchella.
the class Tools method runProcessing.
public static void runProcessing(Event sent, Pipeline pipe, Properties props) throws ProcessorException {
EventsProcessor ep = new EventsProcessor(props.mainQueue, props.outputQueues, props.namedPipeLine, props.maxSteps, props.repository);
sent.inject(pipe, props.mainQueue);
Processor processor;
while ((processor = sent.next()) != null) {
ep.process(sent, processor);
}
}
use of loghub.EventsProcessor in project LogHub by fbacchella.
the class TestConfigurations method testTwoPipe.
@Test
public void testTwoPipe() throws InterruptedException, ConfigException, IOException {
Properties conf = Tools.loadConf("twopipe.conf");
Thread t = new EventsProcessor(conf.mainQueue, conf.outputQueues, conf.namedPipeLine, conf.maxSteps, conf.repository);
t.setDaemon(true);
t.start();
Event sent = Tools.getEvent();
sent.put("message", "1");
sent.inject(conf.namedPipeLine.get("pipeone"), conf.mainQueue);
try {
Event re = conf.outputQueues.get("main").poll(1, TimeUnit.SECONDS);
Assert.assertEquals("wrong event received", "1", re.get("message"));
} finally {
logger.debug("{} is at main pipeline {}", sent, sent.getCurrentPipeline());
t.interrupt();
}
}
use of loghub.EventsProcessor in project LogHub by fbacchella.
the class TestEventProcessing method check.
public static void check(String pipeLineTest, String configFile) {
try {
Properties props = Configuration.parse(configFile);
TestEventProcessing.setAppender();
props.pipelines.stream().forEach(i -> i.configure(props));
Thread t = new EventsProcessor(props.mainQueue, props.outputQueues, props.namedPipeLine, props.maxSteps, props.repository);
t.setName("ProcessingThread");
t.setDaemon(true);
t.start();
ObjectMapper mapper = new ObjectMapper(factory);
ObjectReader reader = mapper.reader().forType(Map.class);
MappingIterator<Map<String, Object>> i = reader.readValues(new InputStreamReader(System.in, "UTF-8"));
while (i.hasNext()) {
Map<String, Object> eventMap = i.next();
Date eventDate = null;
if (eventMap.containsKey(Event.TIMESTAMPKEY) && eventMap.get(Event.TIMESTAMPKEY) instanceof String) {
TemporalAccessor ta = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:m:ss.SSSxx").parse((CharSequence) eventMap.remove(Event.TIMESTAMPKEY));
OffsetDateTime now;
// Try to resolve the time zone first
ZoneId zi = ta.query(TemporalQueries.zone());
ZoneOffset zo = ta.query(TemporalQueries.offset());
if (zo != null) {
now = OffsetDateTime.now(zo);
} else if (zi != null) {
now = OffsetDateTime.now(zi);
} else {
now = OffsetDateTime.now(ZoneId.systemDefault());
}
eventDate = Date.from(now.toInstant());
}
Event ev = Event.emptyTestEvent(ConnectionContext.EMPTY);
ev.putAll(eventMap);
if (eventDate != null) {
ev.setTimestamp(eventDate);
}
ev.inject(props.namedPipeLine.get(pipeLineTest), props.mainQueue);
}
Thread.currentThread().join();
// Thread.sleep(Long.MAX_VALUE);
} catch (IOException e) {
e.printStackTrace();
} catch (ConfigException e) {
System.out.format("Error in %s: %s\n", e.getLocation(), e.getMessage());
System.exit(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Aggregations