jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1151397 - in /jackrabbit/trunk: jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/jcr/ jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/ jackrabbit-standalone/src/main/resources/WEB-INF/ jackrabbit-webapp...
Date Wed, 27 Jul 2011 09:30:29 GMT
Author: angela
Date: Wed Jul 27 09:30:28 2011
New Revision: 1151397

URL: http://svn.apache.org/viewvc?rev=1151397&view=rev
Log:
JCR-3027 - apply modified patch (original author: chad davis)

Modified:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JCRWebdavServerServlet.java
    jackrabbit/trunk/jackrabbit-standalone/src/main/resources/WEB-INF/web.xml
    jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java?rev=1151397&r1=1151396&r2=1151397&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java
Wed Jul 27 09:30:28 2011
@@ -33,11 +33,11 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletResponse;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
-import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 /**
  * <code>JCRWebdavServer</code>...
@@ -48,7 +48,7 @@ public class JCRWebdavServer implements 
     private static Logger log = LoggerFactory.getLogger(JCRWebdavServer.class);
 
     /** the session cache */
-    private final SessionCache cache = new SessionCache();
+    private final SessionCache cache;
 
     /** the jcr repository */
     private final Repository repository;
@@ -64,6 +64,19 @@ public class JCRWebdavServer implements 
     public JCRWebdavServer(Repository repository, SessionProvider sessionProvider) {
         this.repository = repository;
         this.sessionProvider = sessionProvider;
+        cache = new SessionCache();
+    }
+
+    /**
+     * Creates a new JCRWebdavServer that operates on the given repository.
+     *
+     * @param repository
+     * @param concurrencyLevel 
+     */
+    public JCRWebdavServer(Repository repository, SessionProvider sessionProvider, int concurrencyLevel)
{
+        this.repository = repository;
+        this.sessionProvider = sessionProvider;
+        cache = new SessionCache(concurrencyLevel);
     }
 
     //---------------------------------------< DavSessionProvider interface >---
