use of com.ibm.streamsx.topology.TStream in project streamsx.topology by IBMStreams.
the class CompGenerationTest method nestedUDPWithBroadcast.
@Test
public void nestedUDPWithBroadcast() throws Exception {
assumeTrue(SC_OK);
assumeTrue(!isMainRun());
Topology topo = new Topology();
TStream<String> nums = topo.strings("1", "2");
nums.setParallel(() -> 2);
nums = nums.parallel(() -> 4, Routing.BROADCAST);
nums = nums.filter(tup -> true);
nums = nums.endParallel().endParallel();
Tester tester = topo.getTester();
Condition<List<String>> validCount = tester.stringContentsUnordered(nums, "1", "1", "1", "1", "1", "1", "1", "1", "2", "2", "2", "2", "2", "2", "2", "2");
complete(tester, allConditions(validCount), 10, TimeUnit.SECONDS);
assertTrue(validCount.valid());
}
use of com.ibm.streamsx.topology.TStream in project streamsx.topology by IBMStreams.
the class CompGenerationTest method multipleInputPortsDifferentRoutingSchemesMultipleOutputs.
@Test
public void multipleInputPortsDifferentRoutingSchemesMultipleOutputs() throws Exception {
assumeTrue(SC_OK);
assumeTrue(!isMainRun());
Topology topo = new Topology();
TStream<String> nums = topo.strings("1");
TStream<String> nums2 = topo.strings("2");
TStream<String> nums3 = topo.strings("3");
nums = nums.parallel(() -> 3, tup -> 1);
nums2 = nums2.parallel(() -> 3, Routing.BROADCAST);
nums3 = nums3.parallel(3);
Set<TStream<String>> streams = new HashSet<>();
streams.add(nums2);
streams.add(nums3);
nums = nums.union(streams);
TStream<String> nums_1_2 = nums.filter(tup -> tup.equals("1") || tup.equals("2"));
TStream<String> nums_3 = nums.filter(tup -> tup.equals("3"));
nums_1_2 = nums_1_2.endParallel();
nums_3 = nums_3.endParallel();
Tester tester = topo.getTester();
Condition<List<String>> validCount_1_2 = tester.stringContentsUnordered(nums_1_2, "1", "2", "2", "2");
Condition<List<String>> validCount_3 = tester.stringContentsUnordered(nums_3, "3");
complete(tester, allConditions(validCount_1_2, validCount_3), 10, TimeUnit.SECONDS);
assertTrue(validCount_1_2.valid());
assertTrue(validCount_3.valid());
}
use of com.ibm.streamsx.topology.TStream in project streamsx.topology by IBMStreams.
the class CompGenerationTest method multipleInputPortsDifferentWidths.
@Test(expected = IllegalStateException.class)
public void multipleInputPortsDifferentWidths() throws Exception {
assumeTrue(SC_OK);
assumeTrue(!isMainRun());
Topology topo = new Topology();
TStream<String> nums = topo.strings("1");
TStream<String> nums2 = topo.strings("2");
TStream<String> nums3 = topo.strings("3");
nums = nums.parallel(() -> 3, tup -> 1);
nums2 = nums2.parallel(() -> 1, Routing.BROADCAST);
nums3 = nums3.parallel(2);
Set<TStream<String>> streams = new HashSet<>();
streams.add(nums2);
streams.add(nums3);
nums = nums.union(streams);
nums = nums.filter(tup -> true);
nums = nums.endParallel();
Tester tester = topo.getTester();
complete(tester);
}
use of com.ibm.streamsx.topology.TStream in project streamsx.topology by IBMStreams.
the class CompGenerationTest method multipleInputPorts.
@Test
public void multipleInputPorts() throws Exception {
assumeTrue(SC_OK);
assumeTrue(!isMainRun());
Topology topo = new Topology();
TStream<String> nums = topo.strings("1");
TStream<String> nums2 = topo.strings("2");
TStream<String> nums3 = topo.strings("3");
nums = nums.parallel(3);
nums2 = nums2.parallel(3);
nums3 = nums3.parallel(3);
Set<TStream<String>> streams = new HashSet<>();
streams.add(nums2);
streams.add(nums3);
nums = nums.union(streams);
nums = nums.filter(tup -> true);
nums = nums.endParallel();
Tester tester = topo.getTester();
Condition<List<String>> validCount = tester.stringContentsUnordered(nums, "1", "2", "3");
complete(tester, allConditions(validCount), 10, TimeUnit.SECONDS);
assertTrue(validCount.valid());
}
use of com.ibm.streamsx.topology.TStream in project streamsx.topology by IBMStreams.
the class InvokerTest method testParallelHashSerializers.
@Test
public void testParallelHashSerializers() throws Exception {
checkUdpSupported();
Topology topology = newTopology();
SPL.addToolkit(topology, new File(getTestRoot(), "spl/testtk"));
JsonObject sname = new JsonObject();
sname.addProperty("name", "S");
TStream<Byte> s = Invoker.invokeSource(topology, JavaFunctionalOps.SOURCE_KIND, sname, new ByteData(), Byte.class, new ByteSerializer(), null);
s = s.parallel(() -> 3, Routing.HASH_PARTITIONED);
JsonObject pname = new JsonObject();
pname.addProperty("name", "P");
@SuppressWarnings("unchecked") TStream<Byte> sp = (TStream<Byte>) Invoker.invokePipe("testjava::MyPipe", s, pname, new ByteAdder(32), Byte.class, new ByteSerializer(), new ByteSerializer(), null);
sp = sp.endParallel();
JsonObject fname = new JsonObject();
fname.addProperty("name", "F");
@SuppressWarnings("unchecked") TStream<Byte> fsp = (TStream<Byte>) Invoker.invokePipe("testjava::MyPipe", sp, pname, new ByteAdder(0), Byte.class, new ByteSerializer(), null, null);
TStream<String> ss = StringStreams.toString(fsp);
Tester tester = topology.getTester();
Condition<List<String>> contents = tester.stringContentsUnordered(ss, "33", "49", "125", "-11");
Condition<Long> count = tester.tupleCount(ss, 4);
complete(topology.getTester(), count, 10, TimeUnit.SECONDS);
assertTrue(count.valid());
assertTrue(contents.valid());
}
Aggregations