You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "dlmarion (via GitHub)" <gi...@apache.org> on 2025/05/30 19:34:18 UTC
[PR] Disable metrics for thread pools when metrics disabled [accumulo]
dlmarion opened a new pull request, #5605:
URL: https://github.com/apache/accumulo/pull/5605
Metrics were being registered and emittied for thread pools regardless of the metrics property setting. Added a mechanism to disable metrics collection for thread pools when the property is false.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable metrics for thread pools when metrics disabled [accumulo]
Posted by "ddanielr (via GitHub)" <gi...@apache.org>.
ddanielr commented on code in PR #5605:
URL: https://github.com/apache/accumulo/pull/5605#discussion_r2121762665
##########
core/src/main/java/org/apache/accumulo/core/util/threads/ThreadPools.java:
##########
@@ -743,4 +753,15 @@ public void setMeterRegistry(MeterRegistry r) {
}
}
+ /**
+ * Called by MetricsInfoImpl.init on the server side if metrics are disabled. ClientContext calls
+ * {@code #getClientThreadPools(AccumuloConfiguration, UncaughtExceptionHandler)} above.
+ */
+ public void disableThreadPoolMetrics() {
+ metricsEnabled.set(false);
+ synchronized (earlyExecutorServices) {
+ earlyExecutorServices.clear();
Review Comment:
Should this clear also get added on line 750 after all the metrics are added from the list?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable metrics for thread pools when metrics disabled [accumulo]
Posted by "dlmarion (via GitHub)" <gi...@apache.org>.
dlmarion commented on code in PR #5605:
URL: https://github.com/apache/accumulo/pull/5605#discussion_r2121780920
##########
core/src/main/java/org/apache/accumulo/core/util/threads/ThreadPools.java:
##########
@@ -743,4 +753,15 @@ public void setMeterRegistry(MeterRegistry r) {
}
}
+ /**
+ * Called by MetricsInfoImpl.init on the server side if metrics are disabled. ClientContext calls
+ * {@code #getClientThreadPools(AccumuloConfiguration, UncaughtExceptionHandler)} above.
+ */
+ public void disableThreadPoolMetrics() {
+ metricsEnabled.set(false);
+ synchronized (earlyExecutorServices) {
+ earlyExecutorServices.clear();
Review Comment:
Yes, I have already merged, but I can add this in another PR. Good catch!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable metrics for thread pools when metrics disabled [accumulo]
Posted by "dlmarion (via GitHub)" <gi...@apache.org>.
dlmarion merged PR #5605:
URL: https://github.com/apache/accumulo/pull/5605
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable metrics for thread pools when metrics disabled [accumulo]
Posted by "dlmarion (via GitHub)" <gi...@apache.org>.
dlmarion commented on code in PR #5605:
URL: https://github.com/apache/accumulo/pull/5605#discussion_r2121817196
##########
core/src/main/java/org/apache/accumulo/core/util/threads/ThreadPools.java:
##########
@@ -743,4 +753,15 @@ public void setMeterRegistry(MeterRegistry r) {
}
}
+ /**
+ * Called by MetricsInfoImpl.init on the server side if metrics are disabled. ClientContext calls
+ * {@code #getClientThreadPools(AccumuloConfiguration, UncaughtExceptionHandler)} above.
+ */
+ public void disableThreadPoolMetrics() {
+ metricsEnabled.set(false);
+ synchronized (earlyExecutorServices) {
+ earlyExecutorServices.clear();
Review Comment:
Created #5610
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable metrics for thread pools when metrics disabled [accumulo]
Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #5605:
URL: https://github.com/apache/accumulo/pull/5605#discussion_r2116595258
##########
core/src/main/java/org/apache/accumulo/core/classloader/DefaultContextClassLoaderFactory.java:
##########
@@ -74,7 +74,7 @@ private static void setContextConfig(Supplier<Map<String,String>> contextConfigS
private static void startCleanupThread(final AccumuloConfiguration conf,
final Supplier<Map<String,String>> contextConfigSupplier) {
ScheduledFuture<?> future =
- ((ScheduledThreadPoolExecutor) ThreadPools.getClientThreadPools((t, e) -> {
+ ((ScheduledThreadPoolExecutor) ThreadPools.getClientThreadPools(conf, (t, e) -> {
Review Comment:
This code could call `context.threadPools()` if the context were passed down instead of a configuration object. Not sure if that is possible though. Was wondering if this code does things a bit differently than all other code, like maybe all other code will get the thread pools object from the context?
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java:
##########
@@ -242,11 +242,11 @@ public ClientContext(SingletonReservation reservation, ClientInfo info,
} else {
// Provide a default UEH that just logs the error
if (ueh == null) {
- clientThreadPools = ThreadPools.getClientThreadPools((t, e) -> {
+ clientThreadPools = ThreadPools.getClientThreadPools(serverConf, (t, e) -> {
Review Comment:
Wondering if this should call `getConfiguration()` because ServerContext overrides this method.
```suggestion
clientThreadPools = ThreadPools.getClientThreadPools(getConfiguration(), (t, e) -> {
```
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java:
##########
@@ -242,11 +242,11 @@ public ClientContext(SingletonReservation reservation, ClientInfo info,
} else {
// Provide a default UEH that just logs the error
if (ueh == null) {
- clientThreadPools = ThreadPools.getClientThreadPools((t, e) -> {
+ clientThreadPools = ThreadPools.getClientThreadPools(serverConf, (t, e) -> {
log.error("Caught an Exception in client background thread: {}. Thread is dead.", t, e);
});
} else {
- clientThreadPools = ThreadPools.getClientThreadPools(ueh);
+ clientThreadPools = ThreadPools.getClientThreadPools(serverConf, ueh);
Review Comment:
Same question here.
```suggestion
clientThreadPools = ThreadPools.getClientThreadPools(getConfiguration(), ueh);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable metrics for thread pools when metrics disabled [accumulo]
Posted by "dlmarion (via GitHub)" <gi...@apache.org>.
dlmarion commented on code in PR #5605:
URL: https://github.com/apache/accumulo/pull/5605#discussion_r2121462812
##########
core/src/main/java/org/apache/accumulo/core/classloader/DefaultContextClassLoaderFactory.java:
##########
@@ -74,7 +74,7 @@ private static void setContextConfig(Supplier<Map<String,String>> contextConfigS
private static void startCleanupThread(final AccumuloConfiguration conf,
final Supplier<Map<String,String>> contextConfigSupplier) {
ScheduledFuture<?> future =
- ((ScheduledThreadPoolExecutor) ThreadPools.getClientThreadPools((t, e) -> {
+ ((ScheduledThreadPoolExecutor) ThreadPools.getClientThreadPools(conf, (t, e) -> {
Review Comment:
This implements `org.apache.accumulo.core.spi.common.ContextClassLoaderFactory`, part of the SPI, so can't push down the context.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable metrics for thread pools when metrics disabled [accumulo]
Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #5605:
URL: https://github.com/apache/accumulo/pull/5605#discussion_r2121542344
##########
core/src/main/java/org/apache/accumulo/core/classloader/DefaultContextClassLoaderFactory.java:
##########
@@ -74,7 +74,7 @@ private static void setContextConfig(Supplier<Map<String,String>> contextConfigS
private static void startCleanupThread(final AccumuloConfiguration conf,
final Supplier<Map<String,String>> contextConfigSupplier) {
ScheduledFuture<?> future =
- ((ScheduledThreadPoolExecutor) ThreadPools.getClientThreadPools((t, e) -> {
+ ((ScheduledThreadPoolExecutor) ThreadPools.getClientThreadPools(conf, (t, e) -> {
Review Comment:
Its probably okay in this case because the DefaultContextClassLoaderFactory class is not in an SPI or API package. Its constructor already takes a non public AccumuloConfiguration type. As long the change do not require a change to the interface it implements it seems ok.
##########
core/src/main/java/org/apache/accumulo/core/classloader/DefaultContextClassLoaderFactory.java:
##########
@@ -74,7 +74,7 @@ private static void setContextConfig(Supplier<Map<String,String>> contextConfigS
private static void startCleanupThread(final AccumuloConfiguration conf,
final Supplier<Map<String,String>> contextConfigSupplier) {
ScheduledFuture<?> future =
- ((ScheduledThreadPoolExecutor) ThreadPools.getClientThreadPools((t, e) -> {
+ ((ScheduledThreadPoolExecutor) ThreadPools.getClientThreadPools(conf, (t, e) -> {
Review Comment:
Its probably okay in this case because the DefaultContextClassLoaderFactory class is not in an SPI or API package. Its constructor already takes a non public AccumuloConfiguration type. As long the change does not require a change to the interface it implements it seems ok.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable metrics for thread pools when metrics disabled [accumulo]
Posted by "dlmarion (via GitHub)" <gi...@apache.org>.
dlmarion commented on code in PR #5605:
URL: https://github.com/apache/accumulo/pull/5605#discussion_r2121575986
##########
core/src/main/java/org/apache/accumulo/core/classloader/DefaultContextClassLoaderFactory.java:
##########
@@ -74,7 +74,7 @@ private static void setContextConfig(Supplier<Map<String,String>> contextConfigS
private static void startCleanupThread(final AccumuloConfiguration conf,
final Supplier<Map<String,String>> contextConfigSupplier) {
ScheduledFuture<?> future =
- ((ScheduledThreadPoolExecutor) ThreadPools.getClientThreadPools((t, e) -> {
+ ((ScheduledThreadPoolExecutor) ThreadPools.getClientThreadPools(conf, (t, e) -> {
Review Comment:
This also uses a custom UncaughtExceptionHandler, which can't be set when calling `context.threadPools`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable metrics for thread pools when metrics disabled [accumulo]
Posted by "dlmarion (via GitHub)" <gi...@apache.org>.
dlmarion commented on code in PR #5605:
URL: https://github.com/apache/accumulo/pull/5605#discussion_r2121513632
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java:
##########
@@ -242,11 +242,11 @@ public ClientContext(SingletonReservation reservation, ClientInfo info,
} else {
// Provide a default UEH that just logs the error
if (ueh == null) {
- clientThreadPools = ThreadPools.getClientThreadPools((t, e) -> {
+ clientThreadPools = ThreadPools.getClientThreadPools(serverConf, (t, e) -> {
Review Comment:
I had to revert these changes at they caused Spotbugs to fail with:
```
[ERROR] High: serverConfFactory isn't initialized in org.apache.accumulo.server.ServerContext.getConfiguration() when invoked from constructor for superclass [org.apache.accumulo.core.clientImpl.ClientContext, org.apache.accumulo.server.ServerContext, org.apache.accumulo.server.ServerContext] Call from superclass constructor at ClientContext.java:[line 249]Field set (too late) at ServerContext.java:[line 122]At ServerContext.java:[line 162] UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Disable metrics for thread pools when metrics disabled [accumulo]
Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii commented on code in PR #5605:
URL: https://github.com/apache/accumulo/pull/5605#discussion_r2129777116
##########
core/src/main/java/org/apache/accumulo/core/util/threads/ThreadPools.java:
##########
@@ -99,9 +100,14 @@ public static final ThreadPools getServerThreadPools() {
return SERVER_INSTANCE;
}
- public static final ThreadPools getClientThreadPools(UncaughtExceptionHandler ueh) {
+ public static final ThreadPools getClientThreadPools(AccumuloConfiguration conf,
+ UncaughtExceptionHandler ueh) {
ThreadPools clientPools = new ThreadPools(ueh);
- clientPools.setMeterRegistry(Metrics.globalRegistry);
+ if (conf.getBoolean(Property.GENERAL_MICROMETER_ENABLED) == false) {
+ clientPools.disableThreadPoolMetrics();
+ } else {
+ clientPools.setMeterRegistry(Metrics.globalRegistry);
+ }
Review Comment:
To improve readability, this could be written as:
```java
if (conf.getBoolean(Property.GENERAL_MICROMETER_ENABLED)) {
clientPools.setMeterRegistry(Metrics.globalRegistry);
} else {
clientPools.disableThreadPoolMetrics();
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org