[jboss-cvs] JBossAS SVN: r59560 - in trunk/cluster/src: main/org/jboss/ha/framework/server and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jan 11 21:31:09 EST 2007


Author: bstansberry at jboss.com
Date: 2007-01-11 21:31:07 -0500 (Thu, 11 Jan 2007)
New Revision: 59560

Modified:
   trunk/cluster/src/etc/cluster-beans.xml
   trunk/cluster/src/main/org/jboss/ha/framework/server/DistributedStateImpl.java
   trunk/cluster/src/main/org/jboss/ha/jndi/TreeHead.java
Log:
Move to JBoss Cache Alpha2

Modified: trunk/cluster/src/etc/cluster-beans.xml
===================================================================
--- trunk/cluster/src/etc/cluster-beans.xml	2007-01-12 02:29:43 UTC (rev 59559)
+++ trunk/cluster/src/etc/cluster-beans.xml	2007-01-12 02:31:07 UTC (rev 59560)
@@ -72,24 +72,12 @@
 
     </bean>
     
-   <!-- Now we use the above configuration to construct the cache itself -->
-   <bean name="DefaultPartition-HAPartitionCache" class="org.jboss.cache.TreeCacheProxyImpl">
-   
-      <depends>jboss:service=Naming</depends>
-      
-      <constructor factoryClass="org.jboss.cache.factories.DefaultCacheFactory" factoryMethod="createCache">
-         <parameter class="org.jboss.cache.config.Configuration"><inject bean="DefaultPartition-HAPartitionCacheConfig"/></parameter>
-         <parameter class="boolean">false</parameter>
-      </constructor>
-      
-   </bean>
-    
    <!-- Add a handle to the cache to JMX -->
-   <bean name="HAPartitionCacheJmxWrapper" class="org.jboss.cache.jmx.CacheJmxWrapper">
+   <bean name="DefaultPartition-HAPartitionCache" class="org.jboss.cache.jmx.CacheJmxWrapper">
    
       <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.cache:service=HAPartitionCache,partitionName=${jboss.partition.name:DefaultPartition}", exposedInterface=org.jboss.cache.jmx.CacheJmxWrapperMBean.class, registerDirectly=true)</annotation>
       
-      <property name="cache"><inject bean="DefaultPartition-HAPartitionCache"/></property>
+      <property name="configuration"><inject bean="DefaultPartition-HAPartitionCacheConfig"/></property>
         
    </bean>
 
@@ -103,7 +91,7 @@
       <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss:service=DistributedState,partitionName=${jboss.partition.name:DefaultPartition}", exposedInterface=org.jboss.ha.framework.server.DistributedStateImplMBean.class, registerDirectly=true)</annotation>
       
           
-      <property name="clusteredCache"><inject bean="DefaultPartition-HAPartitionCache"/></property>
+      <property name="clusteredCache"><inject bean="DefaultPartition-HAPartitionCache" property="cache"/></property>
       
    </bean>
 
@@ -121,7 +109,7 @@
             <bean name="DefaultPartition-ClusterPartitionConfig" class="org.jboss.ha.framework.server.ClusterPartitionConfig">   
                
                <!-- ClusterPartition requires a Cache for state management -->
-               <property name="clusteredCache"><inject bean="DefaultPartition-HAPartitionCache"/></property>
+               <property name="clusteredCache"><inject bean="DefaultPartition-HAPartitionCache" property="cache"/></property>
                
                <property name="distributedState"><inject bean="DistributedState"/></property>
                 

Modified: trunk/cluster/src/main/org/jboss/ha/framework/server/DistributedStateImpl.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/framework/server/DistributedStateImpl.java	2007-01-12 02:29:43 UTC (rev 59559)
+++ trunk/cluster/src/main/org/jboss/ha/framework/server/DistributedStateImpl.java	2007-01-12 02:31:07 UTC (rev 59560)
@@ -125,7 +125,6 @@
    protected void createService() throws Exception
    {
       super.createService();
-      //cache.addTreeCacheListener(this);
    }
 
    public void startService() throws Exception
