use of com.hortonworks.streamline.streams.StreamlineEvent in project streamline by hortonworks.
the class RuleProcessorRuntime method process.
@Override
public List<Result> process(StreamlineEvent event) throws ProcessingException {
List<Result> results = new ArrayList<>();
try {
List<RuleRuntime> ruleRuntimes = getRulesRuntime(event);
LOG.debug("Process event {}, rule runtimes {}", event, ruleRuntimes);
for (RuleRuntime rr : ruleRuntimes) {
boolean succeeded = false;
for (StreamlineEvent result : rr.evaluate(event)) {
if (result != null) {
results.addAll(rr.process(result));
succeeded = true;
}
}
if (!processAll && succeeded)
break;
}
} catch (Exception e) {
String message = String.format("Error evaluating rule processor with id: %s, error: %s", rulesProcessor.getId(), e.getMessage());
LOG.error(message, e);
throw new ProcessingException(message, e);
}
return results;
}
use of com.hortonworks.streamline.streams.StreamlineEvent in project streamline by hortonworks.
the class RulesBolt method process.
@Override
protected void process(Tuple input, StreamlineEvent event) {
// Input tuple is expected to be an StreamlineEvent
StreamlineEvent eventWithStream = getStreamlineEventWithStream(event, input);
LOG.debug("++++++++ Executing tuple [{}], StreamlineEvent [{}]", input, eventWithStream);
try {
for (Result result : ruleProcessorRuntime.process(eventWithStream)) {
for (StreamlineEvent e : result.events) {
collector.emit(result.stream, input, new Values(e));
}
}
} catch (ProcessingException e) {
throw new RuntimeException(e);
}
}
use of com.hortonworks.streamline.streams.StreamlineEvent in project streamline by hortonworks.
the class EventCorrelatingSpoutOutputCollector method emitDirect.
@Override
public void emitDirect(int taskId, String streamId, List<Object> tuple, Object messageId) {
StreamlineEvent newEvent = injectCorrelationInformation(tuple);
delegate.emitDirect(taskId, streamId, new Values(newEvent), messageId);
}
use of com.hortonworks.streamline.streams.StreamlineEvent in project streamline by hortonworks.
the class EventCorrelatingSpoutOutputCollector method emitDirect.
@Override
public void emitDirect(int taskId, String streamId, List<Object> tuple) {
StreamlineEvent newEvent = injectCorrelationInformation(tuple);
delegate.emitDirect(taskId, streamId, new Values(newEvent));
}
use of com.hortonworks.streamline.streams.StreamlineEvent in project streamline by hortonworks.
the class FieldsGroupingAsCustomGrouping method chooseTasks.
@Override
public List<Integer> chooseTasks(int taskId, List<Object> values) {
List<Integer> result = new ArrayList<>();
StreamlineEvent streamlineEvent = (StreamlineEvent) values.get(0);
List<Object> groupByObjects = new ArrayList<>(groupingFields.size());
for (String groupingField : groupingFields) {
groupByObjects.add(StreamlineRuntimeUtil.getFieldValue(streamlineEvent, groupingField));
}
int taskIndex = (Arrays.deepHashCode(groupByObjects.toArray()) & 0x7FFFFFFF) % targetTasks.size();
result.add(targetTasks.get(taskIndex));
return result;
}
Aggregations