Class AbstractTransactionStore

    • Field Detail

      • underlyingStore

        protected final Store underlyingStore
        The underlying store wrapped by this store
    • Constructor Detail

      • AbstractTransactionStore

        protected AbstractTransactionStore​(Store underlyingStore)
        Constructor
        Parameters:
        underlyingStore - the underlying store
    • Method Detail

      • getInMemorySize

        public int getInMemorySize()
        Returns the current local in-memory store size
        Specified by:
        getInMemorySize in interface Store
        Returns:
        the count of the Elements in the Store and in-memory on the local machine
      • getOffHeapSize

        public int getOffHeapSize()
        Returns the current local off-heap store size
        Specified by:
        getOffHeapSize in interface Store
        Returns:
        the count of the Elements in the Store and off-heap on the local machine
      • getOnDiskSize

        public int getOnDiskSize()
        Returns the current local on-disk store size
        Specified by:
        getOnDiskSize in interface Store
        Returns:
        the count of the Elements in the Store and on-disk on the local machine
      • getInMemorySizeInBytes

        public long getInMemorySizeInBytes()
        Gets the size of the in-memory portion of the store, in bytes.

        This method may be expensive to run, depending on implementation. Implementers may choose to return an approximate size.

        Specified by:
        getInMemorySizeInBytes in interface Store
        Returns:
        the approximate in-memory size of the store in bytes
      • getOffHeapSizeInBytes

        public long getOffHeapSizeInBytes()
        Gets the size of the off-heap portion of the store, in bytes.
        Specified by:
        getOffHeapSizeInBytes in interface Store
        Returns:
        the approximate off-heap size of the store in bytes
      • getOnDiskSizeInBytes

        public long getOnDiskSizeInBytes()
        Gets the size of the on-disk portion of the store, in bytes.
        Specified by:
        getOnDiskSizeInBytes in interface Store
        Returns:
        the on-disk size of the store in bytes
      • containsKeyOnDisk

        public boolean containsKeyOnDisk​(java.lang.Object key)
        A check to see if a key is in the Store and is currently held on disk.
        Specified by:
        containsKeyOnDisk in interface Store
        Parameters:
        key - The Element key
        Returns:
        true if found. No check is made to see if the Element is expired.
      • containsKeyOffHeap

        public boolean containsKeyOffHeap​(java.lang.Object key)
        A check to see if a key is in the Store and is currently held off-heap.
        Specified by:
        containsKeyOffHeap in interface Store
        Parameters:
        key - The Element key
        Returns:
        true if found. No check is made to see if the Element is expired.
      • containsKeyInMemory

        public boolean containsKeyInMemory​(java.lang.Object key)
        A check to see if a key is in the Store and is currently held in memory.
        Specified by:
        containsKeyInMemory in interface Store
        Parameters:
        key - The Element key
        Returns:
        true if found. No check is made to see if the Element is expired.
      • dispose

        public void dispose()
        Prepares for shutdown.
        Specified by:
        dispose in interface Store
      • getStatus

        public Status getStatus()
        Returns the cache status.
        Specified by:
        getStatus in interface Store
      • expireElements

        public void expireElements()
        Expire all elements.
        Specified by:
        expireElements in interface Store
      • flush

        public void flush()
                   throws java.io.IOException
        Flush elements to persistent store.
        Specified by:
        flush in interface Store
        Throws:
        java.io.IOException - if any IO error occurs
      • bufferFull

        public boolean bufferFull()
        Some store types, such as the disk stores can fill their write buffers if puts come in too fast. The thread will wait for a short time before checking again.
        Specified by:
        bufferFull in interface Store
        Returns:
        true if the store write buffer is backed up.
      • setInMemoryEvictionPolicy

        public void setInMemoryEvictionPolicy​(Policy policy)
        Sets the eviction policy strategy. The Store will use a policy at startup. The store may allow changing the eviction policy strategy dynamically. Otherwise implementations will throw an exception if this method is called.
        Specified by:
        setInMemoryEvictionPolicy in interface Store
        Parameters:
        policy - the new policy
      • getInternalContext

        public java.lang.Object getInternalContext()
        This should not be used, and will generally return null
        Specified by:
        getInternalContext in interface Store
        Returns:
        some internal context (probably null)
      • getMBean

        public java.lang.Object getMBean()
        Optional implementation specific MBean exposed by the store.
        Specified by:
        getMBean in interface Store
        Returns:
        implementation specific management bean
      • setNodeCoherent

        public void setNodeCoherent​(boolean coherent)
        Sets the cache in coherent or incoherent mode for the current node depending on the parameter. Calling setNodeCoherent(true) when the cache is already in coherent mode or calling setNodeCoherent(false) when already in incoherent mode will be a no-op.

        It applies to coherent clustering mechanisms only e.g. Terracotta

        Specified by:
        setNodeCoherent in interface Store
        Overrides:
        setNodeCoherent in class AbstractStore
        Parameters:
        coherent - true transitions to coherent mode, false to incoherent mode
        See Also:
        Store.setNodeCoherent(boolean)
      • isNodeCoherent

        public boolean isNodeCoherent()
        Returns true if the cache is in coherent mode for the current node. Returns false otherwise.

        It applies to coherent clustering mechanisms only e.g. Terracotta

        Specified by:
        isNodeCoherent in interface Store
        Overrides:
        isNodeCoherent in class AbstractStore
        Returns:
        true if the cache is in coherent mode cluster-wide, false otherwise
        See Also:
        Store.isNodeCoherent()
      • isCacheCoherent

        public boolean isCacheCoherent()
        Indicates whether this store provides a coherent view of all the elements in a cache. Note that this is same as calling Store.isClusterCoherent() (introduced since 2.0) Use Store.isNodeCoherent() to find out if the cache is coherent in the current node in the cluster
        Specified by:
        isCacheCoherent in interface Store
        Overrides:
        isCacheCoherent in class AbstractStore
        Returns:
        true if the store is coherent; or false if the store potentially splits the cache storage with another store or isn't internally coherent
        See Also:
        Store.isCacheCoherent()
      • isClusterCoherent

        public boolean isClusterCoherent()
        Returns true if the cache is in coherent mode cluster-wide. Returns false otherwise.

        It applies to coherent clustering mechanisms only e.g. Terracotta

        Specified by:
        isClusterCoherent in interface Store
        Overrides:
        isClusterCoherent in class AbstractStore
        Returns:
        true if the cache is in coherent mode cluster-wide, false otherwise
        See Also:
        Store.isClusterCoherent()
      • getSearchAttribute

        public <T> Attribute<T> getSearchAttribute​(java.lang.String attributeName)
                                            throws CacheException
        Retrieve the given named search attribute
        Specified by:
        getSearchAttribute in interface Store
        Overrides:
        getSearchAttribute in class AbstractStore
        Type Parameters:
        T - type of the attribute
        Parameters:
        attributeName - the name of the attribute to retrieve
        Returns:
        the search attribute or null if non-existent
        Throws:
        CacheException
      • hasAbortedSizeOf

        public boolean hasAbortedSizeOf()
        Checks if the cache may contain elements for which the SizeOf engine gave up and only partially calculated the size.
        Specified by:
        hasAbortedSizeOf in interface Store
        Overrides:
        hasAbortedSizeOf in class AbstractStore
        Returns:
        true if at least one partially sized element may be in the cache
      • unsafeGet

        public Element unsafeGet​(java.lang.Object key)
        Returns the local value associated with the key. Local value means that the object mapped to the key is present in the VM locally. In case its not, will return null. Note that even when returning null, the value may be present in the Terracotta server array.

        This operation does not acquire any locks when doing the operation and may return stale values. This Operation does not update last usage statistics

        Specified by:
        unsafeGet in interface TerracottaStore
        Parameters:
        key - the key
        Returns:
        the element associated with key or null
      • getLocalKeys

        public java.util.Set getLocalKeys()
        Returns set of keys from the cache which are present in the node locally.
        Specified by:
        getLocalKeys in interface TerracottaStore
        Returns:
        set of keys present locally in the node
      • quickSize

        public int quickSize()
        Description copied from interface: TerracottaStore
        Get an approximate count of elements in the store.
        Specified by:
        quickSize in interface TerracottaStore
        Returns:
        an approximate count of elements in the store.
      • getOldElement

        public Element getOldElement​(java.lang.Object key)
        Method to get to the Element matching the key, oblivious of any in-flight transaction.
        Parameters:
        key - the key to look for
        Returns:
        the mapped element, outside of any transaction
      • notifyCacheEventListenersChanged

        public void notifyCacheEventListenersChanged()
        Description copied from interface: TerracottaStore
        Notify the underlying store that some change has occured in the set of registered cache listeners.
        Specified by:
        notifyCacheEventListenersChanged in interface TerracottaStore