use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class SPLStreamsTest method testTuples.
@Test
public void testTuples() throws Exception {
Topology topology = new Topology("testTuples");
SPLStream tuples = testTupleStream(topology);
Tester tester = topology.getTester();
Condition<Long> expectedCount = tester.tupleCount(tuples, TEST_TUPLES.length);
Condition<List<Tuple>> expectedTuples = tester.tupleContents(tuples, TEST_TUPLES);
complete(tester, expectedCount, 10, TimeUnit.SECONDS);
assertTrue(expectedCount.valid());
assertTrue(expectedTuples.toString(), expectedTuples.valid());
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class InvokerTest method testParallelHashSerializersWithVirtuals.
@Test
public void testParallelHashSerializersWithVirtuals() throws Exception {
checkUdpSupported();
Topology topology = newTopology();
SPL.addToolkit(topology, new File(getTestRoot(), "spl/testtk"));
JsonObject sname = new JsonObject();
sname.addProperty("name", "S1");
TStream<Byte> s = Invoker.invokeSource(topology, JavaFunctionalOps.SOURCE_KIND, sname, new ByteData(), Byte.class, new ByteSerializer(), null);
JsonObject sname2 = new JsonObject();
sname2.addProperty("name", "S2");
TStream<Byte> s2 = Invoker.invokeSource(topology, JavaFunctionalOps.SOURCE_KIND, sname2, new ByteData(), Byte.class, new ByteSerializer(), null);
s = s.union(s2);
s = s.isolate();
s = s.autonomous();
s = s.lowLatency();
JsonObject llname = new JsonObject();
llname.addProperty("name", "LL");
@SuppressWarnings("unchecked") TStream<Byte> ll = (TStream<Byte>) Invoker.invokePipe("testjava::MyPipe", s, llname, new ByteAdder(3), Byte.class, new ByteSerializer(), new ByteSerializer(), null);
s = ll.endLowLatency();
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(29), 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", "33", "49", "125", "-11");
Condition<Long> count = tester.tupleCount(ss, 8);
complete(topology.getTester(), count, 10, TimeUnit.SECONDS);
assertTrue(count.valid());
assertTrue(contents.valid());
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class SPLJavaPrimitiveTest method testIsolatedVmArgs2.
@Test
public void testIsolatedVmArgs2() throws Exception {
// isolation only works in DISTRIBUTED
assumeTrue(getTesterType() == StreamsContext.Type.DISTRIBUTED_TESTER);
assumeTrue(SC_OK);
Topology t = new Topology("testIsolatedVmArgs1");
SPL.addToolkit(t, new File(getTestRoot(), "spl/testtk"));
// getConfig().put(ContextProperties.KEEP_ARTIFACTS, true);
SPLStream spl = SPLStreams.stringToSPLStream(t.strings("hello"));
// isolate the JavaPrimitive to avoid the restriction/failure
// demonstrated in testIncompatVmArgs
spl = spl.isolate();
Map<String, Object> params = new HashMap<>();
params.put("vmArg", new String[] { "-DXYZZY", "-DFOOBAR" });
SPLStream splResult = JavaPrimitive.invokeJavaPrimitive(testjava.NoOpJavaPrimitive.class, spl, SPLSchemas.STRING, params);
splResult = splResult.isolate();
TStream<String> result = splResult.toStringStream();
completeAndValidate(result, 10, "hello");
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class SPLJavaPrimitiveTest method testSimpleInvoke.
@Test
public void testSimpleInvoke() throws Exception {
Topology t = new Topology("testSimpleInvoke");
SPL.addToolkit(t, new File(getTestRoot(), "spl/testtk"));
SPLStream spl = SPLStreams.stringToSPLStream(t.strings("hello"));
SPLStream splResult = JavaPrimitive.invokeJavaPrimitive(testjava.NoOpJavaPrimitive.class, spl, SPLSchemas.STRING, null);
TStream<String> result = splResult.toStringStream();
completeAndValidate(result, 10, "hello");
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class SPLParallelTest method testRoundRobin.
@Test
public void testRoundRobin() throws Exception {
Topology topology = newTopology();
TStream<String> values = topology.strings("UDP-RR", "@parallel-RR", "Done-RR");
StreamSchema schema = com.ibm.streams.operator.Type.Factory.getStreamSchema("tuple<rstring x>");
SPLStream vs = SPLStreams.convertStream(values, (s, o) -> {
o.setString(0, s);
return o;
}, schema);
vs = vs.parallel(() -> 3, Routing.ROUND_ROBIN);
SPLStream r = vs.filter(new AllowAll<>()).endParallel();
TStream<String> rs = SPLStreams.toStringStream(r);
Tester tester = topology.getTester();
Condition<Long> expectedCount = tester.tupleCount(r, 3);
Condition<List<String>> content = tester.stringContentsUnordered(rs, "UDP-RR", "@parallel-RR", "Done-RR");
assertTrue(complete(tester, expectedCount, 20, TimeUnit.SECONDS));
assertTrue(content.valid());
}
Aggregations