public interface MultiMap<K,V> extends BaseMultiMap<K,V>, DistributedObject
Gotchas:
IMap
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)
Deprecated.
The old Aggregations API is superseded by Fast Aggregations (
com.hazelcast.aggregation )
which does not yet support MultiMap. Hazelcast Jet can be used in the future to replace this functionality. |
<SuppliedValue,Result> |
aggregate(Supplier<K,V,SuppliedValue> supplier,
Aggregation<K,SuppliedValue,Result> aggregation,
JobTracker jobTracker)
Deprecated.
The old Aggregations API is superseded by Fast Aggregations (
com.hazelcast.aggregation )
which does not yet support MultiMap. Hazelcast Jet can be used in the future to replace this functionality. |
void |
clear()
Clears the multimap.
|
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.
|
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.
|
String |
getName()
Returns the name of this multimap.
|
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.
|
int |
size()
Returns the number of key-value pairs in the multimap.
|
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 leaseTimeunit)
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.
|
destroy, getPartitionKey, getServiceName
String getName()
getName
in interface DistributedObject
boolean put(K key, V value)
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.
put
in interface BaseMultiMap<K,V>
key
- the key to be storedvalue
- the value to be storedCollection<V> get(K key)
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.
Warning-2:
The collection is NOT backed by the map, so changes to the map are NOT reflected in the collection, and vice-versa.get
in interface BaseMultiMap<K,V>
key
- the key whose associated values are to be returnedboolean remove(Object key, Object value)
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.remove
in interface BaseMultiMap<K,V>
key
- the key of the entry to removevalue
- the value of the entry to removeCollection<V> remove(Object key)
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.
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>
key
- the key of the entries to removeSet<K> localKeySet()
Warning:
The set is NOT backed by the map, so changes to the map are NOT reflected in the set, and vice-versa.Set<K> keySet()
Warning:
The set is NOT backed by the map, so changes to the map are NOT reflected in the set, and vice-versa.Collection<V> values()
Warning:
The collection is NOT backed by the map, so changes to the map are NOT reflected in the collection, and vice-versa.Set<Map.Entry<K,V>> entrySet()
Warning:
The set is NOT backed by the map, so changes to the map are NOT reflected in the set, and vice-versa.boolean containsKey(K key)
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.
key
- the key whose existence is checked.boolean containsValue(Object value)
value
- the value whose existence is checked.boolean containsEntry(K key, V value)
key
- the key whose existence is checked.value
- the value whose existence is checked.int size()
size
in interface BaseMultiMap<K,V>
void clear()
int valueCount(K key)
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>
key
- the key whose values count is to be returnedString addLocalEntryListener(EntryListener<K,V> listener)
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.listener
- entry listener for this multimaplocalKeySet()
String addEntryListener(EntryListener<K,V> listener, boolean includeValue)
listener
- entry listener for this multimapincludeValue
- true if EntryEvent should
contain the value, false otherwiseboolean removeEntryListener(String registrationId)
registrationId
- registration id of listenerString addEntryListener(EntryListener<K,V> listener, K key, boolean includeValue)
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.
listener
- the entry listenerkey
- the key to listen toincludeValue
- true if EntryEvent should
contain the value, false otherwisevoid lock(K key)
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.
key
- the key to lock.void lock(K key, long leaseTime, TimeUnit timeUnit)
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.key
- the key to lock.leaseTime
- time to wait before releasing the lock.timeUnit
- unit of time for the lease time.boolean isLocked(K key)
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.key
- key to lock to be checked.boolean tryLock(K key)
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.
key
- the key to lock.boolean tryLock(K key, long time, TimeUnit timeunit) throws InterruptedException
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.
time
- the maximum time to wait for the locktimeunit
- the time unit of the time argumentInterruptedException
boolean tryLock(K key, long time, TimeUnit timeunit, long leaseTime, TimeUnit leaseTimeunit) throws InterruptedException
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:
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.key
- key to lock in this map.time
- maximum time to wait for the lock.timeunit
- time unit of the time argument.leaseTime
- time to wait before releasing the lock.leaseTimeunit
- unit of time to specify lease time.NullPointerException
- if the specified key is null.InterruptedException
void unlock(K key)
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.
key
- the key to lock.void forceUnlock(K key)
Warning:
This method uses hashCode and equals of binary form of the key, not the actual implementations of hashCode and equals defined in key's class.key
- key to lock.LocalMultiMapStats getLocalMultiMapStats()
LocalMapStats
from all members of the cluster and combine them.@Deprecated <SuppliedValue,Result> Result aggregate(Supplier<K,V,SuppliedValue> supplier, Aggregation<K,SuppliedValue,Result> aggregation)
com.hazelcast.aggregation
)
which does not yet support MultiMap. Hazelcast Jet can be used in the future to replace this functionality.Supplier
is used to either select or to select and extract a (sub-)value. A predefined set of aggregations can be found in
Aggregations
.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 multimap@Deprecated <SuppliedValue,Result> Result aggregate(Supplier<K,V,SuppliedValue> supplier, Aggregation<K,SuppliedValue,Result> aggregation, JobTracker jobTracker)
com.hazelcast.aggregation
)
which does not yet support MultiMap. Hazelcast Jet can be used in the future to replace this functionality.Supplier
is used to either select, or to select and extract, a (sub-)value. A predefined set of aggregations can be found in
Aggregations
.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 © 2017 Hazelcast, Inc.. All Rights Reserved.