Package com.tangosol.net.partition
Class PartitionSplittingBackingMap
java.lang.Object
com.tangosol.util.Base
com.tangosol.util.AbstractKeyBasedMap
com.tangosol.net.partition.PartitionSplittingBackingMap
- All Implemented Interfaces:
Disposable,PartitionAwareBackingMap,AutoCloseable,Map
- Direct Known Subclasses:
ObservableSplittingBackingCache.CapacityAwareMap
public class PartitionSplittingBackingMap
extends AbstractKeyBasedMap
implements Disposable, PartitionAwareBackingMap
In a partitioned configuration, the PartitionSplittingBackingMap is a
"map multi-plexer" that enables multiple backing maps to be used in place
of a single backing map. The data and operations related to each partition
are routed by the PartitionSplittingBackingMap to a partition-specific
backing map. The two primary benefits are:
- Less data are stored in each backing map, potentially enabling much more total data to be managed, and
- each partition is managed by a separate data structure, potentially increasing concurrency by spreading concurrent operations over multiple data structures.
Also, as with all usage of BinaryMap, if the data are stored off-heap, the proper use of the MaxDirectMemorySize JVM switch will be crucial.
- Since:
- Coherence 3.5
- Author:
- cp 2008-11-20
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassAn implementation of the CacheStatics interface that aggregates across the CacheStatics objects provided by each of the backing maps corresponding to the partitions managed by this PartitionSplittingBackingMap.protected classA KeySet implementation optimized for PartitionSplittingBackingMap.static classThe MapArray is a data structure that provides a mapping between partition IDs and backing maps.classA read-only view into a subset of backing maps managed by the underlying PartitionSplittingBackingMap.classAn Iterator designed to ensure that a stable copy of each partition's keys is available for the duration of the iteration over its keys.Nested classes/interfaces inherited from class com.tangosol.util.AbstractKeyBasedMap
AbstractKeyBasedMap.DeferredCacheEvent<K,V>, AbstractKeyBasedMap.EntrySet, AbstractKeyBasedMap.ValuesCollection Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionPartitionSplittingBackingMap(BackingMapManager bmm, String sName) Create a PartitionSplittingBackingMap that will delegate each partition's data and operations to a separate backing map. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear all key/value mappings.booleancontainsKey(Object oKey) Returns true if this map contains a mapping for the specified key.voidcreatePartition(int nPid) Add a partition to the PartitionAwareBackingMap.voiddestroyPartition(int nPid) Remove a partition from the PartitionAwareBackingMap.voiddispose()Invoked when all resources owned by the implementer can safely be released.Returns the value to which this map maps the specified key.protected MapgetBackingMap(Object oKey) Obtain a backing map for the specified key.Obtain the BackingMapManager that this PartitionAwareBackingMap uses to instantiate and release backing maps.Returns the CacheStatistics for this cache.protected BackingMapManagerContextObtain the BackingMapManagerContext that provides the partition information for keys that are stored in the backing map.protected PartitionSplittingBackingMap.MapArrayGet the mapping between partition IDs and backing maps.getName()Determine the name of the cache for which this PartitionAwareBackingMap exists.getPartitionMap(int nPid) Obtain a Map view for the data in a specific partition.getPartitionMap(PartitionSet partitions) Obtain a Map view for the data in a specific set of partitions.protected SetFactory pattern: Create a Set that represents the keys in the MapbooleanisEmpty()Returns true if this map contains no key-value mappings.protected booleanReturn true iff a subset of the maps that belong to specified partitions contains no entries.booleanisStrict()Determine if any access to data in missing partitions is being treated as an error.protected IteratorCreate an iterator over the keys in this Map.protected IteratoriterateKeys(Map[] amap) Create an iterator over the keys in maps that belong to partitions contained in the specified PartitionSet.protected StringFormat a synthetic name for a partition-specific backing map.Associates the specified value with the specified key in this map.voidCopies all of the mappings from the specified map to this map.protected voidputAllInternal(Map mapPart, Map mapUpdate) Put all entries in mapUpdate into the provided map.protected ObjectputInternal(Map mapPart, Object oKey, Object oValue) Put the key and value into a map representing a given partition.Removes the mapping for this key from this map if present.protected booleanremoveBlind(Object oKey) Removes the mapping for this key from this map if present.protected voidreportMissingPartition(Object oKey, int nPid) Report a missing partition according to the "strict" flag rules.voidsetStrict(boolean fStrict) Specify whether any access to data in missing partitions should be treated as an error.intsize()Returns the number of key-value mappings in this map.protected intReturn the number of key-value mappings in a subset of the maps that belong to specified partitions.toString()Return a human-readable description for this PartitionBackingMap.toString(boolean fVerbose) Return a human-readable description for this PartitionBackingMap.Methods inherited from class com.tangosol.util.AbstractKeyBasedMap
clone, containsValue, entrySet, equals, getAll, hashCode, instantiateEntrySet, instantiateValues, keySet, valuesMethods 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, 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, waitMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.oracle.coherence.common.base.Disposable
closeMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsValue, entrySet, equals, forEach, getOrDefault, hashCode, keySet, merge, putIfAbsent, remove, replace, replace, replaceAll, values
-
Constructor Details
-
PartitionSplittingBackingMap
Create a PartitionSplittingBackingMap that will delegate each partition's data and operations to a separate backing map.- Parameters:
bmm- a BackingMapManager that knows how to create and release the backing maps that this PartitionSplittingBackingMap is responsible forsName- the cache name for which this backing map exists
-
-
Method Details
-
clear
public void clear()Clear all key/value mappings.- Specified by:
clearin interfaceMap- Overrides:
clearin classAbstractKeyBasedMap
-
containsKey
Returns true if this map contains a mapping for the specified key.- Specified by:
containsKeyin interfaceMap- Overrides:
containsKeyin classAbstractKeyBasedMap- Returns:
- true if this map contains a mapping for the specified key, false otherwise.
-
get
Returns the value to which this map maps the specified key.- Specified by:
getin interfaceMap- Specified by:
getin classAbstractKeyBasedMap- Parameters:
oKey- the key object- Returns:
- the value to which this map maps the specified key, or null if the map contains no mapping for this key
-
isEmpty
public boolean isEmpty()Returns true if this map contains no key-value mappings.- Specified by:
isEmptyin interfaceMap- Overrides:
isEmptyin classAbstractKeyBasedMap- Returns:
- true if this map contains no key-value mappings
-
put
Associates the specified value with the specified key in this map.- Specified by:
putin interfaceMap- Overrides:
putin classAbstractKeyBasedMap- Parameters:
oKey- key with which the specified value is to be associatedoValue- value to be associated with the specified key- Returns:
- previous value associated with specified key, or null if there was no mapping for key
-
putAll
Copies all of the mappings from the specified map to this map. The effect of this call is equivalent to that of callingAbstractKeyBasedMap.put(K, V)on this map once for each mapping in the passed map. The behavior of this operation is unspecified if the passed map is modified while the operation is in progress.- Specified by:
putAllin interfaceMap- Overrides:
putAllin classAbstractKeyBasedMap- Parameters:
map- the Map containing the key/value pairings to put into this Map
-
remove
Removes the mapping for this key from this map if present. Expensive: updates both the underlying cache and the local cache.- Specified by:
removein interfaceMap- Overrides:
removein classAbstractKeyBasedMap- Parameters:
oKey- key whose mapping is to be removed from the map- Returns:
- previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values.
-
removeBlind
Removes the mapping for this key from this map if present. This method exists to allow sub-classes to optimize remove functionality for situations in which the original value is not required.- Overrides:
removeBlindin classAbstractKeyBasedMap- Parameters:
oKey- key whose mapping is to be removed from the map- Returns:
- true iff the Map changed as the result of this operation
-
size
public int size()Returns the number of key-value mappings in this map.- Specified by:
sizein interfaceMap- Overrides:
sizein classAbstractKeyBasedMap- Returns:
- the number of key-value mappings in this map
-
iterateKeys
Create an iterator over the keys in this Map. The Iterator must support remove() if the Map supports removal.- Specified by:
iterateKeysin classAbstractKeyBasedMap- Returns:
- a new instance of an Iterator over the keys in this Map
-
instantiateKeySet
Factory pattern: Create a Set that represents the keys in the Map- Overrides:
instantiateKeySetin classAbstractKeyBasedMap- Returns:
- a new instance of Set that represents the keys in the Map
-
getCacheStatistics
Returns the CacheStatistics for this cache.- Returns:
- a CacheStatistics object
-
getBackingMapManager
Obtain the BackingMapManager that this PartitionAwareBackingMap uses to instantiate and release backing maps.- Specified by:
getBackingMapManagerin interfacePartitionAwareBackingMap- Returns:
- the BackingMapManager
-
getName
Determine the name of the cache for which this PartitionAwareBackingMap exists.- Specified by:
getNamein interfacePartitionAwareBackingMap- Returns:
- the cache name
-
createPartition
public void createPartition(int nPid) Add a partition to the PartitionAwareBackingMap.- Specified by:
createPartitionin interfacePartitionAwareBackingMap- Parameters:
nPid- the partition id that the PartitionAwareBackingMap will be responsible for, starting at this instant
-
destroyPartition
public void destroyPartition(int nPid) Remove a partition from the PartitionAwareBackingMap.- Specified by:
destroyPartitionin interfacePartitionAwareBackingMap- Parameters:
nPid- the partition id that the PartitionAwareBackingMap will no longer be responsible for, starting at this instant
-
getPartitionMap
Obtain a Map view for the data in a specific partition.- Specified by:
getPartitionMapin interfacePartitionAwareBackingMap- Parameters:
nPid- the partition ID- Returns:
- the backing map (or null if that partition is not owned)
-
getPartitionMap
Obtain a Map view for the data in a specific set of partitions.- Specified by:
getPartitionMapin interfacePartitionAwareBackingMap- Parameters:
partitions- the masking PartitionSet- Returns:
- a read-only view into a subset of backing maps
-
dispose
public void dispose()Invoked when all resources owned by the implementer can safely be released.Once disposed of the object should no longer be considered to be usable.
Note the Disposable interface is compatible with try-with-resources which will automatically invoke this method.
- Specified by:
disposein interfaceDisposable
-
isStrict
public boolean isStrict()Determine if any access to data in missing partitions is being treated as an error.- Returns:
- true if access to missing partitions is being treated as error
-
setStrict
public void setStrict(boolean fStrict) Specify whether any access to data in missing partitions should be treated as an error. If set to true, any read operation against a missing partition will log an error and any write operation will generate an exception. Otherwise, read operations against missing partitions will just return natural default values and write operations will log warnings.- Parameters:
fStrict- if true, any access to missing partitions should being treated as error
-
putInternal
Put the key and value into a map representing a given partition.- Parameters:
mapPart- a partition mapoKey- oKey with which the specified value is to be associatedoValue- oValue to be associated with the specified oKey- Returns:
- previous value associated with specified key, or null if there was no mapping for the key
-
putAllInternal
Put all entries in mapUpdate into the provided map.- Parameters:
mapPart- a partition mapmapUpdate- the Map containing the key/value pairings to put into mapPart
-
getContext
Obtain the BackingMapManagerContext that provides the partition information for keys that are stored in the backing map.- Returns:
- the BackingMapManagerContext for the underlying service
-
size
Return the number of key-value mappings in a subset of the maps that belong to specified partitions.- Parameters:
amap- the array of maps to process- Returns:
- the number of entries in a subset of the maps
-
isEmpty
Return true iff a subset of the maps that belong to specified partitions contains no entries.- Parameters:
amap- the array of maps to process- Returns:
- true iff the subset of the maps contains no entries
-
iterateKeys
Create an iterator over the keys in maps that belong to partitions contained in the specified PartitionSet.- Parameters:
amap- the array of maps to process- Returns:
- the key iterator
-
getMapArray
Get the mapping between partition IDs and backing maps.- Returns:
- the current MapArray data
-
getBackingMap
Obtain a backing map for the specified key.- Parameters:
oKey- the key- Returns:
- the backing map for the specified key or null if the partition is missing
-
makeName
Format a synthetic name for a partition-specific backing map.- Parameters:
sName- the name of the cachenPid- the partition number- Returns:
- a name that a backing map for a specific partition will be known by, for example as it should appear in JMX
-
toString
Return a human-readable description for this PartitionBackingMap.- Overrides:
toStringin classAbstractKeyBasedMap- Returns:
- a String description of the PartitionBackingMap
-
toString
Return a human-readable description for this PartitionBackingMap.- Parameters:
fVerbose- if true, generate a verbose descrition- Returns:
- a String description of the PartitionBackingMap
-
reportMissingPartition
Report a missing partition according to the "strict" flag rules.- Parameters:
oKey- the key for which an operation failed (optional)nPid- the missing partition; meaningful only if oKey is null
-