use of com.hortonworks.streamline.streams.Result in project streamline by hortonworks.
the class NormalizationProcessorRuntime method process.
/*
* todo: It should receive input Stream also and generate output Stream along with StreamlineEvent. This support should
* come from processor framework, will add later.
*/
@Override
public List<Result> process(StreamlineEvent event) throws ProcessingException {
String currentStreamId = event.getSourceStream() != null ? event.getSourceStream() : NormalizationProcessor.DEFAULT_STREAM_ID;
NormalizationRuntime normalizationRuntime = schemasWithNormalizationRuntime.get(currentStreamId);
LOG.debug("Normalization runtime for this stream [{}]", normalizationRuntime);
StreamlineEvent outputEvent = event;
if (normalizationRuntime != null) {
try {
outputEvent = normalizationRuntime.execute(event);
schemaValidator.validate(outputEvent);
} catch (NormalizationException e) {
throw new RuntimeException(e);
}
} else {
LOG.debug("No normalization defined for stream: [{}]", currentStreamId);
}
// which does not have normalization configuration.
return Collections.singletonList(new Result(NormalizationProcessor.DEFAULT_STREAM_ID, Collections.singletonList(outputEvent)));
}
use of com.hortonworks.streamline.streams.Result in project streamline by hortonworks.
the class RuleRuntime method process.
/**
* Executes a {@link Rule}'s Action
*
* @param event runtime input to this rule
*/
@Override
public List<Result> process(StreamlineEvent event) throws ProcessingException {
LOG.debug("process invoked with StreamlineEvent {}", event);
List<Result> allResults = new ArrayList<>();
try {
for (ActionRuntime action : actions) {
List<Result> actionResults = action.execute(event);
LOG.debug("Applied action {}, Result {}", action, actionResults);
if (actionResults != null) {
allResults.addAll(actionResults);
}
}
} catch (Exception e) {
String message = "Error evaluating rule with id:" + rule.getId();
LOG.error(message);
throw new ProcessingException(message, e);
}
LOG.debug("Returning allResults {}", allResults);
return allResults;
}
use of com.hortonworks.streamline.streams.Result in project streamline by hortonworks.
the class JoinActionRuntime method joinEvents.
/**
* Join all subevents and generate an event for the given output stream.
*
* @param eventGroup
*/
protected List<Result> joinEvents(EventGroup eventGroup) {
StreamlineEvent joinedEvent = joiner.join(eventGroup);
List<Result> results = new ArrayList<>();
for (String stream : getOutputStreams()) {
results.add(new Result(stream, Collections.singletonList(getStreamlineEvent(joinedEvent, stream))));
}
groupedEvents.invalidate(eventGroup.getGroupId());
return results;
}
use of com.hortonworks.streamline.streams.Result 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.Result 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);
}
}
Aggregations