use of loghub.Processor in project LogHub by fbacchella.
the class Test method process.
@Override
public boolean process(Event event) throws ProcessorException {
Boolean testResult = Boolean.TRUE.equals(ifClause.eval(event, Collections.emptyMap()));
Processor nextTransformer = testResult ? thenTransformer : elseTransformer;
event.insertProcessor(nextTransformer);
return testResult;
}
use of loghub.Processor in project LogHub by fbacchella.
the class Configuration method parsePipeline.
private Pipeline parsePipeline(ConfigListener.PipenodesList desc, String currentPipeLineName, int depth, AtomicInteger subPipeCount) throws ConfigException {
List<Processor> allSteps = new ArrayList<Processor>() {
@Override
public String toString() {
StringBuilder buffer = new StringBuilder();
buffer.append("PipeList(");
for (Processor i : this) {
buffer.append(i);
buffer.append(", ");
}
buffer.setLength(buffer.length() - 2);
buffer.append(')');
return buffer.toString();
}
};
desc.processors.stream().map(i -> {
return getProcessor(i, currentPipeLineName, depth, subPipeCount);
}).forEach(allSteps::add);
Pipeline pipe = new Pipeline(allSteps, currentPipeLineName + (depth == 0 ? "" : "$" + subPipeCount.getAndIncrement()), desc.nextPipelineName);
return pipe;
}
use of loghub.Processor in project LogHub by fbacchella.
the class TestFailure method test.
@Test(expected = ProcessorException.class)
public void test() throws ProcessorException {
Processor p = new Processor() {
@Override
public boolean process(Event event) throws ProcessorException {
throw event.buildException("test failure", new RuntimeException("test failure"));
}
@Override
public String getName() {
return null;
}
};
Event event = Tools.getEvent();
event.process(p);
}
use of loghub.Processor in project LogHub by fbacchella.
the class TestToJson method test1.
@Test
public void test1() throws ProcessorException {
Event e = Tools.getEvent();
Processor t = new ParseJson();
e.put("message", "{\"a\": [ 1, 2.0 , 3.01 , {\"b\": true} ] }");
e.process(t);
@SuppressWarnings("unchecked") Collection<Object> a = (Collection<Object>) e.get("a");
a.stream().forEach((i) -> logger.debug(i.getClass()));
logger.debug(e);
}
use of loghub.Processor in project LogHub by fbacchella.
the class FieldsProcessor method delegate.
private void delegate(Set<String> nextfields, Event event) {
final Iterator<String> processing = nextfields.iterator();
Processor fieldProcessor;
if (this instanceof AsyncFieldsProcessor) {
fieldProcessor = new AsyncFieldSubProcessor(processing, ((AsyncFieldsProcessor<?>) this).getTimeout());
} else {
fieldProcessor = new FieldSubProcessor(processing);
}
if (processing.hasNext()) {
event.insertProcessor(fieldProcessor);
}
throw IgnoredEventException.INSTANCE;
}
Aggregations