Search in sources :

Example 1 with BoundedOutOfOrdernessWatermarkEstimator

use of cz.o2.proxima.direct.time.BoundedOutOfOrdernessWatermarkEstimator in project proxima-platform by O2-Czech-Republic.

the class BoundedOutOfOrdernessWatermarkEstimatorTest method testIdlePolicy.

@Test
public void testIdlePolicy() {
    WatermarkIdlePolicy idlePolicy = mock(WatermarkIdlePolicy.class);
    BoundedOutOfOrdernessWatermarkEstimator estimator = BoundedOutOfOrdernessWatermarkEstimator.newBuilder().withWatermarkIdlePolicy(idlePolicy).build();
    StreamElement element = element(now);
    estimator.update(element);
    verify(idlePolicy, times(1)).update(element);
    estimator.idle();
    verify(idlePolicy, times(1)).idle(now);
}
Also used : WatermarkIdlePolicy(cz.o2.proxima.time.WatermarkIdlePolicy) StreamElement(cz.o2.proxima.storage.StreamElement) Test(org.junit.Test)

Example 2 with BoundedOutOfOrdernessWatermarkEstimator

use of cz.o2.proxima.direct.time.BoundedOutOfOrdernessWatermarkEstimator in project proxima-platform by O2-Czech-Republic.

the class BoundedOutOfOrdernessWatermarkEstimatorTest method testFactory.

@Test
public void testFactory() {
    Map<String, Object> cfg = new HashMap<String, Object>() {

        {
            put(prefixedKey(MAX_OUT_OF_ORDERNESS_MS), OUT_OF_ORDERNESS);
        }
    };
    WatermarkIdlePolicyFactory idlePolicyFactory = mock(WatermarkIdlePolicyFactory.class);
    when(idlePolicyFactory.create(cfg)).thenReturn(mock(WatermarkIdlePolicy.class));
    WatermarkEstimatorFactory factory = new BoundedOutOfOrdernessWatermarkEstimator.Factory();
    BoundedOutOfOrdernessWatermarkEstimator watermarkEstimator = (BoundedOutOfOrdernessWatermarkEstimator) factory.create(cfg, idlePolicyFactory);
    assertEquals(OUT_OF_ORDERNESS, watermarkEstimator.getMaxOutOfOrderness());
    verify(idlePolicyFactory, times(1)).create(cfg);
}
Also used : WatermarkIdlePolicyFactory(cz.o2.proxima.time.WatermarkIdlePolicyFactory) WatermarkEstimatorFactory(cz.o2.proxima.time.WatermarkEstimatorFactory) HashMap(java.util.HashMap) WatermarkIdlePolicy(cz.o2.proxima.time.WatermarkIdlePolicy) WatermarkIdlePolicyFactory(cz.o2.proxima.time.WatermarkIdlePolicyFactory) ConfigFactory(com.typesafe.config.ConfigFactory) WatermarkEstimatorFactory(cz.o2.proxima.time.WatermarkEstimatorFactory) Test(org.junit.Test)

Example 3 with BoundedOutOfOrdernessWatermarkEstimator

use of cz.o2.proxima.direct.time.BoundedOutOfOrdernessWatermarkEstimator in project proxima-platform by O2-Czech-Republic.

the class KafkaWatermarkConfigurationTest method testConfigureDefault.

@Test
public void testConfigureDefault() {
    // Check backward compatibility with legacy behaviour
    Map<String, Object> cfg = new HashMap<String, Object>() {

        {
            put("timestamp-skew", 10L);
        }
    };
    KafkaWatermarkConfiguration configuration = new KafkaWatermarkConfiguration(cfg);
    WatermarkIdlePolicyFactory policyFactory = configuration.getWatermarkIdlePolicyFactory();
    BoundedOutOfOrdernessWatermarkEstimator estimator = (BoundedOutOfOrdernessWatermarkEstimator) configuration.getWatermarkEstimatorFactory().create(cfg, policyFactory);
    SkewedProcessingTimeIdlePolicy policy = (SkewedProcessingTimeIdlePolicy) policyFactory.create(cfg);
    assertNotNull(estimator);
    assertNotNull(policy);
    assertEquals(0L, estimator.getMaxOutOfOrderness());
    assertEquals(Watermarks.MIN_WATERMARK, estimator.getMinWatermark());
    assertEquals(10L, policy.getTimestampSkew());
}
Also used : WatermarkIdlePolicyFactory(cz.o2.proxima.time.WatermarkIdlePolicyFactory) HashMap(java.util.HashMap) SkewedProcessingTimeIdlePolicy(cz.o2.proxima.direct.time.SkewedProcessingTimeIdlePolicy) BoundedOutOfOrdernessWatermarkEstimator(cz.o2.proxima.direct.time.BoundedOutOfOrdernessWatermarkEstimator) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 WatermarkIdlePolicy (cz.o2.proxima.time.WatermarkIdlePolicy)2 WatermarkIdlePolicyFactory (cz.o2.proxima.time.WatermarkIdlePolicyFactory)2 HashMap (java.util.HashMap)2 ConfigFactory (com.typesafe.config.ConfigFactory)1 BoundedOutOfOrdernessWatermarkEstimator (cz.o2.proxima.direct.time.BoundedOutOfOrdernessWatermarkEstimator)1 SkewedProcessingTimeIdlePolicy (cz.o2.proxima.direct.time.SkewedProcessingTimeIdlePolicy)1 StreamElement (cz.o2.proxima.storage.StreamElement)1 WatermarkEstimatorFactory (cz.o2.proxima.time.WatermarkEstimatorFactory)1