[jboss-cvs] JBossAS SVN: r80725 - in projects/cluster: ha-server-cache-jbc/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/impl and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Nov 9 16:03:47 EST 2008


Author: bstansberry at jboss.com
Date: 2008-11-09 16:03:47 -0500 (Sun, 09 Nov 2008)
New Revision: 80725

Modified:
   projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/CacheListener.java
   projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/CacheListenerBase.java
   projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/FieldBasedJBossCacheService.java
   projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/JBossCacheService.java
   projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/PassivationListener.java
   projects/cluster/ha-server-cache-jbc/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/impl/CacheListenerUnitTestCase.java
   projects/cluster/ha-server-cache-spi/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi/DistributableSession.java
Log:
[JBAS-6184] Eliminate a JBC Fqn level in clustered session caching

Modified: projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/CacheListener.java
===================================================================
--- projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/CacheListener.java	2008-11-09 16:05:29 UTC (rev 80724)
+++ projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/CacheListener.java	2008-11-09 21:03:47 UTC (rev 80725)
@@ -54,9 +54,9 @@
    private static Logger log_ = Logger.getLogger(CacheListener.class);
    private boolean fieldBased_;
 
-   CacheListener(JBossCacheWrapper wrapper, LocalDistributableSessionManager manager, String hostname, String webapp, boolean field)
+   CacheListener(JBossCacheWrapper wrapper, LocalDistributableSessionManager manager, String contextHostPath, boolean field)
    {      
-      super(manager, hostname, webapp);
+      super(manager, contextHostPath);
       fieldBased_ = field;
    }
 

