Interface PersistenceManager

  • All Superinterfaces:
    org.infinispan.commons.api.Lifecycle
    All Known Implementing Classes:
    PersistenceManagerImpl, PersistenceManagerStub

    public interface PersistenceManager
    extends org.infinispan.commons.api.Lifecycle
    Defines the logic for interacting with the chain of external storage.
    Since:
    4.0
    Author:
    Manik Surtani, Mircea Markus
    • Method Detail

      • isEnabled

        boolean isEnabled()
      • isPreloaded

        boolean isPreloaded()
        Returns:
        true if all entries from the store have been inserted to the cache. If the persistence/preload is disabled or eviction limit was reached when preloading, returns false.
      • preload

        void preload()
        Loads the data from the external store into memory during cache startup.
      • disableStore

        void disableStore​(String storeType)
        Marks the given storage as disabled.
      • getStores

        <T> Set<T> getStores​(Class<T> storeClass)
      • purgeExpired

        void purgeExpired()
        Removes the expired entries from all the existing storage.
      • publishEntries

        <K,​V> org.reactivestreams.Publisher<MarshalledEntry<K,​V>> publishEntries​(Predicate<? super K> filter,
                                                                                             boolean fetchValue,
                                                                                             boolean fetchMetadata,
                                                                                             PersistenceManager.AccessMode mode)
        Returns a publisher that will publish all entries stored by the underlying cache store. Only the first cache store that implements AdvancedCacheLoader will be used. Predicate is applied by the underlying loader in a best attempt to improve performance.

        Caller can tell the store to also fetch the value or metadata. In some cases this can improve performance. If metadata is not fetched the publisher may include expired entries.

        Type Parameters:
        K - key type
        V - value type
        Parameters:
        filter - filter so that only entries whose key matches are returned
        fetchValue - whether to fetch value or not
        fetchMetadata - whether to fetch metadata or not
        mode - access mode to choose what type of loader to use
        Returns:
        publisher that will publish entries
      • publishKeys

        <K> org.reactivestreams.Publisher<K> publishKeys​(Predicate<? super K> filter,
                                                         PersistenceManager.AccessMode mode)
        Returns a publisher that will publish all keys stored by the underlying cache store. Only the first cache store that implements AdvancedCacheLoader will be used. Predicate is applied by the underlying loader in a best attempt to improve performance.

        This method should be preferred over publishEntries(Predicate, boolean, boolean, AccessMode) when only keys are desired as many stores can do this in a significantly more performant way.

        This publisher will never return a key which belongs to an expired entry

        Type Parameters:
        K - key type
        Parameters:
        filter - filter so that only keys which match are returned
        mode - access mode to choose what type of loader to use
        Returns:
        publisher that will publish keys
      • loadFromAllStores

        MarshalledEntry loadFromAllStores​(Object key,
                                          boolean localInvocation,
                                          boolean includeStores)
        Loads an entry from the persistence store for the given key. The returned value may be null. This value is guaranteed to not be expired when it was returned.
        Parameters:
        key - key to read the entry from
        localInvocation - whether this invocation is a local invocation. Some loaders may be ignored if it is not local
        includeStores - if a loader that is also a store can be loaded from
        Returns:
        entry that maps to the key
      • getStateTransferProvider

        AdvancedCacheLoader getStateTransferProvider()
        Returns the store one configured with fetch persistent state, or null if none exist.
      • size

        int size()
      • setClearOnStop

        void setClearOnStop​(boolean clearOnStop)
      • writeToAllNonTxStores

        void writeToAllNonTxStores​(MarshalledEntry marshalledEntry,
                                   PersistenceManager.AccessMode modes)
        Write to all stores that are not transactional. A store is considered transactional if all of the following are true:

        • The store implements TransactionalCacheWriter
        • The store is configured to be transactional
        • The cache's TransactionMode === TRANSACTIONAL

        Parameters:
        marshalledEntry - the entry to be written to all non-tx stores.
        modes - the type of access to the underlying store.
      • prepareAllTxStores

        void prepareAllTxStores​(Transaction transaction,
                                BatchModification batchModification,
                                PersistenceManager.AccessMode accessMode)
                         throws PersistenceException
        Perform the prepare phase of 2PC on all Tx stores.
        Parameters:
        transaction - the current transactional context.
        batchModification - an object containing the write/remove operations required for this transaction.
        accessMode - the type of access to the underlying store.
        Throws:
        PersistenceException - if an error is encountered at any of the underlying stores.
      • commitAllTxStores

        void commitAllTxStores​(Transaction transaction,
                               PersistenceManager.AccessMode accessMode)
        Perform the commit operation for the provided transaction on all Tx stores.
        Parameters:
        transaction - the transactional context to be committed.
        accessMode - the type of access to the underlying store.
      • rollbackAllTxStores

        void rollbackAllTxStores​(Transaction transaction,
                                 PersistenceManager.AccessMode accessMode)
        Perform the rollback operation for the provided transaction on all Tx stores.
        Parameters:
        transaction - the transactional context to be rolledback.
        accessMode - the type of access to the underlying store.
      • writeBatchToAllNonTxStores

        void writeBatchToAllNonTxStores​(Iterable<MarshalledEntry> entries,
                                        PersistenceManager.AccessMode accessMode,
                                        long flags)
        Write all entries to the underlying non-transactional stores as a single batch.
        Parameters:
        entries - a List of MarshalledEntry to be written to the store.
        accessMode - the type of access to the underlying store.
        flags - Flags used during command invocation
      • deleteBatchFromAllNonTxStores

        void deleteBatchFromAllNonTxStores​(Iterable<Object> keys,
                                           PersistenceManager.AccessMode accessMode,
                                           long flags)
        Remove all entries from the underlying non-transactional stores as a single batch.
        Parameters:
        entries - a List of Keys to be removed from the store.
        accessMode - the type of access to the underlying store.
        flags - Flags used during command invocation
      • isAvailable

        boolean isAvailable()
        Returns:
        true if all configured stores are available and ready for read/write operations.