You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2014/06/24 20:39:48 UTC

[1/6] git commit: ACCUMULO-2948 Use an AtomicInteger to any worry from multiple threads access pdCount concurrently.

Repository: accumulo
Updated Branches:
  refs/heads/1.5.2-SNAPSHOT c3de15bd4 -> 886cd1981
  refs/heads/1.6.1-SNAPSHOT 76c910bbe -> cfda8fab6
  refs/heads/master 9defedf28 -> dc6e77694


ACCUMULO-2948 Use an AtomicInteger to any worry from multiple threads access pdCount concurrently.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/886cd198
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/886cd198
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/886cd198

Branch: refs/heads/1.5.2-SNAPSHOT
Commit: 886cd19813052a64c190f80d92e52787c5ffc813
Parents: c3de15b
Author: Josh Elser <el...@apache.org>
Authored: Tue Jun 24 14:07:04 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Tue Jun 24 14:08:57 2014 -0400

----------------------------------------------------------------------
 .../accumulo/fate/zookeeper/ZooLockTest.java    | 31 ++++++++++----------
 1 file changed, 16 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/886cd198/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java b/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
index 717bf0a..40454f6 100644
--- a/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
+++ b/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
@@ -19,6 +19,7 @@ package org.apache.accumulo.fate.zookeeper;
 import java.lang.reflect.Field;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.accumulo.fate.zookeeper.ZooLock.AsyncLockWatcher;
 import org.apache.accumulo.fate.zookeeper.ZooLock.LockLossReason;
@@ -116,13 +117,13 @@ public class ZooLockTest {
     accumulo.start();
     
   }
-  
-  private static int pdCount = 0;
-  
+
+  private static final AtomicInteger pdCount = new AtomicInteger(0);
+
   @Test(timeout = 10000)
   public void testDeleteParent() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
     
     Assert.assertFalse(zl.isLocked());
@@ -152,8 +153,8 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testNoParent() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+ 
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
     
     Assert.assertFalse(zl.isLocked());
@@ -172,8 +173,8 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testDeleteLock() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+ 
     ZooReaderWriter zk = ZooReaderWriter.getInstance(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes());
     zk.mkdirs(parent);
     
@@ -203,8 +204,8 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testDeleteWaiting() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+ 
     ZooReaderWriter zk = ZooReaderWriter.getInstance(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes());
     zk.mkdirs(parent);
     
@@ -269,7 +270,7 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testUnexpectedEvent() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
 
     ConnectedWatcher watcher = new ConnectedWatcher();
     ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 30000, watcher);
@@ -313,8 +314,8 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testTryLock() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 1000, "digest", "secret".getBytes(), parent);
     
     ConnectedWatcher watcher = new ConnectedWatcher();
@@ -350,7 +351,7 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testChangeData() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
     ConnectedWatcher watcher = new ConnectedWatcher();
     ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, watcher);
     zk.addAuthInfo("digest", "secret".getBytes());


[6/6] git commit: Merge branch '1.6.1-SNAPSHOT'

Posted by el...@apache.org.
Merge branch '1.6.1-SNAPSHOT'


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/dc6e7769
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/dc6e7769
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/dc6e7769

Branch: refs/heads/master
Commit: dc6e7769444fdbe368004f6cbe598e168417e012
Parents: 9defedf cfda8fa
Author: Josh Elser <el...@apache.org>
Authored: Tue Jun 24 14:25:43 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Tue Jun 24 14:25:43 2014 -0400

----------------------------------------------------------------------
 .../accumulo/fate/zookeeper/ZooLockTest.java    | 23 ++++++++++----------
 1 file changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------



[2/6] git commit: ACCUMULO-2948 Use an AtomicInteger to any worry from multiple threads access pdCount concurrently.

Posted by el...@apache.org.
ACCUMULO-2948 Use an AtomicInteger to any worry from multiple threads access pdCount concurrently.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/886cd198
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/886cd198
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/886cd198

Branch: refs/heads/1.6.1-SNAPSHOT
Commit: 886cd19813052a64c190f80d92e52787c5ffc813
Parents: c3de15b
Author: Josh Elser <el...@apache.org>
Authored: Tue Jun 24 14:07:04 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Tue Jun 24 14:08:57 2014 -0400

----------------------------------------------------------------------
 .../accumulo/fate/zookeeper/ZooLockTest.java    | 31 ++++++++++----------
 1 file changed, 16 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/886cd198/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java b/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
