use of org.apache.metron.stellar.common.StellarProcessor in project metron by apache.
the class HdfsWriter method init.
@Override
public void init(Map stormConfig, TopologyContext topologyContext, WriterConfiguration configurations) {
this.stormConfig = stormConfig;
this.stellarProcessor = new StellarProcessor();
this.fileNameFormat.prepare(stormConfig, topologyContext);
if (syncPolicy != null) {
// if the user has specified the sync policy, we don't want to override their wishes.
syncPolicyCreator = new ClonedSyncPolicyCreator(syncPolicy);
} else {
// if the user has not, then we want to have the sync policy depend on the batch size.
syncPolicyCreator = (source, config) -> new CountSyncPolicy(config == null ? 1 : config.getBatchSize(source));
}
}
use of org.apache.metron.stellar.common.StellarProcessor in project metron by apache.
the class StellarServiceImpl method validateRules.
@Override
public Map<String, Boolean> validateRules(List<String> rules) {
Map<String, Boolean> results = new HashMap<>();
StellarProcessor stellarProcessor = new StellarProcessor();
for (String rule : rules) {
try {
boolean result = stellarProcessor.validate(rule, Context.EMPTY_CONTEXT());
results.put(rule, result);
} catch (ParseException e) {
results.put(rule, false);
}
}
return results;
}
use of org.apache.metron.stellar.common.StellarProcessor in project metron by apache.
the class GeoEnrichmentFunctionsTest method run.
public Object run(String rule, Map<String, Object> variables) {
StellarProcessor processor = new StellarProcessor();
assertTrue(processor.validate(rule, context), rule + " not valid.");
return processor.parse(rule, new DefaultVariableResolver(x -> variables.get(x), x -> variables.containsKey(x)), StellarFunctions.FUNCTION_RESOLVER(), context);
}
use of org.apache.metron.stellar.common.StellarProcessor in project metron by apache.
the class SimpleHBaseEnrichmentFunctionsTest method run.
public Object run(String rule, Map<String, Object> variables) throws Exception {
StellarProcessor processor = new StellarProcessor();
assertTrue(processor.validate(rule, context), rule + " not valid.");
return processor.parse(rule, new DefaultVariableResolver(x -> variables.get(x), x -> variables.containsKey(x)), StellarFunctions.FUNCTION_RESOLVER(), context);
}
use of org.apache.metron.stellar.common.StellarProcessor in project metron by apache.
the class KafkaFunctionsIntegrationTest method run.
/**
* Runs a Stellar expression.
* @param expression The expression to run.
*/
private Object run(String expression) {
// make the global properties available to the function
Context context = new Context.Builder().with(Context.Capabilities.GLOBAL_CONFIG, () -> global).build();
// execute the expression
StellarProcessor processor = new StellarProcessor();
return processor.parse(expression, new DefaultVariableResolver(x -> variables.get(x), x -> variables.containsKey(x)), functionResolver, context);
}
Aggregations