|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Dictionary<K,V>
java.util.Hashtable
org.jgroups.blocks.DistributedHashtable
ReplicatedHashMap
instead
public class DistributedHashtable
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
.
Nested Class Summary | |
---|---|
static interface |
DistributedHashtable.Notification
Deprecated. |
Field Summary | |
---|---|
protected RpcDispatcher |
disp
Deprecated. |
protected Log |
log
Deprecated. |
protected Promise<java.lang.Boolean> |
state_promise
Deprecated. |
Constructor Summary | |
---|---|
DistributedHashtable(Channel channel,
boolean persistent,
long state_timeout)
Deprecated. |
|
DistributedHashtable(Channel channel,
long state_timeout)
Deprecated. |
|
DistributedHashtable(PullPushAdapter adapter,
java.io.Serializable id)
Deprecated. |
|
DistributedHashtable(PullPushAdapter adapter,
java.io.Serializable id,
long state_timeout)
Deprecated. |
|
DistributedHashtable(java.lang.String groupname,
ChannelFactory factory,
java.lang.String properties,
boolean persistent,
long state_timeout)
Deprecated. Creates a DisttributedHashtable. |
|
DistributedHashtable(java.lang.String groupname,
ChannelFactory factory,
java.lang.String properties,
long state_timeout)
Deprecated. Creates a DistributedHashtable |
Method Summary | |
---|---|
void |
_clear()
Deprecated. |
java.lang.Object |
_put(java.lang.Object key,
java.lang.Object value)
Deprecated. |
void |
_putAll(java.util.Map m)
Deprecated. |
java.lang.Object |
_remove(java.lang.Object key)
Deprecated. |
void |
addNotifier(DistributedHashtable.Notification n)
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. |
java.lang.String |
getGroupName()
Deprecated. |
Address |
getLocalAddress()
Deprecated. |
boolean |
getPersistent()
Deprecated. |
byte[] |
getState()
Deprecated. Answers the group state; e.g., when joining. |
void |
getState(java.io.OutputStream ostream)
Deprecated. Allows an application to write a state through a provided OutputStream. |
byte[] |
getState(java.lang.String state_id)
Deprecated. Allows an application to provide a partial state as a byte array |
void |
getState(java.lang.String state_id,
java.io.OutputStream ostream)
Deprecated. Allows an application to write a partial state through a provided OutputStream. |
protected void |
init(long state_timeout)
Deprecated. |
static void |
main(java.lang.String[] args)
Deprecated. |
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 |
removeNotifier(DistributedHashtable.Notification n)
Deprecated. |
void |
setDeadlockDetection(boolean flag)
Deprecated. |
void |
setPersistent(boolean p)
Deprecated. |
void |
setState(byte[] new_state)
Deprecated. Sets the group state; e.g., when joining. |
void |
setState(java.io.InputStream istream)
Deprecated. Allows an application to read a state through a provided InputStream. |
void |
setState(java.lang.String state_id,
byte[] state)
Deprecated. Allows an application to read a partial state indicated by state_id from a given state byte array parameter. |
void |
setState(java.lang.String state_id,
java.io.InputStream istream)
Deprecated. Allows an application to read a partial state through a provided InputStream. |
void |
start(long state_timeout)
Deprecated. Fetches the state |
void |
stop()
Deprecated. |
void |
suspect(Address suspected_mbr)
Deprecated. Called when a member is suspected |
void |
unblock()
Deprecated. Called after the FLUSH protocol has unblocked previously blocked senders, and messages can be sent again. |
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 |
---|
protected transient RpcDispatcher disp
protected final transient Promise<java.lang.Boolean> state_promise
protected final Log log
Constructor Detail |
---|
public DistributedHashtable(java.lang.String groupname, ChannelFactory factory, java.lang.String properties, long state_timeout) throws ChannelException
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 channel. This will override the properties of
the factory. If null, then the factory properties will be usedstate_timeout
- The time to wait until state is retrieved in milliseconds. A value of 0 means wait forever.
ChannelException
public DistributedHashtable(java.lang.String groupname, ChannelFactory factory, java.lang.String properties, boolean persistent, long state_timeout) throws ChannelException
PersistenceManager
.
groupname
- Name of the group to joinfactory
- Instance of a ChannelFactory to create the channelproperties
- Protocol stack properties. This will override the properties of the factory. If
null, then the factory properties will be usedpersistent
- Whether the contents should be persistedstate_timeout
- Max number of milliseconds to wait until state is
retrieved
ChannelException
public DistributedHashtable(Channel channel, long state_timeout)
public DistributedHashtable(Channel channel, boolean persistent, long state_timeout)
@Deprecated public DistributedHashtable(PullPushAdapter adapter, java.io.Serializable id, long state_timeout) throws ChannelNotConnectedException, ChannelClosedException
adapter
- The PullPushAdapter which to use as underlying transportid
- A serializable object (e.g. an Integer) used to discriminate (multiplex/demultiplex) between
requests/responses for different building blocks on top of PullPushAdapter.state_timeout
- Max number of milliseconds to wait until state is
retrieved
ChannelNotConnectedException
ChannelClosedException
@Deprecated public DistributedHashtable(PullPushAdapter adapter, java.io.Serializable id)
Method Detail |
---|
protected final void init(long state_timeout)
public final void start(long state_timeout) throws ChannelClosedException, ChannelNotConnectedException
state_timeout
-
ChannelClosedException
ChannelNotConnectedException
public Address getLocalAddress()
public java.lang.String getGroupName()
public Channel getChannel()
public boolean getPersistent()
public void setPersistent(boolean p)
public void setDeadlockDetection(boolean flag)
public void addNotifier(DistributedHashtable.Notification n)
public void removeNotifier(DistributedHashtable.Notification n)
public void stop()
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface java.util.Map
put
in class java.util.Hashtable
key
- - the hashtable keyvalue
- - the value
public void putAll(java.util.Map m)
putAll
in interface java.util.Map
putAll
in class java.util.Hashtable
m
- - Mappings to be stored in this mappublic void clear()
clear
in interface java.util.Map
clear
in class java.util.Hashtable
public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map
remove
in class java.util.Hashtable
key
- - the key to be removed.
public java.lang.Object _put(java.lang.Object key, java.lang.Object value)
public void _putAll(java.util.Map m)
Map.putAll(java.util.Map)
public void _clear()
public java.lang.Object _remove(java.lang.Object key)
public void receive(Message msg)
MessageListener
receive
in interface MessageListener
public byte[] getState()
MessageListener
getState
in interface MessageListener
public void setState(byte[] new_state)
MessageListener
setState
in interface MessageListener
public void viewAccepted(View new_view)
MembershipListener
Channel.connect(String)
returns.
viewAccepted
in interface MembershipListener
public void suspect(Address suspected_mbr)
suspect
in interface MembershipListener
public void block()
block
in interface MembershipListener
public static void main(java.lang.String[] args)
public byte[] getState(java.lang.String state_id)
ExtendedMessageListener
getState
in interface ExtendedMessageListener
state_id
- id of the partial state requested
public void getState(java.io.OutputStream ostream)
ExtendedMessageListener
getState
in interface ExtendedMessageListener
ostream
- the OutputStreamOutputStream.close()
public void getState(java.lang.String state_id, java.io.OutputStream ostream)
ExtendedMessageListener
getState
in interface ExtendedMessageListener
state_id
- id of the partial state requestedostream
- the OutputStreamOutputStream.close()
public void setState(java.lang.String state_id, byte[] state)
ExtendedMessageListener
setState
in interface ExtendedMessageListener
state_id
- id of the partial state requestedstate
- partial state for the given state_idpublic void setState(java.io.InputStream istream)
ExtendedMessageListener
setState
in interface ExtendedMessageListener
istream
- the InputStreamInputStream.close()
public void setState(java.lang.String state_id, java.io.InputStream istream)
ExtendedMessageListener
setState
in interface ExtendedMessageListener
state_id
- id of the partial state requestedistream
- the InputStreamInputStream.close()
public void unblock()
ExtendedMembershipListener
Note that during new view installation we provide guarantee that unblock invocation strictly follows view installation at some node A belonging to that view . However, some other message M may squeeze in between view and unblock callbacks. For more details see https://jira.jboss.org/jira/browse/JGRP-986
unblock
in interface ExtendedMembershipListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |