当前位置: 首页>>代码示例>>Java>>正文


Java InstantiationUtil.clone方法代码示例

本文整理汇总了Java中org.apache.flink.util.InstantiationUtil.clone方法的典型用法代码示例。如果您正苦于以下问题:Java InstantiationUtil.clone方法的具体用法?Java InstantiationUtil.clone怎么用?Java InstantiationUtil.clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.flink.util.InstantiationUtil的用法示例。


在下文中一共展示了InstantiationUtil.clone方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createAndStartSimpleConsumerThread

import org.apache.flink.util.InstantiationUtil; //导入方法依赖的package包/类
private SimpleConsumerThread<T> createAndStartSimpleConsumerThread(
		List<KafkaTopicPartitionState<TopicAndPartition>> seedPartitions,
		Node leader,
		ExceptionProxy errorHandler) throws IOException, ClassNotFoundException {
	// each thread needs its own copy of the deserializer, because the deserializer is
	// not necessarily thread safe
	final KeyedDeserializationSchema<T> clonedDeserializer =
			InstantiationUtil.clone(deserializer, runtimeContext.getUserCodeClassLoader());

	// seed thread with list of fetch partitions (otherwise it would shut down immediately again
	SimpleConsumerThread<T> brokerThread = new SimpleConsumerThread<>(
			this, errorHandler, kafkaConfig, leader, seedPartitions, unassignedPartitionsQueue,
			clonedDeserializer, invalidOffsetBehavior);

	brokerThread.setName(String.format("SimpleConsumer - %s - broker-%s (%s:%d)",
			runtimeContext.getTaskName(), leader.id(), leader.host(), leader.port()));
	brokerThread.setDaemon(true);
	brokerThread.start();

	LOG.info("Starting thread {}", brokerThread.getName());
	return brokerThread;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:Kafka08Fetcher.java

示例2: createAndStartSimpleConsumerThread

import org.apache.flink.util.InstantiationUtil; //导入方法依赖的package包/类
private SimpleConsumerThread<T> createAndStartSimpleConsumerThread(
		List<KafkaTopicPartitionState<TopicAndPartition>> seedPartitions,
		Node leader,
		ExceptionProxy errorHandler) throws IOException, ClassNotFoundException
{
	// each thread needs its own copy of the deserializer, because the deserializer is
	// not necessarily thread safe
	final KeyedDeserializationSchema<T> clonedDeserializer =
			InstantiationUtil.clone(deserializer, runtimeContext.getUserCodeClassLoader());

	// seed thread with list of fetch partitions (otherwise it would shut down immediately again
	SimpleConsumerThread<T> brokerThread = new SimpleConsumerThread<>(
			this, errorHandler, kafkaConfig, leader, seedPartitions, unassignedPartitionsQueue, 
			clonedDeserializer, invalidOffsetBehavior);

	brokerThread.setName(String.format("SimpleConsumer - %s - broker-%s (%s:%d)",
			runtimeContext.getTaskName(), leader.id(), leader.host(), leader.port()));
	brokerThread.setDaemon(true);
	brokerThread.start();

	LOG.info("Starting thread {}", brokerThread.getName());
	return brokerThread;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:24,代码来源:Kafka08Fetcher.java

示例3: getClonedDeserializationSchema

import org.apache.flink.util.InstantiationUtil; //导入方法依赖的package包/类
protected KinesisDeserializationSchema<T> getClonedDeserializationSchema() {
	try {
		return InstantiationUtil.clone(deserializationSchema, runtimeContext.getUserCodeClassLoader());
	} catch (IOException | ClassNotFoundException ex) {
		// this really shouldn't happen; simply wrap it around a runtime exception
		throw new RuntimeException(ex);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:9,代码来源:KinesisDataFetcher.java

示例4: configure

import org.apache.flink.util.InstantiationUtil; //导入方法依赖的package包/类
@Override
public TableSink<Row> configure(String[] fieldNames, TypeInformation<?>[] fieldTypes) {
	int[] types = outputFormat.getTypesArray();

	String sinkSchema =
		String.join(", ", IntStream.of(types).mapToObj(JDBCTypeUtil::getTypeName).collect(Collectors.toList()));
	String tableSchema =
		String.join(", ", Stream.of(fieldTypes).map(JDBCTypeUtil::getTypeName).collect(Collectors.toList()));
	String msg = String.format("Schema of output table is incompatible with JDBCAppendTableSink schema. " +
		"Table schema: [%s], sink schema: [%s]", tableSchema, sinkSchema);

	Preconditions.checkArgument(fieldTypes.length == types.length, msg);
	for (int i = 0; i < types.length; ++i) {
		Preconditions.checkArgument(
			JDBCTypeUtil.typeInformationToSqlType(fieldTypes[i]) == types[i],
			msg);
	}

	JDBCAppendTableSink copy;
	try {
		copy = new JDBCAppendTableSink(InstantiationUtil.clone(outputFormat));
	} catch (IOException | ClassNotFoundException e) {
		throw new RuntimeException(e);
	}

	copy.fieldNames = fieldNames;
	copy.fieldTypes = fieldTypes;
	return copy;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:30,代码来源:JDBCAppendTableSink.java

示例5: copy

import org.apache.flink.util.InstantiationUtil; //导入方法依赖的package包/类
@Override
public T copy(T from) {

	try {
		return InstantiationUtil.clone(from);
	} catch (IOException | ClassNotFoundException e) {
		throw new RuntimeException("Could not copy instance of " + from + '.', e);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:JavaSerializer.java

示例6: copy

import org.apache.flink.util.InstantiationUtil; //导入方法依赖的package包/类
@Override
public T copy(T from) {
	try {
		return InstantiationUtil.clone(from, Thread.currentThread().getContextClassLoader());
	} catch (IOException | ClassNotFoundException e) {
		throw new FlinkRuntimeException("Could not copy element via serialization: " + from, e);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:9,代码来源:JavaSerializer.java


注:本文中的org.apache.flink.util.InstantiationUtil.clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。