use of loghub.Expression in project LogHub by fbacchella.
the class Merge method configure.
@Override
public boolean configure(Properties properties) {
if (indexSource == null) {
return false;
}
repository = new EventsRepository<String>(properties);
cumulators = new ConcurrentHashMap<>(seeds.size() + 1);
// Default to timestamp is to keep the first
cumulators.put("@timestamp", Cumulator.FIRST.cumulate(null));
for (Entry<String, Object> i : seeds.entrySet()) {
cumulators.put(i.getKey(), Cumulator.getCumulator(i.getValue()));
}
index = new VarFormatter(indexSource);
// Prepare fire only if test and processor given for that
if (fireSource != null && fireProcessor != null) {
try {
fire = new Expression(fireSource, properties.groovyClassLoader, properties.formatters);
} catch (ExpressionException e) {
Expression.logError(e, fireSource, logger);
return false;
}
if (!fireProcessor.configure(properties)) {
return false;
}
}
if (timeoutProcessor != null && !timeoutProcessor.configure(properties)) {
return false;
}
if (nextPipeline == null) {
return false;
}
return super.configure(properties);
}
use of loghub.Expression in project LogHub by fbacchella.
the class FireEvent method process.
@Override
public boolean process(Event event) throws ProcessorException {
Event newEvent = Event.emptyEvent(ConnectionContext.EMPTY);
for (Map.Entry<String[], Expression> e : expressions.entrySet()) {
Object value = e.getValue().eval(event, Collections.emptyMap());
newEvent.applyAtPath((i, j, k) -> i.put(j, k), e.getKey(), value);
}
return newEvent.inject(pipeDestination, mainQueue);
}
use of loghub.Expression in project LogHub by fbacchella.
the class FireEvent method configure.
@Override
public boolean configure(Properties properties) {
expressions = new HashMap<>(fields.size());
for (Map.Entry<String[], String> i : fields.entrySet()) {
try {
Expression ex = new Expression(i.getValue(), properties.groovyClassLoader, properties.formatters);
expressions.put(i.getKey(), ex);
} catch (ExpressionException e) {
logger.error("invalid expression for field {}: {}", i.getKey(), i.getValue());
return false;
}
}
if (!properties.namedPipeLine.containsKey(destination)) {
logger.error("invalid destination for forked event: {}", destination);
return false;
}
pipeDestination = properties.namedPipeLine.get(destination);
mainQueue = properties.mainQueue;
return super.configure(properties);
}
use of loghub.Expression in project LogHub by fbacchella.
the class Test method configure.
@Override
public boolean configure(Properties properties) {
thenTransformer.configure(properties);
elseTransformer.configure(properties);
try {
ifClause = new Expression(ifClauseSource, properties.groovyClassLoader, properties.formatters);
} catch (ExpressionException e) {
Expression.logError(e, ifClauseSource, logger);
return false;
}
return super.configure(properties);
}
Aggregations