Class ConcurrentSessionModificationMonitor

  • All Implemented Interfaces:
    com.blueriq.component.api.store.keyvalue.IKeyspaceEventListener, org.springframework.beans.factory.DisposableBean

    public class ConcurrentSessionModificationMonitor
    extends Object
    implements com.blueriq.component.api.store.keyvalue.IKeyspaceEventListener, org.springframework.beans.factory.DisposableBean
    This component detects when a session is about to be modified by multiple runtime nodes and interrupts the requests on all but the last request.

    A request which is going to (potentially) modify the session must first register the session with this component and unregister when the request is done. This component will write a "guard" key in the key-value store representing the registered request and session. It also receives notifications from the keyspace monitor when other guards are written and can detect if another request for the same session has started. When a concurrent request is detected, all other registered requests for that session are interrupted.

    Since:
    11.0
    Author:
    Petru Galanton
    • Constructor Detail

      • ConcurrentSessionModificationMonitor

        public ConcurrentSessionModificationMonitor​(com.blueriq.component.api.store.keyvalue.IKeyspaceMonitor keyspaceMonitor,
                                                    com.blueriq.component.api.store.keyvalue.IKeyValueStore keyValueStore)
    • Method Detail

      • destroy

        public void destroy()
                     throws Exception
        Specified by:
        destroy in interface org.springframework.beans.factory.DisposableBean
        Throws:
        Exception
      • onEvent

        public void onEvent​(com.blueriq.component.api.store.keyvalue.KeyspaceEvent event,
                            String key)
        Specified by:
        onEvent in interface com.blueriq.component.api.store.keyvalue.IKeyspaceEventListener
      • register

        public void register​(com.blueriq.component.api.IAquimaSession session,
                             String namespace,
                             String token)
        Registers a request that is going to modify the given session. The request is identified and distinguished from other requests through the token parameter, which should be different for each request (eg. a randomly generated GUID). The namespace parameter helps to group related requests and can be, for example, the HTTP session id.
        Parameters:
        session - the session which should be monitored for concurrent modifications
        namespace - the namespace for this request
        token - a unique identifier for this request
      • unregister

        public void unregister​(com.blueriq.component.api.IAquimaSession session,
                               String namespace,
                               String token)
        Unregisters a previously registered request. The session, namespace and token parameters must be the same as those used to register. This method should be called at the end of the request.
        Parameters:
        session - the session that should no longer be monitored.
        namespace - the namespace for the request
        token - the unique identifier for the request
      • getNamespacedGuard

        protected String getNamespacedGuard​(com.blueriq.component.api.IAquimaSession session,
                                            String namespace,
                                            String token)