[jboss-cvs] JBossAS SVN: r108313 - in branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster: web and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Sep 24 10:10:23 EDT 2010


Author: pferraro
Date: 2010-09-24 10:10:23 -0400 (Fri, 24 Sep 2010)
New Revision: 108313

Modified:
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/web/CacheHelper.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/web/CacheHelperMBean.java
Log:
getSessionVersion needs 2 parameters

Modified: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java	2010-09-24 13:43:51 UTC (rev 108312)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/testutil/SessionTestUtil.java	2010-09-24 14:10:23 UTC (rev 108313)
@@ -94,6 +94,7 @@
    
    private static final Logger log = Logger.getLogger(SessionTestUtil.class);
    private static final String[] STRING_ONLY_TYPES = { String.class.getName() };
+   private static final String[] STRING_STRING_TYPES = { String.class.getName(), String.class.getName() };
    private static final String[] STRING_BOOLEAN_TYPES = { String.class.getName(), boolean.class.getName() };
 /*   
    public static JBossCacheManager<?> createManager(String warName, int maxInactiveInterval, 
@@ -386,12 +387,12 @@
       }
    }
    
-   public static Object getSessionVersion(MBeanServerConnection adaptor, String sessionFqn) throws Exception
+   public static Object getSessionVersion(MBeanServerConnection adaptor, String webapp, String sessionId) throws Exception
    {
       return adaptor.invoke(CacheHelper.OBJECT_NAME, 
                             "getSessionVersion", 
-                            new Object[] { sessionFqn }, 
-                            STRING_ONLY_TYPES);
+                            new Object[] { webapp, sessionId }, 
+                            STRING_STRING_TYPES);
    }
 
    public static Object getBuddySessionVersion(MBeanServerConnection adaptor, String sessionFqn) throws Exception

Modified: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/web/CacheHelper.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/web/CacheHelper.java	2010-09-24 13:43:51 UTC (rev 108312)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/web/CacheHelper.java	2010-09-24 14:10:23 UTC (rev 108313)
@@ -21,19 +21,19 @@
  */
 package org.jboss.test.cluster.web;
 
-import java.util.Collections;
 import java.util.HashSet;
-import java.util.Iterator;
+import java.util.Map;
 import java.util.Set;
 
 import javax.management.ObjectName;
 
 import org.infinispan.Cache;
 import org.infinispan.manager.CacheContainer;
-import org.jboss.ha.ispn.CacheContainerRegistry;
 import org.jboss.ha.ispn.DefaultCacheContainerRegistry;
+import org.jboss.ha.ispn.atomic.AtomicMapCache;
 import org.jboss.mx.util.ObjectNameFactory;
 import org.jboss.system.ServiceMBeanSupport;
