org.jgroups.blocks
public class DistributedQueue extends Object implements MessageListener, MembershipListener, Cloneable
Both keys and values added to the list must be serializable, the reason being that they will be sent across the network to all replicas of the group. An instance of this class will contact an existing member of the group to fetch its initial state. Beware to use a total protocol on initialization or elements would not be in same order on all replicas.
Nested Class Summary | |
---|---|
interface | DistributedQueue.Notification |
Field Summary | |
---|---|
protected Channel | channel |
protected RpcDispatcher | disp |
protected String | groupname |
protected LinkedList | internalQueue |
protected Log | logger |
protected Vector | members |
protected Object | mutex |
protected Vector | notifs |
protected boolean | stopped |
Constructor Summary | |
---|---|
DistributedQueue(String groupname, ChannelFactory factory, String properties, long state_timeout)
Creates a DistributedQueue | |
DistributedQueue(JChannel channel) | |
DistributedQueue(PullPushAdapter adapter, Serializable id)
Uses a user-provided PullPushAdapter to create the dispatcher rather than a Channel. |
Method Summary | |
---|---|
void | add(Object value)
Add the speficied element at the bottom of the queue |
void | addAll(Collection values)
Add the speficied collection to the top of the queue.
|
void | addAtHead(Object value)
Add the speficied element at the top of the queue |
void | addNotifier(DistributedQueue.Notification n) |
void | block() Block sending and receiving of messages until ViewAccepted is called |
protected void | checkResult(RspList rsp, Object retval) |
Channel | getChannel() |
Vector | getContents() |
Address | getLocalAddress() |
byte[] | getState() |
protected void | init() |
static void | main(String[] args) |
Object | peek()
returns the first object on the queue, without removing it.
|
void | receive(Message msg) |
Object | remove()
Try to return the first objet in the queue.It does not wait for an object. |
Object | remove(long timeout) |
void | removeNotifier(DistributedQueue.Notification n) |
void | reset() |
void | setState(byte[] new_state) |
int | size() |
void | start(long state_timeout) |
void | stop() |
void | suspect(Address suspected_mbr) Called when a member is suspected |
String | toString() |
void | viewAccepted(View new_view) |
void | _add(Object value) |
void | _addAll(Collection c) |
void | _addAtHead(Object value) |
protected void | _private_reset() |
Object | _remove() |
void | _reset() |
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.
Parameters: adapter The PullPushAdapter which to use as underlying transport id A serializable object (e.g. an Integer) used to discriminate (multiplex/demultiplex) between requests/responses for different building blocks on top of PullPushAdapter.
Parameters: value
Parameters: values
Parameters: value
Returns: the first object on the queue
Returns: the first object in the queue or null if none were found.
Parameters: timeout The time to wait until an entry is retrieved in milliseconds. A value of 0 means wait forever.
Returns: the first object in the queue or null if none were found