index 717bf0a..40454f6 100644
--- a/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
+++ b/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
@@ -19,6 +19,7 @@ package org.apache.accumulo.fate.zookeeper;
 import java.lang.reflect.Field;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.accumulo.fate.zookeeper.ZooLock.AsyncLockWatcher;
 import org.apache.accumulo.fate.zookeeper.ZooLock.LockLossReason;
@@ -116,13 +117,13 @@ public class ZooLockTest {
     accumulo.start();
     
   }
-  
-  private static int pdCount = 0;
-  
+
+  private static final AtomicInteger pdCount = new AtomicInteger(0);
+
   @Test(timeout = 10000)
   public void testDeleteParent() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
     
     Assert.assertFalse(zl.isLocked());
@@ -152,8 +153,8 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testNoParent() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+ 
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
     
     Assert.assertFalse(zl.isLocked());
@@ -172,8 +173,8 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testDeleteLock() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+ 
     ZooReaderWriter zk = ZooReaderWriter.getInstance(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes());
     zk.mkdirs(parent);
     
@@ -203,8 +204,8 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testDeleteWaiting() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+ 
     ZooReaderWriter zk = ZooReaderWriter.getInstance(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes());
     zk.mkdirs(parent);
     
@@ -269,7 +270,7 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testUnexpectedEvent() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
 
     ConnectedWatcher watcher = new ConnectedWatcher();
     ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 30000, watcher);
@@ -313,8 +314,8 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testTryLock() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 1000, "digest", "secret".getBytes(), parent);
     
     ConnectedWatcher watcher = new ConnectedWatcher();
@@ -350,7 +351,7 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testChangeData() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
     ConnectedWatcher watcher = new ConnectedWatcher();
     ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, watcher);
     zk.addAuthInfo("digest", "secret".getBytes());


[5/6] git commit: Merge branch '1.5.2-SNAPSHOT' into 1.6.1-SNAPSHOT

Posted by el...@apache.org.
Merge branch '1.5.2-SNAPSHOT' into 1.6.1-SNAPSHOT

Conflicts:
	test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/cfda8fab
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/cfda8fab
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/cfda8fab

Branch: refs/heads/1.6.1-SNAPSHOT
Commit: cfda8fab6d290008195769a750994a52986bc964
Parents: 76c910b 886cd19
Author: Josh Elser <el...@apache.org>
Authored: Tue Jun 24 14:25:34 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Tue Jun 24 14:25:34 2014 -0400

----------------------------------------------------------------------
 .../accumulo/fate/zookeeper/ZooLockTest.java    | 23 ++++++++++----------
 1 file changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfda8fab/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
----------------------------------------------------------------------
diff --cc test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
index d19320d,40454f6..4045087
--- a/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
+++ b/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
@@@ -104,121 -104,121 +105,121 @@@ public class ZooLockTest 
        this.notifyAll();
      }
    }
 -  
 +
    @BeforeClass
    public static void setupMiniCluster() throws Exception {
 -    
 +
      folder.create();
 -    
 +
      Logger.getLogger("org.apache.zookeeper").setLevel(Level.ERROR);
 -    
 +
      accumulo = new MiniAccumuloCluster(folder.getRoot(), "superSecret");
 -    
 +
      accumulo.start();
 -    
 +
    }
  
