use of com.hortonworks.streamline.streams.layout.component.impl.splitjoin.SplitAction in project streamline by hortonworks.
the class SplitJoinTest method testCustomSplitJoin.
@Test
public void testCustomSplitJoin() {
String[] outputStreams = { "stream-1", "stream-2", "stream-3" };
final SplitAction splitAction = new SplitAction(MySplitter.class.getName());
splitAction.setOutputStreams(Sets.newHashSet(outputStreams));
final JoinAction joinAction = new JoinAction(MyJoiner.class.getName());
joinAction.setOutputStreams(Collections.singleton("output-stream"));
resetCounters();
runSplitJoin(splitAction, joinAction);
Assert.assertTrue(MySplitter.invocationCount == 1);
Assert.assertTrue(MyJoiner.invocationCount == 1);
}
use of com.hortonworks.streamline.streams.layout.component.impl.splitjoin.SplitAction in project streamline by hortonworks.
the class SplitJoinTest method runSplitJoin.
private void runSplitJoin(SplitJoinRule splitRule, SplitJoinRule joinRule, Map<String, Object> config) {
final SplitAction splitAction = (SplitAction) splitRule.getAction();
SplitActionRuntime splitActionRuntime = new SplitActionRuntime(splitAction);
splitActionRuntime.setActionRuntimeContext(new ActionRuntimeContext(splitRule, splitAction));
splitActionRuntime.initialize(config);
StreamlineEvent streamlineEvent = createRootEvent();
final List<Result> results = splitActionRuntime.execute(streamlineEvent);
JoinAction joinAction = (JoinAction) joinRule.getAction();
JoinActionRuntime joinActionRuntime = new JoinActionRuntime(joinAction);
joinActionRuntime.setActionRuntimeContext(new ActionRuntimeContext(joinRule, joinAction));
joinActionRuntime.initialize(config);
List<Result> effectiveResult = null;
for (Result result : results) {
for (StreamlineEvent event : result.events) {
List<Result> processedResult = joinActionRuntime.execute(event);
if (processedResult != null) {
effectiveResult = processedResult;
}
}
}
Assert.assertNotNull(effectiveResult);
}
use of com.hortonworks.streamline.streams.layout.component.impl.splitjoin.SplitAction in project streamline by hortonworks.
the class TopologyComponentFactory method splitProcessorProvider.
private Map.Entry<String, Provider<StreamlineProcessor>> splitProcessorProvider() {
Provider<StreamlineProcessor> provider = new Provider<StreamlineProcessor>() {
@Override
public StreamlineProcessor create(TopologyComponent component) {
Object splitConfig = component.getConfig().getAny(SplitProcessor.CONFIG_KEY_SPLIT);
ObjectMapper objectMapper = new ObjectMapper();
SplitAction splitAction = objectMapper.convertValue(splitConfig, SplitAction.class);
SplitProcessor splitProcessor = new SplitProcessor();
if (component instanceof TopologyOutputComponent) {
splitProcessor.addOutputStreams(createOutputStreams((TopologyOutputComponent) component));
} else {
throw new IllegalArgumentException("Component " + component + " must be an instance of TopologyOutputComponent");
}
splitProcessor.setSplitAction(splitAction);
return splitProcessor;
}
};
return new SimpleImmutableEntry<>(SPLIT, provider);
}
Aggregations