Author: ozeigermann
Date: Tue Apr 17 22:18:19 2007
New Revision: 529868

URL: http://svn.apache.org/viewvc?view=rev&rev=529868
Log:
Added mode fail-fast that does not block upon conflict, but
immedeately fails.

Modified:
    
jakarta/slide/trunk/src/webdav/server/org/apache/slide/webdav/method/AbstractWebdavMethod.java

Modified: 
jakarta/slide/trunk/src/webdav/server/org/apache/slide/webdav/method/AbstractWebdavMethod.java
URL: 
http://svn.apache.org/viewvc/jakarta/slide/trunk/src/webdav/server/org/apache/slide/webdav/method/AbstractWebdavMethod.java?view=diff&rev=529868&r1=529867&r2=529868
==============================================================================
--- 
jakarta/slide/trunk/src/webdav/server/org/apache/slide/webdav/method/AbstractWebdavMethod.java
 (original)
+++ 
jakarta/slide/trunk/src/webdav/server/org/apache/slide/webdav/method/AbstractWebdavMethod.java
 Tue Apr 17 22:18:19 2007
@@ -1059,6 +1059,11 @@
                 "sequential-mode"));
     }
 
+    protected boolean isFailFastSequential() {
+        return 
"fail-fast".equalsIgnoreCase(token.getNamespaceConfig().getParameter(
+                "sequential-mode"));
+    }
+
     /**
      * Checks if Slide is configured to internally repeat a request if it 
conflicts with other
      * concurrent ones.
@@ -1086,8 +1091,25 @@
         return DEFAULT_MAX_RETRY_REPEATS;
     }
     
-    protected void assureGlobalLocks() {
-        if (this instanceof FineGrainedLockingMethod && 
isFineGrainSequential()) {
+    protected void assureGlobalLocks() throws ConflictException {
+        if (isFailFastSequential()) {
+            boolean locked = true;
+            if (this instanceof ReadMethod) {
+                try {
+                    // NON-BLOCKING
+                    locked = GLOBAL_LOCK.acquire(this, 1, false, true, 
Long.MAX_VALUE);
+                } catch (InterruptedException e) {
+                }
+            } else if (this instanceof WriteMethod) {
+                try {
+                    // NON-BLOCKING
+                    locked = GLOBAL_LOCK.acquire(this, 2, false, true, 
Long.MAX_VALUE);
+                } catch (InterruptedException e) {
+                }
+            }
+            if (!locked)
+                throw new ConflictException("/");
+        } else if (this instanceof FineGrainedLockingMethod && 
isFineGrainSequential()) {
             ((FineGrainedLockingMethod) this).acquireFineGrainLocks();
         } else if (this instanceof ReadMethod) {
             if (isSequentialRead()) {



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to