[jboss-cvs] JBossAS SVN: r106952 - in projects/cluster: ha-server-cache-spi/branches/Session_Ownership/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jul 20 16:56:48 EDT 2010


Author: pferraro
Date: 2010-07-20 16:56:48 -0400 (Tue, 20 Jul 2010)
New Revision: 106952

Added:
   projects/cluster/ha-server-cache-spi/branches/Session_Ownership/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi/SessionOwnershipSupport.java
Modified:
   projects/cluster/ha-server-cache-jbc/branches/Session_Ownership/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/AbstractJBossCacheService.java
   projects/cluster/ha-server-cache-spi/branches/Session_Ownership/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi/DistributedCacheManager.java
Log:
Improve SessionOwnership support API.  Eliminates awkward UNSUPPORTED LockResult.

Modified: projects/cluster/ha-server-cache-jbc/branches/Session_Ownership/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/AbstractJBossCacheService.java
===================================================================
--- projects/cluster/ha-server-cache-jbc/branches/Session_Ownership/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/AbstractJBossCacheService.java	2010-07-20 20:53:45 UTC (rev 106951)
+++ projects/cluster/ha-server-cache-jbc/branches/Session_Ownership/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/impl/jbc/AbstractJBossCacheService.java	2010-07-20 20:56:48 UTC (rev 106952)
@@ -61,12 +61,13 @@
 import org.jboss.web.tomcat.service.session.distributedcache.spi.IncomingDistributableSessionData;
 import org.jboss.web.tomcat.service.session.distributedcache.spi.LocalDistributableSessionManager;
 import org.jboss.web.tomcat.service.session.distributedcache.spi.OutgoingDistributableSessionData;
+import org.jboss.web.tomcat.service.session.distributedcache.spi.SessionOwnershipSupport;
 import org.jboss.web.tomcat.service.session.distributedcache.spi.SessionSerializationFactory;
 
 /**
  * Abstract base implementation of {@link DistributedCacheManager}.
  */
