Search in sources :

Example 11 with UniformIntTupleGenerator

use of org.apache.flink.runtime.operators.testutils.UniformIntTupleGenerator in project flink by apache.

the class AbstractOuterJoinTaskTest method testSortSecondOuterJoinTask.

@Test
public void testSortSecondOuterJoinTask() throws Exception {
    int keyCnt1 = 20;
    int valCnt1 = 20;
    int keyCnt2 = 20;
    int valCnt2 = 20;
    setOutput(this.outList, this.serializer);
    addDriverComparator(this.comparator1);
    addDriverComparator(this.comparator2);
    getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
    getTaskConfig().setDriverStrategy(this.getSortDriverStrategy());
    getTaskConfig().setRelativeMemoryDriver(this.bnljn_frac);
    setNumFileHandlesForSort(4);
    final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();
    addInput(new UniformIntTupleGenerator(keyCnt1, valCnt1, true), this.serializer);
    addInputSorted(new UniformIntTupleGenerator(keyCnt2, valCnt2, false), this.serializer, this.comparator2.duplicate());
    testDriver(testTask, MockJoinStub.class);
    final int expCnt = calculateExpectedCount(keyCnt1, valCnt1, keyCnt2, valCnt2);
    Assert.assertTrue("Result set size was " + this.outList.size() + ". Expected was " + expCnt, this.outList.size() == expCnt);
    this.outList.clear();
}
Also used : RuntimePairComparatorFactory(org.apache.flink.api.java.typeutils.runtime.RuntimePairComparatorFactory) UniformIntTupleGenerator(org.apache.flink.runtime.operators.testutils.UniformIntTupleGenerator) Tuple2(org.apache.flink.api.java.tuple.Tuple2) Test(org.junit.Test)

Example 12 with UniformIntTupleGenerator

use of org.apache.flink.runtime.operators.testutils.UniformIntTupleGenerator in project flink by apache.

the class AbstractOuterJoinTaskTest method testFailingOuterJoinTask.

@Test(expected = ExpectedTestException.class)
public void testFailingOuterJoinTask() throws Exception {
    int keyCnt1 = 20;
    int valCnt1 = 20;
    int keyCnt2 = 20;
    int valCnt2 = 20;
    setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
    addDriverComparator(this.comparator1);
    addDriverComparator(this.comparator2);
    getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
    getTaskConfig().setDriverStrategy(this.getSortDriverStrategy());
    getTaskConfig().setRelativeMemoryDriver(this.bnljn_frac);
    setNumFileHandlesForSort(4);
    final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();
    addInput(new UniformIntTupleGenerator(keyCnt1, valCnt1, true), this.serializer);
    addInput(new UniformIntTupleGenerator(keyCnt2, valCnt2, true), this.serializer);
    testDriver(testTask, MockFailingJoinStub.class);
}
Also used : RuntimePairComparatorFactory(org.apache.flink.api.java.typeutils.runtime.RuntimePairComparatorFactory) UniformIntTupleGenerator(org.apache.flink.runtime.operators.testutils.UniformIntTupleGenerator) Tuple2(org.apache.flink.api.java.tuple.Tuple2) Test(org.junit.Test)

Example 13 with UniformIntTupleGenerator

use of org.apache.flink.runtime.operators.testutils.UniformIntTupleGenerator in project flink by apache.

the class CombineTaskTest method testFailingCombineTask.

