Class ReadWriteBackingMap.StoreWrapper

    • Field Detail

      • f_cLoadOps

        protected final AtomicLong f_cLoadOps
        The number of Load operations.
      • f_cLoadFailures

        protected final AtomicLong f_cLoadFailures
        The number of Load failures.
      • f_cLoadMillis

        protected final AtomicLong f_cLoadMillis
        The cumulative time spent on Load operations.
      • f_cStoreOps

        protected final AtomicLong f_cStoreOps
        The number of Store operations.
      • f_cStoreEntries

        protected final AtomicLong f_cStoreEntries
        The total number of entries written in Store operations.
      • f_cStoreFailures

        protected final AtomicLong f_cStoreFailures
        The number of Store failures.
      • f_cStoreMillis

        protected final AtomicLong f_cStoreMillis
        The cumulative time spent on Store operations.
      • f_cPendingAsyncStoreOps

        protected final AtomicLong f_cPendingAsyncStoreOps
        The number of pending non-blocking store operations.
      • m_cEraseOps

        protected volatile long m_cEraseOps
        The number of Erase operations.
      • m_cEraseFailures

        protected volatile long m_cEraseFailures
        The number of Erase failures.
      • m_cEraseMillis

        protected volatile long m_cEraseMillis
        The cumulative time spent on Erase operations.
      • m_fStoreSupported

        protected boolean m_fStoreSupported
        Flag that determines whether or not Store operations are supported by the wrapped store.
      • m_fStoreAllSupported

        protected boolean m_fStoreAllSupported
        Flag that determines whether or not StoreAll operations are supported by the wrapped store.
      • m_fEraseSupported

        protected boolean m_fEraseSupported
        Flag that determines whether or not Erase operations are supported by the wrapped store.
      • m_fEraseAllSupported

        protected boolean m_fEraseAllSupported
        Flag that determines whether or not EraseAll operations are supported by the wrapped store.
      • m_loadBundler

        protected AbstractBundler m_loadBundler
        The bundler for load() operations.
      • m_storeBundler

        protected AbstractBundler m_storeBundler
        The bundler for store() operations.
      • m_eraseBundler

        protected AbstractBundler m_eraseBundler
        The bundler for erase() operations.
    • Constructor Detail

      • StoreWrapper

        public StoreWrapper()
    • Method Detail

      • ensureLoadBundler

        public AbstractBundler ensureLoadBundler​(int cBundleThreshold)
        Configure the bundler for the "load" operations. If the bundler does not exist and bundling is enabled, it will be instantiated.
        Parameters:
        cBundleThreshold - the bundle size threshold; pass zero to disable "load" operation bundling
        Returns:
        the "load" bundler or null if bundling is disabled
      • ensureStoreBundler

        public AbstractBundler ensureStoreBundler​(int cBundleThreshold)
        Configure the bundler for the "store" operations. If the bundler does not exist and bundling is enabled, it will be instantiated.
        Parameters:
        cBundleThreshold - the bundle size threshold; pass zero to disable "store" operation bundling
        Returns:
        the "store" bundler or null if bundling is disabled
      • ensureEraseBundler

        public AbstractBundler ensureEraseBundler​(int cBundleThreshold)
        Configure the bundler for the "erase" operations. If the bundler does not exist and bundling is enabled, it will be instantiated.
        Parameters:
        cBundleThreshold - the bundle size threshold; pass zero to disable "erase" operation bundling
        Returns:
        the "erase" bundler or null if bundling is disabled
      • getLoadOps

        public long getLoadOps()
        Determine the number of load() operations.
        Returns:
        the number of load() operations
      • getLoadFailures

        public long getLoadFailures()
        Determine the number of load() failures.
        Returns:
        the number of load() failures
      • getLoadMillis

        public long getLoadMillis()
        Determine the cumulative time spent on load() operations.
        Returns:
        the cumulative time spent on load() operations
      • getStoreOps

        public long getStoreOps()
        Determine the number of store() operations.
        Returns:
        the number of store() operations
      • getStoreFailures

        public long getStoreFailures()
        Determine the number of store() failures.
        Returns:
        the number of store() failures
      • getStoreMillis

        public long getStoreMillis()
        Determine the cumulative time spent on store() operations.
        Returns:
        the cumulative time spent on store() operations
      • getEraseOps

        public long getEraseOps()
        Determine the number of erase() operations.
        Returns:
        the number of erase() operations
      • getEraseFailures

        public long getEraseFailures()
        Determine the number of erase() failures.
        Returns:
        the number of erase() failures
      • getEraseMillis

        public long getEraseMillis()
        Determine the cumulative time spent on erase() operations.
        Returns:
        the cumulative time spent on erase() operations
      • getAverageBatchSize

        public long getAverageBatchSize()
        Determine the average number of entries stored per store() operation.
        Returns:
        the average number of entries stored per store() operation
      • getAverageLoadMillis

        public long getAverageLoadMillis()
        Determine the average time spent per load() operation.
        Returns:
        the average time spent per load() operation
      • getAverageStoreMillis

        public long getAverageStoreMillis()
        Determine the average time spent per store() operation.
        Returns:
        the average time spent per store() operation
      • getAverageEraseMillis

        public long getAverageEraseMillis()
        Determine the average time spent per erase() operation.
        Returns:
        the average time spent per erase() operation
      • getPendingAsyncStoreOps

        public long getPendingAsyncStoreOps()
        Determine the number of pending non-blocking store operations.
        Returns:
        the number of pending non-blocking store operations
      • resetStatistics

        public void resetStatistics()
        Reset the CacheStore statistics.
      • getLoadBundler

        public AbstractBundler getLoadBundler()
        Obtain the bundler for the "load" operations.
        Returns:
        the "load" bundler
      • getStoreBundler

        public AbstractBundler getStoreBundler()
        Obtain the bundler for the "store" operations.
        Returns:
        the "store" bundler
      • getEraseBundler

        public AbstractBundler getEraseBundler()
        Obtain the bundler for the "erase" operations.
        Returns:
        the "erase" bundler
      • isStoreSupported

        public boolean isStoreSupported()
        Determine if the wrapped store supports store() operations.
        Returns:
        true if the wrapped store supports store() operations
      • setStoreSupported

        public void setStoreSupported​(boolean fSupported)
        Set the flag that determines whether or not the wrapped store supports store() operations.
        Parameters:
        fSupported - the new value of the flag
      • isStoreAllSupported

        public boolean isStoreAllSupported()
        Determine if the wrapped store supports storeAll() operations.
        Returns:
        true if the wrapped store supports storeAll() operations
      • setStoreAllSupported

        public void setStoreAllSupported​(boolean fSupported)
        Set the flag that determines whether or not the wrapped store supports storeAll() operations.
        Parameters:
        fSupported - the new value of the flag
      • isEraseSupported

        public boolean isEraseSupported()
        Determine if the wrapped store supports erase() operations.
        Returns:
        true if the wrapped store supports erase() operations
      • setEraseSupported

        public void setEraseSupported​(boolean fSupported)
        Set the flag that determines whether or not the wrapped store supports erase() operations.
        Parameters:
        fSupported - the new value of the flag
      • isEraseAllSupported

        public boolean isEraseAllSupported()
        Determine if the wrapped store supports eraseAll() operations.
        Returns:
        true if the wrapped store supports eraseAll() operations
      • setEraseAllSupported

        public void setEraseAllSupported​(boolean fSupported)
        Set the flag that determines whether or not the wrapped store supports eraseAll() operations.
        Parameters:
        fSupported - the new value of the flag
      • isBlocking

        public boolean isBlocking()
        Determine if the wrapped store implements blocking operations.
        Returns:
        true if the operations are blocking
      • load

        protected ReadWriteBackingMap.Entry load​(Object binKey)
        Return the entry associated with the specified key, or null if the key does not have an associated value in the underlying store.

        Same as CacheLoader.load(K), but the key and the value are in the internal format.

        Parameters:
        binKey - binary key whose associated entry is to be returned
        Returns:
        the entry associated with the specified binary key, or null if no value is available for that key
      • loadAll

        protected Set loadAll​(Set setBinKey)
        Return the entry set associated with the specified keys in the passed collection. If a key does not have an associated value in the underlying store, then the return set will not have an entry for that key.

        Same as CacheLoader.loadAll(java.util.Collection<? extends K>), but the keys are in the internal format.

        Parameters:
        setBinKey - a set of keys to load
        Returns:
        a Set of entries for the specified keys
      • store

        protected void store​(ReadWriteBackingMap.Entry binEntry,
                             boolean fAllowChange)
        Store the specified entry in the underlying store.
        Parameters:
        binEntry - the entry
        fAllowChange - if true, any changes made to the entry by the store operation should be applied to the internal cache; otherwise they will be dealt with by the caller
      • storeAll

        protected void storeAll​(Set setBinEntries)
        Store the entries in the specified set in the underlying store.
        Parameters:
        setBinEntries - the set of binary entries
      • erase

        protected void erase​(ReadWriteBackingMap.Entry binEntry)
        Remove the specified entry from the underlying store.
        Parameters:
        binEntry - the entry
      • eraseAll

        protected void eraseAll​(Set setBinEntries)
        Remove the specified entries from the underlying store.
        Parameters:
        setBinEntries - the set of entries
      • replace

        protected void replace​(ReadWriteBackingMap.Entry entry)
        Replace the value in the internal cache for the specified entry.

        For write-behind, we should replace (and undecorate) the value *only* if the internal cache still holds the value it contained when the entry was de-queued for store operations.

        Note: for write-through RWBM, this method is only called while the entry is locked

        Parameters:
        entry - the entry that holds the binary value to replace
      • onLoadFailure

        protected void onLoadFailure​(Object oKeyReal,
                                     Exception e)
        Logs a store load() failure. This method is intended to be overwritten if a particular store can fail and the backing map must take action based on it.
        Parameters:
        oKeyReal - the key
        e - the exception
      • onLoadFailure

        protected void onLoadFailure​(Object oKeyReal,
                                     Exception e,
                                     boolean fThrow)
        Logs a store load() failure. This method is intended to be overwritten if a particular store can fail and the backing map must take action based on it.
        Parameters:
        oKeyReal - the key
        e - the exception
        fThrow - the caller can bubble up exceptions
      • onLoadAllFailure

        protected void onLoadAllFailure​(Collection colKeys,
                                        Exception e)
        Logs a store loadAll() failure. This method is intended to be overwritten if a particular store can fail and the backing map must take action based on it.
        Parameters:
        colKeys - colKeys a collection of keys in external form to load
        e - the exception
      • onLoadAllFailure

        protected void onLoadAllFailure​(Collection colKeys,
                                        Exception e,
                                        boolean fThrow)
        Logs a store loadAll() failure. This method is intended to be overwritten if a particular store can fail and the backing map must take action based on it.
        Parameters:
        colKeys - colKeys a collection of keys in external form to load
        e - the exception
        fThrow - the caller can bubble up exceptions
      • onStoreFailure

        protected void onStoreFailure​(ReadWriteBackingMap.Entry entry,
                                      Exception e)
        Logs a store store() failure. This method is intended to be overwritten if a particular store can fail and the backing map must take action based on it.
        Parameters:
        entry - the entry
        e - the exception
      • onStoreFailure

        protected void onStoreFailure​(ReadWriteBackingMap.Entry entry,
                                      Exception e,
                                      boolean fThrow)
        Logs a store store() failure. This method is intended to be overwritten if a particular store can fail and the backing map must take action based on it.
        Parameters:
        entry - the entry
        e - the exception
        fThrow - whether the store mode supports exceptions
      • onStoreAllFailure

        protected void onStoreAllFailure​(Set setBinEntries,
                                         Exception e)
        Logs a store storeAll() failure. This method is intended to be overwritten if a particular store can fail and the backing map must take action based on it.
        Parameters:
        setBinEntries - set of Entries
        e - the exception
      • onStoreAllFailure

        protected void onStoreAllFailure​(Set setBinEntries,
                                         Exception e,
                                         boolean fThrow)
        Logs a store storeAll() failure. This method is intended to be overwritten if a particular store can fail and the backing map must take action based on it.
        Parameters:
        setBinEntries - set of Entries
        e - the exception
        fThrow - whether the store mode supports exceptions
      • requeue

        protected boolean requeue​(ReadWriteBackingMap.WriteQueue queue,
                                  int cThreshold,
                                  ReadWriteBackingMap.Entry entry)
        Requeue the specified entry.

        Note: Subclasses could override this method and perform some type of the "last recovery attempt" operation if the super.requeue(...) call returns false. Note 2: Starting with Coherence 3.6 a positive threshold value ensures that entries are never dropped. The signature of the method did not change to maintain backward compatibility.

        Parameters:
        queue - the queue (never null)
        cThreshold - the queue size threshold
        entry - the entry to requeue
        Returns:
        starting with Coherence 3.6 this method always returns true
      • calculateRequeueDelay

        protected long calculateRequeueDelay​(ReadWriteBackingMap.WriteQueue queue)
        Calculate the requeue delay after a store operation failed. The default implementations delays the entry by at least a minute or by the two times the write-behind delay.
        Parameters:
        queue - the write-behind queue
        Returns:
        the number of milliseconds until another attempt should be made to persist the specified value
      • onEraseFailure

        protected void onEraseFailure​(Object oKeyReal,
                                      Exception e)
        Logs a store erase() failure. This method is intended to be overwritten if a particular store can fail and the backing map must take action based on it.
        Parameters:
        oKeyReal - the key
        e - the exception
      • onEraseAllFailure

        protected void onEraseAllFailure​(Set setBinEntries,
                                         Exception e)
        Logs a store eraseAll() failure. This method is intended to be overwritten if a particular store can fail and the backing map must take action based on it.
        Parameters:
        setBinEntries - set of Entries
        e - the exception
      • reportUnsupported

        protected void reportUnsupported​(String sOp)
        Log the info about an unsupported operation.
        Parameters:
        sOp - the unsupported operation
      • formatKeys

        protected String formatKeys​(Set setBinEntries,
                                    String sHeader)
        Generate a log message containing the keys from the specified set of entries.
        Parameters:
        setBinEntries - set of Entries
        sHeader - message header
        Returns:
        the formatted message
      • getStore

        public abstract Object getStore()
        Return the cache store object to which this wrapper delegates.
        Returns:
        the cache store object to which this wrapper delegates
      • instantiateLoadBundler

        protected abstract AbstractBundler instantiateLoadBundler()
        Create the bundler for the load operations.
        Returns:
        the "load" bundler
      • instantiateStoreBundler

        protected abstract AbstractBundler instantiateStoreBundler()
        Create the bundler for the store operations.
        Returns:
        the "store" bundler
      • instantiateEraseBundler

        protected abstract AbstractBundler instantiateEraseBundler()
        Create the bundler for the erase operations.
        Returns:
        the "erase" bundler
      • loadInternal

        protected abstract ReadWriteBackingMap.Entry loadInternal​(Object binKey)
        Load the entry associated with the specified key from the underlying store.
        Parameters:
        binKey - binary key whose associated value is to be loaded
        Returns:
        the entry associated with the specified key, or null if no value is available for that key
      • loadAllInternal

        protected abstract Set loadAllInternal​(Set setBinKey)
        Load the entries associated with each of the specified binary keys from the underlying store.
        Parameters:
        setBinKey - a set of binary keys to load
        Returns:
        a Set of entries for the specified keys
      • storeInternal

        protected abstract void storeInternal​(ReadWriteBackingMap.Entry binEntry)
        Store the specified entry in the underlying store.
        Parameters:
        binEntry - the entry to be stored
      • storeAllInternal

        protected abstract void storeAllInternal​(Set setBinEntries)
        Store the entries in the specified set in the underlying store.
        Parameters:
        setBinEntries - the set of entries to be stored
      • eraseInternal

        protected abstract void eraseInternal​(ReadWriteBackingMap.Entry binEntry)
        Remove the specified entry from the underlying store.
        Parameters:
        binEntry - the entry to be removed from the store
      • eraseAllInternal

        protected abstract void eraseAllInternal​(Set setBinEntries)
        Remove the specified entries from the underlying store.
        Parameters:
        setBinEntries - the set entries to be removed from the store