|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Dictionary
java.util.Hashtable
org.javagroups.blocks.ReplicatedHashtable
Provides the abstraction of a java.util.Hashtable that is replicated at several locations. Any change to the hashtable (clear, put, remove etc) will transparently be propagated to all replicas in the group. All read-only methods will always access the local replica.
Both keys and values added to the hashtable must be serializable, the reason
being that they will be sent across the network to all replicas of the group. Having said
this, it is now for example possible to add RMI remote objects to the hashtable as they
are derived from java.rmi.server.RemoteObject
which in turn is serializable.
This allows to lookup shared distributed objects by their name and invoke methods on them,
regardless of one's onw location. A ReplicatedHashtable
thus allows 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.
Contrary to DistributedHashtable, this class does not make use of RpcDispatcher (and RequestCorrelator) but uses plain asynchronous messages instead.
Nested Class Summary | |
static interface |
ReplicatedHashtable.Notification
|
Constructor Summary | |
ReplicatedHashtable(JChannel channel,
long state_timeout)
|
|
ReplicatedHashtable(java.lang.String groupname,
ChannelFactory factory,
java.lang.String properties,
long state_timeout)
Creates a ReplicatedHashtable |
Method Summary | |
void |
addNotifier(ReplicatedHashtable.Notification n)
|
void |
block()
Block sending and receiving of messages until ViewAccepted is called |
void |
clear()
|
Channel |
getChannel()
|
Address |
getLocalAddress()
|
byte[] |
getState()
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
|
void |
receive(Message msg)
|
java.lang.Object |
remove(java.lang.Object key)
|
void |
setState(byte[] new_state)
|
void |
suspect(Address suspected_mbr)
Called when a member is suspected |
void |
viewAccepted(View new_view)
Called by JavaGroups to notify the target object of a change of membership. |
Methods inherited from class java.util.Hashtable |
clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, putAll, rehash, size, toString, values |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ReplicatedHashtable(java.lang.String groupname, ChannelFactory factory, java.lang.String properties, long state_timeout)
groupname
- The name of the group to joinfactory
- The ChannelFactory which will be used to create a channelproperties
- The property string to be used to define the channelstate_timeout
- The time to wait until state is retrieved in milliseconds. A value of 0 means wait forever.public ReplicatedHashtable(JChannel channel, long state_timeout) throws ChannelClosedException, ChannelNotConnectedException
Method Detail |
public Address getLocalAddress()
public Channel getChannel()
public void addNotifier(ReplicatedHashtable.Notification n)
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface java.util.Map
public void clear()
clear
in interface java.util.Map
public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map
public void receive(Message msg)
receive
in interface MessageListener
public byte[] getState()
getState
in interface MessageListener
public void setState(byte[] new_state)
setState
in interface MessageListener
public void viewAccepted(View new_view)
MembershipListener
../Tests/QuoteServer.java
).
viewAccepted
in interface MembershipListener
public void suspect(Address suspected_mbr)
suspect
in interface MembershipListener
public void block()
block
in interface MembershipListener
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |