Search in sources :

Example 1 with ConsistentRegionConfig

use of com.ibm.streamsx.topology.consistent.ConsistentRegionConfig 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);
}
Also used : ConsistentRegionConfig.periodic(com.ibm.streamsx.topology.consistent.ConsistentRegionConfig.periodic) Assert.assertNotNull(org.junit.Assert.assertNotNull) ConsistentRegionConfig(com.ibm.streamsx.topology.consistent.ConsistentRegionConfig) SPLStream(com.ibm.streamsx.topology.spl.SPLStream) HashMap(java.util.HashMap) Test(org.junit.Test) StreamSchema(com.ibm.streams.operator.StreamSchema) Assert.assertSame(org.junit.Assert.assertSame) TimeUnit(java.util.concurrent.TimeUnit) Topology(com.ibm.streamsx.topology.Topology) Map(java.util.Map) SPL(com.ibm.streamsx.topology.spl.SPL) Condition(com.ibm.streamsx.topology.tester.Condition) Assume.assumeTrue(org.junit.Assume.assumeTrue) TestTopology(com.ibm.streamsx.topology.test.TestTopology) Before(org.junit.Before) Type(com.ibm.streams.operator.Type) HashMap(java.util.HashMap) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) StreamSchema(com.ibm.streams.operator.StreamSchema) SPLStream(com.ibm.streamsx.topology.spl.SPLStream) ConsistentRegionConfig(com.ibm.streamsx.topology.consistent.ConsistentRegionConfig) Test(org.junit.Test)

Example 2 with ConsistentRegionConfig

use of com.ibm.streamsx.topology.consistent.ConsistentRegionConfig 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);
}
Also used : ConsistentRegionConfig.periodic(com.ibm.streamsx.topology.consistent.ConsistentRegionConfig.periodic) Assert.assertNotNull(org.junit.Assert.assertNotNull) ConsistentRegionConfig(com.ibm.streamsx.topology.consistent.ConsistentRegionConfig) SPLStream(com.ibm.streamsx.topology.spl.SPLStream) HashMap(java.util.HashMap) Test(org.junit.Test) StreamSchema(com.ibm.streams.operator.StreamSchema) Assert.assertSame(org.junit.Assert.assertSame) TimeUnit(java.util.concurrent.TimeUnit) Topology(com.ibm.streamsx.topology.Topology) Map(java.util.Map) SPL(com.ibm.streamsx.topology.spl.SPL) Condition(com.ibm.streamsx.topology.tester.Condition) Assume.assumeTrue(org.junit.Assume.assumeTrue) TestTopology(com.ibm.streamsx.topology.test.TestTopology) Before(org.junit.Before) Type(com.ibm.streams.operator.Type) HashMap(java.util.HashMap) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) StreamSchema(com.ibm.streams.operator.StreamSchema) SPLStream(com.ibm.streamsx.topology.spl.SPLStream) ConsistentRegionConfig(com.ibm.streamsx.topology.consistent.ConsistentRegionConfig) Test(org.junit.Test)

Example 3 with ConsistentRegionConfig

use of com.ibm.streamsx.topology.consistent.ConsistentRegionConfig in project streamsx.topology by IBMStreams.

the class ConsistentRegionConfigTest method testChangeDrain.

@Test
public void testChangeDrain() {
    ConsistentRegionConfig config = operatorDriven().drainTimeout(27);
    checkCRC(config, Trigger.OPERATOR_DRIVEN, -1, 27, 180, 5);
}
Also used : ConsistentRegionConfig(com.ibm.streamsx.topology.consistent.ConsistentRegionConfig) Test(org.junit.Test)

Example 4 with ConsistentRegionConfig

use of com.ibm.streamsx.topology.consistent.ConsistentRegionConfig in project streamsx.topology by IBMStreams.

the class ConsistentRegionConfigTest method testChangeReset.

@Test
public void testChangeReset() {
    ConsistentRegionConfig config = periodic(4).resetTimeout(99);
    checkCRC(config, Trigger.PERIODIC, 4, 180, 99, 5);
}
Also used : ConsistentRegionConfig(com.ibm.streamsx.topology.consistent.ConsistentRegionConfig) Test(org.junit.Test)

Example 5 with ConsistentRegionConfig

use of com.ibm.streamsx.topology.consistent.ConsistentRegionConfig in project streamsx.topology by IBMStreams.

the class ConsistentRegionConfigTest method testDefaultPeriod.

@Test
public void testDefaultPeriod() {
    ConsistentRegionConfig config = periodic(37);
    checkCRC(config, Trigger.PERIODIC, 37, 180, 180, 5);
}
Also used : ConsistentRegionConfig(com.ibm.streamsx.topology.consistent.ConsistentRegionConfig) Test(org.junit.Test)

Aggregations

ConsistentRegionConfig (com.ibm.streamsx.topology.consistent.ConsistentRegionConfig)12 Test (org.junit.Test)11 StreamSchema (com.ibm.streams.operator.StreamSchema)2 Type (com.ibm.streams.operator.Type)2 Topology (com.ibm.streamsx.topology.Topology)2 ConsistentRegionConfig.periodic (com.ibm.streamsx.topology.consistent.ConsistentRegionConfig.periodic)2 SPL (com.ibm.streamsx.topology.spl.SPL)2 SPLStream (com.ibm.streamsx.topology.spl.SPLStream)2 TestTopology (com.ibm.streamsx.topology.test.TestTopology)2 Condition (com.ibm.streamsx.topology.tester.Condition)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 TimeUnit (java.util.concurrent.TimeUnit)2 Assert.assertNotNull (org.junit.Assert.assertNotNull)2 Assert.assertSame (org.junit.Assert.assertSame)2 Assume.assumeTrue (org.junit.Assume.assumeTrue)2 Before (org.junit.Before)2