@@ -142,10 +155,33 @@ public class JCRWebdavServer implements 
      */
     private class SessionCache {
 
-        private Map<DavSession, Set<Object>> sessionMap = new HashMap<DavSession,
Set<Object>>();
-        private Map<Object, DavSession> referenceToSessionMap = new HashMap<Object,
DavSession>();
+        private static final int CONCURRENCY_LEVEL_DEFAULT = 50;
+        private static final int INITIAL_CAPACITY = 50;
+    	private static final int INITIAL_CAPACITY_REF_TO_SESSION = 3 * INITIAL_CAPACITY;
+    	
+        private ConcurrentMap<DavSession, Set<Object>> sessionMap;
+        private ConcurrentMap<Object, DavSession> referenceToSessionMap;
+
+        /**
+         * Create a new session cache with the {@link #CONCURRENCY_LEVEL_DEFAULT default
concurrency level}.
+         */
+        private SessionCache() {
+            this(CONCURRENCY_LEVEL_DEFAULT);
+        }
 
         /**
+         * Create a new session cache with the specified the level of concurrency
+         * for this server.
+         * 
+         * @param cacheConcurrencyLevel A positive int value specifying the
+         * concurrency level of the server.
+         */
+        private SessionCache(int cacheConcurrencyLevel) {
+        	sessionMap = new ConcurrentHashMap<DavSession, Set<Object>>(INITIAL_CAPACITY,
.75f, cacheConcurrencyLevel);
+        	referenceToSessionMap = new ConcurrentHashMap<Object, DavSession>(INITIAL_CAPACITY_REF_TO_SESSION,
.75f, cacheConcurrencyLevel);
+        }
+        
+        /**
          * Try to retrieve <code>DavSession</code> if a TransactionId or
          * SubscriptionId is present in the request header. If no cached session
          * was found <code>null</code> is returned.
@@ -186,6 +222,8 @@ public class JCRWebdavServer implements 
             if (session == null) {
                 Session repSession = getRepositorySession(request);
                 session = new DavSessionImpl(repSession);
+                
+                // TODO: review again if using ConcurrentMap#putIfAbsent() was more appropriate.
                 sessionMap.put(session, new HashSet<Object>());
                 log.debug("login: User '" + repSession.getUserID() + "' logged in.");
             } else {

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JCRWebdavServerServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JCRWebdavServerServlet.java?rev=1151397&r1=1151396&r2=1151397&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JCRWebdavServerServlet.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JCRWebdavServerServlet.java
Wed Jul 27 09:30:28 2011
@@ -74,6 +74,13 @@ public abstract class JCRWebdavServerSer
     public final static String INIT_PARAM_MISSING_AUTH_MAPPING = "missing-auth-mapping";
 
     /**
+     * Optional 'concurrency-level' parameter defining the concurrency level
+     * within the jcr-server. If the parameter is omitted the internal default
+     * value (50) is used.
+     */
+    public final static String INIT_PARAM_CONCURRENCY_LEVEL = "concurrency-level";
+
+    /**
      * Servlet context attribute used to store the path prefix instead of
      * having a static field with this servlet. The latter causes problems
      * when running multiple
@@ -170,7 +177,17 @@ public abstract class JCRWebdavServerSer
     public DavSessionProvider getDavSessionProvider() {
         if (server == null) {
             Repository repository = getRepository();
-            server = new JCRWebdavServer(repository, getSessionProvider());
+            String cl = getInitParameter(INIT_PARAM_CONCURRENCY_LEVEL);
+            if (cl != null) {
+                try {
+                    server = new JCRWebdavServer(repository, getSessionProvider(), Integer.parseInt(cl));
+                } catch (NumberFormatException e) {
+                    log.debug("Invalid value '" + cl+ "' for init-param 'concurrency-level'.
Using default instead.");
+                    server = new JCRWebdavServer(repository, getSessionProvider());
+                }
+            } else {
+                server = new JCRWebdavServer(repository, getSessionProvider());
+            }
         }
         return server;
     }
@@ -250,7 +267,7 @@ public abstract class JCRWebdavServerSer
      * the node type characteristics of the parent (SNSiblings allowed or not).
      *
      * @param destResource destination resource to be validated.
-     * @param request
+     * @param request The webdav request
      * @param checkHeader flag indicating if the destination header must be present.
      * @return status code indicating whether the destination is valid.
      */
@@ -299,6 +316,7 @@ public abstract class JCRWebdavServerSer
     /**
      * Returns the configured path prefix
      *
+     * @param ctx The servlet context.
      * @return resourcePathPrefix
      * @see #INIT_PARAM_RESOURCE_PATH_PREFIX
      */
@@ -308,6 +326,8 @@ public abstract class JCRWebdavServerSer
 
     /**
      * Returns the repository to be used by this servlet.
+     *
+     * @return the JCR repository to be used by this servlet
      */
     protected abstract Repository getRepository();
 

Modified: jackrabbit/trunk/jackrabbit-standalone/src/main/resources/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-standalone/src/main/resources/WEB-INF/web.xml?rev=1151397&r1=1151396&r2=1151397&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-standalone/src/main/resources/WEB-INF/web.xml (original)
+++ jackrabbit/trunk/jackrabbit-standalone/src/main/resources/WEB-INF/web.xml Wed Jul 27 09:30:28
2011
@@ -127,6 +127,11 @@
             <param-value>/WEB-INF/batchread.properties</param-value>
             <description>JcrRemotingServlet: Optional mapping from node type names
to default depth.</description>
         </init-param>
+        <init-param>
+        	<param-name>concurrency-level</param-name>
+        	<param-value>50</param-value>
+        	<description>Number of concurrent requests expected. Default value is 50.</description>
+        </init-param>
         -->
         <load-on-startup>5</load-on-startup>
     </servlet>

Modified: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml?rev=1151397&r1=1151396&r2=1151397&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml (original)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml Wed Jul 27 09:30:28
2011
@@ -315,7 +315,12 @@
             <param-name>batchread-config</param-name>
             <param-value>/WEB-INF/batchread.properties</param-value>
             <description>JcrRemotingServlet: Optional mapping from node type names
to default depth.</description>
-        </init-param>        
+        </init-param>
+        <!-- init-param>
+        	<param-name>concurrency-level</param-name>
+        	<param-value>50</param-value>
+        	<description>Number of concurrent requests expected. Default value is 50.</description>
+        </init-param -->
         <load-on-startup>5</load-on-startup>
     </servlet>
 



Mime
View raw message