org.jgroups.blocks
Class ReplicatedHashtable

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable
          extended by org.jgroups.blocks.ReplicatedHashtable
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map, MembershipListener, MessageListener

Deprecated. Use ReplicatedHashMap instead

public class ReplicatedHashtable
extends java.util.Hashtable
implements MessageListener, MembershipListener

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.

Author:
Bela Ban, Alfonso Olias-Sanz
See Also:
Serialized Form

Nested Class Summary
static interface ReplicatedHashtable.Notification
          Deprecated.  
static interface ReplicatedHashtable.StateTransferListener
          Deprecated.  
 
Field Summary
protected  Log log
          Deprecated.  
 
Constructor Summary
ReplicatedHashtable(JChannel channel, long state_timeout)
          Deprecated.  
ReplicatedHashtable(JChannel channel, ReplicatedHashtable.StateTransferListener l, long state_timeout)
          Deprecated.  
ReplicatedHashtable(java.lang.String groupname, ChannelFactory factory, ReplicatedHashtable.StateTransferListener l, java.lang.String properties, long state_timeout)
          Deprecated. Creates a ReplicatedHashtable
ReplicatedHashtable(java.lang.String groupname, ChannelFactory factory, java.lang.String properties, long state_timeout)
          Deprecated.  
 
Method Summary
 void _putAll(java.util.Map m)
          Deprecated.  
 void addNotifier(ReplicatedHashtable.Notification n)
          Deprecated.  
 void addStateTransferListener(ReplicatedHashtable.StateTransferListener l)
          Deprecated.  
 void block()
          Deprecated. Block sending and receiving of messages until ViewAccepted is called
 void clear()
          Deprecated. Clears this hashtable so that it contains no keys
 Channel getChannel()
          Deprecated.  
 Address getLocalAddress()
          Deprecated.  
 byte[] getState()
          Deprecated. Answers the group state; e.g., when joining.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Deprecated. Maps the specified key to the specified value in the hashtable.
 void putAll(java.util.Map m)
          Deprecated. Copies all of the mappings from the specified Map to this Hashtable These mappings will replace any mappings that this Hashtable had for any of the keys currently in the specified Map.
 void receive(Message msg)
          Deprecated. Called when a message is received.
 java.lang.Object remove(java.lang.Object key)
          Deprecated. Removes the key (and its corresponding value) from the Hashtable.
 void removeStateTransferListener(ReplicatedHashtable.StateTransferListener l)
          Deprecated.  
 void setState(byte[] new_state)
          Deprecated. Sets the group state; e.g., when joining.
 boolean stateTransferRunning()
          Deprecated.  
 void suspect(Address suspected_mbr)
          Deprecated. Called when a member is suspected
 void viewAccepted(View new_view)
          Deprecated. Called when a change in membership has occurred.
 
Methods inherited from class java.util.Hashtable
clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, rehash, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected final transient Log log
Deprecated. 
Constructor Detail

ReplicatedHashtable

public ReplicatedHashtable(java.lang.String groupname,
                           ChannelFactory factory,
                           ReplicatedHashtable.StateTransferListener l,
                           java.lang.String properties,
                           long state_timeout)
Deprecated. 
Creates a ReplicatedHashtable

Parameters:
groupname - The name of the group to join
factory - The ChannelFactory which will be used to create a channel
properties - The property string to be used to define the channel
state_timeout - The time to wait until state is retrieved in milliseconds. A value of 0 means wait forever.

ReplicatedHashtable

public ReplicatedHashtable(java.lang.String groupname,
                           ChannelFactory factory,
                           java.lang.String properties,
                           long state_timeout)
Deprecated. 

ReplicatedHashtable

public ReplicatedHashtable(JChannel channel,
                           long state_timeout)
                    throws ChannelClosedException,
                           ChannelNotConnectedException
Deprecated. 
Throws:
ChannelClosedException
ChannelNotConnectedException

ReplicatedHashtable

public ReplicatedHashtable(JChannel channel,
                           ReplicatedHashtable.StateTransferListener l,
                           long state_timeout)
                    throws ChannelClosedException,
                           ChannelNotConnectedException
Deprecated. 
Throws:
ChannelClosedException
ChannelNotConnectedException
Method Detail

stateTransferRunning

public boolean stateTransferRunning()
Deprecated. 

getLocalAddress

public Address getLocalAddress()
Deprecated. 

getChannel

public Channel getChannel()
Deprecated. 

addNotifier

public void addNotifier(ReplicatedHashtable.Notification n)
Deprecated. 

addStateTransferListener

public final void addStateTransferListener(ReplicatedHashtable.StateTransferListener l)
Deprecated. 

removeStateTransferListener

public void removeStateTransferListener(ReplicatedHashtable.StateTransferListener l)
Deprecated. 

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Deprecated. 
Maps the specified key to the specified value in the hashtable. Neither of both parameters can be null

Specified by:
put in interface java.util.Map
Overrides:
put in class java.util.Hashtable
Parameters:
key - - the hashtable key
value - - the value
Returns:
the previous value of the specified key in this hashtable, or null if it did not have one

putAll

public void putAll(java.util.Map m)
Deprecated. 
Copies all of the mappings from the specified Map to this Hashtable These mappings will replace any mappings that this Hashtable had for any of the keys currently in the specified Map.

Specified by:
putAll in interface java.util.Map
Overrides:
putAll in class java.util.Hashtable
Parameters:
m - - Mappings to be stored in this map

clear

public void clear()
Deprecated. 
Clears this hashtable so that it contains no keys

Specified by:
clear in interface java.util.Map
Overrides:
clear in class java.util.Hashtable

remove

public java.lang.Object remove(java.lang.Object key)
Deprecated. 
Removes the key (and its corresponding value) from the Hashtable.

Specified by:
remove in interface java.util.Map
Overrides:
remove in class java.util.Hashtable
Parameters:
key - - the key to be removed.
Returns:
the value to which the key had been mapped in this hashtable, or null if the key did not have a mapping.

_putAll

public void _putAll(java.util.Map m)
Deprecated. 
See Also:
Map.putAll(java.util.Map)

receive

public void receive(Message msg)
Deprecated. 
Description copied from interface: MessageListener
Called when a message is received.

Specified by:
receive in interface MessageListener

getState

public byte[] getState()
Deprecated. 
Description copied from interface: MessageListener
Answers the group state; e.g., when joining.

Specified by:
getState in interface MessageListener
Returns:
byte[]

setState

public void setState(byte[] new_state)
Deprecated. 
Description copied from interface: MessageListener
Sets the group state; e.g., when joining.

Specified by:
setState in interface MessageListener

viewAccepted

public void viewAccepted(View new_view)
Deprecated. 
Description copied from interface: MembershipListener
Called when a change in membership has occurred. No long running actions or sending of messages should be done in this callback. If some long running action needs to be performed, it should be done in a separate thread.

Note that on reception of the first view (a new member just joined), the channel will not yet be in the connected state. This only happens when Channel.connect(String) returns.

Specified by:
viewAccepted in interface MembershipListener

suspect

public void suspect(Address suspected_mbr)
Deprecated. 
Called when a member is suspected

Specified by:
suspect in interface MembershipListener

block

public void block()
Deprecated. 
Block sending and receiving of messages until ViewAccepted is called

Specified by:
block in interface MembershipListener


Copyright © 1998-2009 Bela Ban / Red Hat. All Rights Reserved.