@Test
public void testFailingCombineTask() {
    try {
        int keyCnt = 100;
        int valCnt = 20;
        setInput(new UniformIntTupleGenerator(keyCnt, valCnt, false), serializer);
        addDriverComparator(this.comparator);
        addDriverComparator(this.comparator);
        setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
        getTaskConfig().setDriverStrategy(DriverStrategy.SORTED_GROUP_COMBINE);
        getTaskConfig().setRelativeMemoryDriver(combine_frac);
        getTaskConfig().setFilehandlesDriver(2);
        final GroupReduceCombineDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = new GroupReduceCombineDriver<>();
        try {
            testDriver(testTask, MockFailingCombiningReduceStub.class);
            fail("Exception not forwarded.");
        } catch (ExpectedTestException etex) {
        // good!
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : UniformIntTupleGenerator(org.apache.flink.runtime.operators.testutils.UniformIntTupleGenerator) ExpectedTestException(org.apache.flink.runtime.operators.testutils.ExpectedTestException) Tuple2(org.apache.flink.api.java.tuple.Tuple2) ExpectedTestException(org.apache.flink.runtime.operators.testutils.ExpectedTestException) Test(org.junit.Test)

Example 14 with UniformIntTupleGenerator

use of org.apache.flink.runtime.operators.testutils.UniformIntTupleGenerator in project flink by apache.

the class RightOuterJoinTaskTest method testFailingHashRightOuterJoinTask.

@Test(expected = ExpectedTestException.class)
public void testFailingHashRightOuterJoinTask() throws Exception {
    int keyCnt1 = 20;
    int valCnt1 = 20;
    int keyCnt2 = 20;
    int valCnt2 = 20;
    setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
    addDriverComparator(this.comparator1);
    addDriverComparator(this.comparator2);
    getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
    getTaskConfig().setDriverStrategy(DriverStrategy.RIGHT_HYBRIDHASH_BUILD_FIRST);
    getTaskConfig().setRelativeMemoryDriver(this.hash_frac);
    setNumFileHandlesForSort(4);
    final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();
    addInput(new UniformIntTupleGenerator(keyCnt1, valCnt1, true), this.serializer);
    addInput(new UniformIntTupleGenerator(keyCnt2, valCnt2, true), this.serializer);
    testDriver(testTask, MockFailingJoinStub.class);
}
Also used : RuntimePairComparatorFactory(org.apache.flink.api.java.typeutils.runtime.RuntimePairComparatorFactory) UniformIntTupleGenerator(org.apache.flink.runtime.operators.testutils.UniformIntTupleGenerator) Tuple2(org.apache.flink.api.java.tuple.Tuple2) Test(org.junit.Test)

Example 15 with UniformIntTupleGenerator

use of org.apache.flink.runtime.operators.testutils.UniformIntTupleGenerator in project flink by apache.

the class RightOuterJoinTaskTest method testCancelRightOuterJoinTaskWhileProbing.

@Test
public void testCancelRightOuterJoinTaskWhileProbing() throws Exception {
    setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
    addDriverComparator(this.comparator1);
    addDriverComparator(this.comparator2);
    getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
    getTaskConfig().setDriverStrategy(DriverStrategy.RIGHT_HYBRIDHASH_BUILD_FIRST);
    getTaskConfig().setRelativeMemoryDriver(this.hash_frac);
    final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();
    addInput(new UniformIntTupleGenerator(1, 1, true), this.serializer);
    addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);
    final AtomicReference<Throwable> error = new AtomicReference<>();
    final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileSort1()") {

        @Override
        public void run() {
            try {
                testDriver(testTask, MockJoinStub.class);
            } catch (Throwable t) {
                error.set(t);
            }
        }
    };
    taskRunner.start();
    Thread.sleep(1000);
    cancel();
    taskRunner.join(60000);
    assertFalse("Task thread did not finish within 60 seconds", taskRunner.isAlive());
    final Throwable taskError = error.get();
    if (taskError != null) {
        fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
    }
}
Also used : RuntimePairComparatorFactory(org.apache.flink.api.java.typeutils.runtime.RuntimePairComparatorFactory) UniformIntTupleGenerator(org.apache.flink.runtime.operators.testutils.UniformIntTupleGenerator) Tuple2(org.apache.flink.api.java.tuple.Tuple2) AtomicReference(java.util.concurrent.atomic.AtomicReference) InfiniteIntTupleIterator(org.apache.flink.runtime.operators.testutils.InfiniteIntTupleIterator) Test(org.junit.Test)

Aggregations

UniformIntTupleGenerator (org.apache.flink.runtime.operators.testutils.UniformIntTupleGenerator)21 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)20 RuntimePairComparatorFactory (org.apache.flink.api.java.typeutils.runtime.RuntimePairComparatorFactory)16 Test (org.junit.Test)16 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 InfiniteIntTupleIterator (org.apache.flink.runtime.operators.testutils.InfiniteIntTupleIterator)4 ExpectedTestException (org.apache.flink.runtime.operators.testutils.ExpectedTestException)2 IOException (java.io.IOException)1 Random (java.util.Random)1 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)1 Tuple3 (org.apache.flink.api.java.tuple.Tuple3)1 UnionIterator (org.apache.flink.runtime.operators.testutils.UnionIterator)1 UniformIntTupleGeneratorInputFormat (org.apache.flink.test.util.UniformIntTupleGeneratorInputFormat)1