Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-7711

Improve server-side protostream marshaller registration

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Done
    • Icon: Major Major
    • 9.3.0.Final
    • None
    • None
    • None

      A more user friendly way to register protostream marshallers remotely is needed when the protostream marshaller is used for compatibility mode (or transcoding) in the future. It's currently possible to do it with a remote server task but that's a bit hacky.

      This server task shows how it can be done:

      package delays.java.stream;
      
      import org.infinispan.manager.EmbeddedCacheManager;
      import org.infinispan.query.remote.ProtobufMetadataManager;
      import org.infinispan.tasks.ServerTask;
      import org.infinispan.tasks.TaskContext;
      import org.infinispan.tasks.TaskExecutionMode;
      
      import delays.java.stream.pojos.Station;
      import delays.java.stream.pojos.Stop;
      import delays.java.stream.pojos.Train;
      
      public class AddProtobufTask implements ServerTask {
      
         private TaskContext ctx;
      
         @Override
         public void setTaskContext(TaskContext ctx) {
            this.ctx = ctx;
         }
      
         @Override
         public String getName() {
            return "add-protobuf";
         }
      
         @Override
         public Object call() throws Exception {
            EmbeddedCacheManager cm = ctx.getCache().get().getCacheManager();
            ProtobufMetadataManager protobufMetadataManager = cm.getGlobalComponentRegistry().getComponent(ProtobufMetadataManager.class);
            protobufMetadataManager.registerMarshaller(new Stop.Marshaller());
            protobufMetadataManager.registerMarshaller(new Station.Marshaller());
            protobufMetadataManager.registerMarshaller(new Train.Marshaller());
            return null;
         }
      
         @Override
         public TaskExecutionMode getExecutionMode() {
            // Registering marshallers should be done in all nodes
            return TaskExecutionMode.ALL_NODES;
         }
      
      }
      

              anistor Adrian Nistor (Inactive)
              rh-ee-galder Galder ZamarreƱo
              Archiver:
              rhn-support-adongare Amol Dongare

                Created:
                Updated:
                Resolved:
                Archived: