com.opensymphony.oscache.plugins.clustersupport
Class JavaGroupsBroadcastingListener

java.lang.Object
  extended by com.opensymphony.oscache.plugins.clustersupport.AbstractBroadcastingListener
      extended by com.opensymphony.oscache.plugins.clustersupport.JavaGroupsBroadcastingListener
All Implemented Interfaces:
CacheEntryEventListener, CacheEventListener, LifecycleAware, EventListener, org.jgroups.blocks.NotificationBus.Consumer

public class JavaGroupsBroadcastingListener
extends AbstractBroadcastingListener
implements org.jgroups.blocks.NotificationBus.Consumer

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:

Please refer to the clustering documentation for further details on the configuration of this listener.

Author:
Chris Miller

Field Summary
private  org.jgroups.blocks.NotificationBus bus
           
private static String BUS_NAME
           
private static String CHANNEL_PROPERTIES
           
private static String DEFAULT_CHANNEL_PROPERTIES_POST
          The second half of the default channel properties.
private static String DEFAULT_CHANNEL_PROPERTIES_PRE
          The first half of the default channel properties.
private static String DEFAULT_MULTICAST_IP
           
private static org.apache.commons.logging.Log log
           
private static String MULTICAST_IP_PROPERTY
           
 
Fields inherited from class com.opensymphony.oscache.plugins.clustersupport.AbstractBroadcastingListener
cache, CLUSTER_ORIGIN
 
Constructor Summary
JavaGroupsBroadcastingListener()
           
 
Method Summary
 void finialize()
          Shuts down the JavaGroups being managed by this listener.
 Serializable getCache()
          We are not using the caching, so we just return something that identifies us.
 void handleNotification(Serializable serializable)
          Handles incoming notification messages from JavaGroups.
 void initialize(Cache cache, Config config)
          Initializes the broadcasting listener by starting up a JavaGroups notification bus instance to handle incoming and outgoing messages.
 void memberJoined(org.jgroups.Address address)
          A callback that is fired when a new member joins the cluster.
 void memberLeft(org.jgroups.Address address)
          A callback that is fired when an existing member leaves the cluster.
protected  void sendNotification(ClusterNotification message)
          Uses JavaGroups to broadcast the supplied notification message across the cluster.
 
Methods inherited from class com.opensymphony.oscache.plugins.clustersupport.AbstractBroadcastingListener
cacheEntryAdded, cacheEntryFlushed, cacheEntryRemoved, cacheEntryUpdated, cacheFlushed, cacheGroupAdded, cacheGroupEntryAdded, cacheGroupEntryRemoved, cacheGroupFlushed, cacheGroupRemoved, cacheGroupUpdated, cachePatternFlushed, handleClusterNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log

BUS_NAME

private static final String BUS_NAME
See Also:
Constant Field Values

CHANNEL_PROPERTIES

private static final String CHANNEL_PROPERTIES
See Also:
Constant Field Values

MULTICAST_IP_PROPERTY

private static final String MULTICAST_IP_PROPERTY
See Also:
Constant Field Values

DEFAULT_CHANNEL_PROPERTIES_PRE

private static final String DEFAULT_CHANNEL_PROPERTIES_PRE
The first half of the default channel properties. They default channel properties are:
 UDP(mcast_addr=*.*.*.*;mcast_port=45566;ip_ttl=32;\
 mcast_send_buf_size=150000;mcast_recv_buf_size=80000):\
 PING(timeout=2000;num_initial_members=3):\
 MERGE2(min_interval=5000;max_interval=10000):\
 FD_SOCK:VERIFY_SUSPECT(timeout=1500):\
 pbcast.NAKACK(gc_lag=50;retransmit_timeout=300,600,1200,2400,4800;max_xmit_size=8192):\
 UNICAST(timeout=300,600,1200,2400):\
 pbcast.STABLE(desired_avg_gossip=20000):\
 FRAG(frag_size=8096;down_thread=false;up_thread=false):\
 pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;shun=false;print_local_addr=true)
 
Where *.*.*.* is the specified multicast IP, which defaults to 231.12.21.132.

See Also:
Constant Field Values

DEFAULT_CHANNEL_PROPERTIES_POST

private static final String DEFAULT_CHANNEL_PROPERTIES_POST
The second half of the default channel properties. They default channel properties are:
 UDP(mcast_addr=*.*.*.*;mcast_port=45566;ip_ttl=32;\
 mcast_send_buf_size=150000;mcast_recv_buf_size=80000):\
 PING(timeout=2000;num_initial_members=3):\
 MERGE2(min_interval=5000;max_interval=10000):\
 FD_SOCK:VERIFY_SUSPECT(timeout=1500):\
 pbcast.NAKACK(gc_lag=50;retransmit_timeout=300,600,1200,2400,4800;max_xmit_size=8192):\
 UNICAST(timeout=300,600,1200,2400):\
 pbcast.STABLE(desired_avg_gossip=20000):\
 FRAG(frag_size=8096;down_thread=false;up_thread=false):\
 pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;shun=false;print_local_addr=true)
 
Where *.*.*.* is the specified multicast IP, which defaults to 231.12.21.132.

See Also:
Constant Field Values

DEFAULT_MULTICAST_IP

private static final String DEFAULT_MULTICAST_IP
See Also:
Constant Field Values

bus

private org.jgroups.blocks.NotificationBus bus
Constructor Detail

JavaGroupsBroadcastingListener

public JavaGroupsBroadcastingListener()
Method Detail

initialize

public void initialize(Cache cache,
                       Config config)
                throws InitializationException
Initializes the broadcasting listener by starting up a JavaGroups notification bus instance to handle incoming and outgoing messages.

Specified by:
initialize in interface LifecycleAware
Overrides:
initialize in class AbstractBroadcastingListener
Parameters:
config - An OSCache configuration object.
cache - the cache instance that this listener is attached to.
Throws:
InitializationException - If this listener has already been initialized.

finialize

public void finialize()
               throws FinalizationException
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.

Specified by:
finialize in interface LifecycleAware
Throws:
FinalizationException

sendNotification

protected void sendNotification(ClusterNotification message)
Uses JavaGroups to broadcast the supplied notification message across the cluster.

Specified by:
sendNotification in class AbstractBroadcastingListener
Parameters:
message - The cluster nofication message to broadcast.

handleNotification

public void handleNotification(Serializable serializable)
Handles incoming notification messages from JavaGroups. This method should never be called directly.

Specified by:
handleNotification in interface org.jgroups.blocks.NotificationBus.Consumer
Parameters:
serializable - The incoming message object. This must be a ClusterNotification.

getCache

public Serializable getCache()
We are not using the caching, so we just return something that identifies us. This method should never be called directly.

Specified by:
getCache in interface org.jgroups.blocks.NotificationBus.Consumer

memberJoined

public void memberJoined(org.jgroups.Address address)
A callback that is fired when a new member joins the cluster. This method should never be called directly.

Specified by:
memberJoined in interface org.jgroups.blocks.NotificationBus.Consumer
Parameters:
address - The address of the member who just joined.

memberLeft

public void memberLeft(org.jgroups.Address address)
A callback that is fired when an existing member leaves the cluster. This method should never be called directly.

Specified by:
memberLeft in interface org.jgroups.blocks.NotificationBus.Consumer
Parameters:
address - The address of the member who left.


Copyright © 2011 OpenSymphony. All Rights Reserved.