next up previous contents
Next: Customizing the JChannel protocol Up: Building blocks Previous: RpcDispatcher

   
DistributedHashtable

A DistributedHashtable (JavaGroups.DistributedHashtable) is derived from java.util.Hashtable and allows to create several instances of hashtables at different locations. All of these instances have exactly the same state at all times. When creating such an instance, a group name determines which group of hashtables will be joined. The new instance will then query the state from existing members and update itself before starting to service requests. If there are no existing members, it will simply start with an empty state.

Modifications such as put, clear or remove will be propagated in orderly fashion to all replicas. Read-only requests such as get will only be sent to the local copy.

Since both keys and values of a hashtable will be sent across the network as copies, both of them have to be serializable, i.e. implement interface Serializable. This allows for example to register remote RMI objects with any local instance of a hashtable, which can subsequently be looked up by another process which can then invoke remote methods (remote RMI objects are serializable). Thus, a distributed naming and registration service can be built in just a couple of lines.

A DistributedHashtable allows to register for notifications, e.g. when a new item is set, or an existing one removed. All registered listeners will notified when such an event occurs. Notification is always a local process; for example in the case of removing an element, first the element is removed in all replicas, which then notify their listener(s) of the removal (after the fact).

Distributed hashtables allow members in a group to share common state across process and machine boundaries.


next up previous contents
Next: Customizing the JChannel protocol Up: Building blocks Previous: RpcDispatcher

1999-08-19