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 03:25:58 UTC

[1/7] git commit: Merge remote-tracking branch 'origin/1.5.2-SNAPSHOT' into 1.5.2-SNAPSHOT

Repository: accumulo
Updated Branches:
  refs/heads/1.5.2-SNAPSHOT d81b8db30 -> 65782b505
  refs/heads/1.6.1-SNAPSHOT 3583409bd -> fd080f03f
  refs/heads/master 5026b1314 -> f785903c5


Merge remote-tracking branch 'origin/1.5.2-SNAPSHOT' into 1.5.2-SNAPSHOT


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

Branch: refs/heads/1.6.1-SNAPSHOT
Commit: d81b8db30f6a3688126bc23b3eef8de9451b3d77
Parents: f99b565 b304ed7
Author: Josh Elser <el...@apache.org>
Authored: Thu Jun 19 13:30:49 2014 -0700
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jun 19 13:30:49 2014 -0700

----------------------------------------------------------------------
 .../tabletserver/LargestFirstMemoryManager.java | 171 +++++++++++--------
 .../accumulo/test/stress/random/Stream.java     |   1 -
 2 files changed, 103 insertions(+), 69 deletions(-)
----------------------------------------------------------------------



[3/7] git commit: ACCUMULO-2940 Add a Watcher to not use ZooKeeper before we're connected.

Posted by el...@apache.org.
ACCUMULO-2940 Add a Watcher to not use ZooKeeper before we're connected.

ZooKeeper connection is asynchronous, so we need to set a Watcher to know
when the client is actually connected. We should really be checking for connections
after any exception, but we hopefully won't get disconnected mid-test.


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

Branch: refs/heads/master
Commit: 65782b505478a37d01468064c6bcd5eb5cd75f88
Parents: d81b8db
Author: Josh Elser <el...@apache.org>
Authored: Mon Jun 23 19:38:57 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Mon Jun 23 19:38:57 2014 -0400

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


http://git-wip-us.apache.org/repos/asf/accumulo/blob/65782b50/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 0c57250..717bf0a 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
@@ -26,6 +26,9 @@ import org.apache.accumulo.minicluster.MiniAccumuloCluster;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.Watcher.Event.KeeperState;
 import org.apache.zookeeper.ZooDefs;
 import org.apache.zookeeper.ZooKeeper;
 import org.junit.AfterClass;
