ivandika3 commented on code in PR #9387:
URL: https://github.com/apache/ozone/pull/9387#discussion_r2569501839
##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/HddsServerUtil.java:
##########
@@ -730,4 +732,26 @@ private static String createStartupMessage(VersionInfo
versionInfo,
" conf = " + conf);
}
+ public static void setPoolSize(ThreadPoolExecutor executor, int size, Logger
logger) {
+ Preconditions.assertTrue(size > 0, () -> "Pool size must be positive: " +
size);
+
+ int currentCorePoolSize = executor.getCorePoolSize();
+
+ // In ThreadPoolExecutor, maximumPoolSize must always be greater than or
+ // equal to the corePoolSize. We must make sure this invariant holds when
+ // changing the pool size. Therefore, we take into account whether the
+ // new size is greater or smaller than the current core pool size.
+ String change = "unchanged";
+ if (size > currentCorePoolSize) {
+ change = "increased";
+ executor.setMaximumPoolSize(size);
+ executor.setCorePoolSize(size);
+ } else if (size < currentCorePoolSize) {
+ change = "decreased";
+ executor.setCorePoolSize(size);
+ executor.setMaximumPoolSize(size);
+ }
+ LOG.info("{} pool size {} from {} to {}", logger.getName(), change,
currentCorePoolSize, size);
Review Comment:
Yes, I think using `logger` would be better and we can remove
`logger.getName`. Thanks.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]