Search in sources :

Example 1 with ResultPartitionAvailabilityChecker

use of org.apache.flink.runtime.executiongraph.failover.flip1.ResultPartitionAvailabilityChecker in project flink by apache.

the class ExecutionGraphResultPartitionAvailabilityCheckerTest method testPartitionAvailabilityCheck.

@Test
public void testPartitionAvailabilityCheck() {
    final IntermediateResultPartitionID irp1ID = new IntermediateResultPartitionID();
    final IntermediateResultPartitionID irp2ID = new IntermediateResultPartitionID();
    final IntermediateResultPartitionID irp3ID = new IntermediateResultPartitionID();
    final IntermediateResultPartitionID irp4ID = new IntermediateResultPartitionID();
    final Map<IntermediateResultPartitionID, Boolean> expectedAvailability = new HashMap<IntermediateResultPartitionID, Boolean>() {

        {
            put(irp1ID, true);
            put(irp2ID, false);
            put(irp3ID, false);
            put(irp4ID, true);
        }
    };
    // let the partition tracker respect the expected availability result
    final TestingJobMasterPartitionTracker partitionTracker = new TestingJobMasterPartitionTracker();
    partitionTracker.setIsPartitionTrackedFunction(rpID -> expectedAvailability.get(rpID.getPartitionId()));
    // the execution attempt ID should make no difference in this case
    final Function<IntermediateResultPartitionID, ResultPartitionID> partitionIDMapper = intermediateResultPartitionID -> new ResultPartitionID(intermediateResultPartitionID, new ExecutionAttemptID());
    final ResultPartitionAvailabilityChecker resultPartitionAvailabilityChecker = new ExecutionGraphResultPartitionAvailabilityChecker(partitionIDMapper, partitionTracker);
    for (IntermediateResultPartitionID irpID : expectedAvailability.keySet()) {
        assertEquals(expectedAvailability.get(irpID), resultPartitionAvailabilityChecker.isAvailable(irpID));
    }
}
Also used : ResultPartitionAvailabilityChecker(org.apache.flink.runtime.executiongraph.failover.flip1.ResultPartitionAvailabilityChecker) TestingJobMasterPartitionTracker(org.apache.flink.runtime.io.network.partition.TestingJobMasterPartitionTracker) IntermediateResultPartitionID(org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID) ResultPartitionID(org.apache.flink.runtime.io.network.partition.ResultPartitionID) Map(java.util.Map) TestLogger(org.apache.flink.util.TestLogger) Test(org.junit.Test) HashMap(java.util.HashMap) Function(java.util.function.Function) Assert.assertEquals(org.junit.Assert.assertEquals) HashMap(java.util.HashMap) TestingJobMasterPartitionTracker(org.apache.flink.runtime.io.network.partition.TestingJobMasterPartitionTracker) IntermediateResultPartitionID(org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID) ResultPartitionID(org.apache.flink.runtime.io.network.partition.ResultPartitionID) ResultPartitionAvailabilityChecker(org.apache.flink.runtime.executiongraph.failover.flip1.ResultPartitionAvailabilityChecker) IntermediateResultPartitionID(org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 Function (java.util.function.Function)1 ResultPartitionAvailabilityChecker (org.apache.flink.runtime.executiongraph.failover.flip1.ResultPartitionAvailabilityChecker)1 ResultPartitionID (org.apache.flink.runtime.io.network.partition.ResultPartitionID)1 TestingJobMasterPartitionTracker (org.apache.flink.runtime.io.network.partition.TestingJobMasterPartitionTracker)1 IntermediateResultPartitionID (org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID)1 TestLogger (org.apache.flink.util.TestLogger)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Test (org.junit.Test)1