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 12530c71da Fixes ServiceStatusCmdTest and removed unused code (#5249)
12530c71da is described below
commit 12530c71da23673160971e0e4ce021a1241a5050
Author: Daniel Roberts <[email protected]>
AuthorDate: Tue Jan 14 14:56:37 2025 -0500
Fixes ServiceStatusCmdTest and removed unused code (#5249)
Removes unused method from ServiceStatusCmd and modified
ServiceStatusCmdTest to correctly get the number of resource groups for
compactors.
Adds dead compactor for testing ServiceStatusCmd output for compactor
details.
---
.../accumulo/server/util/ServiceStatusCmd.java | 24 -----------
.../accumulo/server/util/ServiceStatusCmdTest.java | 48 +++++++++++++++++++---
2 files changed, 42 insertions(+), 30 deletions(-)
diff --git
a/server/base/src/main/java/org/apache/accumulo/server/util/ServiceStatusCmd.java
b/server/base/src/main/java/org/apache/accumulo/server/util/ServiceStatusCmd.java
index 69782c4d35..aea14d09ff 100644
---
a/server/base/src/main/java/org/apache/accumulo/server/util/ServiceStatusCmd.java
+++
b/server/base/src/main/java/org/apache/accumulo/server/util/ServiceStatusCmd.java
@@ -182,30 +182,6 @@ public class ServiceStatusCmd {
return new StatusSummary(displayNames, byGroup.keySet(), byGroup,
result.getErrorCount());
}
- /**
- * Read the node names from ZooKeeper. Exceptions are counted but ignored.
- *
- * @return Result with error count, Set of the node names.
- */
- @VisibleForTesting
- Result<Set<String>> readNodeNames(final ZooReader zooReader, final String
path) {
- Set<String> nodeNames = new TreeSet<>();
- final AtomicInteger errorCount = new AtomicInteger(0);
- try {
- var children = zooReader.getChildren(path);
- if (children != null) {
- nodeNames.addAll(children);
- }
- } catch (KeeperException | InterruptedException ex) {
- if (Thread.currentThread().isInterrupted()) {
- Thread.currentThread().interrupt();
- throw new IllegalStateException(ex);
- }
- errorCount.incrementAndGet();
- }
- return new Result<>(errorCount.get(), nodeNames);
- }
-
/**
* Read the data from a ZooKeeper node, tracking if an error occurred.
ZooKeeper's exceptions are
* counted but otherwise ignored.
diff --git
a/server/base/src/test/java/org/apache/accumulo/server/util/ServiceStatusCmdTest.java
b/server/base/src/test/java/org/apache/accumulo/server/util/ServiceStatusCmdTest.java
index 8236f28640..163bfed546 100644
---
a/server/base/src/test/java/org/apache/accumulo/server/util/ServiceStatusCmdTest.java
+++
b/server/base/src/test/java/org/apache/accumulo/server/util/ServiceStatusCmdTest.java
@@ -20,6 +20,7 @@ package org.apache.accumulo.server.util;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.accumulo.core.Constants.ZGC_LOCK;
+import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.expect;
@@ -357,21 +358,56 @@ public class ServiceStatusCmdTest {
@Test
public void testCompactorStatus() throws Exception {
replay(zooReader);
+
+ UUID uuid1 = UUID.randomUUID();
+ String lock1Name = "zlock#" + uuid1 + "#0000000001";
+ UUID uuid2 = UUID.randomUUID();
+ String lock2Name = "zlock#" + uuid2 + "#0000000022";
+ UUID uuid3 = UUID.randomUUID();
+ String lock3Name = "zlock#" + uuid3 + "#0000000033";
+ UUID uuid4 = UUID.randomUUID();
+ String lock4Name = "zlock#" + uuid4 + "#0000000044";
+
+ String lock1data =
+
"{\"descriptors\":[{\"uuid\":\"6effb690-c29c-4e0b-92ff-f6b308385a42\",\"service\":\"COMPACTOR\",\"address\":\"hostA:8080\",\"group\":\"q1\"}]}";
+ String lock2data =
+
"{\"descriptors\":[{\"uuid\":\"6effb690-c29c-4e0b-92ff-f6b308385a42\",\"service\":\"COMPACTOR\",\"address\":\"hostC:8081\",\"group\":\"q1\"}]}";
+ String lock3data =
+
"{\"descriptors\":[{\"uuid\":\"6effb690-c29c-4e0b-92ff-f6b308385a42\",\"service\":\"COMPACTOR\",\"address\":\"hostB:9090\",\"group\":\"q2\"}]}";
+ String lock4data =
+
"{\"descriptors\":[{\"uuid\":\"6effb690-c29c-4e0b-92ff-f6b308385a42\",\"service\":\"COMPACTOR\",\"address\":\"hostD:9091\",\"group\":\"q2\"}]}";
+
String lockPath = zRoot + Constants.ZCOMPACTORS;
- expect(zooCache.getChildren(lockPath)).andReturn(List.of("q1", "q2"));
+ expect(zooCache.getChildren(lockPath)).andReturn(List.of("q1", "q2",
"q3"));
expect(zooCache.getChildren(lockPath +
"/q1")).andReturn(List.of("hostA:8080", "hostC:8081"));
expect(zooCache.getChildren(lockPath +
"/q2")).andReturn(List.of("hostB:9090", "hostD:9091"));
- expect(zooCache.getChildren(lockPath +
"/q1/hostA:8080")).andReturn(List.of());
- expect(zooCache.getChildren(lockPath +
"/q1/hostC:8081")).andReturn(List.of());
- expect(zooCache.getChildren(lockPath +
"/q2/hostB:9090")).andReturn(List.of());
- expect(zooCache.getChildren(lockPath +
"/q2/hostD:9091")).andReturn(List.of());
+ // Create compactor group with dead compactor
+ expect(zooCache.getChildren(lockPath +
"/q3")).andReturn(List.of("deadHost:8080"));
+
+ expect(zooCache.getChildren(lockPath +
"/q1/hostA:8080")).andReturn(List.of(lock1Name));
+ expect(zooCache.get(eq(lockPath + "/q1/hostA:8080/" + lock1Name),
anyObject(ZcStat.class)))
+ .andReturn(lock1data.getBytes(UTF_8));
+ expect(zooCache.getChildren(lockPath +
"/q1/hostC:8081")).andReturn(List.of(lock2Name));
+ expect(zooCache.get(eq(lockPath + "/q1/hostC:8081/" + lock2Name),
anyObject(ZcStat.class)))
+ .andReturn(lock2data.getBytes(UTF_8));
+ expect(zooCache.getChildren(lockPath +
"/q2/hostB:9090")).andReturn(List.of(lock3Name));
+ expect(zooCache.get(eq(lockPath + "/q2/hostB:9090/" + lock3Name),
anyObject(ZcStat.class)))
+ .andReturn(lock3data.getBytes(UTF_8));
+ expect(zooCache.getChildren(lockPath +
"/q2/hostD:9091")).andReturn(List.of(lock4Name));
+ expect(zooCache.get(eq(lockPath + "/q2/hostD:9091/" + lock4Name),
anyObject(ZcStat.class)))
+ .andReturn(lock4data.getBytes(UTF_8));
+ expect(zooCache.getChildren(lockPath +
"/q3/deadHost:8080")).andReturn(List.of());
replay(zooCache);
ServiceStatusCmd cmd = new ServiceStatusCmd();
StatusSummary status = cmd.getCompactorStatus(context);
+
LOG.info("compactor group counts: {}", status);
- assertEquals(0, status.getResourceGroups().size());
+ assertEquals(2, status.getResourceGroups().size());
+
+ LOG.info("Live compactor counts: {}", status.getServiceCount());
+ assertEquals(4, status.getServiceCount());
}
@Test