org.alfresco.repo.jgroups
Class AlfrescoJGroupsChannelFactory

java.lang.Object
  extended by org.springframework.extensions.surf.util.AbstractLifecycleBean
      extended by org.alfresco.repo.jgroups.AlfrescoJGroupsChannelFactory
All Implemented Interfaces:
java.util.EventListener, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener

public class AlfrescoJGroupsChannelFactory
extends org.springframework.extensions.surf.util.AbstractLifecycleBean

A cache peer provider that does heartbeat sending and receiving using JGroups.

The cluster name needs to be set before any communication is possible. This can be done using the property AlfrescoJGroupsChannelFactory.setClusterName(String).

The channels provided to the callers will be proxies to underlying channels that will be hot-swappable. This means that the client code can continue to use the channel references while the actual implementation can be switched in and out as required.

Since:
2.1.3

Nested Class Summary
static class AlfrescoJGroupsChannelFactory.ChannelProxy
          A proxy channel that can be used to hot-swap underlying channels.
static class AlfrescoJGroupsChannelFactory.DummyProtocol
           
 
Field Summary
static java.lang.String APP_REGION_DEFAULT
          A catch-all for unknown application regions.
static java.lang.String APP_REGION_EHCACHE_HEARTBEAT
          The application region used by the EHCache heartbeat implementation over JGroups.
static java.lang.String DEFAULT_CONFIG_TCP
          The TCP protocol config
static java.lang.String DEFAULT_CONFIG_UDP
          The UDP protocol config (default)
 
Fields inherited from class org.springframework.extensions.surf.util.AbstractLifecycleBean
log
 
Constructor Summary
AlfrescoJGroupsChannelFactory()
          Bean-enabling constructor
 
Method Summary
static void changeClusterNamePrefix(java.lang.String clusterNamePrefix)
          Set the prefix used to identify the different clusters.
static org.jgroups.Channel getChannel(java.lang.String appRegion)
          /** Creates a channel for the cluster.
static boolean isClusterActive()
          Check if a cluster name was provided.
protected  void onBootstrap(org.springframework.context.ApplicationEvent event)
           
protected  void onShutdown(org.springframework.context.ApplicationEvent event)
           
static void rebuildChannels()
          Rebuild all the channels using the current cluster name and configuration mappings.
 void setClusterName(java.lang.String clusterName)
           
 void setConfigUrlsByAppRegion(java.util.Map configUrlsByAppRegion)
           
 void setJgroupsConfigurationUrl(java.lang.String configUrl)
          Deprecated. Use AlfrescoJGroupsChannelFactory.setConfigUrlsByAppRegion(Map)
 void setProtocolStackMapping(java.util.Map unused)
          Deprecated. Use AlfrescoJGroupsChannelFactory.setConfigUrlsByAppRegion(Map)
 
Methods inherited from class org.springframework.extensions.surf.util.AbstractLifecycleBean
getApplicationContext, onApplicationEvent, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

APP_REGION_DEFAULT

public static final java.lang.String APP_REGION_DEFAULT
A catch-all for unknown application regions.

See Also:
Constant Field Values

APP_REGION_EHCACHE_HEARTBEAT

public static final java.lang.String APP_REGION_EHCACHE_HEARTBEAT
The application region used by the EHCache heartbeat implementation over JGroups.

See Also:
Constant Field Values

DEFAULT_CONFIG_UDP

public static final java.lang.String DEFAULT_CONFIG_UDP
The UDP protocol config (default)

See Also:
Constant Field Values

DEFAULT_CONFIG_TCP

public static final java.lang.String DEFAULT_CONFIG_TCP
The TCP protocol config

See Also:
Constant Field Values
Constructor Detail

AlfrescoJGroupsChannelFactory

public AlfrescoJGroupsChannelFactory()
Bean-enabling constructor

Method Detail

isClusterActive

public static boolean isClusterActive()
Check if a cluster name was provided.

Returns:
Returns true if the cluster configuration is active, i.e. a cluster name was provided

getChannel

public static org.jgroups.Channel getChannel(java.lang.String appRegion)
/** Creates a channel for the cluster. This method should not be heavily used as the checks and synchronizations will slow the calls. Returned channels can be kept and will be modified directly using the factory-held references, if necessary.

The application region is used to determine the protocol configuration to apply.

This method returns a dummy channel if no cluster name has been provided.

Parameters:
appRegion - the application region identifier.
Returns:
Returns a channel

rebuildChannels

public static void rebuildChannels()
Rebuild all the channels using the current cluster name and configuration mappings.


changeClusterNamePrefix

public static void changeClusterNamePrefix(java.lang.String clusterNamePrefix)
Set the prefix used to identify the different clusters. Each application region will have a separate cluster name that will be:
    clusterNamePrefix:appRegion
 
If no cluster name prefix is declared, the cluster is effectively disabled.

NOTE: The channels must be rebuilt.

Parameters:
clusterNamePrefix - a prefix to append to the cluster names used

setClusterName

public void setClusterName(java.lang.String clusterName)
See Also:
AlfrescoJGroupsChannelFactory.changeClusterNamePrefix(String)

setConfigUrlsByAppRegion

public void setConfigUrlsByAppRegion(java.util.Map configUrlsByAppRegion)
See Also:
AlfrescoJGroupsChannelFactory.changeConfigUrlsMapping(Map)

setProtocolStackMapping

public void setProtocolStackMapping(java.util.Map unused)
Deprecated. Use AlfrescoJGroupsChannelFactory.setConfigUrlsByAppRegion(Map)


setJgroupsConfigurationUrl

public void setJgroupsConfigurationUrl(java.lang.String configUrl)
Deprecated. Use AlfrescoJGroupsChannelFactory.setConfigUrlsByAppRegion(Map)


onBootstrap

protected void onBootstrap(org.springframework.context.ApplicationEvent event)
Specified by:
onBootstrap in class org.springframework.extensions.surf.util.AbstractLifecycleBean

onShutdown

protected void onShutdown(org.springframework.context.ApplicationEvent event)
Specified by:
onShutdown in class org.springframework.extensions.surf.util.AbstractLifecycleBean


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.