This is an automated email from the ASF dual-hosted git repository.
kturner 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 6dc52bc4ee tacks number of accesses to zoocache entry for logging
(#5156)
6dc52bc4ee is described below
commit 6dc52bc4ee703cac23921dc61705c45b6734f93c
Author: Keith Turner <[email protected]>
AuthorDate: Mon Dec 9 18:39:36 2024 -0500
tacks number of accesses to zoocache entry for logging (#5156)
Adds an access count to the trace logging when a zoocache entry is
removed because it was not used recently. This will help find data that
is being stored in zoocache and accessed infrequently which may cause
uneedd watches.
---
.../java/org/apache/accumulo/core/fate/zookeeper/ZcNode.java | 9 +++++++++
.../java/org/apache/accumulo/core/fate/zookeeper/ZooCache.java | 3 ++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git
a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZcNode.java
b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZcNode.java
index bcd2b93872..d4ed3c955b 100644
--- a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZcNode.java
+++ b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZcNode.java
@@ -20,6 +20,7 @@ package org.apache.accumulo.core.fate.zookeeper;
import java.util.List;
import java.util.Objects;
+import java.util.concurrent.atomic.AtomicLong;
import com.google.common.base.Preconditions;
@@ -52,6 +53,8 @@ class ZcNode {
static final ZcNode NON_EXISTENT = new ZcNode();
+ private final AtomicLong accessCount = new AtomicLong(0);
+
private ZcNode() {
this.data = null;
this.stat = null;
@@ -96,6 +99,7 @@ class ZcNode {
*/
byte[] getData() {
Preconditions.checkState(cachedData());
+ accessCount.incrementAndGet();
return data;
}
@@ -116,6 +120,7 @@ class ZcNode {
*/
List<String> getChildren() {
Preconditions.checkState(cachedChildren());
+ accessCount.incrementAndGet();
return children;
}
@@ -139,4 +144,8 @@ class ZcNode {
boolean notExists() {
return stat == null && data == null && children == null;
}
+
+ public long getAccessCount() {
+ return accessCount.get();
+ }
}
diff --git
a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooCache.java
b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooCache.java
index ae8e752b20..596037c1de 100644
--- a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooCache.java
+++ b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooCache.java
@@ -181,7 +181,8 @@ public class ZooCache {
this.externalWatcher = watcher;
RemovalListener<String,ZcNode> removalListerner = (path, zcNode, reason)
-> {
try {
- log.trace("{} removing watches for {} because {}", cacheId, path,
reason);
+ log.trace("{} removing watches for {} because {} accesses {}",
cacheId, path, reason,
+ zcNode == null ? -1 : zcNode.getAccessCount());
reader.getZooKeeper().removeWatches(path, ZooCache.this.watcher,
Watcher.WatcherType.Any,
false);
} catch (InterruptedException | KeeperException | RuntimeException e) {