Search in sources :

Example 51 with InvalidProgramException

use of org.apache.flink.api.common.InvalidProgramException in project flink-mirror by flink-ci.

the class GroupingPojoTranslationTest method testCustomPartitioningTupleInvalidTypeSorted.

@Test
public void testCustomPartitioningTupleInvalidTypeSorted() {
    try {
        ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
        DataSet<Pojo3> data = env.fromElements(new Pojo3()).rebalance().setParallelism(4);
        try {
            data.groupBy("a").sortGroup("b", Order.ASCENDING).withPartitioner(new TestPartitionerLong());
            fail("Should throw an exception");
        } catch (InvalidProgramException e) {
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) Test(org.junit.Test)

Example 52 with InvalidProgramException

use of org.apache.flink.api.common.InvalidProgramException in project flink-mirror by flink-ci.

the class GroupingPojoTranslationTest method testCustomPartitioningTupleRejectCompositeKey.

@Test
public void testCustomPartitioningTupleRejectCompositeKey() {
    try {
        ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
        DataSet<Pojo2> data = env.fromElements(new Pojo2()).rebalance().setParallelism(4);
        try {
            data.groupBy("a", "b").withPartitioner(new TestPartitionerInt());
            fail("Should throw an exception");
        } catch (InvalidProgramException e) {
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) Test(org.junit.Test)

Example 53 with InvalidProgramException

use of org.apache.flink.api.common.InvalidProgramException in project flink-mirror by flink-ci.

the class JoinCustomPartitioningTest method testJoinWithKeySelectorsWrongType.

@Test
public void testJoinWithKeySelectorsWrongType() {
    try {
        final Partitioner<Long> partitioner = new TestPartitionerLong();
        ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
        DataSet<Pojo2> input1 = env.fromElements(new Pojo2());
        DataSet<Pojo3> input2 = env.fromElements(new Pojo3());
        try {
            input1.join(input2, JoinHint.REPARTITION_HASH_FIRST).where(new Pojo2KeySelector()).equalTo(new Pojo3KeySelector()).withPartitioner(partitioner);
            fail("should throw an exception");
        } catch (InvalidProgramException e) {
        // expected
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) Test(org.junit.Test)

Example 54 with InvalidProgramException

use of org.apache.flink.api.common.InvalidProgramException in project flink-mirror by flink-ci.

the class DeltaIterationTranslationTest method testRejectWhenSolutionSetKeysDontMatchJoin.

@Test
public void testRejectWhenSolutionSetKeysDontMatchJoin() {
    try {
        ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
        @SuppressWarnings("unchecked") DataSet<Tuple3<Double, Long, String>> initialSolutionSet = env.fromElements(new Tuple3<Double, Long, String>(3.44, 5L, "abc"));
        @SuppressWarnings("unchecked") DataSet<Tuple2<Double, String>> initialWorkSet = env.fromElements(new Tuple2<Double, String>(1.23, "abc"));
        DeltaIteration<Tuple3<Double, Long, String>, Tuple2<Double, String>> iteration = initialSolutionSet.iterateDelta(initialWorkSet, 10, 1);
        try {
            iteration.getWorkset().join(iteration.getSolutionSet()).where(1).equalTo(2);
            fail("Accepted invalid program.");
        } catch (InvalidProgramException e) {
        // all good!
        }
        try {
            iteration.getSolutionSet().join(iteration.getWorkset()).where(2).equalTo(1);
            fail("Accepted invalid program.");
        } catch (InvalidProgramException e) {
        // all good!
        }
    } catch (Exception e) {
        System.err.println(e.getMessage());
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) Tuple2(org.apache.flink.api.java.tuple.Tuple2) Tuple3(org.apache.flink.api.java.tuple.Tuple3) Test(org.junit.Test)

Example 55 with InvalidProgramException

use of org.apache.flink.api.common.InvalidProgramException in project flink-mirror by flink-ci.

the class ClientTest method tryLocalExecution.

/**
 * This test verifies that the local execution environment cannot be created when the program is
 * submitted through a client.
 */
@Test
public void tryLocalExecution() throws ProgramInvocationException, ProgramMissingJobException {
    PackagedProgram packagedProgramMock = mock(PackagedProgram.class);
    when(packagedProgramMock.getUserCodeClassLoader()).thenReturn(packagedProgramMock.getClass().getClassLoader());
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            ExecutionEnvironment.createLocalEnvironment();
            return null;
        }
    }).when(packagedProgramMock).invokeInteractiveModeForExecution();
    try {
        final ClusterClient<?> client = new MiniClusterClient(new Configuration(), MINI_CLUSTER_RESOURCE.getMiniCluster());
        final Configuration configuration = fromPackagedProgram(packagedProgramMock, 1, true);
        ClientUtils.executeProgram(new TestExecutorServiceLoader(client, plan), configuration, packagedProgramMock, false, false);
        fail("Creating the local execution environment should not be possible");
    } catch (InvalidProgramException e) {
    // that is what we want
    }
}
Also used : MiniClusterResourceConfiguration(org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration) Configuration(org.apache.flink.configuration.Configuration) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Test(org.junit.Test)

Aggregations

InvalidProgramException (org.apache.flink.api.common.InvalidProgramException)190 Test (org.junit.Test)108 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)102 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)42 Tuple3 (org.apache.flink.api.java.tuple.Tuple3)31 ArrayList (java.util.ArrayList)29 List (java.util.List)29 HashMap (java.util.HashMap)23 Map (java.util.Map)20 IOException (java.io.IOException)17 Tuple5 (org.apache.flink.api.java.tuple.Tuple5)16 TaskInfo (org.apache.flink.api.common.TaskInfo)15 RuntimeUDFContext (org.apache.flink.api.common.functions.util.RuntimeUDFContext)15 Ordering (org.apache.flink.api.common.operators.Ordering)12 LinkedHashSet (java.util.LinkedHashSet)10 Aggregator (org.apache.flink.api.common.aggregators.Aggregator)10 ConvergenceCriterion (org.apache.flink.api.common.aggregators.ConvergenceCriterion)10 Configuration (org.apache.flink.configuration.Configuration)10 Value (org.apache.flink.types.Value)10 InvalidTypesException (org.apache.flink.api.common.functions.InvalidTypesException)8