Modified: projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/CacheListenerBase.java
===================================================================
--- projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/CacheListenerBase.java	2008-11-09 16:05:29 UTC (rev 80724)
+++ projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/CacheListenerBase.java	2008-11-09 21:03:47 UTC (rev 80725)
@@ -34,29 +34,25 @@
 {
 
    private static final int JSESSION_FQN_INDEX = 0;
-   private static final int HOSTNAME_FQN_INDEX = 1;
-   private static final int WEBAPP_FQN_INDEX = 2;
-   protected static final int SESSION_ID_FQN_INDEX = 3;
+   private static final int WEBAPP_FQN_INDEX = 1;
+   protected static final int SESSION_ID_FQN_INDEX = 2;
    private static final int SESSION_FQN_SIZE = SESSION_ID_FQN_INDEX + 1;
    private static final int BUDDY_BACKUP_ROOT_OWNER_INDEX = BuddyManager.BUDDY_BACKUP_SUBTREE_FQN.size();
    protected static final int BUDDY_BACKUP_ROOT_OWNER_SIZE = BUDDY_BACKUP_ROOT_OWNER_INDEX + 1;
    protected LocalDistributableSessionManager manager_;
-   private String webapp_;
-   private String hostname_;
+   private String contextHostPath_;
 
-   CacheListenerBase(LocalDistributableSessionManager manager, String hostname, String webapp)
+   CacheListenerBase(LocalDistributableSessionManager manager, String contextHostPath)
    {      
-      manager_ = manager;
-      hostname_ = hostname;
-      webapp_ =  webapp;
+      this.manager_ = manager;
+      this.contextHostPath_ = contextHostPath;
    }
 
    protected boolean isFqnForOurWebapp(Fqn fqn, boolean isBuddy)
    {
       try
       {
-         if (webapp_.equals(fqn.get(isBuddy ? BUDDY_BACKUP_ROOT_OWNER_SIZE + WEBAPP_FQN_INDEX : WEBAPP_FQN_INDEX))
-               && hostname_.equals(fqn.get(isBuddy ? BUDDY_BACKUP_ROOT_OWNER_SIZE + HOSTNAME_FQN_INDEX : HOSTNAME_FQN_INDEX))
+         if (contextHostPath_.equals(fqn.get(isBuddy ? BUDDY_BACKUP_ROOT_OWNER_SIZE + WEBAPP_FQN_INDEX : WEBAPP_FQN_INDEX))
                && JBossCacheService.SESSION.equals(fqn.get(isBuddy ? BUDDY_BACKUP_ROOT_OWNER_SIZE + JSESSION_FQN_INDEX : JSESSION_FQN_INDEX)))
             return true;
       }

Modified: projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/FieldBasedJBossCacheService.java
===================================================================
--- projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/FieldBasedJBossCacheService.java	2008-11-09 16:05:29 UTC (rev 80724)
+++ projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/FieldBasedJBossCacheService.java	2008-11-09 21:03:47 UTC (rev 80725)
@@ -49,12 +49,33 @@
 {
    public static final String ATTRIBUTE = "ATTRIBUTE";
 
-   public static Fqn getAttributeFqn(String hostname, String contextPath, String sessionId)
+   public static Fqn getAttributeFqn(String contextHostPath, String sessionId)
    {
-      Object[] objs = new Object[]{SESSION, hostname, contextPath, sessionId, ATTRIBUTE};
+      Object[] objs = new Object[]{SESSION, contextHostPath, sessionId, ATTRIBUTE};
       return Fqn.fromList(Arrays.asList(objs), true);
    }
    
+   public static Fqn getFieldFqn(String contextHostPath, String sessionId, String attributeKey)
+   {
+      List list = new ArrayList(5);
+      list.add(SESSION);
+      list.add(contextHostPath);
+      list.add(sessionId);
+      list.add(ATTRIBUTE);
+      // Guard against string with delimiter.
+      breakKeys(attributeKey, list);
+      return Fqn.fromList(list, true);      
+   }
+
+   private static void breakKeys(String key, List list)
+   {
+      StringTokenizer token = new StringTokenizer(key, FQN_DELIMITER);
+      while(token.hasMoreTokens())
+      {
+         list.add(token.nextToken());
+      }
+   }
+   
    private final PojoCache pojoCache_;
    
    public FieldBasedJBossCacheService(String cacheConfigName) throws ClusteringNotSupportedException
@@ -89,6 +110,9 @@
       return true;
    }
 
+   /**
+    * Overrides the superclass to pull in attributes via PojoCache API.
+    */
    @Override
    protected Map<String, Object> getSessionAttributes(String realId, Map<Object, Object> distributedCacheData)
    {
@@ -101,38 +125,6 @@
       return attrs;
    }
 
-   private Fqn getAttributeFqn(String id)
-   {
-      return getAttributeFqn(hostName_, webAppPath_, id);
-   }
-
-   private Fqn getFieldFqn(String id, String key)
-   {
-      return getFieldFqn(hostName_, webAppPath_, id, key);
-   }
-
-
-   private static void breakKeys(String key, List list)
-   {
-      StringTokenizer token = new StringTokenizer(key, FQN_DELIMITER);
-      while(token.hasMoreTokens())
-      {
-         list.add(token.nextToken());
-      }
-   }
-   public static Fqn getFieldFqn(String hostName, String contextPath, String sessionId, String attributeKey)
-   {
-      List list = new ArrayList(6);
-      list.add(SESSION);
-      list.add(hostName);
-      list.add(contextPath);
-      list.add(sessionId);
-      list.add(ATTRIBUTE);
-      // Guard against string with delimiter.
-      breakKeys(attributeKey, list);
-      return Fqn.fromList(list, true);      
-   }
-
    /**
     * store the pojo instance in the cache. Note that this is for the aop cache.
     * The pojo needs to be "aspectized".
@@ -140,7 +132,7 @@
     * @param realId the session id with any jvmRoute removed
     * @param key    the attribute key
     * @param pojo
-    * @param createRegion TODO
+    * @param DistributableSession session associated with the pojo
     */
    public Object setPojo(String realId, String key, Object pojo, DistributableSession session)
    {
@@ -152,7 +144,7 @@
       
       if (session.needRegionForSession())
       {
-         Fqn sessionRegion = getSessionFqn(realId);
+         Fqn sessionRegion = getSessionFqn(combinedPath_, realId);
          getCache().getRegion(sessionRegion, true);
          session.createdRegionForSession();
          if (log_.isTraceEnabled())
@@ -162,7 +154,7 @@
       }
       
       // Construct the fqn.
-      Fqn fqn = getFieldFqn(realId, key);
+      Fqn fqn = getFieldFqn(combinedPath_, realId, key);
       try {
          // Ignore any cache notifications that our own work generates 
 //         SessionReplicationContext.startCacheActivity();            
@@ -188,7 +180,7 @@
          log_.trace("removePojo(): session id: " +realId + " key: " +key);
       }
       // Construct the fqn.
-      Fqn fqn = getFieldFqn(realId, key);
+      Fqn fqn = getFieldFqn(combinedPath_, realId, key);
       try {
          // Ignore any cache notifications that our own work generates 
 //         SessionReplicationContext.startCacheActivity();
@@ -214,7 +206,7 @@
          log_.trace("removePojoLocal(): session id: " +realId);
       }
       // Construct the fqn.
-      Fqn fqn = getAttributeFqn(realId);
+      Fqn fqn = getAttributeFqn(combinedPath_, realId);
       try {
          // Ignore any cache notifications that our own work generates 
 //         SessionReplicationContext.startCacheActivity();
@@ -238,7 +230,7 @@
          log_.trace("removePojoLocal(): session id: " + realId + " key: " +key);
       }
       // Construct the fqn.
-      Fqn fqn = getFieldFqn(realId, key);
+      Fqn fqn = getFieldFqn(combinedPath_, realId, key);
       try {
          // Ignore any cache notifications that our own work generates 
 //         SessionReplicationContext.startCacheActivity();
@@ -252,7 +244,7 @@
    public Set getPojoKeys(String realId)
    {
       Set keys = null;
-      Fqn fqn = getAttributeFqn(realId);
+      Fqn fqn = getAttributeFqn(combinedPath_, realId);
       try
       {
          keys = getChildrenNames(fqn);
@@ -274,7 +266,7 @@
     */
    public Object getPojo(String realId, String key)
    {
-      Fqn fqn = getFieldFqn(realId, key);
+      Fqn fqn = getFieldFqn(combinedPath_, realId, key);
       if(log_.isTraceEnabled())
       {
          log_.trace("getPojo(): session id: " +realId + " key: " + key +

Modified: projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/JBossCacheService.java
===================================================================
--- projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/JBossCacheService.java	2008-11-09 16:05:29 UTC (rev 80724)
+++ projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/JBossCacheService.java	2008-11-09 21:03:47 UTC (rev 80725)
@@ -80,20 +80,36 @@
    
    // Use Integers as JBC keys -- replication performant but won't be
    // confused with String attribute keys for ATTRIBUTE granularity sessions
-   public static final Integer VERSION_KEY = new Integer(0);
-   public static final Integer TIMESTAMP_KEY = new Integer(1);
-   public static final Integer METADATA_KEY = new Integer(2);
-   public static final Integer ATTRIBUTE_KEY = new Integer(3);
+   // Alternative is an enum, but then we replicate a long classname
+   public static final Integer VERSION_KEY = Integer.valueOf(0);
+   public static final Integer TIMESTAMP_KEY = Integer.valueOf(1);
+   public static final Integer METADATA_KEY = Integer.valueOf(2);
+   public static final Integer ATTRIBUTE_KEY = Integer.valueOf(3);
    private static final Set<Integer> INTERNAL_KEYS = new HashSet<Integer>(Arrays.asList(VERSION_KEY, TIMESTAMP_KEY, METADATA_KEY, ATTRIBUTE_KEY)); 
     
    public static final String FQN_DELIMITER = "/";
    
+   public static String getCombinedPath(String hostname, String contextPath)
+   {
+      return contextPath + "_" + hostname;
+   }
+   
+   public static Fqn getSessionFqn(String contextHostPath, String sessionId)
+   {
+      Object[] objs = new Object[]{SESSION, contextHostPath, sessionId};
+      return Fqn.fromList(Arrays.asList(objs), true);
+   }
+   
+   public static Fqn getBuddyBackupSessionFqn(String dataOwner, String contextHostPath, String sessionId)
+   {
+      Object[] objs = new Object[]{BUDDY_BACKUP, dataOwner, SESSION, contextHostPath, sessionId};
+      return Fqn.fromList(Arrays.asList(objs), true);
+   }
+   
    private Cache plainCache_;
    
-   /** name of webapp's virtual host; hostName + webAppPath + session id is a unique combo. */
-   protected String hostName_;
-   /** Context path for webapp; hostName + webAppPath + session id is a unique combo. */
-   protected String webAppPath_;
+   /** Context path for webapp + hostName; this + session id is a unique combo. */
+   protected String combinedPath_;
    protected BatchingManager batchingManager;
 
    private LocalDistributableSessionManager manager_;
@@ -159,29 +175,33 @@
       manager_ = manager;
       webAppClassLoader_ = tcl;
       
+      String webAppPath;
       String path = manager_.getContextName();
       if( path.length() == 0 || path.equals("/")) {
          // If this is root.
-         webAppPath_ = "ROOT";
+         webAppPath = "ROOT";
       } else if ( path.startsWith("/") ) {
-         webAppPath_ = path.substring(1);
+         webAppPath = path.substring(1);
       } else {
-         webAppPath_ = path;
+         webAppPath = path;
       }
       // JBAS-3941 -- context path can be multi-level, but we don't
       // want that turning into a multilevel Fqn, so escape it
-      // Use '?' which is illegal in a context path
-      webAppPath_ = webAppPath_.replace('/', '?');
-      log_.debug("Old and new web app path are: " +path + ", " +webAppPath_);
+      // Use '-' which is legal in a filesystem path
+      webAppPath = webAppPath.replace('/', '_');
+      log_.debug("Old and new web app path are: " +path + ", " +webAppPath);
       
+      String hostName;      
       String host = manager_.getHostName();
       if( host == null || host.length() == 0) {
-         hostName_ = "localhost";
+         hostName = "localhost";
       }else {
-         hostName_ = host;
+         hostName = host;
       }
-      log_.debug("Old and new virtual host name are: " + host + ", " + hostName_);
+      log_.debug("Old and new virtual host name are: " + host + ", " + hostName);
 
+      this.combinedPath_ = getCombinedPath(hostName, webAppPath);
+      
       if (plainCache_.getCacheStatus() != CacheStatus.STARTED)
       {
          plainCache_.start();
@@ -197,7 +217,7 @@
       }
       this.batchingManager = new BatchingManagerImpl(tm);
       
-      Object[] objs = new Object[]{SESSION, hostName_, webAppPath_};
+      Object[] objs = new Object[]{SESSION, combinedPath_};
       Fqn pathFqn = Fqn.fromList(Arrays.asList(objs), true);
       
       BuddyReplicationConfig brc = plainCache_.getConfiguration().getBuddyReplicationConfig();
@@ -209,7 +229,7 @@
       }
 
       // Listen for cache changes
-      cacheListener_ = new CacheListener(cacheWrapper_, manager_, hostName_, webAppPath_, isFieldBased());
+      cacheListener_ = new CacheListener(cacheWrapper_, manager_, combinedPath_, isFieldBased());
       plainCache_.addCacheListener(cacheListener_);
       
       if(useTreeCacheMarshalling_)
@@ -240,7 +260,7 @@
       if(manager_.isPassivationEnabled())
       {
          log_.debug("Passivation is enabled");
-         passivationListener_ = new PassivationListener(manager_, hostName_, webAppPath_);
+         passivationListener_ = new PassivationListener(manager_, combinedPath_);
          plainCache_.addCacheListener(passivationListener_);
       }
       else
@@ -269,7 +289,7 @@
          plainCache_.removeCacheListener(passivationListener_);
       
       // Construct the fqn
-      Object[] objs = new Object[]{SESSION, hostName_, webAppPath_};
+      Object[] objs = new Object[]{SESSION, combinedPath_};
       Fqn pathFqn = Fqn.fromList(Arrays.asList(objs), true);
 
       if(useTreeCacheMarshalling_)
@@ -337,7 +357,7 @@
     */
    public <T extends DistributableSession> T loadSession(String realId, T toLoad)
    {
-      Fqn fqn = getSessionFqn(realId);
+      Fqn fqn = getSessionFqn(combinedPath_, realId);
       Map sessionData =  cacheWrapper_.getData(fqn, true);
       
       if (sessionData == null) {
@@ -357,10 +377,10 @@
    { 
       if (log_.isTraceEnabled())
       {
-         log_.trace("putSession(): putting session " + session.getIdInternal());
+         log_.trace("putSession(): putting session " + realId);
       }     
       
-      Fqn fqn = getSessionFqn(realId);
+      Fqn fqn = getSessionFqn(combinedPath_, realId);
       
       setupSessionRegion(session, fqn);
       
@@ -417,7 +437,7 @@
 
    public void removeSession(String realId, boolean removeRegion)
    {
-      Fqn fqn = getSessionFqn(realId);
+      Fqn fqn = getSessionFqn(combinedPath_, realId);
       if (log_.isTraceEnabled())
       {
          log_.trace("Remove session from distributed store. Fqn: " + fqn);
@@ -433,7 +453,7 @@
 
    public void removeSessionLocal(String realId, boolean removeRegion)
    {
-      Fqn fqn = getSessionFqn(realId);
+      Fqn fqn = getSessionFqn(combinedPath_, realId);
       if (log_.isTraceEnabled())
       {
          log_.trace("Remove session from my own distributed store only. Fqn: " + fqn);
@@ -455,7 +475,7 @@
       }
       else
       {         
-         Fqn fqn = getSessionFqn(realId, dataOwner);
+         Fqn fqn = getBuddyBackupSessionFqn(dataOwner, combinedPath_, realId);
          if (log_.isTraceEnabled())
          {
             log_.trace("Remove session from my own distributed store only. Fqn: " + fqn);
@@ -471,7 +491,7 @@
       
    public void evictSession(String realId, String dataOwner)
    {    
-      Fqn fqn = dataOwner == null ? getSessionFqn(realId) : getSessionFqn(realId, dataOwner);
+      Fqn fqn = dataOwner == null ? getSessionFqn(combinedPath_, realId) : getBuddyBackupSessionFqn(dataOwner, combinedPath_, realId);
       if(log_.isTraceEnabled())
       {
          log_.trace("evictSession(): evicting session from my distributed store. Fqn: " + fqn);
@@ -481,20 +501,20 @@
    
    public DistributableSessionData getSessionData(String realId, String dataOwner, boolean includeAttributes)
    {
-      Fqn fqn = dataOwner == null ? getSessionFqn(realId) : getSessionFqn(realId, dataOwner);
+      Fqn fqn = dataOwner == null ? getSessionFqn(combinedPath_, realId) : getBuddyBackupSessionFqn(dataOwner, combinedPath_, realId);
       Map<Object, Object> distributedCacheData = cacheWrapper_.getData(fqn, false);
       return getDistributableSessionData(realId, distributedCacheData, includeAttributes);
    }
 
    public Object getAttribute(String realId, String key)
    {
-      Fqn fqn = getSessionFqn(realId);
+      Fqn fqn = getSessionFqn(combinedPath_, realId);
       return getUnMarshalledValue(cacheWrapper_.get(fqn, key));
    }
 
    public void putAttribute(String realId, String key, Object value)
    {
-      Fqn fqn = getSessionFqn(realId);
+      Fqn fqn = getSessionFqn(combinedPath_, realId);
       cacheWrapper_.put(fqn, key, getMarshalledValue(value));
    }
 
@@ -509,14 +529,14 @@
          marshalled.put(entry.getKey(), getMarshalledValue(entry.getValue()));
       }
       
-      Fqn fqn = getSessionFqn(realId);
+      Fqn fqn = getSessionFqn(combinedPath_, realId);
       cacheWrapper_.put(fqn, marshalled);
       
    }
 
    public Object removeAttribute(String realId, String key)
    {
-      Fqn fqn = getSessionFqn(realId);
+      Fqn fqn = getSessionFqn(combinedPath_, realId);
       if (log_.isTraceEnabled())
       {
          log_.trace("Remove attribute from distributed store. Fqn: " + fqn + " key: " + key);
@@ -531,7 +551,7 @@
    public Set getAttributeKeys(String realId)
    {
       Set keys = null;
-      Fqn fqn = getSessionFqn(realId);
+      Fqn fqn = getSessionFqn(combinedPath_, realId);
       try
       {
          Node node = plainCache_.getRoot().getChild(fqn);
@@ -559,7 +579,7 @@
    {
       if (realId == null || realId.length() == 0) return Collections.EMPTY_MAP;
       
-      Fqn fqn = getSessionFqn(realId);
+      Fqn fqn = getSessionFqn(combinedPath_, realId);
       
       Node node = plainCache_.getRoot().getChild(fqn);
       Map<Object, Object> rawData = node.getData();
@@ -579,6 +599,8 @@
    {
       Map<String, String> result = new HashMap<String, String>();
       
+      Fqn webappFqn = getWebappFqn();
+      
       Node bbRoot = plainCache_.getRoot().getChild(BUDDY_BACKUP_FQN);
       if (bbRoot != null)
       {
@@ -588,7 +610,7 @@
             for (Iterator it = owners.iterator(); it.hasNext();)
             {
                Node owner = (Node) it.next();
-               Node webRoot = owner.getChild(getWebappFqn());
+               Node webRoot = owner.getChild(webappFqn);
                if (webRoot != null)
                {
                   Set<String> ids = webRoot.getChildrenNames();
@@ -598,7 +620,7 @@
          }
       }
       
-      storeSessionOwners(getChildrenNames(getWebappFqn()), null, result);
+      storeSessionOwners(getChildrenNames(webappFqn), null, result);
 
       return result;
    }
@@ -606,7 +628,7 @@
    protected Set getChildrenNames(Fqn fqn)
    {
       Node node = plainCache_.getRoot().getChild(fqn);
-      return (node == null ? null : node.getChildrenNames());
+      return (node == null ? Collections.EMPTY_SET : node.getChildrenNames());
    }
 
    private void storeSessionOwners(Set<String> ids, String owner, Map<String, String> map)
@@ -631,15 +653,10 @@
    protected Fqn getWebappFqn()
    {
       // /SESSION/hostname/webAppPath
-      Object[] objs = new Object[]{SESSION, hostName_, webAppPath_};
+      Object[] objs = new Object[]{SESSION, combinedPath_};
       return Fqn.fromList(Arrays.asList(objs), true);
    }
    
-   protected Fqn getSessionFqn(String id)
-   {
-      return getSessionFqn(hostName_, webAppPath_, id);
-   }
-   
    /**
     * Extracts the contents of <code>distributedCacheData</code>.
     * 
@@ -684,23 +701,6 @@
       return attrs;
    }
    
-   public static Fqn getSessionFqn(String hostname, String contextPath, String sessionId)
-   {
-      Object[] objs = new Object[]{SESSION, hostname, contextPath, sessionId};
-      return Fqn.fromList(Arrays.asList(objs), true);
-   }
-
-   private Fqn getSessionFqn(String id, String dataOwner)
-   {
-      return getSessionFqn(dataOwner, hostName_, webAppPath_, id);
-   }
-   
-   public static Fqn getSessionFqn(String dataOwner, String hostname, String contextPath, String sessionId)
-   {
-      Object[] objs = new Object[]{BUDDY_BACKUP, dataOwner, SESSION, hostname, contextPath, sessionId};
-      return Fqn.fromList(Arrays.asList(objs), true);
-   }
-   
    protected void releaseCacheToManager(String cacheConfigName)
    {      
       try

Modified: projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/PassivationListener.java
===================================================================
--- projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/PassivationListener.java	2008-11-09 16:05:29 UTC (rev 80724)
+++ projects/cluster/ha-server-cache-jbc/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/PassivationListener.java	2008-11-09 21:03:47 UTC (rev 80725)
@@ -38,9 +38,9 @@
 public class PassivationListener extends CacheListenerBase
 {
 
-   PassivationListener(LocalDistributableSessionManager manager, String hostname, String webapp)
+   PassivationListener(LocalDistributableSessionManager manager, String contextHostPath)
    {      
-      super(manager, hostname, webapp);
+      super(manager, contextHostPath);
    }
    
    // NOTE: Don't track passivation from here -- we know in JBossCacheManager

Modified: projects/cluster/ha-server-cache-jbc/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/impl/CacheListenerUnitTestCase.java
===================================================================
--- projects/cluster/ha-server-cache-jbc/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/impl/CacheListenerUnitTestCase.java	2008-11-09 16:05:29 UTC (rev 80724)
+++ projects/cluster/ha-server-cache-jbc/trunk/src/test/java/org/jboss/web/tomcat/service/session/distributedcache/impl/CacheListenerUnitTestCase.java	2008-11-09 21:03:47 UTC (rev 80725)
@@ -42,6 +42,9 @@
 public class CacheListenerUnitTestCase extends TestCase
 {
    private static final String DATA_OWNER = "localhost_12345";
+   private static final String CONTEXT_HOST_PATH = JBossCacheService.getCombinedPath("localhost", "webapp");
+   private static final Fqn BASE = JBossCacheService.getSessionFqn(CONTEXT_HOST_PATH, "123");
+   private static final Fqn BUDDY_BASE = JBossCacheService.getBuddyBackupSessionFqn(DATA_OWNER, CONTEXT_HOST_PATH, "123");
    
    public void testIsBuddyFqn()
    {
@@ -50,66 +53,63 @@
       Fqn test = Fqn.fromElements(new Object[]{"random", BuddyManager.BUDDY_BACKUP_SUBTREE});
       assertFalse("Random is not buddy", CacheListenerBase.isBuddyFqn(test));
       
-      test = JBossCacheService.getSessionFqn("localhost", "webapp", "123");
+      test = BASE;
       assertFalse("Normal is not buddy", CacheListenerBase.isBuddyFqn(test));
       
-      test = JBossCacheService.getSessionFqn(DATA_OWNER, "localhost", "webapp", "123");
+      test = BUDDY_BASE;
       assertTrue("Buddy is a buddy", CacheListenerBase.isBuddyFqn(test));
    }
    
    public void testGetBuddyBackupOwner()
    {
-      Fqn test = JBossCacheService.getSessionFqn(DATA_OWNER, "localhost", "webapp", "123");
+      Fqn test = BUDDY_BASE;
       assertEquals("Got correct owner", DATA_OWNER, CacheListenerBase.getBuddyOwner(test));
    }
    
    public void testIsFqnSessionRootSized()
    {
-      Fqn test = JBossCacheService.getSessionFqn("localhost", "webapp", "123");
+      Fqn test = BASE;
       assertTrue("Non-buddy session root correct", CacheListenerBase.isFqnSessionRootSized(test, false));
       assertFalse("Non-buddy session root correct with wrong isBuddy", CacheListenerBase.isFqnSessionRootSized(test, true));
       
-      test = JBossCacheService.getSessionFqn(DATA_OWNER, "localhost", "webapp", "123");
+      test = BUDDY_BASE;
       assertTrue("Buddy session root correct", CacheListenerBase.isFqnSessionRootSized(test, true));
       assertFalse("Buddy session root correct with wrong isBuddy", CacheListenerBase.isFqnSessionRootSized(test, false));
       
-      test = JBossCacheService.getSessionFqn("localhost", "webapp", "123");
-      test = Fqn.fromRelativeElements(test, FieldBasedJBossCacheService.ATTRIBUTE);
+      test = Fqn.fromRelativeElements(BASE, FieldBasedJBossCacheService.ATTRIBUTE);
       assertFalse("Non-buddy non-session root correct", CacheListenerBase.isFqnSessionRootSized(test, false));
       
-      test = JBossCacheService.getSessionFqn(DATA_OWNER, "localhost", "webapp", "123");
+      test = BUDDY_BASE;
       test = Fqn.fromRelativeElements(test, FieldBasedJBossCacheService.ATTRIBUTE);
       assertFalse("Buddy non-session root correct", CacheListenerBase.isFqnSessionRootSized(test, true));
    }
    
    public void testIsPossibleInternalPojoFqn()
    {
-      Fqn test = JBossCacheService.getSessionFqn("localhost", "webapp", "123");
+      Fqn test = BASE;
       assertFalse("Session root correct", CacheListener.isPossibleInternalPojoFqn(test));
       
-      test = FieldBasedJBossCacheService.getAttributeFqn("localhost", "webapp", "123");
+      test = FieldBasedJBossCacheService.getAttributeFqn(CONTEXT_HOST_PATH, "123");
       assertFalse("ATTRIBUTE fqn correct", CacheListener.isPossibleInternalPojoFqn(test));
       
-      test = FieldBasedJBossCacheService.getFieldFqn("localhost", "webapp", "123", "person");
+      test = FieldBasedJBossCacheService.getFieldFqn(CONTEXT_HOST_PATH, "123", "person");
       assertFalse("Pojo attach point correct", CacheListener.isPossibleInternalPojoFqn(test));
       
-      test = JBossCacheService.getSessionFqn("localhost", "webapp", "123");
-      test = Fqn.fromRelativeElements(test, "_JBossInternal_");
+      test = Fqn.fromRelativeElements(BASE, "_JBossInternal_");
       test = Fqn.fromRelativeElements(test, "person");
       assertTrue("Internal pojo correct", CacheListener.isPossibleInternalPojoFqn(test));
    }
    
    public void testGetPojoKeyFromFqn()
    {
-      Fqn test = FieldBasedJBossCacheService.getFieldFqn("localhost", "webapp", "123", "person");
+      Fqn test = FieldBasedJBossCacheService.getFieldFqn(CONTEXT_HOST_PATH, "123", "person");
       assertEquals("Non-buddy pojo field correct", "person", CacheListener.getPojoKeyFromFqn(test, false));
       
-      test = FieldBasedJBossCacheService.getFieldFqn("localhost", "webapp", "123", "person");
+      test = FieldBasedJBossCacheService.getFieldFqn(CONTEXT_HOST_PATH, "123", "person");
       test = Fqn.fromRelativeElements(test, "subobject");
       assertEquals("Non-buddy pojo field correct with subobject", "person", CacheListener.getPojoKeyFromFqn(test, false));
       
-      test = JBossCacheService.getSessionFqn(DATA_OWNER, "localhost", "webapp", "123");
-      test = Fqn.fromRelativeElements(test, FieldBasedJBossCacheService.ATTRIBUTE);
+      test = Fqn.fromRelativeElements(BUDDY_BASE, FieldBasedJBossCacheService.ATTRIBUTE);
       test = Fqn.fromRelativeElements(test, "person");
       assertEquals("Buddy pojo field correct", "person", CacheListener.getPojoKeyFromFqn(test, true));
       

Modified: projects/cluster/ha-server-cache-spi/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi/DistributableSession.java
===================================================================
--- projects/cluster/ha-server-cache-spi/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi/DistributableSession.java	2008-11-09 16:05:29 UTC (rev 80724)
+++ projects/cluster/ha-server-cache-spi/trunk/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi/DistributableSession.java	2008-11-09 21:03:47 UTC (rev 80725)
@@ -34,7 +34,10 @@
  */
 public interface DistributableSession
 {
-   String getIdInternal();
+   /**
+    * Gets the session id with any appended jvmRoute info removed.
+    */
+   String getRealId();
    
    AtomicInteger getVersion();
 
@@ -42,22 +45,19 @@
 
    AtomicLong getSessionTimestamp();
 
+   boolean isSessionMetadataDirty();
+
    DistributableSessionMetadata getSessionMetadata();
 
+   boolean isSessionAttributeMapDirty();
+
    Map<String, Object> getSessionAttributeMap();
 
    void update(DistributableSessionData sessionData);
-
-   boolean isSessionMetadataDirty();
-
-   boolean isSessionAttributeMapDirty();
-
-   boolean getCreateRegionForSession();
    
    boolean needRegionForSession();
    
    boolean hasRegionForSession();
    
    void createdRegionForSession();
-
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list