Search in sources :

Example 61 with TaskConfig

use of org.apache.flink.runtime.operators.util.TaskConfig in project flink by apache.

the class ChainTaskTest method testDataSourceTaskOutputInCloseMethod.

@Test
public void testDataSourceTaskOutputInCloseMethod() throws IOException {
    final int numChainedTasks = 10;
    final int keyCnt = 100;
    final int valCnt = 10;
    final File tempTestFile = new File(tempFolder.getRoot(), UUID.randomUUID().toString());
    DataSourceTaskTest.InputFilePreparator.prepareInputFile(new UniformRecordGenerator(keyCnt, valCnt, false), tempTestFile, true);
    initEnvironment(MEMORY_MANAGER_SIZE, NETWORK_BUFFER_SIZE);
    addOutput(outList);
    final DataSourceTask<Record> testTask = new DataSourceTask<>(mockEnv);
    registerFileInputTask(testTask, DataSourceTaskTest.MockInputFormat.class, tempTestFile.toURI().toString(), "\n");
    for (int i = 0; i < numChainedTasks; i++) {
        final TaskConfig taskConfig = new TaskConfig(new Configuration());
        taskConfig.addOutputShipStrategy(ShipStrategyType.FORWARD);
        taskConfig.setOutputSerializer(serFact);
        taskConfig.setStubWrapper(new UserCodeClassWrapper<>(ChainTaskTest.MockDuplicateLastValueMapFunction.class));
        getTaskConfig().addChainedTask(ChainedFlatMapDriver.class, taskConfig, "chained-" + i);
    }
    try {
        testTask.invoke();
        Assert.assertEquals(keyCnt * valCnt + numChainedTasks, outList.size());
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("Invoke method caused exception.");
    }
}
Also used : DataSourceTask(org.apache.flink.runtime.operators.DataSourceTask) Configuration(org.apache.flink.configuration.Configuration) Record(org.apache.flink.types.Record) TaskConfig(org.apache.flink.runtime.operators.util.TaskConfig) UniformRecordGenerator(org.apache.flink.runtime.operators.testutils.UniformRecordGenerator) DataSourceTaskTest(org.apache.flink.runtime.operators.DataSourceTaskTest) File(java.io.File) IOException(java.io.IOException) DataSourceTaskTest(org.apache.flink.runtime.operators.DataSourceTaskTest) Test(org.junit.Test)

Aggregations

TaskConfig (org.apache.flink.runtime.operators.util.TaskConfig)61 IOException (java.io.IOException)17 Configuration (org.apache.flink.configuration.Configuration)16 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)14 Test (org.junit.Test)14 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)13 BulkIterationPlanNode (org.apache.flink.optimizer.plan.BulkIterationPlanNode)9 BulkPartialSolutionPlanNode (org.apache.flink.optimizer.plan.BulkPartialSolutionPlanNode)9 DualInputPlanNode (org.apache.flink.optimizer.plan.DualInputPlanNode)9 IterationPlanNode (org.apache.flink.optimizer.plan.IterationPlanNode)9 NAryUnionPlanNode (org.apache.flink.optimizer.plan.NAryUnionPlanNode)9 PlanNode (org.apache.flink.optimizer.plan.PlanNode)9 SingleInputPlanNode (org.apache.flink.optimizer.plan.SingleInputPlanNode)9 SinkPlanNode (org.apache.flink.optimizer.plan.SinkPlanNode)9 SolutionSetPlanNode (org.apache.flink.optimizer.plan.SolutionSetPlanNode)9 SourcePlanNode (org.apache.flink.optimizer.plan.SourcePlanNode)9 WorksetIterationPlanNode (org.apache.flink.optimizer.plan.WorksetIterationPlanNode)9 WorksetPlanNode (org.apache.flink.optimizer.plan.WorksetPlanNode)9 CompilerException (org.apache.flink.optimizer.CompilerException)8 OperatorID (org.apache.flink.runtime.jobgraph.OperatorID)8