-   private static int pdCount = 0;
+   private static final AtomicInteger pdCount = new AtomicInteger(0);
  
    @Test(timeout = 10000)
    public void testDeleteParent() throws Exception {
-     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
+     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
  
      ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
 -    
 +
      Assert.assertFalse(zl.isLocked());
 -    
 +
      ZooReaderWriter zk = ZooReaderWriter.getInstance(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes());
 -    
 +
      // intentionally created parent after lock
      zk.mkdirs(parent);
 -    
 +
      zk.delete(parent, -1);
 -    
 +
      zk.mkdirs(parent);
 -    
 +
      TestALW lw = new TestALW();
 -    
 +
      zl.lockAsync(lw, "test1".getBytes());
 -    
 +
      lw.waitForChanges(1);
 -    
 +
      Assert.assertTrue(lw.locked);
      Assert.assertTrue(zl.isLocked());
      Assert.assertNull(lw.exception);
      Assert.assertNull(lw.reason);
 -    
 +
      zl.unlock();
    }
 -  
 +
    @Test(timeout = 10000)
    public void testNoParent() throws Exception {
-     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
- 
+     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+  
      ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
 -    
 +
      Assert.assertFalse(zl.isLocked());
 -    
 +
      TestALW lw = new TestALW();
 -    
 +
      zl.lockAsync(lw, "test1".getBytes());
 -    
 +
      lw.waitForChanges(1);
 -    
 +
      Assert.assertFalse(lw.locked);
      Assert.assertFalse(zl.isLocked());
      Assert.assertNotNull(lw.exception);
      Assert.assertNull(lw.reason);
    }
 -  
 +
    @Test(timeout = 10000)
    public void testDeleteLock() throws Exception {
-     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
- 
+     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+  
      ZooReaderWriter zk = ZooReaderWriter.getInstance(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes());
      zk.mkdirs(parent);
 -    
 +
      ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
 -    
 +
      Assert.assertFalse(zl.isLocked());
 -    
 +
      TestALW lw = new TestALW();
 -    
 +
      zl.lockAsync(lw, "test1".getBytes());
 -    
 +
      lw.waitForChanges(1);
 -    
 +
      Assert.assertTrue(lw.locked);
      Assert.assertTrue(zl.isLocked());
      Assert.assertNull(lw.exception);
      Assert.assertNull(lw.reason);
 -    
 +
      zk.delete(zl.getLockPath(), -1);
 -    
 +
      lw.waitForChanges(2);
 -    
 +
      Assert.assertEquals(LockLossReason.LOCK_DELETED, lw.reason);
      Assert.assertNull(lw.exception);
 -    
 +
    }
 -  
 +
    @Test(timeout = 10000)
    public void testDeleteWaiting() throws Exception {
-     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
- 
+     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+  
      ZooReaderWriter zk = ZooReaderWriter.getInstance(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes());
      zk.mkdirs(parent);
 -    
 +
      ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
 -    
 +
      Assert.assertFalse(zl.isLocked());
 -    
 +
      TestALW lw = new TestALW();
 -    
 +
      zl.lockAsync(lw, "test1".getBytes());
 -    
 +
      lw.waitForChanges(1);
 -    
 +
      Assert.assertTrue(lw.locked);
      Assert.assertTrue(zl.isLocked());
      Assert.assertNull(lw.exception);
@@@ -263,14 -263,14 +264,14 @@@
      Assert.assertTrue(zl3.isLocked());
      Assert.assertNull(lw3.exception);
      Assert.assertNull(lw3.reason);
 -    
 +
      zl3.unlock();
 -    
 +
    }
 -  
 +
    @Test(timeout = 10000)
    public void testUnexpectedEvent() throws Exception {
-     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
+     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
  
      ConnectedWatcher watcher = new ConnectedWatcher();
      ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 30000, watcher);
@@@ -299,22 -299,22 +300,22 @@@
      Assert.assertTrue(zl.isLocked());
      Assert.assertNull(lw.exception);
      Assert.assertNull(lw.reason);
 -    
 +
      // would not expect data to be set on this node either
      zk.setData(zl.getLockPath(), "bar".getBytes(), -1);
 -    
 +
      zk.delete(zl.getLockPath(), -1);
 -    
 +
      lw.waitForChanges(2);
 -    
 +
      Assert.assertEquals(LockLossReason.LOCK_DELETED, lw.reason);
      Assert.assertNull(lw.exception);
 -    
 +
    }
 -  
 +
    @Test(timeout = 10000)
    public void testTryLock() throws Exception {
-     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
+     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
  
      ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 1000, "digest", "secret".getBytes(), parent);
      
@@@ -345,13 -345,13 +346,13 @@@
        field.setAccessible(true);
        Assert.assertTrue((Boolean) field.get(zl));
      }
 -    
 +
      zl.unlock();
    }
 -  
 +
    @Test(timeout = 10000)
    public void testChangeData() throws Exception {
-     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
+     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
      ConnectedWatcher watcher = new ConnectedWatcher();
      ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, watcher);
      zk.addAuthInfo("digest", "secret".getBytes());


[3/6] git commit: ACCUMULO-2948 Use an AtomicInteger to any worry from multiple threads access pdCount concurrently.

Posted by el...@apache.org.
ACCUMULO-2948 Use an AtomicInteger to any worry from multiple threads access pdCount concurrently.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/886cd198
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/886cd198
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/886cd198

