sambenas commented on issue #8127:
URL: https://github.com/apache/storm/issues/8127#issuecomment-3692815945

   @reiabreu Sorry, I submitted this issue and then immediate forgot about it.  
At the moment we are not using the `KryoDecorator`, we have a data model object 
that implements `KryoSerializable` directly and it works like this:
   
   ```
   public class MyModel implements KryoSerializable {
   
     static {
       readSchemaFromFilesystem();
     }
   
     // read(), write(), etc
   
   }
   ```
   
   What I would like to do is move serialization logic into a serializer class. 
 When I experimented with that I had to use the `KryoDecorator` in order to 
read the schema file on the worker processes. It looks something like:
   
   ```
   public class MyKryoDecorator implements KryoDecorator {
   
     @Override
       public void decorate(Kryo kryo) {
           Schema myModelSchema = readSchemaFromFilesystem();
           kryo.register(MyModel.class, new MyModelSerializer(myModelSchema));
       }
   
   }
   ```
   
   But this implementation is still dependent on the schema file not being 
modified in anyway after the topology is submitted.  What I wanted to do is 
instantiate the `MyModelSerializer` class before submitting the topology but, 
to my knowledge, that is not possible because Storm can only register 
serialization by serializer class name, not with actual objects. 
   
   The workaround that I had in mind when opening this issue was to do 
something like this:
   
   ```
   // submitting topology
   topologyConfig.put("schema", readSchemaFromFilesystem());
   submitTopology("myTopology", topologyConfig, myTopology);
   ```
   
   Then in the `KryoDecorator`:
   
   ```
       @Override
       public void decorate(Kryo kryo, Configuration config) {
           Schema myModelSchema = config.get("schema");
           kryo.register(MyModel.class, new MyModelSerializer(myModelSchema));
       }
   ```
   
   I am also open to any other suggestions.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to