public class MProxyImpl extends FactoryAwareNamedProxy implements MProxy, DataSerializable
Instance.InstanceTypefactory, 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, writeDataclone, finalize, getClass, notify, notifyAll, wait, wait, waitreadData, writeDatapublic MapOperationsCounter getMapOperationCounter()
getMapOperationCounter in interface MProxypublic void setHazelcastInstance(HazelcastInstance hazelcastInstance)
setHazelcastInstance in interface HazelcastInstanceAwaresetHazelcastInstance in class FactoryAwareNamedProxypublic Object get(Object key)
IMapWarning:
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)
IMapWarning:
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)
IMapWarning:
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 IMapkey - 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)
IMapWarning:
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)
IMapWarning:
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
IMapWarning:
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 IMapkey - 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)
IMapWarning:
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 IMapkey - key of the entryvalue - value of the entrypublic Object tryLockAndGet(Object key, long time, TimeUnit timeunit) throws TimeoutException
IMapIf 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 IMapkey - 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)
IMapWarning:
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()
IMappublic void putForSync(Object key, Object value)
putForSync in interface MProxypublic void removeForSync(Object key)
removeForSync in interface MProxypublic 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 IMapkey - 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 MProxypublic boolean tryPut(Object key, Object value, long time, TimeUnit timeunit)
IMapWarning:
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)
IMapWarning:
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)
IMapWarning:
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)
IMapWarning:
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 IMapkey - 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)
IMapWarning:
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 IMapputIfAbsent in interface ConcurrentMappublic LocalMapStats getLocalMapStats()
IMapgetLocalMapStats in interface IMappublic 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 range
Index 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)
IMappublic Object getId()
Instancepublic boolean equals(Object o)
public int hashCode()
public void destroy()
Instancepublic Instance.InstanceType getInstanceType()
InstancegetInstanceType in interface Instancepublic boolean removeKey(Object key)
public boolean containsKey(Object key)
IMapWarning:
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 IMapcontainsKey in interface Mappublic boolean containsValue(Object value)
IMapcontainsValue in interface IMapcontainsValue in interface Mappublic MapEntry getMapEntry(Object key)
IMapWarning:
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 IMapkey - key of the entryMapEntrypublic int valueCount(Object key)
valueCount in interface MProxypublic Set localKeySet()
IMapWarning:
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 IMappublic Set localKeySet(Predicate predicate)
IMapWarning:
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 IMappredicate - query criteriapublic Set keySet()
IMappublic Collection values()
IMappublic Set entrySet()
IMapSet 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)
IMapWarning:
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)
IMapWarning:
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)
IMapWarning:
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)
IMapWarning:
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 IMapremove in interface ConcurrentMappublic boolean replace(Object key, Object oldValue, Object newValue)
IMapWarning:
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 IMapreplace in interface ConcurrentMappublic Object replace(Object key, Object value)
IMapWarning:
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 IMapreplace in interface ConcurrentMappublic String getName()
IMapgetName in interface IMapgetName in class FactoryAwareNamedProxypublic boolean lockMap(long time,
TimeUnit timeunit)
IMapIf 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()
IMappublic void lock(Object key)
IMapIf 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)
IMapIf 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)
IMapIf 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)
IMapIf 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)
IMapIf 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)
IMapWarning:
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 IMapkey - key to lock.public String getLongName()
getLongName in interface MProxypublic void addGenericListener(Object listener, Object key, boolean includeValue, Instance.InstanceType instanceType)
addGenericListener in interface MProxypublic void removeGenericListener(Object listener, Object key)
removeGenericListener in interface MProxypublic void addLocalEntryListener(EntryListener entryListener)
IMapmap.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 IMapentryListener - entry listenerIMap.localKeySet()public void addEntryListener(EntryListener listener, boolean includeValue)
IMapaddEntryListener in interface IMaplistener - entry listenerincludeValue - true if EntryEvent should
contain the value.public void addEntryListener(EntryListener listener, Object key, boolean includeValue)
IMapWarning:
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 IMaplistener - entry listenerkey - key to listenincludeValue - true if EntryEvent should
contain the value.public void removeEntryListener(EntryListener listener)
IMapremoveEntryListener in interface IMaplistener - entry listenerpublic void removeEntryListener(EntryListener listener, Object key)
IMapWarning:
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 IMappublic boolean containsEntry(Object key, Object value)
containsEntry in interface MProxypublic boolean removeMulti(Object key, Object value)
removeMulti in interface MProxypublic boolean evict(Object key)
IMapWarning:
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.