Class PutFromLoadValidator

    • Constructor Detail

      • PutFromLoadValidator

        public PutFromLoadValidator​(org.infinispan.AdvancedCache cache,
                                    TimeSource timeSource,
                                    org.infinispan.configuration.cache.Configuration pendingPutsConfiguration)
        Creates a new put from load validator instance.
        Parameters:
        pendingPutsConfiguration -
        cache - Cache instance on which to store pending put information.
      • PutFromLoadValidator

        public PutFromLoadValidator​(org.infinispan.AdvancedCache cache,
                                    TimeSource timeSource,
                                    org.infinispan.manager.EmbeddedCacheManager cacheManager,
                                    org.infinispan.configuration.cache.Configuration pendingPutsConfiguration)
        Creates a new put from load validator instance.
        Parameters:
        cache - Cache instance on which to store pending put information.
        timeSource -
        cacheManager - where to find a cache to store pending put information
        pendingPutsConfiguration -
    • Method Detail

      • addToCache

        public static void addToCache​(org.infinispan.AdvancedCache cache,
                                      PutFromLoadValidator validator)
        Besides the call from constructor, this should be called only from tests when mocking the validator.
      • removeFromCache

        public static PutFromLoadValidator removeFromCache​(org.infinispan.AdvancedCache cache)
        This methods should be called only from tests; it removes existing validator from the cache structures in order to replace it with new one.
        Parameters:
        cache -
      • destroy

        public void destroy()
      • acquirePutFromLoadLock

        public PutFromLoadValidator.Lock acquirePutFromLoadLock​(Object session,
                                                                Object key,
                                                                long txTimestamp)
        Acquire a lock giving the calling thread the right to put data in the cache for the given key.

        NOTE: A call to this method that returns true should always be matched with a call to releasePutFromLoadLock(Object, Lock).

        Parameters:
        session -
        key - the key
        txTimestamp -
        Returns:
        AcquiredLock if the lock is acquired and the cache put can proceed; null if the data should not be cached
      • beginInvalidatingRegion

        public boolean beginInvalidatingRegion()
        Invalidates all previously registered pending puts ensuring a subsequent call to acquirePutFromLoadLock(Object, Object, long) will return false.

        This method will block until any concurrent thread that has acquired the putFromLoad lock for the any key has released the lock. This allows the caller to be certain the putFromLoad will not execute after this method returns, possibly caching stale data.

        Returns:
        true if the invalidation was successful; false if a problem occurred (which the caller should treat as an exception condition)
      • endInvalidatingRegion

        public void endInvalidatingRegion()
        Called when the region invalidation is finished.
      • registerPendingPut

        public void registerPendingPut​(Object session,
                                       Object key,
                                       long txTimestamp)
        Notifies this validator that it is expected that a database read followed by a subsequent acquirePutFromLoadLock(Object, Object, long) call will occur. The intent is this method would be called following a cache miss wherein it is expected that a database read plus cache put will occur. Calling this method allows the validator to treat the subsequent acquirePutFromLoadLock as if the database read occurred when this method was invoked. This allows the validator to compare the timestamp of this call against the timestamp of subsequent removal notifications.
        Parameters:
        session -
        key - key that will be used for subsequent cache put
        txTimestamp -
      • beginInvalidatingKey

        public boolean beginInvalidatingKey​(Object lockOwner,
                                            Object key)
        Invalidates any previously registered pending puts and disables further registrations ensuring a subsequent call to acquirePutFromLoadLock(Object, Object, long) will return false.

        This method will block until any concurrent thread that has acquired the putFromLoad lock for the given key has released the lock. This allows the caller to be certain the putFromLoad will not execute after this method returns, possibly caching stale data.

        After this transaction completes, endInvalidatingKey(Object, Object) needs to be called }
        Parameters:
        key - key identifying data whose pending puts should be invalidated
        Returns:
        true if the invalidation was successful; false if a problem occurred (which the caller should treat as an exception condition)
      • beginInvalidatingWithPFER

        public boolean beginInvalidatingWithPFER​(Object lockOwner,
                                                 Object key,
                                                 Object valueForPFER)
      • endInvalidatingKey

        public boolean endInvalidatingKey​(Object lockOwner,
                                          Object key)
      • endInvalidatingKey

        public boolean endInvalidatingKey​(Object lockOwner,
                                          Object key,
                                          boolean doPFER)
        Called after the transaction completes, allowing caching of entries. It is possible that this method is called without previous invocation of beginInvalidatingKey(Object, Object), then it should be a no-op.
        Parameters:
        lockOwner - owner of the invalidation - transaction or thread
        key -
        Returns:
      • removePendingPutsCache

        public void removePendingPutsCache()