You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2022/01/25 22:33:24 UTC

[accumulo] branch main updated: Fix issues in MiniAccumuloCluster.verifyUp that is causing tests to fail (#2414)

This is an automated email from the ASF dual-hosted git repository.

ctubbsii pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/main by this push:
     new 42b1208  Fix issues in MiniAccumuloCluster.verifyUp that is causing tests to fail (#2414)
42b1208 is described below

commit 42b120806bf062cdb306f8d170d47946e4bc667c
Author: Dave Marion <dl...@apache.org>
AuthorDate: Tue Jan 25 17:33:15 2022 -0500

    Fix issues in MiniAccumuloCluster.verifyUp that is causing tests to fail (#2414)
    
    * Remove use of ZooReaderWriter from MiniAccumuloClusterImpl.verifyUp
    * Don't call ServerContext from MAC, it sets the SingletonMode to SERVER
    * On a restart, there are more tserver ZK entries than expected
    * Remove attempts from verifyUp, let it time out
    * Add check that NativeMap libary path is set if configured to use native
    
    Co-authored-by: Christopher Tubbs <ct...@apache.org>
---
 .../miniclusterImpl/MiniAccumuloClusterImpl.java   | 106 ++++++++++++++-------
 .../accumulo/test/functional/ReadWriteIT.java      |   3 +-
 2 files changed, 71 insertions(+), 38 deletions(-)

diff --git a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java
index cf64861..5edbd35 100644
--- a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java
+++ b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java
@@ -74,6 +74,7 @@ import org.apache.accumulo.core.manager.thrift.ManagerGoalState;
 import org.apache.accumulo.core.manager.thrift.ManagerMonitorInfo;
 import org.apache.accumulo.core.trace.TraceUtil;
 import org.apache.accumulo.core.util.Pair;
+import org.apache.accumulo.fate.util.UtilWaitThread;
 import org.apache.accumulo.fate.zookeeper.ZooReaderWriter;
 import org.apache.accumulo.fate.zookeeper.ZooUtil;
 import org.apache.accumulo.manager.state.SetGoalState;
@@ -97,6 +98,8 @@ import org.apache.hadoop.hdfs.DFSConfigKeys;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.thrift.TException;
 import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.ZooKeeper;
+import org.apache.zookeeper.ZooKeeper.States;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -327,6 +330,13 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
 
     this.config = config.initialize();
 
+    if (Boolean.valueOf(config.getSiteConfig().get(Property.TSERV_NATIVEMAP_ENABLED.getKey()))
+        && config.getNativeLibPaths().length == 0
+        && !config.getSystemProperties().containsKey("accumulo.native.lib.path")) {
+      throw new RuntimeException(
+          "MAC configured to use native maps, but native library path was not provided.");
+    }
+
     mkdirs(config.getConfDir());
     mkdirs(config.getLogDir());
     mkdirs(config.getLibDir());
@@ -608,6 +618,8 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
 
   private void verifyUp() throws InterruptedException, IOException {
 
+    int numTries = 10;
+
     requireNonNull(getClusterControl().managerProcess, "Error starting Manager - no process");
     requireNonNull(getClusterControl().managerProcess.info().startInstant().get(),
         "Error starting Manager - instance not started");
@@ -624,53 +636,73 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
           "Error starting TabletServer " + tsExpectedCount + "- instance not started");
     }
 
-    var zrw = getServerContext().getZooReaderWriter();
-    String rootPath = getServerContext().getZooKeeperRoot();
+    try (ZooKeeper zk = new ZooKeeper(getZooKeepers(), 60000, null)) {
 
-    int tsActualCount = 0;
-    int tryCount = 0;
-    try {
-      while (tsActualCount != tsExpectedCount) {
-        tryCount++;
-        tsActualCount = 0;
-        for (String child : zrw.getChildren(rootPath + Constants.ZTSERVERS)) {
-          tsActualCount++;
-          if (zrw.getChildren(rootPath + Constants.ZTSERVERS + "/" + child).isEmpty())
-            log.info("TServer " + tsActualCount + " not yet present in ZooKeeper");
+      String secret = getSiteConfiguration().get(Property.INSTANCE_SECRET);
+
+      for (int i = 0; i < numTries; i++) {
+        if (zk.getState().equals(States.CONNECTED)) {
+          ZooUtil.digestAuth(zk, secret);
+          break;
+        } else
+          UtilWaitThread.sleep(1000);
+      }
+
+      String instanceId = null;
+      try {
+        for (String name : zk.getChildren(Constants.ZROOT + Constants.ZINSTANCES, null)) {
+          if (name.equals(config.getInstanceName())) {
+            String instanceNamePath = Constants.ZROOT + Constants.ZINSTANCES + "/" + name;
+            byte[] bytes = zk.getData(instanceNamePath, null, null);
+            instanceId = new String(bytes, UTF_8);
+            break;
+          }
         }
-        if (tryCount >= 10) {
-          throw new RuntimeException("Timed out waiting for TServer information in ZooKeeper");
+      } catch (KeeperException e) {
+        throw new RuntimeException("Unable to read instance id from zookeeper.", e);
+      }
+
+      if (instanceId == null) {
+        throw new RuntimeException("Unable to find instance id from zookeeper.");
+      }
+
+      String rootPath = Constants.ZROOT + "/" + instanceId;
+      int tsActualCount = 0;
+      try {
+        while (tsActualCount < tsExpectedCount) {
+          tsActualCount = 0;
+          for (String child : zk.getChildren(rootPath + Constants.ZTSERVERS, null)) {
+            if (zk.getChildren(rootPath + Constants.ZTSERVERS + "/" + child, null).isEmpty()) {
+              log.info("TServer " + tsActualCount + " not yet present in ZooKeeper");
+            } else {
+              tsActualCount++;
+              log.info("TServer " + tsActualCount + " present in ZooKeeper");
+            }
+          }
+          Thread.sleep(500);
         }
-        Thread.sleep(1000);
+      } catch (KeeperException e) {
+        throw new RuntimeException("Unable to read TServer information from zookeeper.", e);
       }
-    } catch (KeeperException e) {
-      throw new RuntimeException("Unable to read TServer information from zookeeper.", e);
-    }
 
-    try {
-      tryCount = 0;
-      while (zrw.getChildren(rootPath + Constants.ZMANAGER_LOCK).isEmpty()) {
-        tryCount++;
-        if (tryCount >= 10) {
-          throw new RuntimeException("Manager not present in ZooKeeper");
+      try {
+        while (zk.getChildren(rootPath + Constants.ZMANAGER_LOCK, null).isEmpty()) {
+          log.info("Manager not yet present in ZooKeeper");
+          Thread.sleep(500);
         }
-        Thread.sleep(1000);
+      } catch (KeeperException e) {
+        throw new RuntimeException("Unable to read Manager information from zookeeper.", e);
       }
-    } catch (KeeperException e) {
-      throw new RuntimeException("Unable to read Manager information from zookeeper.", e);
-    }
 
-    try {
-      tryCount = 0;
-      while (zrw.getChildren(rootPath + Constants.ZGC_LOCK).isEmpty()) {
-        tryCount++;
-        if (tryCount >= 10) {
-          throw new RuntimeException("GC not present in ZooKeeper");
+      try {
+        while (zk.getChildren(rootPath + Constants.ZGC_LOCK, null).isEmpty()) {
+          log.info("GC not yet present in ZooKeeper");
+          Thread.sleep(500);
         }
-        Thread.sleep(1000);
+      } catch (KeeperException e) {
+        throw new RuntimeException("Unable to read GC information from zookeeper.", e);
       }
-    } catch (KeeperException e) {
-      throw new RuntimeException("Unable to read GC information from zookeeper.", e);
+
     }
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ReadWriteIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ReadWriteIT.java
index 2efbaf9..8de2a72 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ReadWriteIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ReadWriteIT.java
@@ -180,7 +180,8 @@ public class ReadWriteIT extends AccumuloClusterHarness {
           Thread.sleep(1000);
         }
       } while (managerLockData != null);
-
+      control.stopAllServers(ServerType.MANAGER);
+      control.stopAllServers(ServerType.TABLET_SERVER);
       control.stopAllServers(ServerType.GARBAGE_COLLECTOR);
       control.stopAllServers(ServerType.MONITOR);
       log.debug("success!");