如何在Storm中注册Kryo序列化程序实例? [英] how to register kryo serializer instances in storm?

查看:146
本文介绍了如何在Storm中注册Kryo序列化程序实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我极力尝试配置要在我的风暴拓扑中使用的序列化程序实例.

I'm desparately trying to configure serializer instances to use in my storm topology.

storm文档指出,有两种注册序列化程序的方法:

The storm documentation states, there are 2 ways to register serializers :

1. The name of a class to register. In this case, Storm will use Kryo’s FieldsSerializer to serialize the class. This may or may not be optimal for the class – see the Kryo docs for more details.
2. A map from the name of a class to register to an implementation of com.esotericsoftware.kryo.Serializer.

我想使用2.->

Map<String, Object> serializerConfig = new HashMap<String, Object>();
serializerConfig.put(Record.class.getName(), new AvroSerializer(params));
conf.put(Config.TOPOLOGY_KRYO_REGISTER, serializerConfig);

不幸的是,这导致

Exception in thread "main" java.lang.IllegalArgumentException: Storm conf is not valid. Must be json-serializable

关于拓扑提交.

有人知道如何做到这一点(注册序列化程序实例)吗?

Does anyone know how to do this (register serializer instances) ?

非常感谢您

推荐答案

有一个

There is a method in the backtype.storm.Config class to register your own class derived from Serializer.

在您的示例中,将其放在创建和提交拓扑的main方法中:

For your example, put this in the main method that creates and submits the topology:

// Read in Storm Configuration
Config conf = new Config();
conf.registerSerialization(Record.class, AvroSerializer.class);

这篇关于如何在Storm中注册Kryo序列化程序实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