Package com.tangosol.net.cache
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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
Nested classes/interfaces inherited from interface com.tangosol.io.BinaryStore
BinaryStore.KeySetAware, BinaryStore.SizeAware
-
-
Constructor Summary
Constructors Constructor Description PagedBinaryStore(int cPages)
Construct a PagedBinaryStore.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SerializationPagedCache.WrapperBinaryStore
advanceCurrentPage(SerializationPagedCache.WrapperBinaryStore store)
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.void
close()
Release underlying resources.void
erase(Binary binKey)
Remove the specified key from the underlying store if present.void
eraseAll()
Remove all data from the underlying store.SerializationPagedCache.WrapperBinaryStore[]
getActivePageArray()
Get the array of BinaryStore objects, one for each active page.int
getActivePageCount()
Determine the number of pages that the PagedBinaryStore is currently managing.protected SerializationPagedCache.WrapperBinaryStore
getCurrentPage()
Obtain the page to which current updates are being performed.int
getCurrentPageNumber()
Determine the number of pages that the PagedBinaryStore has managed in total, including those it is currently managing.int
getMaximumPages()
Determine the maximum number of pages that the cache will manage, beyond which the oldest pages are destroyed.protected SerializationPagedCache.WrapperBinaryStore
getOldestActivePage()
Obtain the oldest active page.SerializationPagedCache.WrapperBinaryStore
getPage(int nPage)
Get the BinaryStore for the page specified by the passed page number.protected Map
getPagedKeyMap()
Obtain the map that manages the mapping from Binary keys to BinaryStore objects.int
getTotalPageCount()
Determine the number of pages that the PagedBinaryStore has managed in total, including those it is currently managing.boolean
isPageActive(int nPage)
Determine if the specified page number is active.Iterator
keys()
Iterate all keys in the underlying store.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.protected void
logException(Throwable e, String sMethod)
Helper to log ignored exceptions.void
store(Binary binKey, Binary binValue)
Store the specified value under the specific key in the underlying store.protected int
toPageIndex(int nPage)
Translate a page number to an index into the PageArray.-
Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
-
-
-
-
Method Detail
-
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 interfaceBinaryStore
- 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 interfaceBinaryStore
- Parameters:
binKey
- key to store the value underbinValue
- value to be stored
-
erase
public void erase(Binary binKey)
Remove the specified key from the underlying store if present.- Specified by:
erase
in interfaceBinaryStore
- 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 interfaceBinaryStore
-
keys
public Iterator keys()
Iterate all keys in the underlying store.- Specified by:
keys
in interfaceBinaryStore
- 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
protected SerializationPagedCache.WrapperBinaryStore advanceCurrentPage(SerializationPagedCache.WrapperBinaryStore store)
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
-
-