Package com.tangosol.net.cache
Class ReadWriteBackingMap.WriteQueue
java.lang.Object
com.tangosol.util.Base
com.tangosol.license.LicensedObject
com.tangosol.license.CoherenceDataGridEdition
com.tangosol.license.CoherenceApplicationEdition
com.tangosol.license.CoherenceCommunityEdition
com.tangosol.net.cache.ReadWriteBackingMap.WriteQueue
- Enclosing class:
- ReadWriteBackingMap
public class ReadWriteBackingMap.WriteQueue
extends com.tangosol.license.CoherenceCommunityEdition
A queue that only releases entries after a configurable period of time.
- Author:
- cp 2002.10.22
- 
Nested Class SummaryNested classes/interfaces inherited from class com.tangosol.license.LicensedObjectcom.tangosol.license.LicensedObject.LicenseDataNested classes/interfaces inherited from class com.tangosol.util.BaseBase.LoggingWriter
- 
Field Summary
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedConstruct a WriteQueue that holds write-behind entries.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanaccelerateEntryRipe(Binary binKey) Move the ripe time for the queued entry up to accelerate the store operation.protected ReadWriteBackingMap.Entryadd(ReadWriteBackingMap.Entry entryNew, long cDelay) Add an entry to the queue.checkPending(Object binKey) Check for an item known to the WriteBehind queue.voidClear the map of pending entries.booleancontainsKey(Object binKey) voidflush()Asynchronous flush, i.e. effectively mark all currently queue'd entries as ripe.longintprotected MapReturn a map of items queued to be written.protected MapObtain a map of entries removed from the queue, but not yet persisted to the underlying datastore.protected LongArrayReturn aLongArrayindexed by ripe time (when entries become eligible to be written), and associated to a list of binary keys.booleanisEmpty()booleanReturn true iff all contents have been persisted to the underlying store.protected booleanCheck whether any threads are waiting for the store operation to complete.remove()Wait for item in the queue to ripen (to be ready to be removed), and when there is one and it is ripe, then remove and return it.remove(long cMillis) Wait for the next item in the queue to ripen (to be ready to be removed), and remove and return it, or return null if the specified wait time has passed.protected ReadWriteBackingMap.EntryRemove a key from the queue if the key is in the queue.protected ReadWriteBackingMap.EntryRemove the first key from the queue immediately.Check for a ripe or soft-ripe item in the queue, and if there is one, return it; otherwise, return null.voidsetDelayMillis(long cMillis) Specify the number of milliseconds that an entry added to the queue will sit in the queue before being removable ("ripe").voidsetDelaySeconds(int cSeconds) Specify the number of seconds that an entry added to the queue will sit in the queue before being removable ("ripe").protected voidsetWaitingOnPending(boolean fPending) Set the flag indicating whether any threads are waiting for the pending store operation to complete.intsize()Methods inherited from class com.tangosol.license.CoherenceCommunityEditionprintLicense, toStringMethods inherited from class com.tangosol.license.LicensedObjectcontainsEdition, ensureEdition, getClassLicenseData, getClassLicenseData, getLicenseData, getLicenseFailure, isExpired, main, printLicense, retain, retain, setLicenseDataMethods inherited from class com.tangosol.util.Baseazzert, 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, newHashMap, newHashMap, newHashSet, newHashSet, 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
- 
Constructor Details- 
WriteQueueprotected WriteQueue()Construct a WriteQueue that holds write-behind entries.
 
- 
- 
Method Details- 
getDelaySecondspublic int getDelaySeconds()- Returns:
- the number of seconds that an entry added to the queue will sit in the queue before being removable ("ripe")
 
- 
setDelaySecondspublic void setDelaySeconds(int cSeconds) Specify the number of seconds that an entry added to the queue will sit in the queue before being removable ("ripe").- Parameters:
- cSeconds- the number of seconds to wait before allowing an entry to be removed from the queue
 
- 
getDelayMillispublic long getDelayMillis()- Returns:
- the number of milliseconds that an entry added to the queue will sit in the queue before being removable ("ripe")
- Since:
- Coherence 3.4
 