-public abstract class AbstractJBossCacheService<T extends OutgoingDistributableSessionData> implements DistributedCacheManager<T>
+public abstract class AbstractJBossCacheService<T extends OutgoingDistributableSessionData> implements DistributedCacheManager<T>, SessionOwnershipSupport
 {   
    public static final String BUDDY_BACKUP = BuddyManager.BUDDY_BACKUP_SUBTREE;
    @SuppressWarnings("unchecked")
@@ -797,9 +798,14 @@
     */
    protected abstract Map<String, Object> getSessionAttributes(String realId, Map<Object, Object> distributedCacheData);
    
-   public boolean getSupportsSessionOwnership()
+   /**
+    * {@inheritDoc}
+    * @see org.jboss.web.tomcat.service.session.distributedcache.spi.DistributedCacheManager#getSessionOwnershipSupport()
+    */
+   @Override
+   public SessionOwnershipSupport getSessionOwnershipSupport()
    {
-      return true;
+      return this;
    }
    
    public LockResult acquireSessionOwnership(String realId, boolean newLock) throws TimeoutException, InterruptedException

Modified: projects/cluster/ha-server-cache-spi/branches/Session_Ownership/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi/DistributedCacheManager.java
===================================================================
--- projects/cluster/ha-server-cache-spi/branches/Session_Ownership/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi/DistributedCacheManager.java	2010-07-20 20:53:45 UTC (rev 106951)
+++ projects/cluster/ha-server-cache-spi/branches/Session_Ownership/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi/DistributedCacheManager.java	2010-07-20 20:56:48 UTC (rev 106952)
@@ -25,8 +25,6 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.jboss.ha.framework.server.lock.TimeoutException;
-
 /**
  * SPI implemented by the distributed caching layer.
  * 
@@ -35,27 +33,6 @@
  */
 public interface DistributedCacheManager<T extends OutgoingDistributableSessionData>
 {
-   /** Result of a {@link #acquireSessionOwnership(String, boolean) lock call}*/
-   public static enum LockResult 
-   { 
-      /** Indicates the lock was acquired after requesting it from the cluster */
-      ACQUIRED_FROM_CLUSTER, 
-      /** Indicates this node already held the lock */
-      ALREADY_HELD, 
-      /** 
-       * Indicates the 'newLock' param passed to 
-       * {@link #lock(String, boolean)}
-       * was <code>true</code> and the local node in fact was unaware of the
-       * lock. If in fact the local node was already aware of the lock (which
-       * would generally indicate a flaw in the application using this class)
-       * NEW_LOCK will not be returned; rather one of the other enum values
-       * will be returned.
-       */
-      NEW_LOCK,
-      /** Indicates {@link #getSupportsSessionOwnership()} will return <code>false</code>*/
-      UNSUPPORTED
-   }
-   
    /**
     * Starts the distributed caching layer.
     */
@@ -258,40 +235,10 @@
    Map<String, Object> getAttributes(String realId);
    
    /**
-    * Indicates whether this manager supports taking ownership of a session
-    * across the cluster.
-    * 
-    * @return <code>true</code> if session ownership is supported; 
-    *         <code>false</code> if not
+    * Returns the session ownership support for this cache manager, or null if session ownership is not supported.
+    * @return the session ownership support
     */
-   boolean getSupportsSessionOwnership();
-   
-   /**
-    * Attempt to take ownership of the session identified by the given id.
-    * 
-    * @param realId the session's id, excluding any jvmRoute
-    * @param newLock <code>true</code> if the caller knows this is a new session
-    *                that doesn't exist elsewhere in the cluster, and thus
-    *                acquiring ownership does not require any cluster-wide
-    *                call
-    *                
-    * @return the result of the attempt
-    * 
-    * @throws TimeoutException
-    * @throws InterruptedException
-    */
-   LockResult acquireSessionOwnership(String realId, boolean newLock) throws TimeoutException, InterruptedException;
-   
-   /**
-    * Releases ownership of a session, thus making it possible for other nodes
-    * to acquire it.
-    * 
-    * @param realId the session's id, excluding any jvmRoute
-    * @param remove <code>true</code> if this release is associated with a 
-    *               session removal, in which case the distributed cache manager
-    *               can stop tracking ownership
-    */
-   void relinquishSessionOwnership(String realId, boolean remove);
-   
+   SessionOwnershipSupport getSessionOwnershipSupport();
+      
    void setForceSynchronous(boolean forceSynchronous);
 }
\ No newline at end of file

Added: projects/cluster/ha-server-cache-spi/branches/Session_Ownership/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi/SessionOwnershipSupport.java
===================================================================
--- projects/cluster/ha-server-cache-spi/branches/Session_Ownership/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi/SessionOwnershipSupport.java	                        (rev 0)
+++ projects/cluster/ha-server-cache-spi/branches/Session_Ownership/src/main/java/org/jboss/web/tomcat/service/session/distributedcache/spi/SessionOwnershipSupport.java	2010-07-20 20:56:48 UTC (rev 106952)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.web.tomcat.service.session.distributedcache.spi;
+
+import org.jboss.ha.framework.server.lock.TimeoutException;
+
+/**
+ * @author Brian Stansberry
+ */
+public interface SessionOwnershipSupport
+{
+   /** Result of a {@link #acquireSessionOwnership(String, boolean) lock call}*/
+   public static enum LockResult 
+   { 
+      /** Indicates the lock was acquired after requesting it from the cluster */
+      ACQUIRED_FROM_CLUSTER, 
+      /** Indicates this node already held the lock */
+      ALREADY_HELD, 
+      /** 
+       * Indicates the 'newLock' param passed to 
+       * {@link #lock(String, boolean)}
+       * was <code>true</code> and the local node in fact was unaware of the
+       * lock. If in fact the local node was already aware of the lock (which
+       * would generally indicate a flaw in the application using this class)
+       * NEW_LOCK will not be returned; rather one of the other enum values
+       * will be returned.
+       */
+      NEW_LOCK
+   }
+
+   /**
+    * Attempt to take ownership of the session identified by the given id.
+    * 
+    * @param realId the session's id, excluding any jvmRoute
+    * @param newLock <code>true</code> if the caller knows this is a new session
+    *                that doesn't exist elsewhere in the cluster, and thus
+    *                acquiring ownership does not require any cluster-wide
+    *                call
+    *                
+    * @return the result of the attempt
+    * 
+    * @throws TimeoutException
+    * @throws InterruptedException
+    */
+   LockResult acquireSessionOwnership(String realId, boolean newLock) throws TimeoutException, InterruptedException;
+   
+   /**
+    * Releases ownership of a session, thus making it possible for other nodes
+    * to acquire it.
+    * 
+    * @param realId the session's id, excluding any jvmRoute
+    * @param remove <code>true</code> if this release is associated with a 
+    *               session removal, in which case the distributed cache manager
+    *               can stop tracking ownership
+    */
+   void relinquishSessionOwnership(String realId, boolean remove);
+}



More information about the jboss-cvs-commits mailing list