我拼命尝试配置序列化器实例以在我的风暴拓扑中使用。
Storm 文档指出,有两种注册序列化器的方法:
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
关于拓扑提交。
有谁知道如何做到这一点(注册序列化器实例)?
非常感谢
有一个backtype.storm.Config 类中的方法 https://storm.incubator.apache.org/apidocs/backtype/storm/Config.html#registerSerialization(java.lang.Class,%20java.lang.Class)注册您自己的从 Serializer 派生的类。
对于您的示例,请将其放入创建和提交拓扑的主方法中:
// Read in Storm Configuration
Config conf = new Config();
conf.registerSerialization(Record.class, AvroSerializer.class);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)