use of com.ibm.streamsx.topology.tuple.BeaconTuple in project streamsx.topology by IBMStreams.
the class AutoTypeTest method _testAutoLimitedSourceClass.
private static void _testAutoLimitedSourceClass() {
Topology t = newTopology();
TStream<BeaconTuple> stream = t.limitedSource(new Supplier<BeaconTuple>() {
@Override
public BeaconTuple get() {
return new BeaconTuple(0);
}
}, 8);
assertEquals(BeaconTuple.class, stream.getTupleClass());
}
use of com.ibm.streamsx.topology.tuple.BeaconTuple in project streamsx.topology by IBMStreams.
the class ParallelTest method testParallelSubmissionParam.
@Test
public void testParallelSubmissionParam() throws Exception {
checkUdpSupported();
Topology topology = newTopology("testParallelSubmissionParam");
final int count = new Random().nextInt(1000) + 37;
String submissionWidthName = "width";
Integer submissionWidth = 5;
TStream<BeaconTuple> fb = BeaconStreams.beacon(topology, count);
TStream<BeaconTuple> pb = fb.parallel(topology.createSubmissionParameter(submissionWidthName, Integer.class));
TStream<Integer> is = pb.transform(randomHashProducer());
TStream<Integer> joined = is.endParallel();
TStream<String> numRegions = joined.transform(uniqueIdentifierMap(count));
Tester tester = topology.getTester();
Condition<Long> expectedCount = tester.tupleCount(numRegions, 1);
Condition<List<String>> regionCount = tester.stringContents(numRegions, submissionWidth.toString());
Map<String, Object> params = new HashMap<>();
params.put(submissionWidthName, submissionWidth);
getConfig().put(ContextProperties.SUBMISSION_PARAMS, params);
complete(tester, allConditions(regionCount, regionCount), 10, TimeUnit.SECONDS);
assertTrue(expectedCount.valid());
assertTrue(regionCount.valid());
}
use of com.ibm.streamsx.topology.tuple.BeaconTuple in project streamsx.topology by IBMStreams.
the class ParallelTest method testParallelSubmissionParamInner.
@Test
public void testParallelSubmissionParamInner() throws Exception {
checkUdpSupported();
Topology topology = newTopology("testParallelSubmissionParamInner");
final int count = new Random().nextInt(1000) + 37;
String submissionWidthName = "width";
Integer submissionWidth = 5;
String submissionAppendName = "append";
boolean submissionAppend = true;
String submissionFlushName = "flush";
Integer submissionFlush = 1;
String submissionThresholdName = "threshold";
String submissionDefaultedThresholdName = "defaultedTreshold";
Integer submissionThreshold = -1;
// getConfig().put(ContextProperties.KEEP_ARTIFACTS, true);
Supplier<Integer> threshold = topology.createSubmissionParameter(submissionThresholdName, Integer.class);
Supplier<Integer> defaultedThreshold = topology.createSubmissionParameter(submissionDefaultedThresholdName, submissionThreshold);
TStream<BeaconTuple> fb = BeaconStreams.beacon(topology, count);
TStream<BeaconTuple> pb = fb.parallel(topology.createSubmissionParameter(submissionWidthName, Integer.class));
TStream<Integer> is = pb.transform(randomHashProducer());
// submission param use within a parallel region
StreamSchema schema = getStreamSchema("tuple<int32 i>");
SPLStream splStream = SPLStreams.convertStream(is, cvtMsgFunc(), schema);
File tmpFile = File.createTempFile("parallelTest", null);
tmpFile.deleteOnExit();
Map<String, Object> splParams = new HashMap<>();
splParams.put("file", tmpFile.getAbsolutePath());
splParams.put("append", topology.createSubmissionParameter(submissionAppendName, submissionAppend));
splParams.put("flush", SPL.createSubmissionParameter(topology, submissionFlushName, SPL.createValue(0, Type.MetaType.UINT32), false));
SPL.invokeSink("spl.adapter::FileSink", splStream, splParams);
// use a submission parameter in "inner" functional logic
is = is.filter(thresholdFilter(threshold));
is = is.filter(thresholdFilter(defaultedThreshold));
// avoid another parallel impl limitation noted in issue#173
is = is.filter(passthru());
TStream<Integer> joined = is.endParallel();
TStream<String> numRegions = joined.transform(uniqueIdentifierMap(count));
Tester tester = topology.getTester();
Condition<Long> expectedCount = tester.tupleCount(numRegions, 1);
Condition<List<String>> regionCount = tester.stringContents(numRegions, submissionWidth.toString());
Map<String, Object> params = new HashMap<>();
params.put(submissionWidthName, submissionWidth);
params.put(submissionFlushName, submissionFlush);
params.put(submissionThresholdName, submissionThreshold);
getConfig().put(ContextProperties.SUBMISSION_PARAMS, params);
complete(tester, allConditions(expectedCount, regionCount), 10, TimeUnit.SECONDS);
assertTrue(expectedCount.valid());
assertTrue(regionCount.valid());
}
use of com.ibm.streamsx.topology.tuple.BeaconTuple in project streamsx.topology by IBMStreams.
the class ParallelTest method testParallelSubmissionParamDefault.
@Test
public void testParallelSubmissionParamDefault() throws Exception {
checkUdpSupported();
Topology topology = newTopology("testParallelSubmissionParamDefault");
final int count = new Random().nextInt(1000) + 37;
String submissionWidthName = "width";
Integer submissionWidth = 5;
TStream<BeaconTuple> fb = BeaconStreams.beacon(topology, count);
TStream<BeaconTuple> pb = fb.parallel(topology.createSubmissionParameter(submissionWidthName, submissionWidth));
TStream<Integer> is = pb.transform(randomHashProducer());
TStream<Integer> joined = is.endParallel();
TStream<String> numRegions = joined.transform(uniqueIdentifierMap(count));
Tester tester = topology.getTester();
Condition<Long> expectedCount = tester.tupleCount(numRegions, 1);
Condition<List<String>> regionCount = tester.stringContents(numRegions, submissionWidth.toString());
complete(tester, allConditions(regionCount, expectedCount), 10, TimeUnit.SECONDS);
assertTrue(expectedCount.valid());
assertTrue(regionCount.valid());
}
use of com.ibm.streamsx.topology.tuple.BeaconTuple in project streamsx.topology by IBMStreams.
the class ParallelTest method testParallelPartitioned.
@Test
public void testParallelPartitioned() throws Exception {
checkUdpSupported();
Topology topology = newTopology("testParallelPartition");
final int count = new Random().nextInt(10) + 37;
TStream<BeaconTuple> kb = topology.source(keyableBeacon5Counter(count));
TStream<BeaconTuple> pb = kb.parallel(new Value<Integer>(5), keyBeacon());
TStream<ChannelAndSequence> cs = pb.transform(channelSeqTransformer());
TStream<ChannelAndSequence> joined = cs.endParallel();
TStream<String> valid_count = joined.transform(partitionCounter(count));
Tester tester = topology.getTester();
Condition<Long> expectedCount = tester.tupleCount(valid_count, 1);
Condition<List<String>> validCount = tester.stringContents(valid_count, "5");
complete(tester, allConditions(expectedCount, validCount), 10, TimeUnit.SECONDS);
assertTrue(expectedCount.valid());
assertTrue(validCount.valid());
}
Aggregations