Branch: refs/heads/master
Commit: 886cd19813052a64c190f80d92e52787c5ffc813
Parents: c3de15b
Author: Josh Elser <el...@apache.org>
Authored: Tue Jun 24 14:07:04 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Tue Jun 24 14:08:57 2014 -0400

----------------------------------------------------------------------
 .../accumulo/fate/zookeeper/ZooLockTest.java    | 31 ++++++++++----------
 1 file changed, 16 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/886cd198/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java b/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
index 717bf0a..40454f6 100644
--- a/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
+++ b/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
@@ -19,6 +19,7 @@ package org.apache.accumulo.fate.zookeeper;
 import java.lang.reflect.Field;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.accumulo.fate.zookeeper.ZooLock.AsyncLockWatcher;
 import org.apache.accumulo.fate.zookeeper.ZooLock.LockLossReason;
@@ -116,13 +117,13 @@ public class ZooLockTest {
     accumulo.start();
     
   }
-  
-  private static int pdCount = 0;
-  
+
+  private static final AtomicInteger pdCount = new AtomicInteger(0);
+
   @Test(timeout = 10000)
   public void testDeleteParent() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
     
     Assert.assertFalse(zl.isLocked());
@@ -152,8 +153,8 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testNoParent() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+ 
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
     
     Assert.assertFalse(zl.isLocked());
@@ -172,8 +173,8 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testDeleteLock() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+ 
     ZooReaderWriter zk = ZooReaderWriter.getInstance(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes());
     zk.mkdirs(parent);
     
@@ -203,8 +204,8 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testDeleteWaiting() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+ 
     ZooReaderWriter zk = ZooReaderWriter.getInstance(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes());
     zk.mkdirs(parent);
     
@@ -269,7 +270,7 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testUnexpectedEvent() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
 
     ConnectedWatcher watcher = new ConnectedWatcher();
     ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 30000, watcher);
@@ -313,8 +314,8 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testTryLock() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 1000, "digest", "secret".getBytes(), parent);
     
     ConnectedWatcher watcher = new ConnectedWatcher();
@@ -350,7 +351,7 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testChangeData() throws Exception {
-    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
+    String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
     ConnectedWatcher watcher = new ConnectedWatcher();
     ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, watcher);
     zk.addAuthInfo("digest", "secret".getBytes());


[4/6] git commit: Merge branch '1.5.2-SNAPSHOT' into 1.6.1-SNAPSHOT

Posted by el...@apache.org.
Merge branch '1.5.2-SNAPSHOT' into 1.6.1-SNAPSHOT

Conflicts:
	test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/cfda8fab
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/cfda8fab
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/cfda8fab

Branch: refs/heads/master
Commit: cfda8fab6d290008195769a750994a52986bc964
Parents: 76c910b 886cd19
Author: Josh Elser <el...@apache.org>
Authored: Tue Jun 24 14:25:34 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Tue Jun 24 14:25:34 2014 -0400

----------------------------------------------------------------------
 .../accumulo/fate/zookeeper/ZooLockTest.java    | 23 ++++++++++----------
 1 file changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/cfda8fab/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
----------------------------------------------------------------------
diff --cc test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
index d19320d,40454f6..4045087
--- a/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
+++ b/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
@@@ -104,121 -104,121 +105,121 @@@ public class ZooLockTest 
        this.notifyAll();
      }
    }
 -  
 +
    @BeforeClass
    public static void setupMiniCluster() throws Exception {
 -    
 +
      folder.create();
 -    
 +
      Logger.getLogger("org.apache.zookeeper").setLevel(Level.ERROR);
 -    
 +
      accumulo = new MiniAccumuloCluster(folder.getRoot(), "superSecret");
 -    
 +
      accumulo.start();
 -    
 +
    }
  