@@ -42,7 +45,24 @@ public class ZooLockTest {
   public static TemporaryFolder folder = new TemporaryFolder();
   
   private static MiniAccumuloCluster accumulo;
-  
+
+  static class ConnectedWatcher implements Watcher {
+    volatile boolean connected = false;
+
+    @Override
+    public synchronized void process(WatchedEvent event) {
+      if (event.getState() == KeeperState.SyncConnected) { // For ZK >3.4.... || event.getState() == KeeperState.ConnectedReadOnly) {
+        connected = true;
+      } else {
+        connected = false;
+      }
+    }
+
+    public synchronized boolean isConnected() {
+      return connected;
+    }
+  }
+
   static class TestALW implements AsyncLockWatcher {
     
     LockLossReason reason = null;
@@ -101,8 +121,6 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testDeleteParent() throws Exception {
-    accumulo.getZooKeepers();
-    
     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
     
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
@@ -134,8 +152,6 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testNoParent() throws Exception {
-    accumulo.getZooKeepers();
-    
     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
     
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
@@ -156,8 +172,6 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testDeleteLock() throws Exception {
-    accumulo.getZooKeepers();
-    
     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
     
     ZooReaderWriter zk = ZooReaderWriter.getInstance(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes());
@@ -189,8 +203,6 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testDeleteWaiting() throws Exception {
-    accumulo.getZooKeepers();
-    
     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
     
     ZooReaderWriter zk = ZooReaderWriter.getInstance(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes());
@@ -257,12 +269,15 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testUnexpectedEvent() throws Exception {
-    accumulo.getZooKeepers();
-    
     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    
-    ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 30000, null);
+
+    ConnectedWatcher watcher = new ConnectedWatcher();
+    ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 30000, watcher);
     zk.addAuthInfo("digest", "secret".getBytes());
+
+    while (!watcher.isConnected()) {
+      Thread.sleep(200);
+    }
     
     zk.create(parent, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
     
@@ -302,8 +317,13 @@ public class ZooLockTest {
     
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 1000, "digest", "secret".getBytes(), parent);
     
-    ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, null);
+    ConnectedWatcher watcher = new ConnectedWatcher();
+    ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, watcher);
     zk.addAuthInfo("digest", "secret".getBytes());
+
+    while (!watcher.isConnected()) {
+      Thread.sleep(200);
+    }
     
     for (int i = 0; i < 10; i++) {
       zk.create(parent, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
@@ -331,8 +351,14 @@ public class ZooLockTest {
   @Test(timeout = 10000)
   public void testChangeData() throws Exception {
     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, null);
+    ConnectedWatcher watcher = new ConnectedWatcher();
+    ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, watcher);
     zk.addAuthInfo("digest", "secret".getBytes());
+
+    while (!watcher.isConnected()) {
+      Thread.sleep(200);
+    }
+    
     zk.create(parent, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
     
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 1000, "digest", "secret".getBytes(), parent);


[7/7] git commit: Merge branch '1.5.2-SNAPSHOT'

Posted by el...@apache.org.
Merge branch '1.5.2-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/f785903c
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/f785903c
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/f785903c

Branch: refs/heads/master
Commit: f785903c5ba33a9127e6cebdb7981f340fe407b5
Parents: 5026b13 65782b5
Author: Josh Elser <el...@apache.org>
Authored: Mon Jun 23 20:29:09 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Mon Jun 23 20:29:09 2014 -0400

----------------------------------------------------------------------
 .../accumulo/fate/zookeeper/ZooLockTest.java    | 54 +++++++++++++++-----
 1 file changed, 40 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/f785903c/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 e902818,717bf0a..d19320d
--- a/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
+++ b/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
@@@ -39,13 -41,30 +42,30 @@@ import org.junit.rules.TemporaryFolder
   * 
   */
  public class ZooLockTest {
 -  
 -  public static TemporaryFolder folder = new TemporaryFolder();
 -  
 +
 +  public static TemporaryFolder folder = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target"));
 +
    private static MiniAccumuloCluster accumulo;
  
+   static class ConnectedWatcher implements Watcher {
+     volatile boolean connected = false;
+ 
+     @Override
+     public synchronized void process(WatchedEvent event) {
+       if (event.getState() == KeeperState.SyncConnected) { // For ZK >3.4.... || event.getState() == KeeperState.ConnectedReadOnly) {
+         connected = true;
+       } else {
+         connected = false;
+       }
+     }
+ 
+     public synchronized boolean isConnected() {
+       return connected;
+     }
+   }
+ 
    static class TestALW implements AsyncLockWatcher {
 -    
 +
      LockLossReason reason = null;
      boolean locked = false;
      Exception exception = null;
@@@ -84,129 -103,121 +104,121 @@@
        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;
 -  
 +
    @Test(timeout = 10000)
    public void testDeleteParent() throws Exception {
-     accumulo.getZooKeepers();
- 
      String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
 -    
 +
      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 {
-     accumulo.getZooKeepers();
- 
      String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
 -    
 +
      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 {
-     accumulo.getZooKeepers();
- 
      String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
 -    
 +
      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 {
-     accumulo.getZooKeepers();
- 
      String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
 -    
 +
      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);
@@@ -251,35 -262,38 +263,38 @@@
      Assert.assertTrue(zl3.isLocked());
      Assert.assertNull(lw3.exception);
      Assert.assertNull(lw3.reason);
 -    
 +
      zl3.unlock();
 -    
 +
    }
 -  
 +
    @Test(timeout = 10000)
    public void testUnexpectedEvent() throws Exception {
-     accumulo.getZooKeepers();
- 
      String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
  
-     ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 30000, null);
+     ConnectedWatcher watcher = new ConnectedWatcher();
+     ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 30000, watcher);
      zk.addAuthInfo("digest", "secret".getBytes());
  
+     while (!watcher.isConnected()) {
+       Thread.sleep(200);
+     }
+     
      zk.create(parent, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
 -    
 +
      ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
 -    
 +
      Assert.assertFalse(zl.isLocked());
 -    
 +
      // would not expect data to be set on this node, but it should not cause problems.....
      zk.setData(parent, "foo".getBytes(), -1);
 -    
 +
      TestALW lw = new TestALW();
 -    
 +
      zl.lockAsync(lw, "test1".getBytes());
 -    
 +
      lw.waitForChanges(1);
 -    
 +
      Assert.assertTrue(lw.locked);
      Assert.assertTrue(zl.isLocked());
      Assert.assertNull(lw.exception);
@@@ -300,12 -314,17 +315,17 @@@
    @Test(timeout = 10000)
    public void testTryLock() throws Exception {
      String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
 -    
 +
      ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 1000, "digest", "secret".getBytes(), parent);
- 
-     ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, null);
+     
+     ConnectedWatcher watcher = new ConnectedWatcher();
+     ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, watcher);
      zk.addAuthInfo("digest", "secret".getBytes());
  
+     while (!watcher.isConnected()) {
+       Thread.sleep(200);
+     }
+     
      for (int i = 0; i < 10; i++) {
        zk.create(parent, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        zk.delete(parent, -1);
@@@ -332,17 -351,23 +352,23 @@@
    @Test(timeout = 10000)
    public void testChangeData() throws Exception {
      String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-     ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, null);
+     ConnectedWatcher watcher = new ConnectedWatcher();
+     ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, watcher);
      zk.addAuthInfo("digest", "secret".getBytes());
+ 
+     while (!watcher.isConnected()) {
+       Thread.sleep(200);
+     }
+     
      zk.create(parent, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
 -    
 +
      ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 1000, "digest", "secret".getBytes(), parent);
 -    
 +
      TestALW lw = new TestALW();
 -    
 +
      zl.lockAsync(lw, "test1".getBytes());
      Assert.assertEquals("test1", new String(zk.getData(zl.getLockPath(), null, null)));
 -    
 +
      zl.replaceLockData("test2".getBytes());
      Assert.assertEquals("test2", new String(zk.getData(zl.getLockPath(), null, null)));
    }


[5/7] git commit: ACCUMULO-2940 Add a Watcher to not use ZooKeeper before we're connected.

Posted by el...@apache.org.
ACCUMULO-2940 Add a Watcher to not use ZooKeeper before we're connected.

ZooKeeper connection is asynchronous, so we need to set a Watcher to know
when the client is actually connected. We should really be checking for connections
after any exception, but we hopefully won't get disconnected mid-test.


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

Branch: refs/heads/1.5.2-SNAPSHOT
Commit: 65782b505478a37d01468064c6bcd5eb5cd75f88
Parents: d81b8db
Author: Josh Elser <el...@apache.org>
Authored: Mon Jun 23 19:38:57 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Mon Jun 23 19:38:57 2014 -0400

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


http://git-wip-us.apache.org/repos/asf/accumulo/blob/65782b50/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 0c57250..717bf0a 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
@@ -26,6 +26,9 @@ import org.apache.accumulo.minicluster.MiniAccumuloCluster;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.Watcher.Event.KeeperState;
 import org.apache.zookeeper.ZooDefs;
 import org.apache.zookeeper.ZooKeeper;
 import org.junit.AfterClass;
@@ -42,7 +45,24 @@ public class ZooLockTest {
   public static TemporaryFolder folder = new TemporaryFolder();
   
   private static MiniAccumuloCluster accumulo;
-  
+
+  static class ConnectedWatcher implements Watcher {
+    volatile boolean connected = false;
+
+    @Override
+    public synchronized void process(WatchedEvent event) {
+      if (event.getState() == KeeperState.SyncConnected) { // For ZK >3.4.... || event.getState() == KeeperState.ConnectedReadOnly) {
+        connected = true;
+      } else {
+        connected = false;
+      }
+    }
+
+    public synchronized boolean isConnected() {
+      return connected;
+    }
+  }
+
   static class TestALW implements AsyncLockWatcher {
     
     LockLossReason reason = null;
@@ -101,8 +121,6 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testDeleteParent() throws Exception {
-    accumulo.getZooKeepers();
-    
     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
     
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
@@ -134,8 +152,6 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testNoParent() throws Exception {
-    accumulo.getZooKeepers();
-    
     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
     
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
@@ -156,8 +172,6 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testDeleteLock() throws Exception {
-    accumulo.getZooKeepers();
-    
     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
     
     ZooReaderWriter zk = ZooReaderWriter.getInstance(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes());
@@ -189,8 +203,6 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testDeleteWaiting() throws Exception {
-    accumulo.getZooKeepers();
-    
     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
     
     ZooReaderWriter zk = ZooReaderWriter.getInstance(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes());
@@ -257,12 +269,15 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testUnexpectedEvent() throws Exception {
-    accumulo.getZooKeepers();
-    
     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    
-    ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 30000, null);
+
+    ConnectedWatcher watcher = new ConnectedWatcher();
+    ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 30000, watcher);
     zk.addAuthInfo("digest", "secret".getBytes());
+
+    while (!watcher.isConnected()) {
+      Thread.sleep(200);
+    }
     
     zk.create(parent, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
     
@@ -302,8 +317,13 @@ public class ZooLockTest {
     
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 1000, "digest", "secret".getBytes(), parent);
     
-    ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, null);
+    ConnectedWatcher watcher = new ConnectedWatcher();
+    ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, watcher);
     zk.addAuthInfo("digest", "secret".getBytes());
+
+    while (!watcher.isConnected()) {
+      Thread.sleep(200);
+    }
     
     for (int i = 0; i < 10; i++) {
       zk.create(parent, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
@@ -331,8 +351,14 @@ public class ZooLockTest {
   @Test(timeout = 10000)
   public void testChangeData() throws Exception {
     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, null);
+    ConnectedWatcher watcher = new ConnectedWatcher();
+    ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, watcher);
     zk.addAuthInfo("digest", "secret".getBytes());
+
+    while (!watcher.isConnected()) {
+      Thread.sleep(200);
+    }
+    
     zk.create(parent, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
     
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 1000, "digest", "secret".getBytes(), parent);


[6/7] 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/fd080f03
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/fd080f03
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/fd080f03

Branch: refs/heads/1.6.1-SNAPSHOT
Commit: fd080f03f663579c8de6058f1ed14acb38638618
Parents: 3583409 65782b5
Author: Josh Elser <el...@apache.org>
Authored: Mon Jun 23 19:46:09 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Mon Jun 23 19:46:09 2014 -0400

----------------------------------------------------------------------
 .../accumulo/fate/zookeeper/ZooLockTest.java    | 54 +++++++++++++++-----
 1 file changed, 40 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/fd080f03/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 e902818,717bf0a..d19320d
--- a/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
+++ b/test/src/test/java/org/apache/accumulo/fate/zookeeper/ZooLockTest.java
@@@ -39,13 -41,30 +42,30 @@@ import org.junit.rules.TemporaryFolder
   * 
   */
  public class ZooLockTest {
 -  
 -  public static TemporaryFolder folder = new TemporaryFolder();
 -  
 +
 +  public static TemporaryFolder folder = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target"));
 +
    private static MiniAccumuloCluster accumulo;
  
+   static class ConnectedWatcher implements Watcher {
+     volatile boolean connected = false;
+ 
+     @Override
+     public synchronized void process(WatchedEvent event) {
+       if (event.getState() == KeeperState.SyncConnected) { // For ZK >3.4.... || event.getState() == KeeperState.ConnectedReadOnly) {
+         connected = true;
+       } else {
+         connected = false;
+       }
+     }
+ 
+     public synchronized boolean isConnected() {
+       return connected;
+     }
+   }
+ 
    static class TestALW implements AsyncLockWatcher {
 -    
 +
      LockLossReason reason = null;
      boolean locked = false;
      Exception exception = null;
@@@ -84,129 -103,121 +104,121 @@@
        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;
 -  
 +
    @Test(timeout = 10000)
    public void testDeleteParent() throws Exception {
-     accumulo.getZooKeepers();
- 
      String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
 -    
 +
      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 {
-     accumulo.getZooKeepers();
- 
      String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
 -    
 +
      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 {
-     accumulo.getZooKeepers();
- 
      String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
 -    
 +
      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 {
-     accumulo.getZooKeepers();
- 
      String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
 -    
 +
      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);
@@@ -251,35 -262,38 +263,38 @@@
      Assert.assertTrue(zl3.isLocked());
      Assert.assertNull(lw3.exception);
      Assert.assertNull(lw3.reason);
 -    
 +
      zl3.unlock();
 -    
 +
    }
 -  
 +
    @Test(timeout = 10000)
    public void testUnexpectedEvent() throws Exception {
-     accumulo.getZooKeepers();
- 
      String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
  
-     ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 30000, null);
+     ConnectedWatcher watcher = new ConnectedWatcher();
+     ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 30000, watcher);
      zk.addAuthInfo("digest", "secret".getBytes());
  
+     while (!watcher.isConnected()) {
+       Thread.sleep(200);
+     }
+     
      zk.create(parent, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
 -    
 +
      ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
 -    
 +
      Assert.assertFalse(zl.isLocked());
 -    
 +
      // would not expect data to be set on this node, but it should not cause problems.....
      zk.setData(parent, "foo".getBytes(), -1);
 -    
 +
      TestALW lw = new TestALW();
 -    
 +
      zl.lockAsync(lw, "test1".getBytes());
 -    
 +
      lw.waitForChanges(1);
 -    
 +
      Assert.assertTrue(lw.locked);
      Assert.assertTrue(zl.isLocked());
      Assert.assertNull(lw.exception);
@@@ -300,12 -314,17 +315,17 @@@
    @Test(timeout = 10000)
    public void testTryLock() throws Exception {
      String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
 -    
 +
      ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 1000, "digest", "secret".getBytes(), parent);
- 
-     ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, null);
+     
+     ConnectedWatcher watcher = new ConnectedWatcher();
+     ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, watcher);
      zk.addAuthInfo("digest", "secret".getBytes());
  
+     while (!watcher.isConnected()) {
+       Thread.sleep(200);
+     }
+     
      for (int i = 0; i < 10; i++) {
        zk.create(parent, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        zk.delete(parent, -1);
@@@ -332,17 -351,23 +352,23 @@@
    @Test(timeout = 10000)
    public void testChangeData() throws Exception {
      String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-     ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, null);
+     ConnectedWatcher watcher = new ConnectedWatcher();
+     ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, watcher);
      zk.addAuthInfo("digest", "secret".getBytes());
+ 
+     while (!watcher.isConnected()) {
+       Thread.sleep(200);
+     }
+     
      zk.create(parent, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
 -    
 +
      ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 1000, "digest", "secret".getBytes(), parent);
 -    
 +
      TestALW lw = new TestALW();
 -    
 +
      zl.lockAsync(lw, "test1".getBytes());
      Assert.assertEquals("test1", new String(zk.getData(zl.getLockPath(), null, null)));
 -    
 +
      zl.replaceLockData("test2".getBytes());
      Assert.assertEquals("test2", new String(zk.getData(zl.getLockPath(), null, null)));
    }


[4/7] git commit: ACCUMULO-2940 Add a Watcher to not use ZooKeeper before we're connected.

Posted by el...@apache.org.
ACCUMULO-2940 Add a Watcher to not use ZooKeeper before we're connected.

ZooKeeper connection is asynchronous, so we need to set a Watcher to know
when the client is actually connected. We should really be checking for connections
after any exception, but we hopefully won't get disconnected mid-test.


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

Branch: refs/heads/1.6.1-SNAPSHOT
Commit: 65782b505478a37d01468064c6bcd5eb5cd75f88
Parents: d81b8db
Author: Josh Elser <el...@apache.org>
Authored: Mon Jun 23 19:38:57 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Mon Jun 23 19:38:57 2014 -0400

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


http://git-wip-us.apache.org/repos/asf/accumulo/blob/65782b50/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 0c57250..717bf0a 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
@@ -26,6 +26,9 @@ import org.apache.accumulo.minicluster.MiniAccumuloCluster;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.Watcher.Event.KeeperState;
 import org.apache.zookeeper.ZooDefs;
 import org.apache.zookeeper.ZooKeeper;
 import org.junit.AfterClass;
@@ -42,7 +45,24 @@ public class ZooLockTest {
   public static TemporaryFolder folder = new TemporaryFolder();
   
   private static MiniAccumuloCluster accumulo;
-  
+
+  static class ConnectedWatcher implements Watcher {
+    volatile boolean connected = false;
+
+    @Override
+    public synchronized void process(WatchedEvent event) {
+      if (event.getState() == KeeperState.SyncConnected) { // For ZK >3.4.... || event.getState() == KeeperState.ConnectedReadOnly) {
+        connected = true;
+      } else {
+        connected = false;
+      }
+    }
+
+    public synchronized boolean isConnected() {
+      return connected;
+    }
+  }
+
   static class TestALW implements AsyncLockWatcher {
     
     LockLossReason reason = null;
@@ -101,8 +121,6 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testDeleteParent() throws Exception {
-    accumulo.getZooKeepers();
-    
     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
     
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
@@ -134,8 +152,6 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testNoParent() throws Exception {
-    accumulo.getZooKeepers();
-    
     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
     
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes(), parent);
@@ -156,8 +172,6 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testDeleteLock() throws Exception {
-    accumulo.getZooKeepers();
-    
     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
     
     ZooReaderWriter zk = ZooReaderWriter.getInstance(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes());
@@ -189,8 +203,6 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testDeleteWaiting() throws Exception {
-    accumulo.getZooKeepers();
-    
     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
     
     ZooReaderWriter zk = ZooReaderWriter.getInstance(accumulo.getZooKeepers(), 30000, "digest", "secret".getBytes());
@@ -257,12 +269,15 @@ public class ZooLockTest {
   
   @Test(timeout = 10000)
   public void testUnexpectedEvent() throws Exception {
-    accumulo.getZooKeepers();
-    
     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    
-    ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 30000, null);
+
+    ConnectedWatcher watcher = new ConnectedWatcher();
+    ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 30000, watcher);
     zk.addAuthInfo("digest", "secret".getBytes());
+
+    while (!watcher.isConnected()) {
+      Thread.sleep(200);
+    }
     
     zk.create(parent, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
     
@@ -302,8 +317,13 @@ public class ZooLockTest {
     
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 1000, "digest", "secret".getBytes(), parent);
     
-    ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, null);
+    ConnectedWatcher watcher = new ConnectedWatcher();
+    ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, watcher);
     zk.addAuthInfo("digest", "secret".getBytes());
+
+    while (!watcher.isConnected()) {
+      Thread.sleep(200);
+    }
     
     for (int i = 0; i < 10; i++) {
       zk.create(parent, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
@@ -331,8 +351,14 @@ public class ZooLockTest {
   @Test(timeout = 10000)
   public void testChangeData() throws Exception {
     String parent = "/zltest-" + this.hashCode() + "-l" + pdCount++;
-    ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, null);
+    ConnectedWatcher watcher = new ConnectedWatcher();
+    ZooKeeper zk = new ZooKeeper(accumulo.getZooKeepers(), 1000, watcher);
     zk.addAuthInfo("digest", "secret".getBytes());
+
+    while (!watcher.isConnected()) {
+      Thread.sleep(200);
+    }
+    
     zk.create(parent, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
     
     ZooLock zl = new ZooLock(accumulo.getZooKeepers(), 1000, "digest", "secret".getBytes(), parent);


[2/7] git commit: Merge remote-tracking branch 'origin/1.5.2-SNAPSHOT' into 1.5.2-SNAPSHOT

Posted by el...@apache.org.
Merge remote-tracking branch 'origin/1.5.2-SNAPSHOT' into 1.5.2-SNAPSHOT


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

Branch: refs/heads/master
Commit: d81b8db30f6a3688126bc23b3eef8de9451b3d77
Parents: f99b565 b304ed7
Author: Josh Elser <el...@apache.org>
Authored: Thu Jun 19 13:30:49 2014 -0700
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jun 19 13:30:49 2014 -0700

----------------------------------------------------------------------
 .../tabletserver/LargestFirstMemoryManager.java | 171 +++++++++++--------
 .../accumulo/test/stress/random/Stream.java     |   1 -
 2 files changed, 103 insertions(+), 69 deletions(-)
----------------------------------------------------------------------