- 
setDelayMillispublic void setDelayMillis(long cMillis) Specify the number of milliseconds that an entry added to the queue will sit in the queue before being removable ("ripe").- Parameters:
- cMillis- the number of milliseconds to wait before allowing an entry to be removed from the queue
- Since:
- Coherence 3.4
 
- 
addAdd an entry to the queue. By specifying a cDelay that is greater than 0, persisting of this entry will be delayed with the specified number of milliseconds. Note that the delay will always be adjusted to make sure that this entry ripes no earlier than any existing ones.- Parameters:
- entryNew- the entry to insert
- cDelay- the number of milliseconds until the entry is considered ripe
- Returns:
- an old entry for the same key, if such an entry existed at the time this method was invoked; null otherwise
 
- 
removeRemove a key from the queue if the key is in the queue. This method is used, for example, if an item has actually been removed from the backing map.- Parameters:
- binKey- the key object
- Returns:
- the corresponding entry in the queue or null if the specified key was not in the queue
 
- 
removeImmediateRemove the first key from the queue immediately.- Returns:
- the first entry in the queue or null if the queue is empty
 
- 
removeWait for item in the queue to ripen (to be ready to be removed), and when there is one and it is ripe, then remove and return it.- Returns:
- the next item in the queue (it will only return null when the backing map is no longer active)
 
- 
removeWait for the next item in the queue to ripen (to be ready to be removed), and remove and return it, or return null if the specified wait time has passed.- Parameters:
- cMillis- the number of ms to wait for an entry to ripen; pass -1 to wait indefinitely or 0 for no wait
- Returns:
- the next item in the queue, or null if the wait time has passed or if the backing map is no longer active
 
- 
removeNoWaitCheck for a ripe or soft-ripe item in the queue, and if there is one, return it; otherwise, return null.Unlike the remove(java.lang.Object)method, this method will also remove soft-ripe items as calculated using the write-batch factor. A soft-ripe item is an item that has been in the write-behind queue for at least the following duration:D' = (1.0 - F)*D where:D = write-behind delay F = write-batch factor - Returns:
- the next item in the queue if one is ripe or soft-ripe and if the backing map is active, otherwise null
 
- 
sizepublic int size()- Returns:
- the length of the queue
 
- 
isEmptypublic boolean isEmpty()- Returns:
- true if and only if the queue contains no items
 
- 
isFlushedpublic boolean isFlushed()Return true iff all contents have been persisted to the underlying store.- Returns:
- true iff all contents have been persisted to the underlying store
 
- 
flushpublic void flush()Asynchronous flush, i.e. effectively mark all currently queue'd entries as ripe.
- 
containsKey- Parameters:
- binKey- the key to look for
- Returns:
- true if and only if the queue contains the specified key
 
- 
checkPendingCheck for an item known to the WriteBehind queue.- Parameters:
- binKey- the key object to look for
- Returns:
- a value from the queue or a pending map
 
- 
clearPendingpublic void clearPending()Clear the map of pending entries. Notify all threads that may be waiting for pending store operations to complete.
- 
accelerateEntryRipeMove the ripe time for the queued entry up to accelerate the store operation.- Parameters:
- binKey- the binary key
- Returns:
- true if the entry has already been stored
 
- 
getEntryMapReturn a map of items queued to be written.- Returns:
- the map of items queued to be written
 
- 
getRipeArrayReturn aLongArrayindexed by ripe time (when entries become eligible to be written), and associated to a list of binary keys.- Returns:
- a LongArray of items in the queue
 
- 
getPendingMapObtain a map of entries removed from the queue, but not yet persisted to the underlying datastore. The returned map is not thread safe, so all access to its content must be synchronized by the caller.- Returns:
- the map of items not yet persisted to the underlying datastore
 
- 
isWaitingOnPendingprotected boolean isWaitingOnPending()Check whether any threads are waiting for the store operation to complete.- Returns:
- true iff there is at least one waiting thread
 
- 
setWaitingOnPendingprotected void setWaitingOnPending(boolean fPending) Set the flag indicating whether any threads are waiting for the pending store operation to complete.- Parameters:
- fPending- the boolean value to set
 
 
-