Search in sources :

Example 1 with JoinAction

use of com.hortonworks.streamline.streams.layout.component.impl.splitjoin.JoinAction 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 JoinAction

use of com.hortonworks.streamline.streams.layout.component.impl.splitjoin.JoinAction 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 JoinAction

use of com.hortonworks.streamline.streams.layout.component.impl.splitjoin.JoinAction 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 JoinAction

use of com.hortonworks.streamline.streams.layout.component.impl.splitjoin.JoinAction 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 JoinAction

use of com.hortonworks.streamline.streams.layout.component.impl.splitjoin.JoinAction 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);
}
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)

Aggregations

JoinAction (com.hortonworks.streamline.streams.layout.component.impl.splitjoin.JoinAction)6 SplitAction (com.hortonworks.streamline.streams.layout.component.impl.splitjoin.SplitAction)6 Test (org.junit.Test)4 Result (com.hortonworks.streamline.streams.Result)1 StreamlineEvent (com.hortonworks.streamline.streams.StreamlineEvent)1 ActionRuntimeContext (com.hortonworks.streamline.streams.runtime.rule.action.ActionRuntimeContext)1 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1 Expectations (mockit.Expectations)1