[jboss-cvs] JBossCache/src/org/jboss/cache/jmx ...

Brian Stansberry brian.stansberry at jboss.com
Sun Nov 12 23:42:43 EST 2006


  User: bstansberry
  Date: 06/11/12 23:42:43

  Added:       src/org/jboss/cache/jmx   CacheLegacyJmxWrapperMBean.java
                        CacheLegacyJmxWrapper.java
  Log:
  [JBCACHE-832] Develop mbean for use in JBoss JMX microkernel
  
  Revision  Changes    Path
  1.1      date: 2006/11/13 04:42:43;  author: bstansberry;  state: Exp;JBossCache/src/org/jboss/cache/jmx/CacheLegacyJmxWrapperMBean.java
  
  Index: CacheLegacyJmxWrapperMBean.java
  ===================================================================
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2006, Red Hat Middleware LLC, and individual contributors
   * as indicated by the @author tags. See the copyright.txt file in the
   * distribution for a full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
   * the License, or (at your option) any later version.
   *
   * This software is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this software; if not, write to the Free
   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
   */
  package org.jboss.cache.jmx;
  
  import javax.transaction.TransactionManager;
  
  import org.jboss.cache.Region;
  import org.jboss.cache.TreeCache;
  import org.jboss.cache.config.BuddyReplicationConfig;
  import org.jboss.cache.config.CacheLoaderConfig;
  import org.jboss.cache.config.EvictionConfig;
  import org.jgroups.jmx.JChannelFactoryMBean;
  import org.w3c.dom.Element;
  
  /**
   * StandardMBean interface for {@link CacheLegacyJmxWrapper}.
   * 
   * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
   * @version $Revision: 1.1 $
   */
  public interface CacheLegacyJmxWrapperMBean extends CacheJmxWrapperMBean
  {
     /**
      * Get the name of the replication group
      */
     String getClusterName();
  
     /**
      * Set the name of the replication group
      */
     void setClusterName(String name);
  
     /**
      * Sets whether marshalling uses scoped class loaders on a per region basis.
      * <p />
      * This property must be set to <code>true</code> before any call to
      * {@link Region#registerContextClassLoader(ClassLoader)}.
      *
      * @param isTrue
      */
     void setUseRegionBasedMarshalling(boolean isTrue);
  
     /**
      * Gets whether marshalling uses scoped class loaders on a per region basis.
      * 
      * @return true if region based marshalling is used.
      */
     boolean getUseRegionBasedMarshalling();
  
     /**
      * Gets whether the cache should create interceptor mbeans
      * that are used to capture and publish interceptor statistics.
      *
      * @return true if mbeans should be created for each interceptor
      */
     boolean getExposeManagementStatistics();
     
     void setExposeManagementStatistics(boolean expose);
  
     /**
      * Get the cluster properties (e.g. the protocol stack specification in case of JGroups)
      */
     String getClusterProperties();
  
     /**
      * Set the cluster properties. If the cache is to use the new properties, it has to be redeployed
      *
      * @param cluster_props The properties for the cluster (JGroups)
      */
     void setClusterProperties(String cluster_props);
  
     Element getCacheLoaderConfiguration();
  
     void setCacheLoaderConfiguration(Element cache_loader_config);
  
     boolean getSyncCommitPhase();
  
     void setSyncCommitPhase(boolean sync_commit_phase);
  
     boolean getSyncRollbackPhase();
  
     void setSyncRollbackPhase(boolean sync_rollback_phase);
  
     Element getEvictionPolicyConfig();
     
     /**
      * Setup eviction policy configuration
      */
     void setEvictionPolicyConfig(Element config);
  
     /**
      * Convert a list of elements to the JG property string
      */
     void setClusterConfig(Element config);
  
     /**
      * Get the max time to wait until the initial state is retrieved. This is used in a replicating cache: when a new cache joins the cluster, it needs to acquire the (replicated) state of the other members to initialize itself. If no state has been received within <tt>timeout</tt> milliseconds, the map will be empty.
      *
      * @return long Number of milliseconds to wait for the state. 0 means to wait forever.
      */
     long getInitialStateRetrievalTimeout();
  
     /**
      * Set the initial state transfer timeout (see {@link #getInitialStateRetrievalTimeout()})
      */
     void setInitialStateRetrievalTimeout(long timeout);
  
     /**
      * Returns the current caching mode. Valid values are <ul> <li>LOCAL <li>REPL_ASYNC <li>REPL_SYNC <ul>
      *
      * @return String The caching mode
      */
     String getCacheMode();
  
     /**
      * Sets the default caching mode)
      */
     void setCacheMode(String mode) throws Exception;
  
     /**
      * Returns the default max timeout after which synchronous replication calls return.
      *
      * @return long Number of milliseconds after which a sync repl call must return. 0 means to wait forever
      */
     long getSyncReplTimeout();
  
     /**
      * Sets the default maximum wait time for synchronous replication to receive all results
      */
     void setSyncReplTimeout(long timeout);
  
     boolean getUseReplQueue();
  
     void setUseReplQueue(boolean flag);
  
     long getReplQueueInterval();
  
     void setReplQueueInterval(long interval);
  
     int getReplQueueMaxElements();
  
     void setReplQueueMaxElements(int max_elements);
  
     /**
      * Returns the transaction isolation level.
      */
     String getIsolationLevel();
  
     /**
      * Set the transaction isolation level. This determines the locking strategy to be used
      */
     void setIsolationLevel(String level);
  
     /**
      * Returns whether or not any initial state transfer or subsequent partial
      * state transfer following an <code>activateRegion</code> call should
      * include in-memory state. Allows for warm/hot caches (true/false). The
      * characteristics of a state transfer can be further defined by a cache
      * loader's FetchPersistentState property.
      */
     boolean getFetchInMemoryState();
  
     /**
      * Sets whether or not any initial or subsequent partial state transfer
      * should include in-memory state.
      */
     void setFetchInMemoryState(boolean flag);
  
     /**
      * Gets the format version of the data transferred during an initial state
      * transfer or a call to {@link #activateRegion(String)}.  Different
      * releases of JBossCache may format this data differently; this property
      * identifies the format version being used by this cache instance.
      * <p>
      * The default value for this property is
      * {@link TreeCache#DEFAULT_REPLICATION_VERSION}.
      * </p>
      *
      * @return    a short identifying JBossCache release; e.g. <code>124</code>
      *            for JBossCache 1.2.4
      */
     String getReplicationVersion();
  
     /**
      * Sets the format version of the data transferred during an initial state
      * transfer or a call to {@link #activateRegion(String)}.  Different
      * releases of JBossCache may format this data differently; this property
      * identifies the format version being used by this cache instance. Setting
      * this property to a value other than the default allows a cache instance
      * from a later release to interoperate with a cache instance from an
      * earlier release.
      *
      * @param version a short identifying JBossCache release;
      *                e.g. <code>124</code> for JBossCache 1.2.4
      */
     void setReplicationVersion(String version);
  
     /**
      * Default max time to wait for a lock. If the lock cannot be acquired within this time, a LockingException will be thrown.
      *
      * @return long Max number of milliseconds to wait for a lock to be acquired
      */
     long getLockAcquisitionTimeout();
  
     /**
      * Set the max time for lock acquisition. A value of 0 means to wait forever (not recomended). Note that lock acquisition timeouts may be removed in the future when we have deadlock detection.
      *
      * @param timeout
      */
     void setLockAcquisitionTimeout(long timeout);
  
     String getTransactionManagerLookupClass();
  
     /**
      * Sets the class of the TransactionManagerLookup impl. This will attempt to create an instance, and will throw an exception if this fails.
      *
      * @param cl
      * @throws Exception
      */
     void setTransactionManagerLookupClass(String cl) throws Exception;
  
     TransactionManager getTransactionManager();
  
     void setTransactionManager(TransactionManager manager);
  
     void setNodeLockingScheme(String nodeLockingScheme);
  
     String getNodeLockingScheme();
  
     /**
      * Gets whether the entire tree is inactive upon startup, only responding
      * to replication messages after {@link #activateRegion(String)} is
      * called to activate one or more parts of the tree.
      * <p/>
      * This property is only relevant if {@link #getUseMarshalling()} is
      * <code>true</code>.
      */
     boolean isInactiveOnStartup();
  
     /**
      * Sets whether the entire tree is inactive upon startup, only responding
      * to replication messages after {@link #activateRegion(String)} is
      * called to activate one or more parts of the tree.
      * <p>
      * This property is only relevant if {@link #getUseMarshalling()} is
      * <code>true</code>.
      *
      */
     void setInactiveOnStartup(boolean inactiveOnStartup);
  
     /**
      * Sets the buddy replication configuration element
      * @param config
      */
     void setBuddyReplicationConfig(Element config);
  
     /**
      * Retrieves the buddy replication cofiguration element
      * @return config
      */
     Element getBuddyReplicationConfig();
  
     /**
      * Retrieves the JGroups multiplexer service name if defined.
      * @return the multiplexer service name
      */
     String getMultiplexerService();
  
     /**
      * Sets the JGroups multiplexer service name.
      * This attribute is optional; if not provided, a JGroups JChannel will be used
      * 
      * @param serviceName the multiplexer service name
      */
     void setMultiplexerService(String serviceName);
  
     /**
      * Retrieves the JGroups multiplexer stack name if defined.
      * @return the multiplexer stack name
      */
     String getMultiplexerStack();
  
     /**
      * Used with JGroups multiplexer, specifies stack to be used (e.g., fc-fast-minimalthreads) 
      * This attribute is optional; if not provided, a default multiplexer stack will be used.
      * 
      * @param stackName the name of the multiplexer stack
      */
     void setMultiplexerStack(String stackName);
  
     JChannelFactoryMBean getMuxChannelFactory();
  
     void setMuxChannelFactory(JChannelFactoryMBean factory);
      
  }
  
  
  
  1.1      date: 2006/11/13 04:42:43;  author: bstansberry;  state: Exp;JBossCache/src/org/jboss/cache/jmx/CacheLegacyJmxWrapper.java
  
  Index: CacheLegacyJmxWrapper.java
  ===================================================================
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2006, Red Hat Middleware LLC, and individual contributors
   * as indicated by the @author tags. See the copyright.txt file in the
   * distribution for a full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
   * the License, or (at your option) any later version.
   *
   * This software is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this software; if not, write to the Free
   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
   */
  package org.jboss.cache.jmx;
  
  import javax.transaction.TransactionManager;
  
  import org.jboss.cache.CacheSPI;
  import org.jboss.cache.config.BuddyReplicationConfig;
  import org.jboss.cache.config.CacheLoaderConfig;
  import org.jboss.cache.config.Configuration;
  import org.jboss.cache.config.EvictionConfig;
  import org.jboss.cache.factories.XmlConfigurationParser;
  import org.jgroups.jmx.JChannelFactoryMBean;
  import org.w3c.dom.Element;
  
  /**
   * {@link CacheJmxWrapper} subclass that supports building the 
   * {@link Configuration} from MBean attribute injection.  Allows
   * configuration of the cache using the JBoss AS 4.x JMX microkernel.
   * 
   * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
   * @version $Revision: 1.1 $
   */
  public class CacheLegacyJmxWrapper 
        extends CacheJmxWrapper implements CacheLegacyJmxWrapperMBean
  {
     private Element buddyReplConfig;
     private Element evictionConfig;
     private Element cacheLoaderConfig;
  
     public CacheLegacyJmxWrapper()
     {
        super();
        setConfiguration(new Configuration());
     }
     
     public Configuration getConfiguration()
     {
        Configuration result = super.getConfiguration();
        if (result == null)
        {
           result = new Configuration();
           setConfiguration(result);
        }
        return result;
     }
  
     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 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 String getMultiplexerService()
     {
        return getConfiguration().getMultiplexerService();
     }
  
     public String getMultiplexerStack()
     {
        return getConfiguration().getMultiplexerStack();
     }
  
     public JChannelFactoryMBean 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);
     }
  
     public void setCacheLoaderConfiguration(Element cache_loader_config)
     {
        CacheLoaderConfig clc = null;
        if (cache_loader_config != null)
        {
           clc = XmlConfigurationParser.parseCacheLoaderConfig(cache_loader_config);
        }
        getConfiguration().setCacheLoaderConfig(clc);
     }
  
     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);
     }
  
     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, null);
        }
        getConfiguration().setEvictionConfig(ec);
     }
     
     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(String serviceName)
     {
        getConfiguration().setMultiplexerService(serviceName);
     }
  
     public void setMultiplexerStack(String stackName)
     {
        getConfiguration().setMultiplexerStack(stackName);
     }
  
     public void setMuxChannelFactory(JChannelFactoryMBean 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);
     }
  
  }
  
  
  



More information about the jboss-cvs-commits mailing list