|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractMap<K,V> org.jgroups.blocks.ReplicatedHashMap<K,V>
public class ReplicatedHashMap<K,V>
Implementation of a ConcurrentMap
with replication of the contents across a cluster.
Any change to the hashmap (clear(), put(), remove() etc) will transparently be propagated to all replicas in the group.
All read-only methods will always access the local replica.
Keys and values added to the hashmap must be serializable, the reason being that they will be sent across the network to all replicas of the group.
AReplicatedHashMap
allows one to implement a distributed naming service in just a couple of lines.
An instance of this class will contact an existing member of the group to fetch its initial state.
Nested Class Summary | |
---|---|
static interface |
ReplicatedHashMap.Notification<K,V>
|
Nested classes/interfaces inherited from class java.util.AbstractMap |
---|
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
Nested classes/interfaces inherited from interface java.util.Map |
---|
java.util.Map.Entry<K,V> |
Field Summary | |
---|---|
protected RequestOptions |
call_options
|
protected RpcDispatcher |
disp
|
protected Log |
log
|
protected java.util.concurrent.ConcurrentMap<K,V> |
map
wrapped map instance |
protected static java.util.Map<java.lang.Short,java.lang.reflect.Method> |
methods
|
Constructor Summary | |
---|---|
ReplicatedHashMap(Channel channel)
Constructs a new ReplicatedHashMap with channel. |
|
ReplicatedHashMap(java.util.concurrent.ConcurrentMap<K,V> map,
Channel channel)
Constructs a new ReplicatedHashMap using provided map instance. |
Method Summary | ||
---|---|---|
void |
_clear()
|
|
V |
_put(K key,
V value)
|
|
void |
_putAll(java.util.Map<? extends K,? extends V> map)
|
|
V |
_putIfAbsent(K key,
V value)
|
|
V |
_remove(java.lang.Object key)
|
|
boolean |
_remove(java.lang.Object key,
java.lang.Object value)
|
|
V |
_replace(K key,
V value)
|
|
boolean |
_replace(K key,
V oldValue,
V newValue)
|
|
void |
addNotifier(ReplicatedHashMap.Notification n)
|
|
void |
block()
Block sending and receiving of messages until ViewAccepted is called |
|
void |
clear()
Removes all of the mappings from this map. |
|
boolean |
containsKey(java.lang.Object key)
|
|
boolean |
containsValue(java.lang.Object value)
|
|
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet()
|
|
V |
get(java.lang.Object key)
|
|
Channel |
getChannel()
|
|
java.lang.String |
getClusterName()
|
|
Address |
getLocalAddress()
|
|
void |
getState(java.io.OutputStream ostream)
Allows an application to write a state through a provided OutputStream. |
|
long |
getTimeout()
The timeout (in milliseconds) for blocking updates |
|
protected void |
init()
|
|
boolean |
isBlockingUpdates()
|
|
java.util.Set<K> |
keySet()
|
|
V |
put(K key,
V value)
Maps the specified key to the specified value in this table. |
|
void |
putAll(java.util.Map<? extends K,? extends V> m)
Copies all of the mappings from the specified map to this one. |
|
V |
putIfAbsent(K key,
V value)
|
|
void |
receive(Message msg)
Called when a message is received. |
|
V |
remove(java.lang.Object key)
Removes the key (and its corresponding value) from this map. |
|
boolean |
remove(java.lang.Object key,
java.lang.Object value)
|
|
void |
removeNotifier(ReplicatedHashMap.Notification n)
|
|
V |
replace(K key,
V value)
|
|
boolean |
replace(K key,
V oldValue,
V newValue)
|
|
void |
setBlockingUpdates(boolean blocking_updates)
Whether updates across the cluster should be asynchronous (default) or synchronous) |
|
void |
setState(java.io.InputStream istream)
Allows an application to read a state through a provided InputStream. |
|
void |
setTimeout(long timeout)
Sets the cluster call timeout (until all acks have been received) |
|
int |
size()
|
|
void |
start(long state_timeout)
Fetches the state |
|
void |
stop()
|
|
void |
suspect(Address suspected_mbr)
Called when a member is suspected |
|
static
|
synchronizedMap(ReplicatedMap<K,V> map)
Creates a synchronized facade for a ReplicatedMap. |
|
void |
unblock()
Called after the FLUSH protocol has unblocked previously blocked senders, and messages can be sent again. |
|
java.util.Collection<V> |
values()
|
|
void |
viewAccepted(View new_view)
Called when a change in membership has occurred. |
Methods inherited from class java.util.AbstractMap |
---|
clone, equals, hashCode, isEmpty, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
equals, hashCode, isEmpty |
Field Detail |
---|
protected static java.util.Map<java.lang.Short,java.lang.reflect.Method> methods
protected RpcDispatcher disp
protected final RequestOptions call_options
protected final Log log
protected java.util.concurrent.ConcurrentMap<K,V> map
Constructor Detail |
---|
public ReplicatedHashMap(Channel channel)
start(long)
to start this map.
public ReplicatedHashMap(java.util.concurrent.ConcurrentMap<K,V> map, Channel channel)
Method Detail |
---|
protected final void init()
public boolean isBlockingUpdates()
public void setBlockingUpdates(boolean blocking_updates)
blocking_updates
- public long getTimeout()
public void setTimeout(long timeout)
timeout
- The timeout (in milliseconds) for blocking updatespublic final void start(long state_timeout) throws java.lang.Exception
state_timeout
-
java.lang.Exception
public Address getLocalAddress()
public java.lang.String getClusterName()
public Channel getChannel()
public void addNotifier(ReplicatedHashMap.Notification n)
public void removeNotifier(ReplicatedHashMap.Notification n)
public void stop()
public V put(K key, V value)
The value can be retrieved by calling the get method with a key that is equal to the original key.
put
in interface java.util.Map<K,V>
put
in class java.util.AbstractMap<K,V>
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified key
java.lang.NullPointerException
- if the specified key or value is nullpublic V putIfAbsent(K key, V value)
putIfAbsent
in interface java.util.concurrent.ConcurrentMap<K,V>
java.lang.NullPointerException
- if the specified key or value is nullpublic void putAll(java.util.Map<? extends K,? extends V> m)
putAll
in interface java.util.Map<K,V>
putAll
in class java.util.AbstractMap<K,V>
m
- mappings to be stored in this mappublic void clear()
clear
in interface java.util.Map<K,V>
clear
in class java.util.AbstractMap<K,V>
public V remove(java.lang.Object key)
remove
in interface java.util.Map<K,V>
remove
in class java.util.AbstractMap<K,V>
key
- the key that needs to be removed
java.lang.NullPointerException
- if the specified key is nullpublic boolean remove(java.lang.Object key, java.lang.Object value)
remove
in interface java.util.concurrent.ConcurrentMap<K,V>
java.lang.NullPointerException
- if the specified key is nullpublic boolean replace(K key, V oldValue, V newValue)
replace
in interface java.util.concurrent.ConcurrentMap<K,V>
java.lang.NullPointerException
- if any of the arguments are nullpublic V replace(K key, V value)
replace
in interface java.util.concurrent.ConcurrentMap<K,V>
java.lang.NullPointerException
- if the specified key or value is nullpublic V _put(K key, V value)
_put
in interface ReplicatedMap<K,V>
public V _putIfAbsent(K key, V value)
_putIfAbsent
in interface ReplicatedMap<K,V>
public void _putAll(java.util.Map<? extends K,? extends V> map)
_putAll
in interface ReplicatedMap<K,V>
Map.putAll(java.util.Map)
public void _clear()
_clear
in interface ReplicatedMap<K,V>
public V _remove(java.lang.Object key)
_remove
in interface ReplicatedMap<K,V>
public boolean _remove(java.lang.Object key, java.lang.Object value)
_remove
in interface ReplicatedMap<K,V>
public boolean _replace(K key, V oldValue, V newValue)
_replace
in interface ReplicatedMap<K,V>
public V _replace(K key, V value)
_replace
in interface ReplicatedMap<K,V>
public void receive(Message msg)
MessageListener
receive
in interface MessageListener
public void getState(java.io.OutputStream ostream) throws java.lang.Exception
MessageListener
getState
in interface MessageListener
ostream
- the OutputStream
java.lang.Exception
- if the streaming fails, any exceptions should be thrown so that the state requester
can re-throw them and let the caller know what happenedOutputStream.close()
public void setState(java.io.InputStream istream) throws java.lang.Exception
MessageListener
setState
in interface MessageListener
istream
- the InputStream
java.lang.Exception
- if the streaming fails, any exceptions should be thrown so that the state requester
can catch them and thus know what happenedInputStream.close()
public void viewAccepted(View new_view)
MembershipListener
Channel.connect(String)
returns.
viewAccepted
in interface MembershipListener
public void suspect(Address suspected_mbr)
suspect
in interface MembershipListener
public void block()
block
in interface MembershipListener
public void unblock()
MembershipListener
Note that during new view installation we provide guarantee that unblock invocation strictly follows view installation at some node A belonging to that view . However, some other message M may squeeze in between view and unblock callbacks. For more details see https://jira.jboss.org/jira/browse/JGRP-986
unblock
in interface MembershipListener
public static <K,V> ReplicatedMap<K,V> synchronizedMap(ReplicatedMap<K,V> map)
map
-
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<K,V>
containsKey
in class java.util.AbstractMap<K,V>
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map<K,V>
containsValue
in class java.util.AbstractMap<K,V>
public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
entrySet
in interface java.util.Map<K,V>
entrySet
in class java.util.AbstractMap<K,V>
public V get(java.lang.Object key)
get
in interface java.util.Map<K,V>
get
in class java.util.AbstractMap<K,V>
public java.util.Set<K> keySet()
keySet
in interface java.util.Map<K,V>
keySet
in class java.util.AbstractMap<K,V>
public int size()
size
in interface java.util.Map<K,V>
size
in class java.util.AbstractMap<K,V>
public java.util.Collection<V> values()
values
in interface java.util.Map<K,V>
values
in class java.util.AbstractMap<K,V>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |