JavaGroups
Class DistributedHashtable

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--JavaGroups.DistributedHashtable

public class DistributedHashtable
extends java.util.Hashtable
implements MessageListener, java.lang.Cloneable

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 DistributedHashtable 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 (using the state exchange funclet StateExchangeFunclet.

See Also:
Serialized Form

Inner Class Summary
static interface DistributedHashtable.Notification
           
 
Constructor Summary
DistributedHashtable(java.lang.String groupname, ChannelFactory factory, java.lang.String properties)
           
 
Method Summary
 void _clear()
           
 java.lang.Object _put(java.lang.Object key, java.lang.Object value)
           
 java.lang.Object _remove(java.lang.Object key)
           
 void AddNotifier(DistributedHashtable.Notification n)
           
 void clear()
           
 java.lang.Object 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(java.lang.Object new_state)
           
 
Methods inherited from class java.util.Hashtable
clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, putAll, size, toString, values
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DistributedHashtable

public DistributedHashtable(java.lang.String groupname,
                            ChannelFactory factory,
                            java.lang.String properties)
Method Detail

AddNotifier

public void AddNotifier(DistributedHashtable.Notification n)

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Overrides:
put in class java.util.Hashtable

clear

public void clear()
Overrides:
clear in class java.util.Hashtable

remove

public java.lang.Object remove(java.lang.Object key)
Overrides:
remove in class java.util.Hashtable

_put

public java.lang.Object _put(java.lang.Object key,
                             java.lang.Object value)

_clear

public void _clear()

_remove

public java.lang.Object _remove(java.lang.Object key)

Receive

public void Receive(Message msg)
Specified by:
Receive in interface MessageListener

GetState

public java.lang.Object GetState()
Specified by:
GetState in interface MessageListener

SetState

public void SetState(java.lang.Object new_state)
Specified by:
SetState in interface MessageListener