本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}