本文整理匯總了Java中org.apache.flink.runtime.operators.util.TaskConfig.setStubWrapper方法的典型用法代碼示例。如果您正苦於以下問題:Java TaskConfig.setStubWrapper方法的具體用法?Java TaskConfig.setStubWrapper怎麽用?Java TaskConfig.setStubWrapper使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.flink.runtime.operators.util.TaskConfig
的用法示例。
在下文中一共展示了TaskConfig.setStubWrapper方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: registerFileInputTask
import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的package包/類
public void registerFileInputTask(AbstractInvokable inTask,
Class<? extends DelimitedInputFormat<Record>> stubClass, String inPath, String delimiter)
{
DelimitedInputFormat<Record> format;
try {
format = stubClass.newInstance();
}
catch (Throwable t) {
throw new RuntimeException("Could not instantiate test input format.", t);
}
format.setFilePath(inPath);
format.setDelimiter(delimiter);
TaskConfig dsConfig = new TaskConfig(this.mockEnv.getTaskConfiguration());
dsConfig.setStubWrapper(new UserCodeObjectWrapper<>(format));
this.inputSplitProvider.addInputSplits(inPath, 5);
}
示例2: createOutput
import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的package包/類
private static OutputFormatVertex createOutput(JobGraph jobGraph, String resultPath, int numSubTasks,
TypeSerializerFactory<?> serializer) {
OutputFormatVertex output = JobGraphUtils.createFileOutput(jobGraph, "Final Output", numSubTasks);
TaskConfig outputConfig = new TaskConfig(output.getConfiguration());
{
outputConfig.addInputToGroup(0);
outputConfig.setInputSerializer(serializer, 0);
outputConfig.setStubWrapper(new UserCodeClassWrapper<CsvOutputFormat>(CsvOutputFormat.class));
outputConfig.setStubParameter(FileOutputFormat.FILE_PARAMETER_KEY, resultPath);
Configuration outputUserConfig = outputConfig.getStubParameters();
outputUserConfig.setString(CsvOutputFormat.RECORD_DELIMITER_PARAMETER, "\n");
outputUserConfig.setString(CsvOutputFormat.FIELD_DELIMITER_PARAMETER, " ");
outputUserConfig.setClass(CsvOutputFormat.FIELD_TYPE_PARAMETER_PREFIX + 0, LongValue.class);
outputUserConfig.setInteger(CsvOutputFormat.RECORD_POSITION_PARAMETER_PREFIX + 0, 0);
outputUserConfig.setClass(CsvOutputFormat.FIELD_TYPE_PARAMETER_PREFIX + 1, LongValue.class);
outputUserConfig.setInteger(CsvOutputFormat.RECORD_POSITION_PARAMETER_PREFIX + 1, 1);
outputUserConfig.setInteger(CsvOutputFormat.NUM_FIELDS_PARAMETER, 2);
}
return output;
}
示例3: createMapper
import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的package包/類
private static AbstractJobVertex createMapper(JobGraph jobGraph, int numSubTasks, TypeSerializerFactory<?> serializer) {
AbstractJobVertex pointsInput = JobGraphUtils.createTask(RegularPactTask.class, "Map[DotProducts]", jobGraph, numSubTasks);
{
TaskConfig taskConfig = new TaskConfig(pointsInput.getConfiguration());
taskConfig.setStubWrapper(new UserCodeClassWrapper<DotProducts>(DotProducts.class));
taskConfig.addOutputShipStrategy(ShipStrategyType.FORWARD);
taskConfig.setOutputSerializer(serializer);
taskConfig.setDriver(CollectorMapDriver.class);
taskConfig.setDriverStrategy(DriverStrategy.COLLECTOR_MAP);
taskConfig.addInputToGroup(0);
taskConfig.setInputLocalStrategy(0, LocalStrategy.NONE);
taskConfig.setInputSerializer(serializer, 0);
taskConfig.setBroadcastInputName("models", 0);
taskConfig.addBroadcastInputToGroup(0);
taskConfig.setBroadcastInputSerializer(serializer, 0);
}
return pointsInput;
}
示例4: createOutput
import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的package包/類
private static OutputFormatVertex createOutput(JobGraph jobGraph, String resultPath, int numSubTasks, TypeSerializerFactory<?> serializer) {
OutputFormatVertex output = JobGraphUtils.createFileOutput(jobGraph, "Output", numSubTasks);
{
TaskConfig taskConfig = new TaskConfig(output.getConfiguration());
taskConfig.addInputToGroup(0);
taskConfig.setInputSerializer(serializer, 0);
@SuppressWarnings("unchecked")
CsvOutputFormat outFormat = new CsvOutputFormat("\n", " ", LongValue.class, LongValue.class, LongValue.class);
outFormat.setOutputFilePath(new Path(resultPath));
taskConfig.setStubWrapper(new UserCodeObjectWrapper<CsvOutputFormat>(outFormat));
}
return output;
}
示例5: createPointsInput
import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的package包/類
private static InputFormatVertex createPointsInput(JobGraph jobGraph, String pointsPath, int numSubTasks, TypeSerializerFactory<?> serializer) {
@SuppressWarnings("unchecked")
CsvInputFormat pointsInFormat = new CsvInputFormat('|', IntValue.class, DoubleValue.class, DoubleValue.class, DoubleValue.class);
InputFormatVertex pointsInput = JobGraphUtils.createInput(pointsInFormat, pointsPath, "[Points]", jobGraph, numSubTasks);
{
TaskConfig taskConfig = new TaskConfig(pointsInput.getConfiguration());
taskConfig.addOutputShipStrategy(ShipStrategyType.FORWARD);
taskConfig.setOutputSerializer(serializer);
TaskConfig chainedMapper = new TaskConfig(new Configuration());
chainedMapper.setDriverStrategy(DriverStrategy.COLLECTOR_MAP);
chainedMapper.setStubWrapper(new UserCodeObjectWrapper<PointBuilder>(new PointBuilder()));
chainedMapper.addOutputShipStrategy(ShipStrategyType.FORWARD);
chainedMapper.setOutputSerializer(serializer);
taskConfig.addChainedTask(ChainedCollectorMapDriver.class, chainedMapper, "Build points");
}
return pointsInput;
}
示例6: createCentersInput
import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的package包/類
private static InputFormatVertex createCentersInput(JobGraph jobGraph, String centersPath, int numSubTasks, TypeSerializerFactory<?> serializer) {
@SuppressWarnings("unchecked")
CsvInputFormat modelsInFormat = new CsvInputFormat('|', IntValue.class, DoubleValue.class, DoubleValue.class, DoubleValue.class);
InputFormatVertex modelsInput = JobGraphUtils.createInput(modelsInFormat, centersPath, "[Models]", jobGraph, numSubTasks);
{
TaskConfig taskConfig = new TaskConfig(modelsInput.getConfiguration());
taskConfig.addOutputShipStrategy(ShipStrategyType.FORWARD);
taskConfig.setOutputSerializer(serializer);
TaskConfig chainedMapper = new TaskConfig(new Configuration());
chainedMapper.setDriverStrategy(DriverStrategy.COLLECTOR_MAP);
chainedMapper.setStubWrapper(new UserCodeObjectWrapper<PointBuilder>(new PointBuilder()));
chainedMapper.addOutputShipStrategy(ShipStrategyType.FORWARD);
chainedMapper.setOutputSerializer(serializer);
taskConfig.addChainedTask(ChainedCollectorMapDriver.class, chainedMapper, "Build centers");
}
return modelsInput;
}
示例7: createOutput
import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的package包/類
private static OutputFormatVertex createOutput(JobGraph jobGraph, String resultPath, int numSubTasks, TypeSerializerFactory<?> serializer) {
OutputFormatVertex output = JobGraphUtils.createFileOutput(jobGraph, "Output", numSubTasks);
{
TaskConfig taskConfig = new TaskConfig(output.getConfiguration());
taskConfig.addInputToGroup(0);
taskConfig.setInputSerializer(serializer, 0);
PointOutFormat outFormat = new PointOutFormat();
outFormat.setOutputFilePath(new Path(resultPath));
taskConfig.setStubWrapper(new UserCodeObjectWrapper<PointOutFormat>(outFormat));
}
return output;
}
示例8: registerFileInputTask
import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的package包/類
public void registerFileInputTask(AbstractInvokable inTask,
Class<? extends DelimitedInputFormat> stubClass, String inPath, String delimiter)
{
DelimitedInputFormat format;
try {
format = stubClass.newInstance();
}
catch (Throwable t) {
throw new RuntimeException("Could not instantiate test input format.", t);
}
format.setFilePath(inPath);
format.setDelimiter(delimiter);
TaskConfig dsConfig = new TaskConfig(this.mockEnv.getTaskConfiguration());
dsConfig.setStubWrapper(new UserCodeObjectWrapper<DelimitedInputFormat>(format));
this.inputSplitProvider.addInputSplits(inPath, 5);
inTask.setEnvironment(this.mockEnv);
inTask.registerInputOutput();
}
示例9: registerTask
import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的package包/類
public void registerTask(
@SuppressWarnings("rawtypes") Class<? extends Driver> driver,
Class<? extends RichFunction> stubClass) {
final TaskConfig config = new TaskConfig(this.mockEnv.getTaskConfiguration());
config.setDriver(driver);
config.setStubWrapper(new UserCodeClassWrapper<>(stubClass));
}
示例10: registerFileOutputTask
import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的package包/類
public void registerFileOutputTask(FileOutputFormat<Record> outputFormat, String outPath) {
TaskConfig dsConfig = new TaskConfig(this.mockEnv.getTaskConfiguration());
outputFormat.setOutputFilePath(new Path(outPath));
outputFormat.setWriteMode(WriteMode.OVERWRITE);
dsConfig.setStubWrapper(new UserCodeObjectWrapper<>(outputFormat));
}
示例11: createDualInputVertex
import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的package包/類
private JobVertex createDualInputVertex(DualInputPlanNode node) throws CompilerException {
final String taskName = node.getNodeName();
final DriverStrategy ds = node.getDriverStrategy();
final JobVertex vertex = new JobVertex(taskName);
final TaskConfig config = new TaskConfig(vertex.getConfiguration());
vertex.setResources(node.getMinResources(), node.getPreferredResources());
vertex.setInvokableClass( (this.currentIteration != null && node.isOnDynamicPath()) ? IterationIntermediateTask.class : BatchTask.class);
// set user code
config.setStubWrapper(node.getProgramOperator().getUserCodeWrapper());
config.setStubParameters(node.getProgramOperator().getParameters());
// set the driver strategy
config.setDriver(ds.getDriverClass());
config.setDriverStrategy(ds);
if (node.getComparator1() != null) {
config.setDriverComparator(node.getComparator1(), 0);
}
if (node.getComparator2() != null) {
config.setDriverComparator(node.getComparator2(), 1);
}
if (node.getPairComparator() != null) {
config.setDriverPairComparator(node.getPairComparator());
}
// assign memory, file-handles, etc.
assignDriverResources(node, config);
return vertex;
}
示例12: createDataSourceVertex
import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的package包/類
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;
}
示例13: createDataSinkVertex
import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的package包/類
private JobVertex createDataSinkVertex(SinkPlanNode node) throws CompilerException {
final OutputFormatVertex vertex = new OutputFormatVertex(node.getNodeName());
final TaskConfig config = new TaskConfig(vertex.getConfiguration());
vertex.setResources(node.getMinResources(), node.getPreferredResources());
vertex.setInvokableClass(DataSinkTask.class);
vertex.setFormatDescription(getDescriptionForUserCode(node.getProgramOperator().getUserCodeWrapper()));
// set user code
config.setStubWrapper(node.getProgramOperator().getUserCodeWrapper());
config.setStubParameters(node.getProgramOperator().getParameters());
return vertex;
}
示例14: createDualInputVertex
import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的package包/類
private AbstractJobVertex createDualInputVertex(DualInputPlanNode node) throws CompilerException {
final String taskName = node.getNodeName();
final DriverStrategy ds = node.getDriverStrategy();
final AbstractJobVertex vertex = new AbstractJobVertex(taskName);
final TaskConfig config = new TaskConfig(vertex.getConfiguration());
vertex.setInvokableClass( (this.currentIteration != null && node.isOnDynamicPath()) ? IterationIntermediatePactTask.class : RegularPactTask.class);
// set user code
config.setStubWrapper(node.getPactContract().getUserCodeWrapper());
config.setStubParameters(node.getPactContract().getParameters());
// set the driver strategy
config.setDriver(ds.getDriverClass());
config.setDriverStrategy(ds);
if (node.getComparator1() != null) {
config.setDriverComparator(node.getComparator1(), 0);
}
if (node.getComparator2() != null) {
config.setDriverComparator(node.getComparator2(), 1);
}
if (node.getPairComparator() != null) {
config.setDriverPairComparator(node.getPairComparator());
}
// assign memory, file-handles, etc.
assignDriverResources(node, config);
return vertex;
}
示例15: createDataSourceVertex
import org.apache.flink.runtime.operators.util.TaskConfig; //導入方法依賴的package包/類
private InputFormatVertex createDataSourceVertex(SourcePlanNode node) throws CompilerException {
final InputFormatVertex vertex = new InputFormatVertex(node.getNodeName());
final TaskConfig config = new TaskConfig(vertex.getConfiguration());
vertex.setInvokableClass(DataSourceTask.class);
// set user code
config.setStubWrapper(node.getPactContract().getUserCodeWrapper());
config.setStubParameters(node.getPactContract().getParameters());
config.setOutputSerializer(node.getSerializer());
return vertex;
}