@@ -213,7 +212,7 @@
    }
 
    public Cache getClusteredCache()
-   {
+   {     
       return cache;
    }
 
@@ -301,7 +300,7 @@
    public Collection getAllCategories ()
    {
       try {
-         Node base = cache.getChild(ROOTFQN);
+         Node base = cache.getRoot().getChild(ROOTFQN);
          Collection keys = (base == null ? null : base.getChildrenNames());
          if(keys != null && keys.size() > 0) {
             keys = Collections.unmodifiableCollection(keys);
@@ -321,10 +320,10 @@
      */
    public Collection getAllKeys(String category) {
       try {
-         Node nodeLogger = getLogger(category);
-         if (nodeLogger==null)
+         Node node = getNode(category);
+         if (node==null)
             return null;
-         return nodeLogger.getKeys();
+         return node.getKeys();
       } catch (CacheException ce) {
          return null;
 		}
@@ -338,7 +337,7 @@
      */
    public Collection getAllValues(String category) {
       try {
-         Node categoryNode = getLogger(category);
+         Node categoryNode = getNode(category);
          if (categoryNode == null) {
             return null;
          }
@@ -482,26 +481,14 @@
       return new Fqn(new Object[] { ROOT, category, key, value });
    }
 
-   // FIXME Why is this method named "getLogger"???  Suspect a bug here!
-   protected Node getLogger(String category) throws CacheException {
-      return cache.getChild(buildFqn(category));
+   protected Node getNode(String category) throws CacheException {
+      return cache.getRoot().getChild(buildFqn(category));
    }
 
    // Inner classes -------------------------------------------------
    
    private class DSCacheListener extends AbstractCacheListener
    {
-      /**
-       * Called when a node is about to be evicted or has been evicted from the
-       * in-memory cache.
-       * Note: Currently TreeCacheListener has {@link TreeCacheListener#nodeEvicted(Fqn)}
-       * which will be merged with method in release 1.3.
-       *
-       * @param fqn
-       * @param pre
-       * @see TreeCacheListener#nodeEvicted(Fqn)
-       */
-      public void nodeEvict(Fqn fqn, boolean pre) {}
 
       /**
        * Called when a node is about to be removed or has been removed from the
@@ -544,45 +531,15 @@
          DistributedStateImpl.this.notifyKeyListenersOfRemove((String)fqn.get(ROOTFQNSIZE), "", "", isLocal);
       }
 
-      /**
-       * Called when a node is about to be modified or has been modified.
-       * Note: Currently TreeCacheListener has {@link TreeCacheListener#nodeModified(Fqn)}
-       * which will be merged with this method in release 1.3.
-       *
-       * @param fqn
-       * @param pre
-       * @param isLocal
-       * @see TreeCacheListener#nodeModified(Fqn)
-       */
-      public void nodeModify(Fqn fqn, boolean pre, boolean isLocal) {
-         // we're not interested in pre events or changes to another root in a shared cache instance
-         // we're also not interested in local changes as we issue our own notification
-         if (isLocal || pre || !fqn.isChildOf(ROOTFQN))
+      public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, ModificationType modType, Map data) {
+         
+         if (pre || !fqn.isChildOf(ROOTFQN))
             return;
          
-         // this logic currently doesn't work because key isn't stored as a node
-         /*
-         if (fqn.size() == ROOTFQNSIZE + 2) {
-            String category = (String) fqn.get(ROOTFQNSIZE);
-            Serializable key = (Serializable)fqn.get(ROOTFQNSIZE + 1);
-            try
-            {
-               Serializable value = (Serializable) cache.get(fqn);
-               
-               if (value != null) {  // show new value
-                  notifyKeyListeners(category, key, value, isLocal);
-               }
-            }
-            catch (CacheException e)
-            {
-               log.error("Caught exception getting value for category " + category +
-                         ", key " + key);
-            }     
-         }
-         */
+         //System.out.println("*** DistributedStateImpl.nodeModified; fqn="+fqn+"; pre="+pre+"; isLocal="+isLocal);
          // for now, just return category name
          DistributedStateImpl.this.notifyKeyListeners((String)fqn.get(ROOTFQNSIZE), "", "", isLocal);
-      }      
+      }
    }
 
 }

Modified: trunk/cluster/src/main/org/jboss/ha/jndi/TreeHead.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/jndi/TreeHead.java	2007-01-12 02:29:43 UTC (rev 59559)
+++ trunk/cluster/src/main/org/jboss/ha/jndi/TreeHead.java	2007-01-12 02:31:07 UTC (rev 59560)
@@ -151,7 +151,7 @@
       {
          Fqn temp = new Fqn(m_root, Fqn.fromString(name.toString()));
          // TODO why not jst call remove -- why hasChild first?
-         if (m_cache.hasChild(temp))
+         if (m_cache.getRoot().hasChild(temp))
          {
             m_cache.removeNode(temp);
             return;
@@ -182,7 +182,7 @@
          Object removed = m_cache.remove(ctx, key);
          if (removed == null)
          {
-            if (!m_cache.hasChild(ctx))
+            if (!m_cache.getRoot().hasChild(ctx))
             {
                throw new NotContextException(name.getPrefix(size - 1).toString() + " not a context");
             }
@@ -216,7 +216,7 @@
       // is the name a context?
       try
       {
-         Node n = m_cache.getChild(new Fqn(m_root, Fqn.fromString(name.toString())));
+         Node n = m_cache.getRoot().getChild(new Fqn(m_root, Fqn.fromString(name.toString())));
          if (n != null)
          {
             Name fullName = (Name)(name.clone());
@@ -328,7 +328,7 @@
       else
          ctx = m_root;
       
-      boolean exists = m_cache.hasChild(ctx);
+      boolean exists = m_cache.getRoot().hasChild(ctx);
       if (!exists)
       {  
          try
@@ -345,7 +345,7 @@
       {
          list = new Vector();
 
-         Node base = m_cache.getChild(ctx);
+         Node base = m_cache.getRoot().getChild(ctx);
          if (base != null)
          {
             Map data = base.getData();
@@ -395,7 +395,7 @@
       else
          ctx = m_root;
       
-      boolean exists = m_cache.hasChild(ctx);
+      boolean exists = m_cache.getRoot().hasChild(ctx);
       if (!exists)
       {
          // not found in global jndi, look in local.
@@ -413,7 +413,7 @@
       {
          list = new Vector();
          
-         Node node = m_cache.getChild(ctx);
+         Node node = m_cache.getRoot().getChild(ctx);
          if (node != null)
          {
             Map data = node.getData();
@@ -461,7 +461,7 @@
      String str = name.toString();
      Fqn fqn = Fqn.fromString(str);
      Fqn ctx = new Fqn(m_root, fqn);
-     if (m_cache.hasChild(ctx))
+     if (m_cache.getRoot().hasChild(ctx))
      {
         throw new NameAlreadyBoundException();
      }
@@ -478,7 +478,7 @@
      else
         pctx = m_root;
      
-     boolean exists = m_cache.hasChild(pctx);
+     boolean exists = m_cache.getRoot().hasChild(pctx);
      if (!exists)
      {
         throw new NotContextException(name.getPrefix(size - 1).toString());
@@ -510,7 +510,7 @@
    private void putTreeRoot()
       throws CacheException
    {         
-      if (!m_cache.hasChild(m_root))
+      if (!m_cache.getRoot().hasChild(m_root))
       {   
          m_cache.put(m_root, null);
       }
@@ -538,7 +538,7 @@
       else
          ctx = m_root;
    
-      boolean exists = m_cache.hasChild(ctx);
+      boolean exists = m_cache.getRoot().hasChild(ctx);
       if (!exists)
       {
          throw new NotContextException(name.getPrefix(size - 1).toString() + " not a context");
@@ -548,7 +548,7 @@
       }
       if (!rebind)
       {
-         Node node = m_cache.getChild(ctx);
+         Node node = m_cache.getRoot().getChild(ctx);
          if (node != null && (node.get(key) != null))
          {
             throw new NameAlreadyBoundException(key);




More information about the jboss-cvs-commits mailing list