com.opensymphony.oscache.plugins.clustersupport
public class: JavaGroupsBroadcastingListener [javadoc |
source]
java.lang.Object
com.opensymphony.oscache.plugins.clustersupport.AbstractBroadcastingListener
com.opensymphony.oscache.plugins.clustersupport.JavaGroupsBroadcastingListener
All Implemented Interfaces:
NotificationBus.Consumer, LifecycleAware, CacheEntryEventListener
A concrete implementation of the AbstractBroadcastingListener based on
the JavaGroups library. This Class uses JavaGroups to broadcast cache flush
messages across a cluster.
One of the following properties should be configured in oscache.properties for
this listener:
- cache.cluster.multicast.ip - The multicast IP that JavaGroups should use for broadcasting
- cache.cluster.properties - The JavaGroups channel properties to use. Allows for precise
control over the behaviour of JavaGroups
Please refer to the clustering documentation for further details on the configuration of this listener.
- author:
< - a href="mailto:chris@swebtec.com">Chris Miller
| Methods from com.opensymphony.oscache.plugins.clustersupport.AbstractBroadcastingListener: |
|---|
|
cacheEntryAdded, cacheEntryFlushed, cacheEntryRemoved, cacheEntryUpdated, cacheFlushed, cacheGroupAdded, cacheGroupEntryAdded, cacheGroupEntryRemoved, cacheGroupFlushed, cacheGroupRemoved, cacheGroupUpdated, cachePatternFlushed, handleClusterNotification, initialize, sendNotification |
| Method from com.opensymphony.oscache.plugins.clustersupport.JavaGroupsBroadcastingListener Detail: |
public synchronized void finialize() throws FinalizationException {
if (log.isInfoEnabled()) {
log.info("JavaGroups shutting down...");
}
// It's possible that the notification bus is null (CACHE-154)
if (bus != null) {
bus.stop();
bus = null;
} else {
log.warn("Notification bus wasn't initialized or finialize was invoked before!");
}
if (log.isInfoEnabled()) {
log.info("JavaGroups shutdown complete.");
}
}
Shuts down the JavaGroups being managed by this listener. This
occurs once the cache is shut down and this listener is no longer
in use. |
public Serializable getCache() {
return "JavaGroupsBroadcastingListener: " + bus.getLocalAddress();
}
We are not using the caching, so we just return something that identifies
us. This method should never be called directly. |
public void handleNotification(Serializable serializable) {
if (!(serializable instanceof ClusterNotification)) {
log.error("An unknown cluster notification message received (class=" + serializable.getClass().getName() + "). Notification ignored.");
return;
}
handleClusterNotification((ClusterNotification) serializable);
}
Handles incoming notification messages from JavaGroups. This method should
never be called directly. |
public synchronized void initialize(Cache cache,
Config config) throws InitializationException {
super.initialize(cache, config);
String properties = config.getProperty(CHANNEL_PROPERTIES);
String multicastIP = config.getProperty(MULTICAST_IP_PROPERTY);
if ((properties == null) && (multicastIP == null)) {
multicastIP = DEFAULT_MULTICAST_IP;
}
if (properties == null) {
properties = DEFAULT_CHANNEL_PROPERTIES_PRE + multicastIP.trim() + DEFAULT_CHANNEL_PROPERTIES_POST;
} else {
properties = properties.trim();
}
if (log.isInfoEnabled()) {
log.info("Starting a new JavaGroups broadcasting listener with properties=" + properties);
}
try {
bus = new NotificationBus(BUS_NAME, properties);
bus.start();
bus.getChannel().setOpt(Channel.LOCAL, new Boolean(false));
bus.setConsumer(this);
log.info("JavaGroups clustering support started successfully");
} catch (Exception e) {
throw new InitializationException("Initialization failed: " + e);
}
}
Initializes the broadcasting listener by starting up a JavaGroups notification
bus instance to handle incoming and outgoing messages. |
public void memberJoined(Address address) {
if (log.isInfoEnabled()) {
log.info("A new member at address '" + address + "' has joined the cluster");
}
}
A callback that is fired when a new member joins the cluster. This
method should never be called directly. |
public void memberLeft(Address address) {
if (log.isInfoEnabled()) {
log.info("Member at address '" + address + "' left the cluster");
}
}
A callback that is fired when an existing member leaves the cluster.
This method should never be called directly. |
protected void sendNotification(ClusterNotification message) {
bus.sendNotification(message);
}
Uses JavaGroups to broadcast the supplied notification message across the cluster. |