public class ClientMapProxy<K,V> extends ClientProxy implements IMap<K,V>
Modifier and Type | Field and Description |
---|---|
protected static String |
NULL_KEY_IS_NOT_ALLOWED |
protected static String |
NULL_LISTENER_IS_NOT_ALLOWED |
protected static String |
NULL_PREDICATE_IS_NOT_ALLOWED |
protected static String |
NULL_VALUE_IS_NOT_ALLOWED |
name
Constructor and Description |
---|
ClientMapProxy(String serviceName,
String name) |
Modifier and Type | Method and Description |
---|---|
String |
addEntryListener(EntryListener listener,
boolean includeValue)
Adds an entry listener for this map.
|
String |
addEntryListener(EntryListener listener,
K key,
boolean includeValue)
Adds the specified entry listener for the specified key.
|
String |
addEntryListener(EntryListener listener,
Predicate<K,V> predicate,
boolean includeValue)
Adds an continuous entry listener for this map.
|
String |
addEntryListener(EntryListener listener,
Predicate<K,V> predicate,
K key,
boolean includeValue)
Adds an continuous entry listener for this map.
|
String |
addEntryListener(MapListener listener,
boolean includeValue)
Adds a
MapListener for this map. |
String |
addEntryListener(MapListener listener,
K key,
boolean includeValue)
Adds a
MapListener for this map. |
String |
addEntryListener(MapListener listener,
Predicate<K,V> predicate,
boolean includeValue)
Adds a
MapListener for this map. |
String |
addEntryListener(MapListener listener,
Predicate<K,V> predicate,
K key,
boolean includeValue)
Adds a
MapListener for this map. |
void |
addIndex(String attribute,
boolean ordered)
Adds an index to this map for the specified entries so
that queries can run faster.
|
String |
addInterceptor(MapInterceptor interceptor)
Adds an interceptor for this map.
|
String |
addLocalEntryListener(EntryListener listener)
Adds a local entry listener for this map.
|
String |
addLocalEntryListener(EntryListener listener,
Predicate<K,V> predicate,
boolean includeValue)
Adds a local entry listener for this map.
|
String |
addLocalEntryListener(EntryListener listener,
Predicate<K,V> predicate,
K key,
boolean includeValue)
Adds a local entry listener for this map.
|
String |
addLocalEntryListener(MapListener listener)
Adds a
MapListener for this map. |
String |
addLocalEntryListener(MapListener listener,
Predicate<K,V> predicate,
boolean includeValue)
Adds a
MapListener for this map. |
String |
addLocalEntryListener(MapListener listener,
Predicate<K,V> predicate,
K key,
boolean includeValue)
Adds a local entry listener for this map.
|
String |
addPartitionLostListener(MapPartitionLostListener listener)
Adds a MapPartitionLostListener.
|
<SuppliedValue,Result> |
aggregate(Supplier<K,V,SuppliedValue> supplier,
Aggregation<K,SuppliedValue,Result> aggregation)
Executes a predefined aggregation on the maps data set.
|
<SuppliedValue,Result> |
aggregate(Supplier<K,V,SuppliedValue> supplier,
Aggregation<K,SuppliedValue,Result> aggregation,
JobTracker jobTracker)
Executes a predefined aggregation on the maps data set.
|
void |
clear()
This method clears the map and invokes
MapStore.deleteAll(java.util.Collection<K>) deleteAll on MapStore which,
if connected to a database, will delete the records from that database. |
boolean |
containsKey(Object key)
Returns
true if this map contains an entry for the specified
key. |
protected boolean |
containsKeyInternal(Data keyData) |
boolean |
containsValue(Object value) |
void |
delete(Object key)
Removes the mapping for a key from this map if it is present
(optional operation).
|
protected void |
deleteInternal(Data keyData) |
Set<Map.Entry<K,V>> |
entrySet()
Returns a
Set clone of the mappings contained in this map. |
Set<Map.Entry<K,V>> |
entrySet(Predicate predicate)
Queries the map based on the specified predicate and
returns the matching entries.
|
Set<Map.Entry<K,V>> |
entrySetWithPagingPredicate(PagingPredicate pagingPredicate) |
boolean |
evict(K key)
Evicts the specified key from this map.
|
void |
evictAll()
Evicts all keys from this map except the locked ones.
|
protected boolean |
evictInternal(Data keyData) |
Map<K,Object> |
executeOnEntries(EntryProcessor entryProcessor)
Applies the user defined EntryProcessor to the all entries in the map.
|
Map<K,Object> |
executeOnEntries(EntryProcessor entryProcessor,
Predicate predicate)
Applies the user defined EntryProcessor to the entries in the map which satisfies provided predicate.
|
Object |
executeOnKey(K key,
EntryProcessor entryProcessor)
Applies the user defined EntryProcessor to the entry mapped by the key.
|
Object |
executeOnKeyInternal(Data keyData,
EntryProcessor entryProcessor) |
Map<K,Object> |
executeOnKeys(Set<K> keys,
EntryProcessor entryProcessor)
Applies the user defined EntryProcessor to the entries mapped by the collection of keys.
|
void |
flush()
If this map has a MapStore, this method flushes
all the local dirty entries by calling MapStore.storeAll() and/or MapStore.deleteAll().
|
void |
forceUnlock(K key)
Releases the lock for the specified key regardless of the lock owner.
|
V |
get(Object key)
Returns the value for the specified key, or
null if this map does not contain this key. |
Map<K,V> |
getAll(Set<K> keys)
Returns the entries for the given keys.
|
protected List<com.hazelcast.client.impl.protocol.codec.MapGetAllCodec.ResponseParameters> |
getAllInternal(Map<Integer,List<Data>> partitionToKeyData,
Map<K,V> result) |
Future<V> |
getAsync(K key)
Asynchronously gets the given key.
|
protected ICompletableFuture<V> |
getAsyncInternal(Data keyData) |
EntryView<K,V> |
getEntryView(K key)
Returns the EntryView for the specified key.
|
protected V |
getInternal(Data keyData) |
LocalMapStats |
getLocalMapStats()
Returns LocalMapStats for this map.
|
protected long |
getTimeInMillis(long time,
TimeUnit timeunit) |
boolean |
isEmpty()
Returns true if this map contains no entries.
|
boolean |
isLocked(K key)
Checks the lock for the specified key.
|
Set<K> |
keySet()
Returns a set clone of the keys contained in this map.
|
Set<K> |
keySet(Predicate predicate)
Queries the map based on the specified predicate and
returns the keys of matching entries.
|
void |
loadAll(boolean replaceExistingValues)
Loads all keys into the store.
|
void |
loadAll(Set<K> keys,
boolean replaceExistingValues)
Loads the given keys.
|
protected void |
loadAllInternal(boolean replaceExistingValues,
Set<Data> dataKeys) |
Set<K> |
localKeySet()
Returns the locally owned set of keys.
|
Set<K> |
localKeySet(Predicate predicate)
Returns the keys of matching locally owned entries.
|
void |
lock(K key)
Acquires the 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.
|
protected Map<K,Object> |
prepareResult(Collection<Map.Entry<Data,Data>> entries) |
V |
put(K key,
V value)
Associates the specified value with the specified key in this map.
|
V |
put(K key,
V value,
long ttl,
TimeUnit timeunit)
Puts an entry into this map with a given ttl (time to live) value.
|
void |
putAll(Map<? extends K,? extends V> m)
No atomicity guarantees are given.
|
protected void |
putAllInternal(Map<Integer,Map<Data,Data>> entryMap) |
Future<V> |
putAsync(K key,
V value)
Asynchronously puts the given key and value.
|
Future<V> |
putAsync(K key,
V value,
long ttl,
TimeUnit timeunit)
Asynchronously puts the given key and value into this map with a given ttl (time to live) value.
|
protected Future<V> |
putAsyncInternal(long ttl,
TimeUnit timeunit,
Data keyData,
Data valueData) |
V |
putIfAbsent(K key,
V value)
If the specified key is not already associated
with a value, associate it with the given value.
|
V |
putIfAbsent(K key,
V value,
long ttl,
TimeUnit timeunit)
Puts an entry into this map with a given ttl (time to live) value
if the specified key is not already associated with a value.
|
protected V |
putIfAbsentInternal(long ttl,
TimeUnit timeunit,
Data keyData,
Data valueData) |
protected V |
putInternal(long ttl,
TimeUnit timeunit,
Data keyData,
Data valueData) |
void |
putTransient(K key,
V value,
long ttl,
TimeUnit timeunit)
Same as
#put(K, V, long, java.util.concurrent.TimeUnit) except that MapStore, if defined,
will not be called to store/persist the entry. |
protected void |
putTransientInternal(long ttl,
TimeUnit timeunit,
Data keyData,
Data valueData) |
V |
remove(Object key)
Removes the mapping for a key from this map if it is present.
|
boolean |
remove(Object key,
Object value)
Removes the entry for a key only if currently mapped to a given value.
|
Future<V> |
removeAsync(K key)
Asynchronously removes the given key.
|
protected Future<V> |
removeAsyncInternal(Data keyData) |
boolean |
removeEntryListener(String registrationId)
Removes the specified entry listener.
|
void |
removeInterceptor(String id)
Removes the given interceptor for this map so it will not intercept operations anymore.
|
protected com.hazelcast.client.impl.protocol.codec.MapRemoveCodec.ResponseParameters |
removeInternal(Data keyData) |
protected boolean |
removeInternal(Data keyData,
Data valueData) |
boolean |
removePartitionLostListener(String registrationId)
Removes the specified map partition lost listener.
|
V |
replace(K key,
V value)
Replaces the entry for a key only if it is currently mapped to some value.
|
boolean |
replace(K key,
V oldValue,
V newValue)
Replaces the entry for a key only if currently mapped to a given value.
|
protected boolean |
replaceIfSameInternal(Data keyData,
Data oldValueData,
Data newValueData) |
protected V |
replaceInternal(Data keyData,
Data valueData) |
void |
set(K key,
V value)
Puts an entry into this map.
|
void |
set(K key,
V value,
long ttl,
TimeUnit timeunit)
Puts an entry into this map with a given ttl (time to live) value.
|
protected void |
setInternal(long ttl,
TimeUnit timeunit,
Data keyData,
Data valueData) |
int |
size()
Returns the number of entries in this map.
|
Future |
submitToKey(K key,
EntryProcessor entryProcessor)
Applies the user defined EntryProcessor to the entry mapped by the key.
|
void |
submitToKey(K key,
EntryProcessor entryProcessor,
ExecutionCallback callback)
Applies the user defined EntryProcessor to the entry mapped by the key with
specified ExecutionCallback to listen event status and returns immediately.
|
Future |
submitToKeyInternal(Data keyData,
EntryProcessor entryProcessor) |
void |
submitToKeyInternal(Data keyData,
EntryProcessor entryProcessor,
ExecutionCallback callback) |
String |
toString() |
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.
|
boolean |
tryPut(K key,
V value,
long timeout,
TimeUnit timeunit)
Tries to put the given key and value into this map within a specified
timeout value.
|
protected boolean |
tryPutInternal(long timeout,
TimeUnit timeunit,
Data keyData,
Data valueData) |
boolean |
tryRemove(K key,
long timeout,
TimeUnit timeunit)
Tries to remove the entry with the given key from this map
within the specified timeout value.
|
protected boolean |
tryRemoveInternal(long timeout,
TimeUnit timeunit,
Data keyData) |
void |
unlock(K key)
Releases the lock for the specified key.
|
Collection<V> |
values()
Returns a collection clone of the values contained in this map.
|
Collection<V> |
values(Predicate predicate)
Queries the map based on the specified predicate and
returns the values of matching entries.
|
deregisterListener, destroy, equals, getClient, getContext, getId, getName, getPartitionKey, getServiceName, hashCode, invoke, invoke, invokeOnPartition, invokeOnPartitionInterruptibly, onDestroy, onInitialize, onShutdown, registerListener, setContext, throwExceptionIfNull, toData, toObject
clone, equals, 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
protected static final String NULL_LISTENER_IS_NOT_ALLOWED
protected static final String NULL_PREDICATE_IS_NOT_ALLOWED
public boolean containsKey(Object key)
IMap
true
if this map contains an entry for the specified
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. The key will first be searched for in memory. If the key is not
found, and if a key is attributed, a MapLoader
will then attempt to load the key.
containsKey
in interface BaseMap<K,V>
containsKey
in interface IMap<K,V>
containsKey
in interface Map<K,V>
key
- The specified key.true
if this map contains an entry for the specified key.protected boolean containsKeyInternal(Data keyData)
public boolean containsValue(Object value)
IMap
containsValue
in interface IMap<K,V>
containsValue
in interface Map<K,V>
public V get(Object key)
IMap
null
if this map does not contain this key.
Warning:
This method returns a clone of the original value, so modifying the returned value does not change the actual value in the map. You should put the modified value back to make changes visible to all nodes.
V value = map.get(key); value.updateSomeProperty(); map.put(key, value);
Warning-2:
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 V put(K key, V value)
IMap
Warning:
This method returns a clone of the previous value, not the original (identically equal) value previously put into the map.
Warning-2:
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 V remove(Object key)
IMap
The map will not contain a mapping for the specified key once the call returns.
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:
This method returns a clone of the previous value, not the original (identically equal) value previously put into the map.
protected com.hazelcast.client.impl.protocol.codec.MapRemoveCodec.ResponseParameters removeInternal(Data keyData)
public boolean remove(Object key, Object value)
IMap
if (map.containsKey(key) && map.get(key).equals(value)) { map.remove(key); return true; } else return false;except that the action is performed atomically.
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 delete(Object key)
IMap
Unlike IMap.remove(Object)
, this operation does not return
the removed value, which avoids the serialization cost of the returned value.
The map will not contain a mapping for the specified key once the call returns.
Warning:
This method breaks the contract of EntryListener. When an entry is removed by delete(), it fires an EntryEvent with a null oldValue. Also, a listener with predicates will have null values, so only keys can be queried via predicates.protected void deleteInternal(Data keyData)
public void flush()
IMap
public Future<V> getAsync(K key)
IMap
Future future = map.getAsync(key);
// do some other stuff, when ready get the result.
Object value = future.get();
Future.get() will block until the actual map.get() completes.
If the application requires timely response,
then Future.get(timeout, timeunit) can be used.
try{
Future future = map.getAsync(key);
Object value = future.get(40, TimeUnit.MILLISECOND);
}catch (TimeoutException t) {
// time wasn't enough
}
ExecutionException is never thrown.
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.protected ICompletableFuture<V> getAsyncInternal(Data keyData)
public Future<V> putAsync(K key, V value)
IMap
Future future = map.putAsync(key, value);
// do some other stuff, when ready get the result.
Object oldValue = future.get();
Future.get() will block until the actual map.put() completes.
If the application requires a timely response,
then you can use Future.get(timeout, timeunit).
try{
Future future = map.putAsync(key, newValue);
Object oldValue = future.get(40, TimeUnit.MILLISECOND);
}catch (TimeoutException t) {
// time wasn't enough
}
ExecutionException is never thrown.
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 Future<V> putAsync(K key, V value, long ttl, TimeUnit timeunit)
IMap
Future future = map.putAsync(key, value, ttl, timeunit);
// do some other stuff, when ready get the result
Object oldValue = future.get();
Future.get() will block until the actual map.get() completes.
If your application requires a timely response,
then you can use Future.get(timeout, timeunit).
try{
Future future = map.putAsync(key, newValue, ttl, timeunit);
Object oldValue = future.get(40, TimeUnit.MILLISECOND);
}catch (TimeoutException t) {
// time wasn't enough
}
ExecutionException is never thrown.
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:
Time resolution for TTL is seconds. The given TTL value is rounded to the next closest second value.putAsync
in interface IMap<K,V>
key
- the key of the map entry.value
- the new value of the map entry.ttl
- maximum time for this entry to stay in the map.
0 means infinite.timeunit
- time unit for the ttl.Future
protected Future<V> putAsyncInternal(long ttl, TimeUnit timeunit, Data keyData, Data valueData)
public Future<V> removeAsync(K key)
IMap
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.removeAsync
in interface IMap<K,V>
key
- The key of the map entry to remove.Future
from which the value
removed from the map can be retrieved.public boolean tryRemove(K key, long timeout, TimeUnit timeunit)
IMap
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:
This method returns a clone of the previous value, not the original (identically equal) value previously put into the map.
protected boolean tryRemoveInternal(long timeout, TimeUnit timeunit, Data keyData)
public boolean tryPut(K key, V value, long timeout, TimeUnit timeunit)
IMap
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.protected boolean tryPutInternal(long timeout, TimeUnit timeunit, Data keyData, Data valueData)
public V put(K key, V value, long ttl, TimeUnit timeunit)
IMap
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:
This method returns a clone of the previous value, not the original (identically equal) value previously put into the map.
Warning 3:
Time resolution for TTL is seconds. The given TTL value is rounded to the next closest second value.public void putTransient(K key, V value, long ttl, TimeUnit timeunit)
IMap
#put(K, V, long, java.util.concurrent.TimeUnit)
except that MapStore, if defined,
will not be called to store/persist the entry. If ttl is 0, then
the entry lives forever.
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:
Time resolution for TTL is seconds. The given TTL value is rounded to next closest second value.putTransient
in interface IMap<K,V>
key
- key of the entryvalue
- value of the entryttl
- maximum time for this entry to stay in the map.
0 means infinite.timeunit
- time unit for the ttlprotected void putTransientInternal(long ttl, TimeUnit timeunit, Data keyData, Data valueData)
public V putIfAbsent(K key, V value)
IMap
if (!map.containsKey(key)) return map.put(key, value); else return map.get(key);except that the action is performed atomically.
Note:
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.Also, this method returns a clone of the previous value, not the original (identically equal) value previously put into the map.
putIfAbsent
in interface BaseMap<K,V>
putIfAbsent
in interface IMap<K,V>
putIfAbsent
in interface ConcurrentMap<K,V>
key
- The specified key.value
- The value to associate with the key when there is no previous value.public V putIfAbsent(K key, V value, long ttl, TimeUnit timeunit)
IMap
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:
This method returns a clone of the previous value, not the original (identically equal) value previously put into the map.
Warning 3:
Time resolution for TTL is seconds. The given TTL value is rounded to the next closest second value.putIfAbsent
in interface IMap<K,V>
key
- key of the entry.value
- value of the entry.ttl
- maximum time for this entry to stay in the map.timeunit
- time unit for the ttl.protected V putIfAbsentInternal(long ttl, TimeUnit timeunit, Data keyData, Data valueData)
public boolean replace(K key, V oldValue, V newValue)
IMap
if (map.containsKey(key) && map.get(key).equals(oldValue)) { map.put(key, newValue); return true; } else return false;except that the action is performed atomically.
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.replace
in interface BaseMap<K,V>
replace
in interface IMap<K,V>
replace
in interface ConcurrentMap<K,V>
key
- The specified key.oldValue
- Replace the key value if it is the old value.newValue
- The new value to replace the old value.true
if the value was replaced.protected boolean replaceIfSameInternal(Data keyData, Data oldValueData, Data newValueData)
public V replace(K key, V value)
IMap
if (map.containsKey(key)) { return map.put(key, value); } else return null;except that the action is performed atomically.
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:
This method returns a clone of the previous value, not the original (identically equal) value previously put into the map.
replace
in interface BaseMap<K,V>
replace
in interface IMap<K,V>
replace
in interface ConcurrentMap<K,V>
key
- The specified key.value
- The value to replace the previous value.key
, or null
if there was no mapping for key
.public void set(K key, V value, long ttl, TimeUnit timeunit)
IMap
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:
Time resolution for TTL is seconds. The given TTL value is rounded to the next closest second value.public void lock(K key)
IMap
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.
You get a lock whether the value is present in the map or not. Other threads (possibly on other systems) would block on their invoke oflock()
until the non-existent key is unlocked. If the lock
holder introduces the key to the map, the put()
operation
is not blocked. If a thread not holding a lock on the non-existent key
tries to introduce the key while a lock exists on the non-existent key,
the put()
operation blocks until it is unlocked.
Scope of the lock is this map only.
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.
There is no lock timeout on this method. Locks will be held infinitely.
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)
IMap
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 the lock has been acquired.
Scope of the lock is this map only. 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)
IMap
If the lock is acquired then returns true, else 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)
IMap
If the lock is not available then the current thread doesn't wait and 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
IMap
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 IMap<K,V>
key
- key to lock in this map.time
- maximum time to wait for the lock.timeunit
- time unit of the time argument.InterruptedException
public boolean tryLock(K key, long time, TimeUnit timeunit, long leaseTime, TimeUnit leaseUnit) throws InterruptedException
IMap
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.tryLock
in interface IMap<K,V>
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.leaseUnit
- unit of time to specify lease time.InterruptedException
public void unlock(K key)
IMap
If the current thread is the holder of this lock, then the hold
count is decremented. If the hold count is zero, then the lock
is released. If the current thread is not the holder of this
lock, then IllegalMonitorStateException
is thrown.
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)
IMap
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 IMap<K,V>
key
- the key to lock.public String addLocalEntryListener(MapListener listener)
IMap
MapListener
for this map. To receive an event, you should
implement a corresponding MapListener
sub-interface for that event.
Note that entries in distributed map are partitioned across
the cluster members; each member owns and manages the some portion of the
entries. Owned entries are called local entries. This
listener will be listening for the events of local entries. Let's say
your cluster has member1 and member2. On member2 you added a local listener and from
member1, you call map.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 IMap<K,V>
listener
- MapListener
for this map.IMap.localKeySet()
,
MapListener
public String addLocalEntryListener(EntryListener listener)
IMap
map.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 IMap<K,V>
listener
- entry listener.IMap.localKeySet()
public String addLocalEntryListener(MapListener listener, Predicate<K,V> predicate, boolean includeValue)
IMap
MapListener
for this map. To receive an event, you should
implement a corresponding MapListener
sub-interface for that event.
Listener will get notified for map events filtered by the given predicate.addLocalEntryListener
in interface IMap<K,V>
listener
- MapListener
for this map.predicate
- predicate for filtering entriesincludeValue
- true if EntryEvent should
contain the value.MapListener
public String addLocalEntryListener(EntryListener listener, Predicate<K,V> predicate, boolean includeValue)
IMap
addLocalEntryListener
in interface IMap<K,V>
listener
- entry listenerpredicate
- predicate for filtering entriesincludeValue
- true if EntryEvent should
contain the value.public String addLocalEntryListener(MapListener listener, Predicate<K,V> predicate, K key, boolean includeValue)
IMap
addLocalEntryListener
in interface IMap<K,V>
listener
- MapListener
for this map.predicate
- predicate for filtering entries.key
- key to listen for.includeValue
- true if EntryEvent should
contain the value.MapListener
public String addLocalEntryListener(EntryListener listener, Predicate<K,V> predicate, K key, boolean includeValue)
IMap
addLocalEntryListener
in interface IMap<K,V>
listener
- entry listener.predicate
- predicate for filtering entries.key
- key to listen for.includeValue
- true if EntryEvent should
contain the value.public String addInterceptor(MapInterceptor interceptor)
IMap
addInterceptor
in interface IMap<K,V>
interceptor
- map interceptor.public void removeInterceptor(String id)
IMap
removeInterceptor
in interface IMap<K,V>
id
- registration id of the map interceptor.public String addEntryListener(MapListener listener, boolean includeValue)
IMap
MapListener
for this map. To receive an event, you should
implement a corresponding MapListener
sub-interface for that event.addEntryListener
in interface IMap<K,V>
listener
- MapListener
for this map.includeValue
- true if EntryEvent should
contain the value.MapListener
public String addEntryListener(EntryListener listener, boolean includeValue)
IMap
addEntryListener
in interface IMap<K,V>
listener
- the added entry listener for this map.includeValue
- true if EntryEvent should
contain the value.public boolean removeEntryListener(String registrationId)
IMap
removeEntryListener
in interface IMap<K,V>
registrationId
- id of registered listener.public String addPartitionLostListener(MapPartitionLostListener listener)
IMap
IMap.removePartitionLostListener(String)
method.
There is no check for duplicate registrations, so if you register the listener twice, it will get events twice.
IMPORTANT: Please @see com.hazelcast.partition.PartitionLostListener for weaknesses.
IMPORTANT: Listeners registered from HazelcastClient may miss some of the map partition lost events due
to design limitations.addPartitionLostListener
in interface IMap<K,V>
listener
- the added MapPartitionLostListener.IMap.removePartitionLostListener(String)
public boolean removePartitionLostListener(String registrationId)
IMap
removePartitionLostListener
in interface IMap<K,V>
registrationId
- id of registered listener.public String addEntryListener(MapListener listener, K key, boolean includeValue)
IMap
MapListener
for this map. To receive an event, you should
implement a corresponding MapListener
sub-interface for that event.
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 IMap<K,V>
listener
- MapListener
for this map.key
- key to listen for.includeValue
- true if EntryEvent should
contain the value.MapListener
public String addEntryListener(EntryListener listener, K key, boolean includeValue)
IMap
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 IMap<K,V>
listener
- specified entry listener.key
- key to listen for.includeValue
- true if EntryEvent should
contain the value.public String addEntryListener(MapListener listener, Predicate<K,V> predicate, K key, boolean includeValue)
IMap
MapListener
for this map. To receive an event, you should
implement a corresponding MapListener
sub-interface for that event.addEntryListener
in interface IMap<K,V>
listener
- the continuous MapListener
for this map.predicate
- predicate for filtering entries.key
- key to listen for.includeValue
- true if EntryEvent should
contain the value.MapListener
public String addEntryListener(EntryListener listener, Predicate<K,V> predicate, K key, boolean includeValue)
IMap
addEntryListener
in interface IMap<K,V>
listener
- the continuous entry listener for this map.predicate
- predicate for filtering entries.key
- key to listen for.includeValue
- true if EntryEvent should
contain the value.public String addEntryListener(MapListener listener, Predicate<K,V> predicate, boolean includeValue)
IMap
MapListener
for this map. To receive an event, you should
implement a corresponding MapListener
sub-interface for that event.addEntryListener
in interface IMap<K,V>
listener
- the added continuous MapListener
for this map.predicate
- predicate for filtering entries.includeValue
- true if EntryEvent should
contain the value.MapListener
public String addEntryListener(EntryListener listener, Predicate<K,V> predicate, boolean includeValue)
IMap
addEntryListener
in interface IMap<K,V>
listener
- the added continuous entry listener for this map.predicate
- predicate for filtering entries.includeValue
- true if EntryEvent should
contain the value.public EntryView<K,V> getEntryView(K key)
IMap
Warning:
This method returns a clone of original mapping, modifying the returned value does not change the actual value in the map. One should put modified value back to make changes visible to all nodes.
Warning-2:
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.getEntryView
in interface IMap<K,V>
key
- the key of the entry.EntryView
public boolean evict(K key)
IMap
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.protected boolean evictInternal(Data keyData)
public void evictAll()
IMap
IMap.clear()
method.
The EVICT_ALL event is fired for any registered listeners.
See MapEvictedListener.mapEvicted(MapEvent)
.evictAll
in interface IMap<K,V>
IMap.clear()
public void loadAll(boolean replaceExistingValues)
IMap
public void loadAll(Set<K> keys, boolean replaceExistingValues)
IMap
public Set<K> keySet()
IMap
Warning:
The set is NOT backed by the map, so changes to the map are NOT reflected in the set, and vice-versa. This method is always executed by a distributed query, so it may throw aQueryResultSizeExceededException
if GroupProperty.QUERY_RESULT_SIZE_LIMIT
is configured.public Map<K,V> getAll(Set<K> keys)
IMap
MapLoader.loadAll(java.util.Collection)
.
Warning:
The returned map is NOT backed by the original map, so changes to the original map are NOT reflected in the returned map, and vice-versa.Warning-2:
This method uses hashCode and equals of the binary form of the keys, not the actual implementations of hashCode and equals defined in the key's class.protected List<com.hazelcast.client.impl.protocol.codec.MapGetAllCodec.ResponseParameters> getAllInternal(Map<Integer,List<Data>> partitionToKeyData, Map<K,V> result)
public Collection<V> values()
IMap
Warning:
The collection is NOT backed by the map, so changes to the map are NOT reflected in the collection, and vice-versa. This method is always executed by a distributed query, so it may throw aQueryResultSizeExceededException
if GroupProperty.QUERY_RESULT_SIZE_LIMIT
is configured.public Set<Map.Entry<K,V>> entrySet()
IMap
Set
clone of the mappings contained in this map.
Warning:
The set is NOT backed by the map, so changes to the map are NOT reflected in the set, and vice-versa. This method is always executed by a distributed query, so it may throw aQueryResultSizeExceededException
if GroupProperty.QUERY_RESULT_SIZE_LIMIT
is configured.public Set<K> keySet(Predicate predicate)
IMap
Warning:
The set is NOT backed by the map, so changes to the map are NOT reflected in the set, and vice-versa. This method is always executed by a distributed query, so it may throw aQueryResultSizeExceededException
if GroupProperty.QUERY_RESULT_SIZE_LIMIT
is configured.keySet
in interface IMap<K,V>
predicate
- specified query criteria.GroupProperty.QUERY_RESULT_SIZE_LIMIT
public Set<Map.Entry<K,V>> entrySet(Predicate predicate)
IMap
Warning:
The set is NOT backed by the map, so changes to the map are NOT reflected in the set, and vice-versa. This method is always executed by a distributed query, so it may throw aQueryResultSizeExceededException
if GroupProperty.QUERY_RESULT_SIZE_LIMIT
is configured.entrySet
in interface IMap<K,V>
predicate
- specified query criteria.GroupProperty.QUERY_RESULT_SIZE_LIMIT
public Set<Map.Entry<K,V>> entrySetWithPagingPredicate(PagingPredicate pagingPredicate)
public Collection<V> values(Predicate predicate)
IMap
Warning:
The collection is NOT backed by the map, so changes to the map are NOT reflected in the collection, and vice-versa. This method is always executed by a distributed query, so it may throw aQueryResultSizeExceededException
if GroupProperty.QUERY_RESULT_SIZE_LIMIT
is configured.values
in interface IMap<K,V>
predicate
- specified query criteria.GroupProperty.QUERY_RESULT_SIZE_LIMIT
public Set<K> localKeySet()
IMap
Warning:
The set is NOT backed by the map, so changes to the map are NOT reflected in the set, and vice-versa. This method is always executed by a distributed query, so it may throw aQueryResultSizeExceededException
if GroupProperty.QUERY_RESULT_SIZE_LIMIT
is configured.localKeySet
in interface IMap<K,V>
GroupProperty.QUERY_RESULT_SIZE_LIMIT
public Set<K> localKeySet(Predicate predicate)
IMap
Warning:
The set is NOT backed by the map, so changes to the map are NOT reflected in the set, and vice-versa. This method is always executed by a distributed query, so it may throw aQueryResultSizeExceededException
if GroupProperty.QUERY_RESULT_SIZE_LIMIT
is configured.localKeySet
in interface IMap<K,V>
predicate
- specified query criteria.GroupProperty.QUERY_RESULT_SIZE_LIMIT
public void addIndex(String attribute, boolean ordered)
IMap
public class Employee implements Serializable { private boolean active = false; private int age; private String name = null; // other fields. // getters setter }If you are querying your values mostly based on age and active then you should consider indexing these fields.
IMap imap = Hazelcast.getMap("employees"); imap.addIndex("age", true); // ordered, since we have ranged queries for this field imap.addIndex("active", false); // not ordered, because boolean field cannot have rangeIndex attribute should either have a getter method or be public. You should also make sure to add the indexes before adding entries to this map.
public LocalMapStats getLocalMapStats()
IMap
getLocalMapStats
in interface IMap<K,V>
public Object executeOnKey(K key, EntryProcessor entryProcessor)
IMap
executeOnKey
in interface IMap<K,V>
public Object executeOnKeyInternal(Data keyData, EntryProcessor entryProcessor)
public void submitToKey(K key, EntryProcessor entryProcessor, ExecutionCallback callback)
IMap
submitToKey
in interface IMap<K,V>
key
- key to be processed.entryProcessor
- processor to process the key.callback
- to listen whether operation is finished or not.public void submitToKeyInternal(Data keyData, EntryProcessor entryProcessor, ExecutionCallback callback)
public Future submitToKey(K key, EntryProcessor entryProcessor)
IMap
submitToKey
in interface IMap<K,V>
key
- key to be processedentryProcessor
- processor to process the keyFuture
public Future submitToKeyInternal(Data keyData, EntryProcessor entryProcessor)
public Map<K,Object> executeOnEntries(EntryProcessor entryProcessor)
IMap
executeOnEntries
in interface IMap<K,V>
public Map<K,Object> executeOnEntries(EntryProcessor entryProcessor, Predicate predicate)
IMap
executeOnEntries
in interface IMap<K,V>
public <SuppliedValue,Result> Result aggregate(Supplier<K,V,SuppliedValue> supplier, Aggregation<K,SuppliedValue,Result> aggregation)
IMap
Supplier
is used to either select or to select and extract a (sub-)value. A predefined set of aggregations can be found in
Aggregations
.aggregate
in interface IMap<K,V>
SuppliedValue
- the final type emitted from the supplier.Result
- the resulting aggregation value type.supplier
- the supplier to select and / or extract a (sub-)value from the map.aggregation
- the aggregation that is being executed against the map.public <SuppliedValue,Result> Result aggregate(Supplier<K,V,SuppliedValue> supplier, Aggregation<K,SuppliedValue,Result> aggregation, JobTracker jobTracker)
IMap
Supplier
is used to either select or to select and extract a (sub-)value. A predefined set of aggregations can be found in
Aggregations
.aggregate
in interface IMap<K,V>
SuppliedValue
- the final type emitted from the supplier.Result
- the resulting aggregation value type.supplier
- the supplier to select and / or extract a (sub-)value from the map.aggregation
- the aggregation that is being executed against the map.jobTracker
- the JobTracker
instance to execute the aggregation.public Map<K,Object> executeOnKeys(Set<K> keys, EntryProcessor entryProcessor)
IMap
executeOnKeys
in interface IMap<K,V>
public void set(K key, V value)
IMap
Warning:
This method breaks the contract of EntryListener. When an entry is updated by set(), it fires an EntryEvent with a null oldValue.Warning-2:
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 int size()
BaseMap
public boolean isEmpty()
BaseMap
public void putAll(Map<? extends K,? extends V> m)
IMap
public void clear()
IMap
MapStore.deleteAll(java.util.Collection<K>)
deleteAll on MapStore which,
if connected to a database, will delete the records from that database.
The MAP_CLEARED event is fired for any registered listeners.
See MapClearedListener.mapCleared(MapEvent)
.
To clear a map without calling MapStore.deleteAll(java.util.Collection<K>)
, use IMap.evictAll()
.protected long getTimeInMillis(long time, TimeUnit timeunit)
Copyright © 2016 Hazelcast, Inc.. All Rights Reserved.