org.apache.flink.runtime.operators.DataSourceTask Java Examples

The following examples show how to use org.apache.flink.runtime.operators.DataSourceTask. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JobGraphGenerator.java    From flink with Apache License 2.0 6 votes vote down vote up
private JobVertex createDataSourceVertex(SourcePlanNode node) throws CompilerException {
	final InputOutputFormatVertex vertex = new InputOutputFormatVertex(node.getNodeName());
	final TaskConfig config = new TaskConfig(vertex.getConfiguration());

	final OperatorID operatorID = new OperatorID();

	vertex.setResources(node.getMinResources(), node.getPreferredResources());
	vertex.setInvokableClass(DataSourceTask.class);
	vertex.setFormatDescription(operatorID, getDescriptionForUserCode(node.getProgramOperator().getUserCodeWrapper()));

	// set user code
	new InputOutputFormatContainer(Thread.currentThread().getContextClassLoader())
		.addInputFormat(operatorID, (UserCodeWrapper<? extends InputFormat<?, ?>>) node.getProgramOperator().getUserCodeWrapper())
		.addParameters(operatorID, node.getProgramOperator().getParameters())
		.write(config);

	config.setOutputSerializer(node.getSerializer());
	return vertex;
}
 
Example #2
Source File: JobGraphGenerator.java    From flink with Apache License 2.0 6 votes vote down vote up
private JobVertex createDataSourceVertex(SourcePlanNode node) throws CompilerException {
	final InputOutputFormatVertex vertex = new InputOutputFormatVertex(node.getNodeName());
	final TaskConfig config = new TaskConfig(vertex.getConfiguration());

	final OperatorID operatorID = new OperatorID();

	vertex.setResources(node.getMinResources(), node.getPreferredResources());
	vertex.setInvokableClass(DataSourceTask.class);
	vertex.setFormatDescription(operatorID, getDescriptionForUserCode(node.getProgramOperator().getUserCodeWrapper()));

	// set user code
	new InputOutputFormatContainer(Thread.currentThread().getContextClassLoader())
		.addInputFormat(operatorID, (UserCodeWrapper<? extends InputFormat<?, ?>>) node.getProgramOperator().getUserCodeWrapper())
		.addParameters(operatorID, node.getProgramOperator().getParameters())
		.write(config);

	config.setOutputSerializer(node.getSerializer());
	return vertex;
}
 
Example #3
Source File: JobGraphGenerator.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private InputFormatVertex createDataSourceVertex(SourcePlanNode node) throws CompilerException {
	final InputFormatVertex vertex = new InputFormatVertex(node.getNodeName());
	final TaskConfig config = new TaskConfig(vertex.getConfiguration());

	vertex.setResources(node.getMinResources(), node.getPreferredResources());
	vertex.setInvokableClass(DataSourceTask.class);
	vertex.setFormatDescription(getDescriptionForUserCode(node.getProgramOperator().getUserCodeWrapper()));

	// set user code
	config.setStubWrapper(node.getProgramOperator().getUserCodeWrapper());
	config.setStubParameters(node.getProgramOperator().getParameters());

	config.setOutputSerializer(node.getSerializer());
	return vertex;
}
 
Example #4
Source File: ChainTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@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.");
	}
}
 
Example #5
Source File: MockRecordWriter.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public MockRecordWriter(DataSourceTask<?> inputBase, Class<StreamRecord<Tuple1<Integer>>> outputClass) {
	super(inputBase.getEnvironment().getWriter(0));
}