+import org.jboss.web.tomcat.service.session.distributedcache.ispn.SessionMapEntry;
 
 /**
  * Helper class to locate and invoke methods on the cache mbeans used by JBossWeb.
@@ -56,107 +56,45 @@
    public static final ObjectName OBJECT_NAME = 
       ObjectNameFactory.create("jboss.test:service=WebTestCacheHelper");
    
-   public static final Integer VERSION_KEY = new Integer(0);   
-/*
-   private String cacheConfigName;
-   private Cache cache;
+   private CacheContainer container;
 //   private boolean usePojoCache;
    
-   public CacheHelper()
-   {      
-   }
-   
-   public static Cache getCacheInstance(String cacheConfig)
+   public void setCacheConfigName(String cacheConfigName)
    {
-      try
-      {
-//         CacheManager cm = CacheManagerLocator.getCacheManagerLocator().getCacheManager(null);
-//         return cm.getCache(cacheConfig, true);
-         CacheContainerRegistry cr = DefaultCacheContainerRegistry.getInstance();
-         CacheContainer cc = cr.getCacheContainer("entity");
-         Cache cache = cc.getCache(cacheConfigName);
-         cache.start();
-         return cache;
-
-      }
-      catch (RuntimeException re)
-      {
-         throw re;
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException("getCacheInstance: Exception: " +e);
-      }
+      this.container = DefaultCacheContainerRegistry.getInstance().getCacheContainer(cacheConfigName);
    }
    
-   public void setCacheConfigName(String cacheConfigName)
+   public Object getSessionVersion(String webapp, String sessionId)
    {
-      if (this.cacheConfigName == null || !this.cacheConfigName.equals(cacheConfigName))
-         releaseCache();
-      this.cacheConfigName = cacheConfigName;
-      getCache();
+      Cache<String, Map<Object, Object>> cache = this.container.getCache(webapp);
+      Map<Object, Object> map = new AtomicMapCache<String, Object, Object>(cache).get(sessionId);
+      return (map != null) ? SessionMapEntry.VERSION.get(map) : null;
    }
    
-   public Object getSessionVersion(String sessionFqn)
+   public Object getBuddySessionVersion(String webapp, String sessionId) throws Exception
    {
-      return getCache().get(Fqn.fromString(sessionFqn), VERSION_KEY);
+      return this.getSessionVersion(webapp, sessionId);
    }
    
-   public Object getBuddySessionVersion(String sessionFqn) throws Exception
+   public Set<String> getSessionIds(String webapp) throws Exception
    {
-      Object result = null;
-
-      Fqn fqn = Fqn.fromString(sessionFqn);
-      
-      Set buddies = getBuddyBackupRoots();
-      for (Iterator iter = buddies.iterator(); iter.hasNext();)
+      Cache<Object, Map<Object, Object>> cache = this.container.getCache(webapp);
+      Set<String> sessions = new HashSet<String>();
+      for (Object key: cache.keySet())
       {
-         Node buddy = (Node) iter.next();
-         Node session = buddy.getChild(fqn);
-         if (session != null)
+         if (key instanceof String)
          {
-            result = (Integer) session.get(VERSION_KEY);
-            break;
+            sessions.add((String) key);
          }
       }
-
-      return result;
+      return sessions;
    }
    
-   public Set getSessionIds(String warFqn) throws Exception
+   public Set getSessionIds(String webapp, boolean includeBuddies) throws Exception
    {
-      return getSessionIds(warFqn, true);
+      return this.getSessionIds(webapp);
    }
-   
-   public Set getSessionIds(String warFqn, boolean includeBuddies) throws Exception
-   {
-      Set result = new HashSet();
-      
-      Fqn fqn = Fqn.fromString(warFqn);
-      Node main = getCache().getRoot().getChild(fqn);
-      if (main != null)
-      {
-         result.addAll(main.getChildrenNames());
-      }
-      
-      if (includeBuddies)
-      {
-         //    Check in the buddy backup tree
-         
-         Set buddies = getBuddyBackupRoots();
-         for (Iterator iter = buddies.iterator(); iter.hasNext();)
-         {
-            Node buddy = (Node) iter.next();
-            Node warRoot = buddy.getChild(fqn);
-            if (warRoot != null)
-            {
-               result.addAll(warRoot.getChildrenNames());
-            }
-         }
-      }
-      return result;
-   }
-   
+   /*
    public Set getSSOIds() throws Exception
    {
       Set result = new HashSet();
@@ -206,34 +144,24 @@
       
       return false;
    }
-   
+   */
    public void startService() throws Exception
    {
       super.startService();
       
-      cacheConfigName = System.getProperty(CACHE_CONFIG_PROP);
+      String cacheConfigName = System.getProperty(CACHE_CONFIG_PROP);
       
-      getLog().debug("cacheConfigName=" + cacheConfigName);
+      if (cacheConfigName != null)
+      {
+         this.setCacheConfigName(cacheConfigName);
+      }
    }
    
    public void stopService() throws Exception
    {
       super.stopService();
-      releaseCache();
    }
-   
-   public void releaseCache()
-   {
-      if (cache != null && cacheConfigName != null)
-      {
-         CacheManager cm = CacheManagerLocator.getCacheManagerLocator().getCacheManager(null);
-         cm.releaseCache(cacheConfigName);
-         
-         cache = null;
-      }      
-   }
-   
-
+/*
    private Set getBuddyBackupRoots()
    {
       Set buddies = null;
@@ -248,18 +176,5 @@
       }
       return buddies;
    }
-   
-   private Cache getCache()
-   {
-      if (cache == null)
-      {
-         
-         getLog().debug("Getting cache: cacheConfigName=" + cacheConfigName);
-         cache = getCacheInstance(cacheConfigName);
-         if (cache.getCacheStatus() != CacheStatus.STARTED)
-            cache.start();
-      }
-      return cache;
-   }
-   */
+*/
 }

Modified: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/web/CacheHelperMBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/web/CacheHelperMBean.java	2010-09-24 13:43:51 UTC (rev 108312)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/web/CacheHelperMBean.java	2010-09-24 14:10:23 UTC (rev 108313)
@@ -25,21 +25,19 @@
 
 public interface CacheHelperMBean
 {
-   /*
    void setCacheConfigName(String cacheConfigName);
    
-   Object getSessionVersion(String sessionFqn);
+   Object getSessionVersion(String webapp, String sessionId);
 
-   Object getBuddySessionVersion(String sessionFqn) throws Exception;
+   Object getBuddySessionVersion(String webapp, String sessionId) throws Exception;
 
-   Set getSessionIds(String warFqn) throws Exception;
+   Set getSessionIds(String webapp) throws Exception;
    
-   Set getSessionIds(String warFqn, boolean includeBuddies) throws Exception;
+   Set getSessionIds(String webapp, boolean includeBuddies) throws Exception;
    
-   Set getSSOIds() throws Exception;
+//   Set getSSOIds() throws Exception;
    
-   boolean getCacheHasSSO(String ssoId) throws Exception;
+//   boolean getCacheHasSSO(String ssoId) throws Exception;
    
-   void releaseCache();
-*/
+//   void releaseCache();
 }
\ No newline at end of file



More information about the jboss-cvs-commits mailing list