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/07 05:33:07 UTC
[accumulo] branch main updated: Fix MiniAccumuloClusterImpl.verifyUp() (#2410)
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 3951427 Fix MiniAccumuloClusterImpl.verifyUp() (#2410)
3951427 is described below
commit 39514270b1d8fad1b68b9e559467df9f5f81e4a5
Author: Christopher Tubbs <ct...@apache.org>
AuthorDate: Fri Jan 7 00:30:47 2022 -0500
Fix MiniAccumuloClusterImpl.verifyUp() (#2410)
Fix verifyUp method broken by #2408. The previous code attempted to use
a client singleton resource (ZooSession, created inside ZooReaderWriter)
without instantiating an AccumuloClient. This fix ensures that resource
is created after MiniAccumuloClusterImpl's ServerContext has been
created, so a client context is established before the client singleton
resource is used.
---
.../miniclusterImpl/MiniAccumuloClusterImpl.java | 60 +++++++---------------
1 file changed, 18 insertions(+), 42 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 28b38f0..cf64861 100644
--- a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java
+++ b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java
@@ -19,6 +19,7 @@
package org.apache.accumulo.miniclusterImpl;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.Objects.requireNonNull;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
import java.io.File;
@@ -41,7 +42,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Objects;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.ExecutionException;
@@ -608,66 +608,43 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
private void verifyUp() throws InterruptedException, IOException {
- Objects.requireNonNull(getClusterControl().managerProcess,
- "Error starting Manager - no process");
- Objects.requireNonNull(getClusterControl().managerProcess.info().startInstant().get(),
+ requireNonNull(getClusterControl().managerProcess, "Error starting Manager - no process");
+ requireNonNull(getClusterControl().managerProcess.info().startInstant().get(),
"Error starting Manager - instance not started");
- Objects.requireNonNull(getClusterControl().gcProcess, "Error starting GC - no process");
- Objects.requireNonNull(getClusterControl().gcProcess.info().startInstant().get(),
+ requireNonNull(getClusterControl().gcProcess, "Error starting GC - no process");
+ requireNonNull(getClusterControl().gcProcess.info().startInstant().get(),
"Error starting GC - instance not started");
int tsExpectedCount = 0;
for (Process tsp : getClusterControl().tabletServerProcesses) {
tsExpectedCount++;
- Objects.requireNonNull(tsp,
- "Error starting TabletServer " + tsExpectedCount + " - no process");
- Objects.requireNonNull(tsp.info().startInstant().get(),
+ requireNonNull(tsp, "Error starting TabletServer " + tsExpectedCount + " - no process");
+ requireNonNull(tsp.info().startInstant().get(),
"Error starting TabletServer " + tsExpectedCount + "- instance not started");
}
- String zk = config.getExistingZooKeepers() != null ? config.getExistingZooKeepers()
- : config.getZooKeepers();
-
- ZooReaderWriter zrw =
- new ZooReaderWriter(zk, 30000, Property.INSTANCE_SECRET.getDefaultValue());
-
- String instanceId = null;
- try {
- for (String name : zrw.getChildren(Constants.ZROOT + Constants.ZINSTANCES)) {
- if (name.equals(config.getInstanceName())) {
- String instanceNamePath = Constants.ZROOT + Constants.ZINSTANCES + "/" + name;
- byte[] bytes = zrw.getData(instanceNamePath);
- instanceId = new String(bytes, UTF_8);
- break;
- }
- }
- } catch (KeeperException e) {
- throw new RuntimeException("Unable to read instance name from zookeeper.", e);
- }
- if (instanceId == null) {
- throw new RuntimeException(config.getInstanceName() + " instance name not found in ZK");
- }
- String rootPath = ZooUtil.getRoot(instanceId);
+ var zrw = getServerContext().getZooReaderWriter();
+ String rootPath = getServerContext().getZooKeeperRoot();
int tsActualCount = 0;
int tryCount = 0;
- while (tsActualCount != tsExpectedCount) {
- tryCount++;
- try {
+ 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");
}
- } catch (KeeperException e) {
- throw new RuntimeException("Unable to read TServer information from zookeeper.", e);
- }
- if (tryCount >= 10) {
- throw new RuntimeException("Timed out waiting for TServer information in ZooKeeper");
+ if (tryCount >= 10) {
+ throw new RuntimeException("Timed out waiting for TServer information in ZooKeeper");
+ }
+ Thread.sleep(1000);
}
- Thread.sleep(1000);
+ } catch (KeeperException e) {
+ throw new RuntimeException("Unable to read TServer information from zookeeper.", e);
}
try {
@@ -695,7 +672,6 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
} catch (KeeperException e) {
throw new RuntimeException("Unable to read GC information from zookeeper.", e);
}
-
}
private List<String> buildRemoteDebugParams(int port) {