Class SerializationPagedCache.PagedBinaryStore

java.lang.Object
com.tangosol.util.Base
com.tangosol.net.cache.SerializationPagedCache.PagedBinaryStore
All Implemented Interfaces:
BinaryStore
Enclosing class:
SerializationPagedCache

public class SerializationPagedCache.PagedBinaryStore extends Base implements BinaryStore
A virtual BinaryStore implementation that aggregates a sequence (newest to oldest) of periodic BinaryStore objects.
  • Constructor Details

    • PagedBinaryStore

      public PagedBinaryStore(int cPages)
      Construct a PagedBinaryStore.
      Parameters:
      cPages - the maximum number of pages to have active at a time
  • Method Details

    • load

      public Binary load(Binary binKey)
      Return the value associated with the specified key, or null if the key does not have an associated value in the underlying store.
      Specified by:
      load in interface BinaryStore
      Parameters:
      binKey - key whose associated value is to be returned
      Returns:
      the value associated with the specified key, or null if no value is available for that key
    • store

      public void store(Binary binKey, Binary binValue)
      Store the specified value under the specific key in the underlying store. This method is intended to support both key/value creation and value update for a specific key.
      Specified by:
      store in interface BinaryStore
      Parameters:
      binKey - key to store the value under
      binValue - value to be stored
    • erase

      public void erase(Binary binKey)
      Remove the specified key from the underlying store if present.
      Specified by:
      erase in interface BinaryStore
      Parameters:
      binKey - key whose mapping is to be removed from the map
    • eraseAll

      public void eraseAll()
      Remove all data from the underlying store.
      Specified by:
      eraseAll in interface BinaryStore
    • keys

      public Iterator keys()
      Iterate all keys in the underlying store.
      Specified by:
      keys in interface BinaryStore
      Returns:
      a read-only iterator of the keys in the underlying store
    • close

      public void close()
      Release underlying resources.
    • getMaximumPages

      public int getMaximumPages()
      Determine the maximum number of pages that the cache will manage, beyond which the oldest pages are destroyed.
      Returns:
      the maximum number of pages that the cache will manage
    • getActivePageCount

      public int getActivePageCount()
      Determine the number of pages that the PagedBinaryStore is currently managing. This is the "active" page count.
      Returns:
      the number of pages that the PagedBinaryStore is currently managing
    • getTotalPageCount

      public int getTotalPageCount()
      Determine the number of pages that the PagedBinaryStore has managed in total, including those it is currently managing.
      Returns:
      the total number of pages ever managed by the PagedBinaryStore
    • getCurrentPageNumber

      public int getCurrentPageNumber()
      Determine the number of pages that the PagedBinaryStore has managed in total, including those it is currently managing.
      Returns:
      the total number of pages ever managed by the PagedBinaryStore
    • isPageActive

      public boolean isPageActive(int nPage)
      Determine if the specified page number is active. A page is active if it is either the current page, or a page that has not aged to the point that it has been discarded.
      Parameters:
      nPage - the page number to test
      Returns:
      if the specified page is active
    • getActivePageArray

      public SerializationPagedCache.WrapperBinaryStore[] getActivePageArray()
      Get the array of BinaryStore objects, one for each active page. The array is indexed by "page indexes" and not page numbers. Page numbers are sequential page ids; they can be translated to page indices by using the toPageIndex method.
      Returns:
      the array of active BinaryStore objects
    • getPage

      public SerializationPagedCache.WrapperBinaryStore getPage(int nPage)
      Get the BinaryStore for the page specified by the passed page number. The page number is basically the infinitely increasing counter of pages; the first page is 0, the second is 1, and so on.
      Parameters:
      nPage - the page number
      Returns:
      the correspodning BinaryStore, or null if the specified page number is not active
    • getCurrentPage

      protected SerializationPagedCache.WrapperBinaryStore getCurrentPage()
      Obtain the page to which current updates are being performed. This page is referred to as the "current" page.
      Returns:
      the BinaryStore that holds the current page's data
    • getOldestActivePage

      protected SerializationPagedCache.WrapperBinaryStore getOldestActivePage()
      Obtain the oldest active page.
      Returns:
      the BinaryStore that holds the oldest active page's data
    • toPageIndex

      protected int toPageIndex(int nPage)
      Translate a page number to an index into the PageArray.
      Parameters:
      nPage - the page number
      Returns:
      an index into the PageArray, or -1 if the page number is no longer valid
    • getPagedKeyMap

      protected Map getPagedKeyMap()
      Obtain the map that manages the mapping from Binary keys to BinaryStore objects. The BinaryStore objects are actually wrappers around the real BinaryStore objects that each manage one "page" of data.
      Returns:
      the map of Binary key to BinaryStore
    • advanceCurrentPage

      Advance the current page, using the passed BinaryStore as the store for the new current page, and returning the oldest active page, if the maximum number of active pages is exceeded by the advancing of the current page.
      Parameters:
      store - the BinaryStore to use for the new current page
      Returns:
      the oldest active page, if keeping it would exceed the maximum number of pages; otherwise null
    • logException

      protected void logException(Throwable e, String sMethod)
      Helper to log ignored exceptions.
      Parameters:
      e - the throwable object
      sMethod - the calling method name