use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class ConsistentRegionTest method testConsistentOperatorDriven.
@Test
public void testConsistentOperatorDriven() throws Exception {
Topology topology = new Topology("testConsistentOperatorDriven");
final int N = 2000;
StreamSchema schema = Type.Factory.getStreamSchema("tuple<uint64 id>");
Map<String, Object> params = new HashMap<>();
params.put("iterations", N);
params.put("period", 0.01);
params.put("triggerCount", SPL.createValue(37, Type.MetaType.UINT32));
SPLStream b = SPL.invokeSource(topology, "spl.utility::Beacon", params, schema);
ConsistentRegionConfig config = ConsistentRegionConfig.operatorDriven();
assertSame(b, b.setConsistent(config));
// Create a mini-flow
b = b.filter(t -> true);
Condition<Void> resets = topology.getTester().resetConsistentRegions(5);
assertNotNull(resets);
Condition<Long> exact = topology.getTester().tupleCount(b, N);
complete(topology.getTester(), exact, 80, TimeUnit.SECONDS);
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class ConsistentRegionTest method testConsistentPeriodic.
@Test
public void testConsistentPeriodic() throws Exception {
Topology topology = new Topology("testConsistentPeriodic");
final int N = 2000;
StreamSchema schema = Type.Factory.getStreamSchema("tuple<uint64 id>");
Map<String, Object> params = new HashMap<>();
params.put("iterations", N);
params.put("period", 0.01);
SPLStream b = SPL.invokeSource(topology, "spl.utility::Beacon", params, schema);
ConsistentRegionConfig config = periodic(2);
assertSame(b, b.setConsistent(config));
// Create a mini-flow
b = b.filter(t -> true);
Condition<Long> exact = topology.getTester().tupleCount(b, N);
Condition<Void> resets = topology.getTester().resetConsistentRegions(null);
assertNotNull(resets);
complete(topology.getTester(), exact, 80, TimeUnit.SECONDS);
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class JobConfigSubmissionTest method testItDirect.
private void testItDirect(String topologyName, JobConfig config, String... expected) throws Exception {
// Uses a Java primitive operator directly.
assumeTrue(hasStreamsInstall());
// JobConfig only apply to DISTRIBUTED submit
assumeTrue(isDistributedOrService());
config.addToConfig(getConfig());
Topology topology = newTopology(topologyName);
topology.addClassDependency(JobPropertiesTestOp.class);
SPLStream sourceSPL = JavaPrimitive.invokeJavaPrimitiveSource(topology, JobPropertiesTestOp.class, SPLSchemas.STRING, null);
TStream<String> source = sourceSPL.toStringStream();
Condition<Long> end = topology.getTester().tupleCount(source, 4);
Condition<List<String>> result = topology.getTester().stringContents(source, expected);
complete(topology.getTester(), end.and(result), 10, TimeUnit.SECONDS);
assertTrue(result.valid());
assertTrue(end.valid());
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class PublishSubscribeSPLTest method testSPLPublishAllowFilterWithSubscribe.
/**
* Test that with publish allow filter set to false
* a subscriber without a filter gets the full set of data.
*/
@Test
public void testSPLPublishAllowFilterWithSubscribe() throws Exception {
final Topology t = new Topology();
SPLStream source = SPLStreamsTest.testTupleStream(t);
final String topic = uniqueTopic("SPLPublishAllowFilterWithSubscribe");
source = addStartupDelay(source);
source.publish(topic, true);
SPLStream sub = SPLStreams.subscribe(t, topic, source.getSchema());
TStream<String> subscribe = sub.transform(new GetTupleId());
completeAndValidate(subscribe, 20, "SPL:0", "SPL:1", "SPL:2", "SPL:3");
}
use of com.ibm.streamsx.topology.Topology in project streamsx.topology by IBMStreams.
the class PublishSubscribeSPLTest method _testSPLPublishFilteredSubscribe.
private void _testSPLPublishFilteredSubscribe(String topic, boolean allowFilters, boolean useParams) throws Exception {
final Topology t = new Topology();
topic = uniqueTopic(topic);
SPL.addToolkit(t, new File(getTestRoot(), "spl/testtk"));
SPLStream source = SPLStreamsTest.testTupleStream(t);
source = addStartupDelay(source);
Supplier<String> pubParam = useParams ? t.createSubmissionParameter("PFSPL", String.class) : null;
if (useParams)
source.publish(pubParam, allowFilters);
else
source.publish(topic, allowFilters);
// Filter on the vi attribute, passing the value 321.
Map<String, Object> params = new HashMap<>();
params.put("topic", topic);
params.put("value", 43675232L);
SPLStream sub = SPL.invokeSource(t, "testspl::Int64SubscribeFilter", params, source.getSchema());
TStream<String> subscribe = sub.transform(new GetTupleId());
if (useParams) {
JobConfig jco = new JobConfig();
jco.addSubmissionParameter("PFSPL", topic);
jco.addToConfig(getConfig());
}
completeAndValidate(subscribe, 20, "SPL:1");
}
Aggregations