-   private static int pdCount = 0;
+   private static final AtomicInteger pdCount = new AtomicInteger(0);
  
    @Test(timeout = 10000)
    public void testDeleteParent() throws Exception {
-     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
+     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
  
      ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
 -    
 +
      Assert.assertFalse(zl.isLocked());
 -    
 +
      ZooReaderWriter zk = ZooReaderWriter.getInstance(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes());
 -    
 +
      // intentionally created parent after lock
      zk.mkdirs(parent);
 -    
 +
      zk.delete(parent, -1);
 -    
 +
      zk.mkdirs(parent);
 -    
 +
      TestALW lw = new TestALW();
 -    
 +
      zl.lockAsync(lw, "test1".getBytes());
 -    
 +
      lw.waitForChanges(1);
 -    
 +
      Assert.assertTrue(lw.locked);
      Assert.assertTrue(zl.isLocked());
      Assert.assertNull(lw.exception);
      Assert.assertNull(lw.reason);
 -    
 +
      zl.unlock();
    }
 -  
 +
    @Test(timeout = 10000)
    public void testNoParent() throws Exception {
-     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
- 
+     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+  
      ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
 -    
 +
      Assert.assertFalse(zl.isLocked());
 -    
 +
      TestALW lw = new TestALW();
 -    
 +
      zl.lockAsync(lw, "test1".getBytes());
 -    
 +
      lw.waitForChanges(1);
 -    
 +
      Assert.assertFalse(lw.locked);
      Assert.assertFalse(zl.isLocked());
      Assert.assertNotNull(lw.exception);
      Assert.assertNull(lw.reason);
    }
 -  
 +
    @Test(timeout = 10000)
    public void testDeleteLock() throws Exception {
-     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
- 
+     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+  
      ZooReaderWriter zk = ZooReaderWriter.getInstance(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes());
      zk.mkdirs(parent);
 -    
 +
      ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
 -    
 +
      Assert.assertFalse(zl.isLocked());
 -    
 +
      TestALW lw = new TestALW();
 -    
 +
      zl.lockAsync(lw, "test1".getBytes());
 -    
 +
      lw.waitForChanges(1);
 -    
 +
      Assert.assertTrue(lw.locked);
      Assert.assertTrue(zl.isLocked());
      Assert.assertNull(lw.exception);
      Assert.assertNull(lw.reason);
 -    
 +
      zk.delete(zl.getLockPath(), -1);
 -    
 +
      lw.waitForChanges(2);
 -    
 +
      Assert.assertEquals(LockLossReason.LOCK_DELETED, lw.reason);
      Assert.assertNull(lw.exception);
 -    
 +
    }
 -  
 +
    @Test(timeout = 10000)
    public void testDeleteWaiting() throws Exception {
-     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
- 
+     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
+  
      ZooReaderWriter zk = ZooReaderWriter.getInstance(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes());
      zk.mkdirs(parent);
 -    
 +
      ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
 -    
 +
      Assert.assertFalse(zl.isLocked());
 -    
 +
      TestALW lw = new TestALW();
 -    
 +
      zl.lockAsync(lw, "test1".getBytes());
 -    
 +
      lw.waitForChanges(1);
 -    
 +
      Assert.assertTrue(lw.locked);
      Assert.assertTrue(zl.isLocked());
      Assert.assertNull(lw.exception);
@@@ -263,14 -263,14 +264,14 @@@
      Assert.assertTrue(zl3.isLocked());
      Assert.assertNull(lw3.exception);
      Assert.assertNull(lw3.reason);
 -    
 +
      zl3.unlock();
 -    
 +
    }
 -  
 +
    @Test(timeout = 10000)
    public void testUnexpectedEvent() throws Exception {
-     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
+     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
  
      ConnectedWatcher watcher = new ConnectedWatcher();
      ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 30000, watcher);
@@@ -299,22 -299,22 +300,22 @@@
      Assert.assertTrue(zl.isLocked());
      Assert.assertNull(lw.exception);
      Assert.assertNull(lw.reason);
 -    
 +
      // would not expect data to be set on this node either
      zk.setData(zl.getLockPath(), "bar".getBytes(), -1);
 -    
 +
      zk.delete(zl.getLockPath(), -1);
 -    
 +
      lw.waitForChanges(2);
 -    
 +
      Assert.assertEquals(LockLossReason.LOCK_DELETED, lw.reason);
      Assert.assertNull(lw.exception);
 -    
 +
    }
 -  
 +
    @Test(timeout = 10000)
    public void testTryLock() throws Exception {
-     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
+     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
  
      ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 1000, "digest", "secret".getBytes(), parent);
      
@@@ -345,13 -345,13 +346,13 @@@
        field.setAccessible(true);
        Assert.assertTrue((Boolean) field.get(zl));
      }
 -    
 +
      zl.unlock();
    }
 -  
 +
    @Test(timeout = 10000)
    public void testChangeData() throws Exception {
-     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
+     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount.incrementAndGet();
      ConnectedWatcher watcher = new ConnectedWatcher();
      ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, watcher);
      zk.addAuthInfo("digest", "secret".getBytes());