[jboss-cvs] JBossCache/src/org/jboss/cache/jmx ...
Brian Stansberry
brian.stansberry at jboss.com
Wed May 23 16:23:25 EDT 2007
User: bstansberry
Date: 07/05/23 16:23:25
Modified: src/org/jboss/cache/jmx LegacyConfiguration.java
CacheJmxWrapperMBean.java CacheJmxWrapper.java
Removed: src/org/jboss/cache/jmx CacheLegacyJmxWrapperMBean.java
CacheLegacyJmxWrapper.java
Log:
[JBCACHE-1071] Merge CacheLegacyJmxWrapper into CacheJmxWrapper
Revision Changes Path
1.4 +1 -2 JBossCache/src/org/jboss/cache/jmx/LegacyConfiguration.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: LegacyConfiguration.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/jmx/LegacyConfiguration.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- LegacyConfiguration.java 23 May 2007 10:28:48 -0000 1.3
+++ LegacyConfiguration.java 23 May 2007 20:23:25 -0000 1.4
@@ -32,11 +32,10 @@
* Legacy configuration attributes from JBC 1.x.
*
* @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public interface LegacyConfiguration
{
-
/**
* Get the name of the replication group
*/
1.9 +2 -2 JBossCache/src/org/jboss/cache/jmx/CacheJmxWrapperMBean.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheJmxWrapperMBean.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/jmx/CacheJmxWrapperMBean.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- CacheJmxWrapperMBean.java 23 May 2007 19:24:37 -0000 1.8
+++ CacheJmxWrapperMBean.java 23 May 2007 20:23:25 -0000 1.9
@@ -21,12 +21,12 @@
* <ol>
* <li> Lifecycle methods - create, start, stop, destroy</li>
* <li> Configuration (read-only) getter - which retrieves a String (or formatted HTML for web based JMX consoles) representation of the configuration</li>
- * <li> Setters for a specific subset of config elements which may be changed at runtime</li>
+ * <li> Properties exposing {@link Configuration} elements</li>
* <li> Cache information methods (numNodes, numAttributes, lockInfo, printDetails) which print as Strings or as formatted HTML (for web based JMX consoles)</li>
*
* @since 2.0.0
*/
-public interface CacheJmxWrapperMBean
+public interface CacheJmxWrapperMBean extends LegacyConfiguration
{
void create() throws CacheException;
1.24 +359 -2 JBossCache/src/org/jboss/cache/jmx/CacheJmxWrapper.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheJmxWrapper.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/jmx/CacheJmxWrapper.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- CacheJmxWrapper.java 23 May 2007 19:26:53 -0000 1.23
+++ CacheJmxWrapper.java 23 May 2007 20:23:25 -0000 1.24
@@ -28,10 +28,18 @@
import org.jboss.cache.CacheImpl;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.CacheStatus;
+import org.jboss.cache.config.BuddyReplicationConfig;
+import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.RuntimeConfig;
+import org.jboss.cache.factories.XmlConfigurationParser;
import org.jboss.cache.interceptors.Interceptor;
import org.jgroups.Address;
+import org.jgroups.Channel;
+import org.jgroups.ChannelFactory;
+import org.w3c.dom.Element;
import javax.management.JMException;
import javax.management.ListenerNotFoundException;
@@ -43,6 +51,8 @@
import javax.management.NotificationFilter;
import javax.management.NotificationListener;
import javax.management.ObjectName;
+import javax.transaction.TransactionManager;
+
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@@ -52,7 +62,7 @@
* {@link CacheImpl}.
*
* @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.23 $
+ * @version $Revision: 1.24 $
*/
public class CacheJmxWrapper
extends NotificationBroadcasterSupport
@@ -70,6 +80,14 @@
private final CacheNotificationListener cacheNotificationListener;
private CacheStatus cacheStatus;
+ // Legacy config support
+
+ private Element buddyReplConfig;
+ private Element evictionConfig;
+ private Element cacheLoaderConfig;
+ private Element clusterConfig;
+ private ObjectName multiplexerService;
+
// ----------------------------------------------------------- Constructors
public CacheJmxWrapper()
@@ -93,7 +111,12 @@
public Configuration getConfiguration()
{
- return cache == null ? config : cache.getConfiguration();
+ Configuration cfg = (cache == null ? config : cache.getConfiguration());
+ if (cfg == null)
+ {
+ cfg = config = new Configuration();
+ }
+ return cfg;
}
public String getConfigurationAsString()
@@ -168,6 +191,303 @@
this.registerInterceptors = register;
}
+ // ---------------------------------------------------- LegacyConfiguration
+
+ public Element getBuddyReplicationConfig()
+ {
+ return buddyReplConfig;
+ }
+
+ public Element getCacheLoaderConfiguration()
+ {
+ return cacheLoaderConfig;
+ }
+
+ public String getCacheMode()
+ {
+ return getConfiguration().getCacheModeString();
+ }
+
+ public String getClusterName()
+ {
+ return getConfiguration().getClusterName();
+ }
+
+ public String getClusterProperties()
+ {
+ return getConfiguration().getClusterConfig();
+ }
+
+ public Element getClusterConfig()
+ {
+ return clusterConfig;
+ }
+
+ public Element getEvictionPolicyConfig()
+ {
+ return evictionConfig;
+ }
+
+ public boolean getExposeManagementStatistics()
+ {
+ return getConfiguration().getExposeManagementStatistics();
+ }
+
+ public boolean getFetchInMemoryState()
+ {
+ return getConfiguration().isFetchInMemoryState();
+ }
+
+ public long getInitialStateRetrievalTimeout()
+ {
+ return getConfiguration().getInitialStateRetrievalTimeout();
+ }
+
+ public String getIsolationLevel()
+ {
+ return getConfiguration().getIsolationLevelString();
+ }
+
+ public long getLockAcquisitionTimeout()
+ {
+ return getConfiguration().getLockAcquisitionTimeout();
+ }
+
+ public ObjectName getMultiplexerService()
+ {
+ return multiplexerService;
+ }
+
+ public String getMultiplexerStack()
+ {
+ return getConfiguration().getMultiplexerStack();
+ }
+
+ public ChannelFactory getMuxChannelFactory()
+ {
+ return getConfiguration().getRuntimeConfig().getMuxChannelFactory();
+ }
+
+ public String getNodeLockingScheme()
+ {
+ return getConfiguration().getNodeLockingSchemeString();
+ }
+
+ public long getReplQueueInterval()
+ {
+ return getConfiguration().getReplQueueInterval();
+ }
+
+ public int getReplQueueMaxElements()
+ {
+ return getConfiguration().getReplQueueMaxElements();
+ }
+
+ public String getReplicationVersion()
+ {
+ return getConfiguration().getReplVersionString();
+ }
+
+ public boolean getSyncCommitPhase()
+ {
+ return getConfiguration().isSyncCommitPhase();
+ }
+
+ public long getSyncReplTimeout()
+ {
+ return getConfiguration().getSyncReplTimeout();
+ }
+
+ public boolean getSyncRollbackPhase()
+ {
+ return getConfiguration().isSyncRollbackPhase();
+ }
+
+ public TransactionManager getTransactionManager()
+ {
+ return getConfiguration().getRuntimeConfig().getTransactionManager();
+ }
+
+ public String getTransactionManagerLookupClass()
+ {
+ return getConfiguration().getTransactionManagerLookupClass();
+ }
+
+ public boolean getUseRegionBasedMarshalling()
+ {
+ return getConfiguration().isUseRegionBasedMarshalling();
+ }
+
+ public boolean getUseReplQueue()
+ {
+ return getConfiguration().isUseReplQueue();
+ }
+
+ public boolean isInactiveOnStartup()
+ {
+ return getConfiguration().isInactiveOnStartup();
+ }
+
+ public void setBuddyReplicationConfig(Element config)
+ {
+ BuddyReplicationConfig brc = null;
+ if (config != null)
+ {
+ brc = XmlConfigurationParser.parseBuddyReplicationConfig(config);
+ }
+ getConfiguration().setBuddyReplicationConfig(brc);
+ this.buddyReplConfig = config;
+ }
+
+ public void setCacheLoaderConfiguration(Element cache_loader_config)
+ {
+ CacheLoaderConfig clc = null;
+ if (cache_loader_config != null)
+ {
+ clc = XmlConfigurationParser.parseCacheLoaderConfig(cache_loader_config);
+ }
+ getConfiguration().setCacheLoaderConfig(clc);
+ this.cacheLoaderConfig = cache_loader_config;
+ }
+
+ public void setCacheMode(String mode) throws Exception
+ {
+ getConfiguration().setCacheModeString(mode);
+ }
+
+ public void setClusterConfig(Element config)
+ {
+ String props = null;
+ if (config != null)
+ {
+ props = XmlConfigurationParser.parseClusterConfigXml(config);
+ }
+ getConfiguration().setClusterConfig(props);
+ this.clusterConfig = config;
+ }
+
+ public void setClusterName(String name)
+ {
+ getConfiguration().setClusterName(name);
+ }
+
+ public void setClusterProperties(String cluster_props)
+ {
+ getConfiguration().setClusterConfig(cluster_props);
+ }
+
+ public void setEvictionPolicyConfig(Element config)
+ {
+ EvictionConfig ec = null;
+ if (config != null)
+ {
+ ec = XmlConfigurationParser.parseEvictionConfig(config);
+ }
+ getConfiguration().setEvictionConfig(ec);
+ this.evictionConfig = config;
+ }
+
+ public void setExposeManagementStatistics(boolean expose)
+ {
+ getConfiguration().setExposeManagementStatistics(expose);
+ }
+
+ public void setFetchInMemoryState(boolean flag)
+ {
+ getConfiguration().setFetchInMemoryState(flag);
+ }
+
+ public void setInactiveOnStartup(boolean inactiveOnStartup)
+ {
+ getConfiguration().setInactiveOnStartup(inactiveOnStartup);
+ }
+
+ public void setInitialStateRetrievalTimeout(long timeout)
+ {
+ getConfiguration().setInitialStateRetrievalTimeout(timeout);
+ }
+
+ public void setIsolationLevel(String level)
+ {
+ getConfiguration().setIsolationLevelString(level);
+ }
+
+ public void setLockAcquisitionTimeout(long timeout)
+ {
+ getConfiguration().setLockAcquisitionTimeout(timeout);
+ }
+
+ public void setMultiplexerService(ObjectName muxService)
+ {
+ this.multiplexerService = muxService;
+ }
+
+ public void setMultiplexerStack(String stackName)
+ {
+ getConfiguration().setMultiplexerStack(stackName);
+ }
+
+ public void setMuxChannelFactory(ChannelFactory factory)
+ {
+ getConfiguration().getRuntimeConfig().setMuxChannelFactory(factory);
+ }
+
+ public void setNodeLockingScheme(String nodeLockingScheme)
+ {
+ getConfiguration().setNodeLockingSchemeString(nodeLockingScheme);
+ }
+
+ public void setReplQueueInterval(long interval)
+ {
+ getConfiguration().setReplQueueInterval(interval);
+ }
+
+ public void setReplQueueMaxElements(int max_elements)
+ {
+ getConfiguration().setReplQueueMaxElements(max_elements);
+ }
+
+ public void setReplicationVersion(String version)
+ {
+ getConfiguration().setReplVersionString(version);
+ }
+
+ public void setSyncCommitPhase(boolean sync_commit_phase)
+ {
+ getConfiguration().setSyncCommitPhase(sync_commit_phase);
+ }
+
+ public void setSyncReplTimeout(long timeout)
+ {
+ getConfiguration().setSyncReplTimeout(timeout);
+ }
+
+ public void setSyncRollbackPhase(boolean sync_rollback_phase)
+ {
+ getConfiguration().setSyncRollbackPhase(sync_rollback_phase);
+ }
+
+ public void setTransactionManager(TransactionManager manager)
+ {
+ getConfiguration().getRuntimeConfig().setTransactionManager(manager);
+ }
+
+ public void setTransactionManagerLookupClass(String cl) throws Exception
+ {
+ getConfiguration().setTransactionManagerLookupClass(cl);
+ }
+
+ public void setUseRegionBasedMarshalling(boolean isTrue)
+ {
+ getConfiguration().setUseRegionBasedMarshalling(isTrue);
+ }
+
+ public void setUseReplQueue(boolean flag)
+ {
+ getConfiguration().setUseReplQueue(flag);
+ }
+
+
// -------------------------------------------------------------- Lifecycle
public void create() throws CacheException
@@ -398,6 +718,7 @@
public void setCache(Cache cache)
{
if (cacheStatus != CacheStatus.INSTANTIATED
+ && cacheStatus != CacheStatus.CREATING
&& cacheStatus != CacheStatus.DESTROYED)
{
throw new IllegalStateException("Cannot set underlying cache after call to create()");
@@ -490,6 +811,10 @@
{
log.debug("Constructing Cache");
setCache(DefaultCacheFactory.getInstance().createCache(config, false));
+ if (multiplexerService != null)
+ {
+ injectMuxChannel();
+ }
}
protected boolean registerInterceptors() throws CacheException
@@ -534,6 +859,38 @@
// -------------------------------------------------------- Private methods
+ private void injectMuxChannel() throws CacheException
+ {
+ Configuration cfg = getConfiguration();
+ RuntimeConfig rtcfg = cfg.getRuntimeConfig();
+
+ // Only inject if there isn't already a channel or factory
+ if (rtcfg.getMuxChannelFactory() == null && rtcfg.getChannel() == null)
+ {
+ MBeanServer mbs = getMBeanServer();
+ if (mbs != null)
+ {
+ Channel ch;
+ try
+ {
+ ch = (Channel) mbs.invoke(multiplexerService, "createMultiplexerChannel", new Object[]{cfg.getMultiplexerStack(), cfg.getClusterName()}, new String[]{String.class.getName(), String.class.getName()});
+ }
+ catch (Exception e)
+ {
+ throw new CacheException("Exception creating multiplexed channel", e);
+ }
+ rtcfg.setChannel(ch);
+ }
+ else
+ {
+ throw new CacheException("Cannot access " + multiplexerService +
+ " as no MBeanServer is available. Register this MBean with " +
+ "the JMX server before calling create()");
+ }
+ }
+
+ }
+
/**
* Adds and removes the CacheListener.
More information about the jboss-cvs-commits
mailing list