public class ObjectMultiMapProxy<K,V> extends MultiMapProxySupport implements MultiMap<K,V>, InitializingObject
Modifier and Type | Field and Description |
---|---|
protected static String |
NULL_KEY_IS_NOT_ALLOWED |
protected static String |
NULL_VALUE_IS_NOT_ALLOWED |
config, lockSupport, name
PARTITIONING_STRATEGY
Constructor and Description |
---|
ObjectMultiMapProxy(MultiMapConfig config,
MultiMapService service,
NodeEngine nodeEngine,
String name) |
Modifier and Type | Method and Description |
---|---|
String |
addEntryListener(EntryListener<K,V> listener,
boolean includeValue)
Adds an entry listener for this multimap.
|
String |
addEntryListener(EntryListener<K,V> listener,
K key,
boolean includeValue)
Adds the specified entry listener for the specified key.
|
String |
addLocalEntryListener(EntryListener<K,V> listener)
Adds a local entry listener for this multimap.
|
<SuppliedValue,Result> |
aggregate(Supplier<K,V,SuppliedValue> supplier,
Aggregation<K,SuppliedValue,Result> aggregation)
Executes a predefined aggregation on the multimaps data set.
|
<SuppliedValue,Result> |
aggregate(Supplier<K,V,SuppliedValue> supplier,
Aggregation<K,SuppliedValue,Result> aggregation,
JobTracker jobTracker)
Executes a predefined aggregation on the multimaps data set.
|
boolean |
containsEntry(K key,
V value)
Returns whether the multimap contains the given key-value pair.
|
boolean |
containsKey(K key)
Returns whether the multimap contains an entry with the key.
|
boolean |
containsValue(Object value)
Returns whether the multimap contains an entry with the value.
|
void |
delete(Object key)
Deletes all the entries with the given key.
|
Set<Map.Entry<K,V>> |
entrySet()
Returns the set of key-value pairs in the multimap.
|
void |
forceUnlock(K key)
Releases the lock for the specified key regardless of the lock owner.
|
Collection<V> |
get(K key)
Returns the collection of values associated with the key.
|
LocalMultiMapStats |
getLocalMultiMapStats()
Returns
LocalMultiMapStats for this map. |
void |
initialize() |
boolean |
isLocked(K key)
Checks the lock for the specified key.
|
Set<K> |
keySet()
Returns the set of keys in the multimap.
|
Set<K> |
localKeySet()
Returns the locally owned set of keys.
|
void |
lock(K key)
Acquires a lock for the specified key.
|
void |
lock(K key,
long leaseTime,
TimeUnit timeUnit)
Acquires the lock for the specified key for the specified lease time.
|
boolean |
put(K key,
V value)
Stores a key-value pair in the multimap.
|
Collection<V> |
remove(Object key)
Removes all the entries with the given key.
|
boolean |
remove(Object key,
Object value)
Removes the given key value pair from the multimap.
|
boolean |
removeEntryListener(String registrationId)
Removes the specified entry listener.
|
boolean |
tryLock(K key)
Tries to acquire the lock for the specified key.
|
boolean |
tryLock(K key,
long time,
TimeUnit timeunit)
Tries to acquire the lock for the specified key.
|
boolean |
tryLock(K key,
long time,
TimeUnit timeunit,
long leaseTime,
TimeUnit leaseUnit)
Tries to acquire the lock for the specified key for the specified
lease time.
|
void |
unlock(K key)
Releases the lock for the specified key.
|
int |
valueCount(K key)
Returns the number of values that match the given key in the multimap.
|
Collection<V> |
values()
Returns the collection of values in the multimap.
|
clear, containsInternal, countInternal, deleteInternal, entrySetInternal, getAllInternal, getName, getServiceName, keySetInternal, localKeySetInternal, putInternal, removeInternal, removeInternal, size, toString, valuesInternal
destroy, equals, getDistributedObjectName, getNameAsPartitionAwareData, getNodeEngine, getOperationService, getPartitionId, getPartitionKey, getService, hashCode, invalidate, invokeOnPartition, isClusterVersionEqualTo, isClusterVersionGreaterOrEqual, isClusterVersionGreaterThan, isClusterVersionLessOrEqual, isClusterVersionLessThan, isClusterVersionUnknown, isClusterVersionUnknownOrGreaterOrEqual, isClusterVersionUnknownOrGreaterThan, isClusterVersionUnknownOrLessOrEqual, isClusterVersionUnknownOrLessThan, postDestroy, preDestroy, throwNotActiveException, toData
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
destroy, getName, getPartitionKey, getServiceName
protected static final String NULL_KEY_IS_NOT_ALLOWED
protected static final String NULL_VALUE_IS_NOT_ALLOWED
public ObjectMultiMapProxy(MultiMapConfig config, MultiMapService service, NodeEngine nodeEngine, String name)
public void initialize()
initialize
in interface InitializingObject
public boolean put(K key, V value)
MultiMap
Warning: This method uses hashCode
and equals
of
the binary form of the key
, not the actual implementations of
hashCode
and equals
defined in the key
's class.
public Collection<V> get(K key)
MultiMap
Warning 1: This method uses hashCode
and equals
of
the binary form of the key
, not the actual implementations of
hashCode
and equals
defined in the key
's class.
Warning 2: The collection is NOT backed by the map, so changes to the map are NOT reflected in the collection, and vice-versa.
public boolean remove(Object key, Object value)
MultiMap
Warning: This method uses hashCode
and equals
of
the binary form of the key
, not the actual implementations of
hashCode
and equals
defined in the key
's class.
public Collection<V> remove(Object key)
MultiMap
Warning 1: This method uses hashCode
and equals
of
the binary form of the key
, not the actual implementations of
hashCode
and equals
defined in the key
's class.
Warning 2: The collection is NOT backed by the map, so changes to the map are NOT reflected in the collection, and vice-versa.
remove
in interface BaseMultiMap<K,V>
remove
in interface MultiMap<K,V>
key
- the key of the entries to removepublic void delete(Object key)
MultiMap
Warning: This method uses hashCode
and equals
of
the binary form of the key
, not the actual implementations of
hashCode
and equals
defined in the key
's class.
public Set<K> localKeySet()
MultiMap
Each key in this map is owned and managed by a specific member in the cluster.
Note that ownership of these keys might change over time so that key ownerships can be almost evenly distributed in the cluster.
Warning: The collection is NOT backed by the map, so changes to the map are NOT reflected in the collection, and vice-versa.
localKeySet
in interface MultiMap<K,V>
public Set<K> keySet()
MultiMap
Warning: The collection is NOT backed by the map, so changes to the map are NOT reflected in the collection, and vice-versa.
public Collection<V> values()
MultiMap
Warning: The collection is NOT backed by the map, so changes to the map are NOT reflected in the collection, and vice-versa.
public Set<Map.Entry<K,V>> entrySet()
MultiMap
Warning: The collection is NOT backed by the map, so changes to the map are NOT reflected in the collection, and vice-versa.
public boolean containsKey(K key)
MultiMap
Warning: This method uses hashCode
and equals
of
the binary form of the key
, not the actual implementations of
hashCode
and equals
defined in the key
's class.
containsKey
in interface MultiMap<K,V>
key
- the key whose existence is checkedtrue
if the multimap contains an entry with the key,
false
otherwisepublic boolean containsValue(Object value)
MultiMap
containsValue
in interface MultiMap<K,V>
value
- the value whose existence is checkedtrue
if the multimap contains an entry with the value,
false
otherwise.public boolean containsEntry(K key, V value)
MultiMap
Warning: This method uses hashCode
and equals
of
the binary form of the key
, not the actual implementations of
hashCode
and equals
defined in the key
's class.
containsEntry
in interface MultiMap<K,V>
key
- the key whose existence is checkedvalue
- the value whose existence is checkedtrue
if the multimap contains the key-value pair,
false
otherwisepublic int valueCount(K key)
MultiMap
Warning: This method uses hashCode
and equals
of
the binary form of the key
, not the actual implementations of
hashCode
and equals
defined in the key
's class.
valueCount
in interface BaseMultiMap<K,V>
valueCount
in interface MultiMap<K,V>
key
- the key whose values count is to be returnedpublic String addLocalEntryListener(EntryListener<K,V> listener)
MultiMap
The added listener will be only listening for the events (add/remove/update) of the locally owned entries.
Note that entries in distributed multimap are partitioned across the cluster members; each member owns and manages some portion of the entries. Owned entries are called local entries. This listener will be listening for the events of local entries.
For example your cluster has member1 and member2. On member2 you added a
local listener, and from member1, you call multimap.put(key2, value2)
.
If the key2 is owned by member2, then the local listener will be notified
for the add/update event. Also note that entries can migrate to other
nodes for load balancing and/or membership change.
addLocalEntryListener
in interface MultiMap<K,V>
listener
- entry listener for this multimapMultiMap.localKeySet()
public String addEntryListener(EntryListener<K,V> listener, boolean includeValue)
MultiMap
The listener will be notified for all multimap add/remove/update/evict events.
addEntryListener
in interface MultiMap<K,V>
listener
- entry listener for this multimapincludeValue
- true
if EntryEvent
should contain the value,
false
otherwisepublic boolean removeEntryListener(String registrationId)
MultiMap
Returns silently if no such listener was added before.
removeEntryListener
in interface MultiMap<K,V>
registrationId
- registration ID of listenerpublic String addEntryListener(EntryListener<K,V> listener, K key, boolean includeValue)
MultiMap
The listener will be notified for all add/remove/update/evict events for the specified key only.
Warning: This method uses hashCode
and equals
of
the binary form of the key
, not the actual implementations of
hashCode
and equals
defined in the key
's class.
addEntryListener
in interface MultiMap<K,V>
listener
- the entry listenerkey
- the key to listen toincludeValue
- true
if EntryEvent
should contain the value,
false
otherwisepublic void lock(K key)
MultiMap
If the lock is not available, then the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired.
The scope of the lock is for this multimap only. The acquired lock is only for the key in this multimap.
Locks are re-entrant, so if the key is locked N times, then it should be unlocked N times before another thread can acquire it.
Warning: This method uses hashCode
and equals
of
the binary form of the key
, not the actual implementations of
hashCode
and equals
defined in the key
's class.
public void lock(K key, long leaseTime, TimeUnit timeUnit)
MultiMap
After the lease time, the lock will be released.
If the lock is not available, then the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired.
Scope of the lock is for this map only.The acquired lock is only for the key in this map.
Locks are re-entrant, so if the key is locked N times, then it should be unlocked N times before another thread can acquire it.
Warning: This method uses hashCode
and equals
of
the binary form of the key
, not the actual implementations of
hashCode
and equals
defined in the key
's class.
public boolean isLocked(K key)
MultiMap
If the lock is acquired, this method returns true
, else it
returns false
.
Warning: This method uses hashCode
and equals
of
the binary form of the key
, not the actual implementations of
hashCode
and equals
defined in the key
's class.
public boolean tryLock(K key)
MultiMap
If the lock is not available, then the current thread does not wait and the method returns false immediately.
Warning: This method uses hashCode
and equals
of
the binary form of the key
, not the actual implementations of
hashCode
and equals
defined in the key
's class.
public boolean tryLock(K key, long time, TimeUnit timeunit) throws InterruptedException
MultiMap
If the lock is not available, then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of two things happens:
Warning: This method uses hashCode
and equals
of
the binary form of the key
, not the actual implementations of
hashCode
and equals
defined in the key
's class.
tryLock
in interface MultiMap<K,V>
time
- the maximum time to wait for the locktimeunit
- the time unit of the time
argumenttrue
if the lock was acquired, false
if the
waiting time elapsed before the lock was acquiredInterruptedException
public boolean tryLock(K key, long time, TimeUnit timeunit, long leaseTime, TimeUnit leaseUnit) throws InterruptedException
MultiMap
After lease time, the lock will be released.
If the lock is not available, then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of two things happens:
hashCode
and equals
of
the binary form of the key
, not the actual implementations of
hashCode
and equals
defined in the key
's class.tryLock
in interface MultiMap<K,V>
key
- key to lock in this maptime
- maximum time to wait for the locktimeunit
- time unit of the time
argumentleaseTime
- time to wait before releasing the lockleaseUnit
- unit of time to specify lease timetrue
if the lock was acquired and false
if the
waiting time elapsed before the lock was acquiredInterruptedException
public void unlock(K key)
MultiMap
It never blocks and returns immediately.
Warning: This method uses hashCode
and equals
of
the binary form of the key
, not the actual implementations of
hashCode
and equals
defined in the key
's class.
public void forceUnlock(K key)
MultiMap
It always successfully unlocks the key, never blocks and returns immediately.
Warning: This method uses hashCode
and equals
of
the binary form of the key
, not the actual implementations of
hashCode
and equals
defined in the key
's class.
forceUnlock
in interface MultiMap<K,V>
key
- key to lockpublic LocalMultiMapStats getLocalMultiMapStats()
MultiMap
LocalMultiMapStats
for this map.
LocalMultiMapStats
is the statistics for the local portion of this
distributed multi map and contains information such as ownedEntryCount
backupEntryCount, lastUpdateTime, and lockedEntryCount.
LocalMapStats
from all members of the cluster and combine them.getLocalMultiMapStats
in interface MultiMap<K,V>
public <SuppliedValue,Result> Result aggregate(Supplier<K,V,SuppliedValue> supplier, Aggregation<K,SuppliedValue,Result> aggregation)
MultiMap
The Supplier
is used to
either select or to select and extract a (sub-)value.
A predefined set of aggregations can be found in
Aggregations
.
Method does not honor Quorum.
aggregate
in interface MultiMap<K,V>
SuppliedValue
- the final type emitted from the supplierResult
- the resulting aggregation value typesupplier
- the supplier to select and / or extract a (sub-)value from the multimapaggregation
- the aggregation that is being executed against the multimappublic <SuppliedValue,Result> Result aggregate(Supplier<K,V,SuppliedValue> supplier, Aggregation<K,SuppliedValue,Result> aggregation, JobTracker jobTracker)
MultiMap
The Supplier
is used to
either select, or to select and extract, a (sub-)value.
A predefined set of aggregations can be found in
Aggregations
.
Method does not honor Quorum.
aggregate
in interface MultiMap<K,V>
SuppliedValue
- the final type emitted from the supplierResult
- the resulting aggregation value typesupplier
- the supplier to select and / or extract a (sub-)value from the multimapaggregation
- the aggregation that is being executed against the multimapjobTracker
- the JobTracker
instance to execute the aggregationCopyright © 2020 Hazelcast, Inc.. All Rights Reserved.