manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1541348 - in /manifoldcf/branches/CONNECTORS-13/framework/core/src: main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperConnection.java test/java/org/apache/manifoldcf/core/lockmanager/TestZooKeeperLocks.java
Date Wed, 13 Nov 2013 01:33:44 GMT
Author: kwright
Date: Wed Nov 13 01:33:44 2013
New Revision: 1541348

URL: http://svn.apache.org/r1541348
Log:
Finish debugging zookeeper test

Modified:
    manifoldcf/branches/CONNECTORS-13/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperConnection.java
    manifoldcf/branches/CONNECTORS-13/framework/core/src/test/java/org/apache/manifoldcf/core/lockmanager/TestZooKeeperLocks.java

Modified: manifoldcf/branches/CONNECTORS-13/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperConnection.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-13/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperConnection.java?rev=1541348&r1=1541347&r2=1541348&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-13/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperConnection.java
(original)
+++ manifoldcf/branches/CONNECTORS-13/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperConnection.java
Wed Nov 13 01:33:44 2013
@@ -80,9 +80,9 @@ public class ZooKeeperConnection
 
     try
     {
-      // Assert that we want a read lock
+      // Assert that we want a write lock
       lockNode = createSequentialChild(lockPath,WRITE_PREFIX);
-      String lockSequenceNumber = lockNode.substring(WRITE_PREFIX.length());
+      String lockSequenceNumber = lockNode.substring(lockPath.length() + 1 + WRITE_PREFIX.length());
       // See if we got it
       List<String> children = zookeeper.getChildren(lockPath,false);
       for (String x : children)
@@ -127,7 +127,7 @@ public class ZooKeeperConnection
     {
       // Assert that we want a read lock
       lockNode = createSequentialChild(lockPath,NONEXWRITE_PREFIX);
-      String lockSequenceNumber = lockNode.substring(NONEXWRITE_PREFIX.length());
+      String lockSequenceNumber = lockNode.substring(lockPath.length() + 1 + NONEXWRITE_PREFIX.length());
       // See if we got it
       List<String> children = zookeeper.getChildren(lockPath,false);
       for (String x : children)
@@ -170,7 +170,7 @@ public class ZooKeeperConnection
     {
       // Assert that we want a read lock
       lockNode = createSequentialChild(lockPath,READ_PREFIX);
-      String lockSequenceNumber = lockNode.substring(READ_PREFIX.length());
+      String lockSequenceNumber = lockNode.substring(lockPath.length() + 1 + READ_PREFIX.length());
       // See if we got it
       List<String> children = zookeeper.getChildren(lockPath,false);
       for (String x : children)

Modified: manifoldcf/branches/CONNECTORS-13/framework/core/src/test/java/org/apache/manifoldcf/core/lockmanager/TestZooKeeperLocks.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-13/framework/core/src/test/java/org/apache/manifoldcf/core/lockmanager/TestZooKeeperLocks.java?rev=1541348&r1=1541347&r2=1541348&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-13/framework/core/src/test/java/org/apache/manifoldcf/core/lockmanager/TestZooKeeperLocks.java
(original)
+++ manifoldcf/branches/CONNECTORS-13/framework/core/src/test/java/org/apache/manifoldcf/core/lockmanager/TestZooKeeperLocks.java
Wed Nov 13 01:33:44 2013
@@ -27,8 +27,8 @@ import static org.junit.Assert.*;
 
 public class TestZooKeeperLocks extends ZooKeeperBase
 {
-  protected final static int readerThreadCount = 20;
-  protected final static int writerThreadCount = 20;
+  protected final static int readerThreadCount = 10;
+  protected final static int writerThreadCount = 5;
 
   @Test
   public void multiThreadZooKeeperLockTest()
@@ -174,7 +174,7 @@ public class TestZooKeeperLocks extends 
           ai.incrementAndGet();
           // Wait until all readers have been counted.  This test will hang if the readers
function
           // exclusively
-          while (ai.intValue() < readerThreadCount)
+          while (ai.get() < readerThreadCount)
           {
             Thread.sleep(10L);
           }
@@ -188,7 +188,7 @@ public class TestZooKeeperLocks extends 
         // Now, all the writers will get involved; we just need to make sure we never see
an inconsistent value
         while (ai.get() < readerThreadCount + 2*writerThreadCount)
         {
-          System.out.println("Waiting for all read threads to succeed...");
+          System.out.println("Waiting for all write threads to succeed...");
           lo = new ZooKeeperLockObject(lp, lockKey, pool);
           enterReadLock(lo);
           try
@@ -202,6 +202,7 @@ public class TestZooKeeperLocks extends 
           {
             leaveReadLock(lo);
           }
+          Thread.sleep(100L);
         }
         System.out.println("Done with reader thread");
       }
@@ -254,19 +255,20 @@ public class TestZooKeeperLocks extends 
         {
           lo = new ZooKeeperLockObject(lp, lockKey, pool);
           enterWriteLock(lo);
+          System.out.println("Made it into write lock");
           try
           {
             // Check if we made it in during read cycle... that would be bad.
             if (ai.get() > 0 && ai.get() < readerThreadCount)
               throw new Exception("Was able to write even when readers were active");
-            if (ai.get() == readerThreadCount)
+            if (ai.get() >= readerThreadCount)
               break;
           }
           finally
           {
             leaveWriteLock(lo);
           }
-          Thread.sleep(10L);
+          Thread.sleep(100L);
         }
         
         // Get write lock, increment twice, and leave write lock
@@ -281,6 +283,7 @@ public class TestZooKeeperLocks extends 
           Thread.sleep(50L);
           // Increment again
           ai.incrementAndGet();
+          System.out.println("Updated write count");
         }
         finally
         {



Mime
View raw message