Search in sources :

Example 1 with SplitAction

use of com.hortonworks.streamline.streams.layout.component.impl.splitjoin.SplitAction in project streamline by hortonworks.

the class SplitJoinTest method testSplitJoinProcessorsWithActionsHavingStreams.

@Test
public void testSplitJoinProcessorsWithActionsHavingStreams() throws Exception {
    String[] outputStreams = { "stream-1", "stream-2", "stream-3" };
    final SplitAction splitAction = new SplitAction();
    splitAction.setOutputStreams(Sets.newHashSet(outputStreams));
    final JoinAction joinAction = new JoinAction();
    joinAction.setOutputStreams(Collections.singleton("output-stream"));
    runSplitJoin(splitAction, joinAction);
}
Also used : JoinAction(com.hortonworks.streamline.streams.layout.component.impl.splitjoin.JoinAction) SplitAction(com.hortonworks.streamline.streams.layout.component.impl.splitjoin.SplitAction) Test(org.junit.Test)

Example 2 with SplitAction

use of com.hortonworks.streamline.streams.layout.component.impl.splitjoin.SplitAction in project streamline by hortonworks.

the class SplitJoinTest method testCustomSplitJoinWithRules.

@Test
public void testCustomSplitJoinWithRules() {
    String[] outputStreams = { "stream-1", "stream-2", "stream-3" };
    final SplitAction splitAction = new SplitAction(MySplitter.class.getName());
    SplitJoinRule splitRule = new SplitJoinRule("split", splitAction, Sets.newHashSet(outputStreams));
    final JoinAction joinAction = new JoinAction(MyJoiner.class.getName());
    SplitJoinRule joinRule = new SplitJoinRule("join", joinAction, Collections.singleton("output-stream"));
    resetCounters();
    runSplitJoin(splitRule, joinRule);
    Assert.assertTrue(MySplitter.invocationCount == 1);
    Assert.assertTrue(MyJoiner.invocationCount == 1);
}
Also used : JoinAction(com.hortonworks.streamline.streams.layout.component.impl.splitjoin.JoinAction) SplitAction(com.hortonworks.streamline.streams.layout.component.impl.splitjoin.SplitAction) Test(org.junit.Test)

Example 3 with SplitAction

use of com.hortonworks.streamline.streams.layout.component.impl.splitjoin.SplitAction in project streamline by hortonworks.

the class SplitJoinTest method testSplitJoinProcessorsWithRuleHavingStreams.

@Test
public void testSplitJoinProcessorsWithRuleHavingStreams() throws Exception {
    String[] outputStreams = { "stream-1", "stream-2", "stream-3" };
    SplitJoinRule splitRule = new SplitJoinRule("split", new SplitAction(), Sets.newHashSet(outputStreams));
    SplitJoinRule joinRule = new SplitJoinRule("join", new JoinAction(), Collections.singleton("output-stream"));
    runSplitJoin(splitRule, joinRule);
}
Also used : JoinAction(com.hortonworks.streamline.streams.layout.component.impl.splitjoin.JoinAction) SplitAction(com.hortonworks.streamline.streams.layout.component.impl.splitjoin.SplitAction) Test(org.junit.Test)

Example 4 with SplitAction

use of com.hortonworks.streamline.streams.layout.component.impl.splitjoin.SplitAction in project streamline by hortonworks.

the class SplitJoinTest method runCustomLoadedSplitJoin.

protected void runCustomLoadedSplitJoin(String splitterClassName, String joinerClassName, final InputStream splitJarInputStream, final InputStream joinJarInputStream) throws IOException {
    String[] outputStreams = { "stream-1", "stream-2", "stream-3" };
    final Long splitJarId = 1L;
    final Long joinJarId = splitJarId + 1;
    try {
        new Expectations() {

            {
                mockCatalogRestClient.getFile(splitJarId);
                result = splitJarInputStream;
                mockCatalogRestClient.getFile(joinJarId);
                result = joinJarInputStream;
            }
        };
        final SplitAction splitAction = new SplitAction(splitJarId, splitterClassName);
        splitAction.setOutputStreams(Sets.newHashSet(outputStreams));
        final JoinAction joinAction = new JoinAction(joinJarId, joinerClassName);
        joinAction.setOutputStreams(Collections.singleton("output-stream"));
        Map<String, Object> config = new HashMap<>();
        config.put(Constants.CATALOG_ROOT_URL, "dummy-url");
        final Path tempDirectory = Files.createTempDirectory("sj-test");
        tempDirectory.toFile().deleteOnExit();
        config.put(Constants.LOCAL_FILES_PATH, tempDirectory);
        runSplitJoin(splitAction, joinAction, config);
    } finally {
        splitJarInputStream.close();
        joinJarInputStream.close();
    }
}
Also used : Expectations(mockit.Expectations) Path(java.nio.file.Path) JoinAction(com.hortonworks.streamline.streams.layout.component.impl.splitjoin.JoinAction) HashMap(java.util.HashMap) SplitAction(com.hortonworks.streamline.streams.layout.component.impl.splitjoin.SplitAction)

Example 5 with SplitAction

use of com.hortonworks.streamline.streams.layout.component.impl.splitjoin.SplitAction in project streamline by hortonworks.

the class SplitJoinTopologyTest method createSplitBolt.

private RulesBolt createSplitBolt() {
    SplitAction splitAction = new SplitAction();
    splitAction.setOutputStreams(Collections.singleton(SPLIT_STREAM_ID.getId()));
    SplitRulesProcessor splitRulesProcessor = new SplitRulesProcessor(SPLIT_STREAM_ID, splitAction);
    return new RulesBolt(splitRulesProcessor.get(), getScriptType());
}
Also used : SplitAction(com.hortonworks.streamline.streams.layout.component.impl.splitjoin.SplitAction) RulesBolt(com.hortonworks.streamline.streams.runtime.storm.bolt.rules.RulesBolt)

Aggregations

SplitAction (com.hortonworks.streamline.streams.layout.component.impl.splitjoin.SplitAction)8 JoinAction (com.hortonworks.streamline.streams.layout.component.impl.splitjoin.JoinAction)6 Test (org.junit.Test)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Result (com.hortonworks.streamline.streams.Result)1 StreamlineEvent (com.hortonworks.streamline.streams.StreamlineEvent)1 TopologyComponent (com.hortonworks.streamline.streams.catalog.TopologyComponent)1 TopologyOutputComponent (com.hortonworks.streamline.streams.catalog.TopologyOutputComponent)1 StreamlineProcessor (com.hortonworks.streamline.streams.layout.component.StreamlineProcessor)1 SplitProcessor (com.hortonworks.streamline.streams.layout.component.impl.splitjoin.SplitProcessor)1 ActionRuntimeContext (com.hortonworks.streamline.streams.runtime.rule.action.ActionRuntimeContext)1 RulesBolt (com.hortonworks.streamline.streams.runtime.storm.bolt.rules.RulesBolt)1 Path (java.nio.file.Path)1 SimpleImmutableEntry (java.util.AbstractMap.SimpleImmutableEntry)1 HashMap (java.util.HashMap)1 Expectations (mockit.Expectations)1