Class ReplicatedHashtable
- All Implemented Interfaces:
Serializable
,Cloneable
,Map
,MembershipListener
,MessageListener
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Deprecated.static interface
Deprecated. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionReplicatedHashtable
(String groupname, ChannelFactory factory, String properties, long state_timeout) Deprecated.ReplicatedHashtable
(String groupname, ChannelFactory factory, ReplicatedHashtable.StateTransferListener l, String properties, long state_timeout) Deprecated.Creates a ReplicatedHashtableReplicatedHashtable
(JChannel channel, long state_timeout) Deprecated.ReplicatedHashtable
(JChannel channel, ReplicatedHashtable.StateTransferListener l, long state_timeout) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated.void
Deprecated.final void
Deprecated.void
block()
Deprecated.Block sending and receiving of messages until ViewAccepted is calledvoid
clear()
Deprecated.Clears this hashtable so that it contains no keysDeprecated.Deprecated.byte[]
getState()
Deprecated.Answers the group state; e.g., when joining.Deprecated.Maps the specified key to the specified value in the hashtable.void
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
Deprecated.Called when a message is received.Deprecated.Removes the key (and its corresponding value) from the Hashtable.void
Deprecated.void
setState
(byte[] new_state) Deprecated.Sets the group state; e.g., when joining.boolean
Deprecated.void
Deprecated.Called when a member is suspectedvoid
viewAccepted
(View new_view) Deprecated.Called when a change in membership has occurred.Methods inherited from class java.util.Hashtable
clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keys, keySet, merge, putIfAbsent, rehash, remove, replace, replace, replaceAll, size, toString, values
-
Field Details
-
log
protected final transient org.apache.commons.logging.Log logDeprecated.
-
-
Constructor Details
-
ReplicatedHashtable
public ReplicatedHashtable(String groupname, ChannelFactory factory, ReplicatedHashtable.StateTransferListener l, String properties, long state_timeout) Deprecated.Creates a ReplicatedHashtable- Parameters:
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.
-
ReplicatedHashtable
public ReplicatedHashtable(String groupname, ChannelFactory factory, String properties, long state_timeout) Deprecated. -
ReplicatedHashtable
public ReplicatedHashtable(JChannel channel, long state_timeout) throws ChannelClosedException, ChannelNotConnectedException Deprecated. -
ReplicatedHashtable
public ReplicatedHashtable(JChannel channel, ReplicatedHashtable.StateTransferListener l, long state_timeout) throws ChannelClosedException, ChannelNotConnectedException Deprecated.
-
-
Method Details
-
stateTransferRunning
public boolean stateTransferRunning()Deprecated. -
getLocalAddress
Deprecated. -
getChannel
Deprecated. -
addNotifier
Deprecated. -
addStateTransferListener
Deprecated. -
removeStateTransferListener
Deprecated. -
put
Deprecated.Maps the specified key to the specified value in the hashtable. Neither of both parameters can be null -
putAll
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. -
clear
public void clear()Deprecated.Clears this hashtable so that it contains no keys -
remove
Deprecated.Removes the key (and its corresponding value) from the Hashtable. -
_putAll
Deprecated.- See Also:
-
receive
Deprecated.Description copied from interface:MessageListener
Called when a message is received.- Specified by:
receive
in interfaceMessageListener
- Parameters:
msg
-
-
getState
public byte[] getState()Deprecated.Description copied from interface:MessageListener
Answers the group state; e.g., when joining.- Specified by:
getState
in interfaceMessageListener
- 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 interfaceMessageListener
- Parameters:
new_state
-
-
viewAccepted
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 whenChannel.connect(String)
returns.- Specified by:
viewAccepted
in interfaceMembershipListener
-
suspect
Deprecated.Called when a member is suspected- Specified by:
suspect
in interfaceMembershipListener
-
block
public void block()Deprecated.Block sending and receiving of messages until ViewAccepted is called- Specified by:
block
in interfaceMembershipListener
-
ReplicatedHashMap
instead