public class MProxyImpl extends FactoryAwareNamedProxy implements MProxy, DataSerializable
Instance.InstanceType
factory, name
Constructor and Description |
---|
MProxyImpl() |
Modifier and Type | Method and Description |
---|---|
boolean |
add(Object value) |
void |
addEntryListener(EntryListener listener,
boolean includeValue)
Adds an entry listener for this map.
|
void |
addEntryListener(EntryListener listener,
Object key,
boolean includeValue)
Adds the specified entry listener for the specified key.
|
void |
addGenericListener(Object listener,
Object key,
boolean includeValue,
Instance.InstanceType instanceType) |
void |
addIndex(Expression expression,
boolean ordered)
Adds an index to this map based on the provided expression.
|
void |
addIndex(String attribute,
boolean ordered)
Adds an index to this map for the specified entries so
that queries can run faster.
|
void |
addLocalEntryListener(EntryListener entryListener)
Adds a local entry listener for this map.
|
Set |
allKeys() |
void |
clear() |
boolean |
containsEntry(Object key,
Object value) |
boolean |
containsKey(Object key)
|
boolean |
containsValue(Object value) |
void |
destroy()
Destroys this instance cluster-wide.
|
Set |
entrySet()
Returns a
Set clone of the mappings contained in this map. |
Set |
entrySet(Predicate predicate)
Queries the map based on the specified predicate and
returns the matching entries.
|
boolean |
equals(Object o) |
boolean |
evict(Object key)
Evicts the specified key from this map.
|
void |
flush()
If this map has a MapStore and write-delay-seconds is
bigger than 0 (write-behind) then this method flushes
all the local dirty entries by calling MapStore.storeAll() and/or MapStore.deleteAll()
|
void |
forceUnlock(Object key)
Releases the lock for the specified key regardless of the lock owner.
|
Object |
get(Object key)
|
Map |
getAll(Set keys)
Returns the entries for the given keys.
|
Future |
getAsync(Object key)
Asynchronously gets the given key.
|
Object |
getId()
Returns the unique id for this instance.
|
Instance.InstanceType |
getInstanceType()
Returns instance type such as map, set, list, lock, topic, multimap, id generator
|
LocalMapStats |
getLocalMapStats()
Returns LocalMapStats for this map.
|
String |
getLongName() |
MapEntry |
getMapEntry(Object key)
Returns the MapEntry for the specified key.
|
MapOperationsCounter |
getMapOperationCounter() |
String |
getName()
Returns the name of this map
|
int |
hashCode() |
boolean |
isEmpty() |
boolean |
isLocked(Object key)
Checks the lock for the specified key.
|
Set |
keySet()
Returns a set clone of the keys contained in this map.
|
Set |
keySet(Predicate predicate)
Queries the map based on the specified predicate and
returns the keys of matching entries.
|
Set |
localKeySet()
Returns the locally owned set of keys.
|
Set |
localKeySet(Predicate predicate)
Returns the keys of matching locally owned entries.
|
void |
lock(Object key)
Acquires the lock for the specified key.
|
boolean |
lockMap(long time,
TimeUnit timeunit)
Tries to acquire the lock for the entire map.
|
Object |
put(Object key,
Object value)
|
Object |
put(Object key,
Object value,
long ttl,
TimeUnit timeunit)
Puts an entry into this map with a given ttl (time to live) value.
|
void |
putAll(Map t) |
void |
putAndUnlock(Object key,
Object value)
Puts the key and value into this map and unlocks the key
if the calling thread owns the lock.
|
Future |
putAsync(Object key,
Object value)
Asynchronously puts the given key and value.
|
void |
putForSync(Object key,
Object value) |
boolean |
putFromLoad(Object key,
Object value) |
Object |
putIfAbsent(Object key,
Object value)
|
Object |
putIfAbsent(Object key,
Object 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.
|
boolean |
putMulti(Object key,
Object value) |
void |
putTransient(Object key,
Object value,
long time,
TimeUnit timeunit)
Same as
#put(K, V, long, TimeUnit) but MapStore, if defined,
will not be called to store/persist the entry. |
Object |
remove(Object key)
|
boolean |
remove(Object key,
Object value)
|
Future |
removeAsync(Object key)
Asynchronously removes the given key.
|
void |
removeEntryListener(EntryListener listener)
Removes the specified entry listener
Returns silently if there is no such listener added before.
|
void |
removeEntryListener(EntryListener listener,
Object key)
Removes the specified entry listener for the specified key.
|
void |
removeForSync(Object key) |
void |
removeGenericListener(Object listener,
Object key) |
boolean |
removeKey(Object key) |
boolean |
removeMulti(Object key,
Object value) |
Object |
replace(Object key,
Object value)
|
boolean |
replace(Object key,
Object oldValue,
Object newValue)
|
void |
set(Object key,
Object value)
Puts an entry into this map.
|
void |
set(Object key,
Object value,
long time,
TimeUnit timeunit)
Puts an entry into this map with a given ttl (time to live) value.
|
void |
setHazelcastInstance(HazelcastInstance hazelcastInstance) |
int |
size() |
String |
toString() |
boolean |
tryLock(Object key)
Tries to acquire the lock for the specified key.
|
boolean |
tryLock(Object key,
long time,
TimeUnit timeunit)
Tries to acquire the lock for the specified key.
|
Object |
tryLockAndGet(Object key,
long time,
TimeUnit timeunit)
Tries to acquire the lock for the specified key and returns
the value of the key if lock is required in time.
|
boolean |
tryPut(Object key,
Object value,
long time,
TimeUnit timeunit)
Tries to put the given key, value into this map within specified
timeout value.
|
Object |
tryRemove(Object key,
long time,
TimeUnit timeunit)
Tries to remove the entry with the given key from this map
within specified timeout value.
|
void |
unlock(Object key)
Releases the lock for the specified key.
|
void |
unlockMap()
Unlocks the map.
|
int |
valueCount(Object key) |
Collection |
values()
Returns a collection clone of the values contained in this map.
|
Collection |
values(Predicate predicate)
Queries the map based on the specified predicate and
returns the values of matching entries.
|
getFactory, readData, setName, writeData
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
readData, writeData
public MapOperationsCounter getMapOperationCounter()
getMapOperationCounter
in interface MProxy
public void setHazelcastInstance(HazelcastInstance hazelcastInstance)
setHazelcastInstance
in interface HazelcastInstanceAware
setHazelcastInstance
in class FactoryAwareNamedProxy
public Object get(Object key)
IMap
Warning:
This method returns a clone of original value, 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.
V value = map.get(key); value.updateSomeProperty(); map.put(key, value);
Warning-2:
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.Warning-3:
If cache-value is true (default is true), this method returns a clone of original value but also caches that value for fast access in local. Modifications done to this cached value without putting it back to map will be visible to only local node, not entire cluster, successive get calls will return the same cached value. To reflect modifications to distributed map, one should put modified value back into map.
public Object put(Object key, Object value)
IMap
Warning:
This method returns a clone of previous value, not the original (identically equal) value previously put into map.
Warning-2:
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.public Future getAsync(Object 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 binary form of the key, not the actual implementations of hashCode and equals defined in key's class.public Future putAsync(Object key, Object 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.get() completes.
If the application requires timely response,
then Future.get(timeout, timeunit) can be used.
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 binary form of the key, not the actual implementations of hashCode and equals defined in key's class.public Future removeAsync(Object key)
IMap
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.removeAsync
in interface IMap
key
- The key of the map entry to remove.Future
from which the value
removed from the map can be retrieved.public Object put(Object key, Object value, long ttl, TimeUnit timeunit)
IMap
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.Warning-2:
This method returns a clone of previous value, not the original (identically equal) value previously put into map.
public Object remove(Object key)
IMap
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.
Warning-2:
This method returns a clone of previous value, not the original (identically equal) value previously put into map.
public Object tryRemove(Object key, long time, TimeUnit timeunit) throws TimeoutException
IMap
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.Warning-2:
This method returns a clone of previous value, not the original (identically equal) value previously put into map.
tryRemove
in interface IMap
key
- key of the entrytime
- maximum time to wait for acquiring the lock
for the keytimeunit
- time unit for the timeoutTimeoutException
- if lock cannot be acquired for the given key within timeoutpublic void putAndUnlock(Object key, Object value)
IMap
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.putAndUnlock
in interface IMap
key
- key of the entryvalue
- value of the entrypublic Object tryLockAndGet(Object key, long time, TimeUnit timeunit) throws TimeoutException
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 binary form of the key, not the actual implementations of hashCode and equals defined in key's class.Warning:
This method returns a clone of original value, 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.
V value = map.get(key); value.updateSomeProperty(); map.put(key, value);
tryLockAndGet
in interface IMap
key
- key of the entrytime
- maximum time to wait for the locktimeunit
- time unit of the time argument.TimeoutException
- if lock cannot be acquired in time.public Map getAll(Set keys)
IMap
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 binary form of the keys, not the actual implementations of hashCode and equals defined in key's class.public void flush()
IMap
public void putForSync(Object key, Object value)
putForSync
in interface MProxy
public void removeForSync(Object key)
removeForSync
in interface MProxy
public void putTransient(Object key, Object value, long time, TimeUnit timeunit)
IMap
#put(K, V, long, TimeUnit)
but MapStore, if defined,
will not be called to store/persist the entry. If ttl is 0, then
the entry lives forever.
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.putTransient
in interface IMap
key
- key of the entryvalue
- value of the entrytime
- maximum time for this entry to stay in the map.
0 means infinite.timeunit
- time unit for the ttlpublic boolean putFromLoad(Object key, Object value)
putFromLoad
in interface MProxy
public boolean tryPut(Object key, Object value, long time, TimeUnit timeunit)
IMap
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.public void set(Object key, Object value)
IMap
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.public void set(Object key, Object value, long time, TimeUnit timeunit)
IMap
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.public Object putIfAbsent(Object key, Object value, long ttl, TimeUnit timeunit)
IMap
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.Warning-2:
This method returns a clone of previous value, not the original (identically equal) value previously put into map.
putIfAbsent
in interface IMap
key
- key of the entryvalue
- value of the entryttl
- maximum time for this entry to stay in the maptimeunit
- time unit for the ttlpublic Object putIfAbsent(Object key, Object value)
IMap
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.Warning-2:
This method returns a clone of previous value, not the original (identically equal) value previously put into map.
putIfAbsent
in interface IMap
putIfAbsent
in interface ConcurrentMap
public LocalMapStats getLocalMapStats()
IMap
getLocalMapStats
in interface IMap
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 void addIndex(Expression expression, boolean ordered)
IMap
public Object getId()
Instance
public boolean equals(Object o)
public int hashCode()
public void destroy()
Instance
public Instance.InstanceType getInstanceType()
Instance
getInstanceType
in interface Instance
public boolean removeKey(Object key)
public boolean containsKey(Object key)
IMap
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.
containsKey
in interface IMap
containsKey
in interface Map
public boolean containsValue(Object value)
IMap
containsValue
in interface IMap
containsValue
in interface Map
public MapEntry getMapEntry(Object 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 binary form of the key, not the actual implementations of hashCode and equals defined in key's class.getMapEntry
in interface IMap
key
- key of the entryMapEntry
public int valueCount(Object key)
valueCount
in interface MProxy
public Set 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.localKeySet
in interface IMap
public Set 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.localKeySet
in interface IMap
predicate
- query criteriapublic Set keySet()
IMap
public Collection values()
IMap
public Set entrySet()
IMap
Set
clone of the mappings contained in this map.
The set is NOT backed by the map,
so changes to the map are NOT reflected in the set, and vice-versa.public Set 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.public Collection 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.public Set 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.public boolean remove(Object key, Object value)
IMap
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.remove
in interface IMap
remove
in interface ConcurrentMap
public boolean replace(Object key, Object oldValue, Object newValue)
IMap
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.replace
in interface IMap
replace
in interface ConcurrentMap
public Object replace(Object key, Object value)
IMap
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.Warning-2:
This method returns a clone of previous value, not the original (identically equal) value previously put into map.
replace
in interface IMap
replace
in interface ConcurrentMap
public String getName()
IMap
getName
in interface IMap
getName
in class FactoryAwareNamedProxy
public boolean lockMap(long time, TimeUnit timeunit)
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:
public void unlockMap()
IMap
public void lock(Object 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.
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 binary form of the key, not the actual implementations of hashCode and equals defined in key's class.public boolean isLocked(Object key)
IMap
If the lock is acquired then returns true, else false.
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.public boolean tryLock(Object 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 binary form of the key, not the actual implementations of hashCode and equals defined in key's class.public boolean tryLock(Object key, long time, TimeUnit timeunit)
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 binary form of the key, not the actual implementations of hashCode and equals defined in key's class.public void unlock(Object key)
IMap
If the current thread is the holder of this lock then the hold
count is decremented. If the hold count is now 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 binary form of the key, not the actual implementations of hashCode and equals defined in key's class.public void forceUnlock(Object key)
IMap
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.forceUnlock
in interface IMap
key
- key to lock.public String getLongName()
getLongName
in interface MProxy
public void addGenericListener(Object listener, Object key, boolean includeValue, Instance.InstanceType instanceType)
addGenericListener
in interface MProxy
public void removeGenericListener(Object listener, Object key)
removeGenericListener
in interface MProxy
public void addLocalEntryListener(EntryListener entryListener)
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
entryListener
- entry listenerIMap.localKeySet()
public void addEntryListener(EntryListener listener, boolean includeValue)
IMap
addEntryListener
in interface IMap
listener
- entry listenerincludeValue
- true if EntryEvent should
contain the value.public void addEntryListener(EntryListener listener, Object key, boolean includeValue)
IMap
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.addEntryListener
in interface IMap
listener
- entry listenerkey
- key to listenincludeValue
- true if EntryEvent should
contain the value.public void removeEntryListener(EntryListener listener)
IMap
removeEntryListener
in interface IMap
listener
- entry listenerpublic void removeEntryListener(EntryListener listener, Object key)
IMap
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.removeEntryListener
in interface IMap
public boolean containsEntry(Object key, Object value)
containsEntry
in interface MProxy
public boolean removeMulti(Object key, Object value)
removeMulti
in interface MProxy
public boolean evict(Object key)
IMap
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.Copyright © 2013 Hazelcast, Inc.. All rights reserved.