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

Granularity of remote event listener implementations doing the same job

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

    • Icon: Enhancement Enhancement
    • Resolution: Obsolete
    • Icon: Major Major
    • None
    • None
    • Remote Protocols
    • None

      Currently, if N clients add the same listener to a cache that does the same job, e.g. keeping a near cache consistent, this results in N server-side cluster listeners created, each potentially installed in different nodes. If one of those nodes fails, all clients that had a listener registered to that node will have to find a different node for this listener.

      The downsides of this approach is that there are as many cluster listeners installed as clients have added listeners (or have near cache enabled), which might not very efficient. If a node goes down, all clients that have cluster listeners there need to failover to some other node.

      The advantage of this approach is simplicity of the approach to decide where to add the listener and where to failover to.

      For this type of scenarios, an alternative set up might be worth exploring:

      If all these client side listeners are interested in exactly the same events, and the client ID would be exposed via the RemoteCache API, a server side cluster listener multi-plexing between all these clients could be potentially built. In other words, instead of having N clients register N cluster listeners, the first client would register the cluster listener with a client listener ID, and if more registrations were added with the same client listener ID, the connections would be added to the existing cluster listener implementation.

      The maximise the efficiency of this solution, all clients (even running in different JMVs), given the same client listener ID, should agree upon the node to add the listener in. For a distributed cache, hashing on the cache name would work. For replicated caches, since there's no hashing available, the first node of the view could be used.

      Since the logic to be executed server-side varies between being the first node adding the client listener vs the others, synchronization would be added to make sure that the first invocation only creates the cluster listener, and the others simply add the channel to the listener.

      Failover is a bit more tricky too, because if the node with the cluster listener goes down, all the clients have to failover, which again exposes a 1st vs the others type of logic.

      Advantages of this approach is the reduction in number of cluster listeners and potentially efficiency coming from a single cluster listener implementation server side.

      The disadvantages come from the server side logic to add/failover a cluster listener, which need to take into account if the listener is present or not. Other disadvantages come from needing the clients to use some specific routing for adding listeners for same node.

            [ISPN-5093] Granularity of remote event listener implementations doing the same job

            Infinispan issue tracking has been migrated to GitHub issues: https://github.com/infinispan/infinispan/issues
            If you still want this issue to be worked on, create a new issue on GitHub and link this issue.

            Tristan Tarrant added a comment - Infinispan issue tracking has been migrated to GitHub issues: https://github.com/infinispan/infinispan/issues If you still want this issue to be worked on, create a new issue on GitHub and link this issue.

            Will Burns added a comment -

            This has a good step forward with ISPN-4491, however there is a part missing that if we resused the same value multiple times we could further reduce output, although sending a single message is a huge step forward.

            We could use https://github.com/infinispan/infinispan/blob/master/commons/src/main/java/org/infinispan/commons/marshall/InstanceReusingAdvancedExternalizer.java class to allow for the message to automatically cache the same values (although if we had converters there is a possibility it could create object equal but not instance equal objects that we would also have to look into.

            Will Burns added a comment - This has a good step forward with ISPN-4491 , however there is a part missing that if we resused the same value multiple times we could further reduce output, although sending a single message is a huge step forward. We could use https://github.com/infinispan/infinispan/blob/master/commons/src/main/java/org/infinispan/commons/marshall/InstanceReusingAdvancedExternalizer.java class to allow for the message to automatically cache the same values (although if we had converters there is a possibility it could create object equal but not instance equal objects that we would also have to look into.

              Unassigned Unassigned
              rh-ee-galder Galder Zamarreño
              Archiver:
              rhn-support-adongare Amol Dongare

                Created:
                Updated:
                Resolved:
                Archived: