org.jgroups.blocks

Class NotificationBus

public class NotificationBus extends Object implements MessageListener, MembershipListener

This class provides notification sending and handling capability. Producers can send notifications to all registered consumers. Provides hooks to implement shared group state, which allows an application programmer to maintain a local cache which is replicated by all instances. NotificationBus sits on top of a channel, however it creates its channel itself, so the application programmers do not have to provide their own channel.

Author: Bela Ban

Nested Class Summary
interfaceNotificationBus.Consumer
Field Summary
protected Loglog
Constructor Summary
NotificationBus()
NotificationBus(String bus_name)
NotificationBus(String bus_name, String properties)
Method Summary
voidblock()
SerializablegetCache()
SerializablegetCacheFromCoordinator(long timeout, int max_tries)
Determines the coordinator and asks it for its cache.
SerializablegetCacheFromMember(Address mbr, long timeout, int max_tries)
Determines the coordinator and asks it for its cache.
ChannelgetChannel()
Answers the Channel.
AddressgetLocalAddress()
VectorgetMembership()
Returns a reference to the real membership: don't modify.
byte[]getState()
booleanisCoordinator()
voidnotifyConsumer(Serializable n)
Don't multicast this to all members, just apply it to local consumers.
voidreceive(Message msg)
voidsendNotification(Serializable n)
Pack the argument in a Info, serialize that one into the message buffer and send the message
voidsetConsumer(NotificationBus.Consumer c)
voidsetState(byte[] state)
voidstart()
voidstop()
voidsuspect(Address suspected_mbr)
voidviewAccepted(View new_view)

Field Detail

log

protected final Log log

Constructor Detail

NotificationBus

public NotificationBus()

NotificationBus

public NotificationBus(String bus_name)

NotificationBus

public NotificationBus(String bus_name, String properties)

Method Detail

block

public void block()

getCache

public Serializable getCache()

getCacheFromCoordinator

public Serializable getCacheFromCoordinator(long timeout, int max_tries)
Determines the coordinator and asks it for its cache. If there is no coordinator (because we are first member), null will be returned. Used only internally by NotificationBus.

Parameters: timeout Max number of msecs until the call returns max_tries Max number of attempts to fetch the cache from the coordinator

getCacheFromMember

public Serializable getCacheFromMember(Address mbr, long timeout, int max_tries)
Determines the coordinator and asks it for its cache. If there is no coordinator (because we are first member), null will be returned. Used only internally by NotificationBus.

Parameters: mbr The address of the member from which to fetch the state. If null, the current coordinator will be asked for the state timeout Max number of msecs until the call returns - if timeout elapses null will be returned max_tries Max number of attempts to fetch the cache from the coordinator (will be set to 1 if < 1)

getChannel

public Channel getChannel()
Answers the Channel. Used to operate on the underlying channel directly, e.g. perform operations that are not provided using only NotificationBus. Should be used sparingly.

Returns: underlying Channel

getLocalAddress

public Address getLocalAddress()

getMembership

public Vector getMembership()
Returns a reference to the real membership: don't modify. If you need to modify, make a copy first !

Returns: Vector of Address objects

getState

public byte[] getState()

isCoordinator

public boolean isCoordinator()

notifyConsumer

public void notifyConsumer(Serializable n)
Don't multicast this to all members, just apply it to local consumers.

receive

public void receive(Message msg)

sendNotification

public void sendNotification(Serializable n)
Pack the argument in a Info, serialize that one into the message buffer and send the message

setConsumer

public void setConsumer(NotificationBus.Consumer c)

setState

public void setState(byte[] state)

start

public void start()

stop

public void stop()

suspect

public void suspect(Address suspected_mbr)

viewAccepted

public void viewAccepted(View new_view)
Copyright ? 1998-2005 Bela Ban. All Rights Reserved.