Search in sources :

Example 1 with WatermarkAlignmentParams

use of org.apache.flink.api.common.eventtime.WatermarkAlignmentParams in project flink by apache.

the class SourceCoordinatorAlignmentTest method testWatermarkAlignmentWithTwoGroups.

@Test
public void testWatermarkAlignmentWithTwoGroups() throws Exception {
    try (AutoCloseableRegistry closeableRegistry = new AutoCloseableRegistry()) {
        long maxDrift = 1000L;
        SourceCoordinator<?, ?> sourceCoordinator1 = getAndStartNewSourceCoordinator(new WatermarkAlignmentParams(maxDrift, "group1", Long.MAX_VALUE), closeableRegistry);
        SourceCoordinator<?, ?> sourceCoordinator2 = getAndStartNewSourceCoordinator(new WatermarkAlignmentParams(maxDrift, "group2", Long.MAX_VALUE), closeableRegistry);
        int subtask0 = 0;
        int subtask1 = 1;
        reportWatermarkEvent(sourceCoordinator1, subtask0, 42);
        assertLatestWatermarkAlignmentEvent(subtask0, 1042);
        reportWatermarkEvent(sourceCoordinator2, subtask1, 44);
        assertLatestWatermarkAlignmentEvent(subtask0, 1042);
        assertLatestWatermarkAlignmentEvent(subtask1, 1044);
        reportWatermarkEvent(sourceCoordinator1, subtask0, 5000);
        assertLatestWatermarkAlignmentEvent(subtask0, 6000);
        assertLatestWatermarkAlignmentEvent(subtask1, 1044);
    }
}
Also used : AutoCloseableRegistry(org.apache.flink.core.fs.AutoCloseableRegistry) WatermarkAlignmentParams(org.apache.flink.api.common.eventtime.WatermarkAlignmentParams) Test(org.junit.Test)

Example 2 with WatermarkAlignmentParams

use of org.apache.flink.api.common.eventtime.WatermarkAlignmentParams in project flink by apache.

the class SourceCoordinatorAlignmentTest method testWatermarkAlignment.

@Test
public void testWatermarkAlignment() throws Exception {
    try (AutoCloseableRegistry closeableRegistry = new AutoCloseableRegistry()) {
        SourceCoordinator<?, ?> sourceCoordinator1 = getAndStartNewSourceCoordinator(new WatermarkAlignmentParams(1000L, "group1", Long.MAX_VALUE), closeableRegistry);
        int subtask0 = 0;
        int subtask1 = 1;
        reportWatermarkEvent(sourceCoordinator1, subtask0, 42);
        assertLatestWatermarkAlignmentEvent(subtask0, 1042);
        reportWatermarkEvent(sourceCoordinator1, subtask1, 44);
        assertLatestWatermarkAlignmentEvent(subtask0, 1042);
        assertLatestWatermarkAlignmentEvent(subtask1, 1042);
        reportWatermarkEvent(sourceCoordinator1, subtask0, 5000);
        assertLatestWatermarkAlignmentEvent(subtask0, 1044);
        assertLatestWatermarkAlignmentEvent(subtask1, 1044);
    }
}
Also used : AutoCloseableRegistry(org.apache.flink.core.fs.AutoCloseableRegistry) WatermarkAlignmentParams(org.apache.flink.api.common.eventtime.WatermarkAlignmentParams) Test(org.junit.Test)

Example 3 with WatermarkAlignmentParams

use of org.apache.flink.api.common.eventtime.WatermarkAlignmentParams in project flink by apache.

the class SourceCoordinatorAlignmentTest method testWatermarkAlignmentWithIdleness.

@Test
public void testWatermarkAlignmentWithIdleness() throws Exception {
    try (AutoCloseableRegistry closeableRegistry = new AutoCloseableRegistry()) {
        SourceCoordinator<?, ?> sourceCoordinator1 = getAndStartNewSourceCoordinator(new WatermarkAlignmentParams(1000L, "group1", Long.MAX_VALUE), closeableRegistry);
        int subtask0 = 0;
        int subtask1 = 1;
        reportWatermarkEvent(sourceCoordinator1, subtask0, 42);
        assertLatestWatermarkAlignmentEvent(subtask0, 1042);
        reportWatermarkEvent(sourceCoordinator1, subtask1, 44);
        assertLatestWatermarkAlignmentEvent(subtask0, 1042);
        assertLatestWatermarkAlignmentEvent(subtask1, 1042);
        // subtask0 becomes idle
        reportWatermarkEvent(sourceCoordinator1, subtask0, Long.MAX_VALUE);
        assertLatestWatermarkAlignmentEvent(subtask0, 1044);
        assertLatestWatermarkAlignmentEvent(subtask1, 1044);
        // subtask0 becomes active again
        reportWatermarkEvent(sourceCoordinator1, subtask0, 42);
        assertLatestWatermarkAlignmentEvent(subtask0, 1042);
        assertLatestWatermarkAlignmentEvent(subtask1, 1042);
    }
}
Also used : AutoCloseableRegistry(org.apache.flink.core.fs.AutoCloseableRegistry) WatermarkAlignmentParams(org.apache.flink.api.common.eventtime.WatermarkAlignmentParams) Test(org.junit.Test)

Aggregations

WatermarkAlignmentParams (org.apache.flink.api.common.eventtime.WatermarkAlignmentParams)3 AutoCloseableRegistry (org.apache.flink.core.fs.AutoCloseableRegistry)3 Test (org.junit.Test)3