use of com.ibm.streamsx.topology.TStream in project streamsx.topology by IBMStreams.
the class LowLatencyTest method testNested.
@Test
public void testNested() throws Exception {
// ensure nested low latency yields all fns in the same container
final Topology topology = newTopology();
final Tester tester = topology.getTester();
String[] s1Strs = { "a" };
TStream<String> s1 = topology.strings(s1Strs);
TStream<String> s2 = s1.isolate().lowLatency().modify(getContainerIdAppend()).invocationName("OuterStart").lowLatency().modify(getContainerIdAppend()).invocationName("Inner").endLowLatency().modify(getContainerIdAppend()).invocationName("OuterEnd").endLowLatency();
s2 = s2.filter(v -> true);
TStream<String> ids = s2.flatMap(v -> getContainerIds(v)).invocationName("Flatten");
ids = TestTopology.uniqueValues(ids);
Condition<Long> uCount = tester.tupleCount(s2, 1);
Condition<Long> uIds = tester.tupleCount(ids, 1);
complete(tester, uCount.and(uIds), 10, TimeUnit.SECONDS);
assertTrue(uCount.valid());
assertTrue(uIds.valid());
}
use of com.ibm.streamsx.topology.TStream in project streamsx.topology by IBMStreams.
the class LowLatencyTest method testLowLatencySplit.
@Test
public void testLowLatencySplit() throws Exception {
assumeTrue(!isStreamingAnalyticsRun());
// lowLatency().split() is an interesting case because split()
// has >1 oports.
final Topology topology = newTopology("testLowLatencySplit");
int splitWidth = 3;
String[] strs = { "ch0", "ch1", "ch2" };
TStream<String> s1 = topology.strings(strs);
s1 = s1.isolate();
s1 = s1.lowLatency();
// ///////////////////////////////////
// assume that if s1.modify and the split().[modify()] are
// in the same PE, that s1.split() is in the same too
TStream<String> s2 = s1.modify(unaryGetPEId()).endLowLatency();
List<TStream<String>> splits = s1.split(splitWidth, roundRobinSplitter());
List<TStream<String>> splitChResults = new ArrayList<>();
for (int i = 0; i < splits.size(); i++) {
splitChResults.add(splits.get(i).modify(unaryGetPEId()));
}
TStream<String> splitChFanin = splitChResults.get(0).union(new HashSet<>(splitChResults.subList(1, splitChResults.size())));
// ///////////////////////////////////
TStream<String> all = splitChFanin.endLowLatency();
TStream<String> peIds = all.filter(v -> true).union(s2.filter(v -> true));
peIds = TestTopology.uniqueValues(peIds);
Tester tester = topology.getTester();
Condition<Long> uCount = tester.tupleCount(all, strs.length);
Condition<Long> uniqueIds = tester.tupleCount(peIds, 1);
complete(tester, uCount.and(uniqueIds), 10, TimeUnit.SECONDS);
assertTrue(uniqueIds.valid());
assertTrue(uCount.valid());
}
use of com.ibm.streamsx.topology.TStream in project streamsx.topology by IBMStreams.
the class PlaceableTest method testSimpleColocate.
/**
*/
@Test
public void testSimpleColocate() throws Exception {
adlOk();
Topology t = newTopology();
TStream<String> sa = t.strings("a");
TStream<String> sb = t.strings("b");
sa = sa.transform(tuple -> tuple).invocationName("SA");
sb = sb.transform(tuple -> tuple).invocationName("SB");
sa.colocate(sb);
sa = sa.isolate().filter(tuple -> true);
sb = sb.isolate().filter(tuple -> true);
sa = sa.union(sb);
Document adl = produceADL(t);
adlAssertDefaultHostpool(adl);
adlAssertColocated(adl, false, "SA", "SB");
}
use of com.ibm.streamsx.topology.TStream in project streamsx.topology by IBMStreams.
the class PlaceableTest method testNoColocate.
@Test
public void testNoColocate() throws Exception {
adlOk();
Topology t = newTopology();
TStream<String> sa = t.strings("a");
TStream<String> sb = t.strings("b");
sa = sa.transform(identity());
sb = sb.transform(tuple -> tuple);
sa = sa.union(sb);
sa.forEach(tuple -> {
});
Document adl = produceADL(t);
adlAssertDefaultHostpool(adl);
adlAssertNoColocated(adl);
}
use of com.ibm.streamsx.topology.TStream in project streamsx.topology by IBMStreams.
the class PlaceableTest method testSplit.
@Test
public void testSplit() {
assumeTrue(isMainRun());
Topology t = newTopology();
TStream<String> s = t.strings("3");
List<TStream<String>> splits = s.split(3, x -> 0);
splits.get(0).addResourceTags("tag1");
for (TStream<String> l : splits) {
assertEquals(1, l.getResourceTags().size());
assertTrue(l.getResourceTags().contains("tag1"));
}
splits.get(2).addResourceTags("tag921");
for (TStream<String> l : splits) {
assertEquals(2, l.getResourceTags().size());
assertTrue(l.getResourceTags().contains("tag1"));
assertTrue(l.getResourceTags().contains("tag921"));
}
}
Aggregations