NealSun96 commented on a change in pull request #973:
URL: https://github.com/apache/helix/pull/973#discussion_r420321054
##########
File path:
helix-core/src/main/java/org/apache/helix/task/TaskStateModelFactory.java
##########
@@ -102,4 +106,73 @@ public boolean isShutdown() {
public boolean isTerminated() {
return _taskExecutor.isTerminated();
}
+
+ /*
+ * Get target thread pool size from InstanceConfig first; if that fails, get
it from
+ * ClusterConfig; if that fails, fall back to the default value.
+ */
+ private int getTaskThreadPoolSize() {
+ ConfigAccessor configAccessor = _manager.getConfigAccessor();
+ // Check instance config first for thread pool size
+ InstanceConfig instanceConfig =
+ configAccessor.getInstanceConfig(_manager.getClusterName(),
_manager.getInstanceName());
+ if (instanceConfig != null) {
+ int targetTaskThreadPoolSize =
instanceConfig.getTargetTaskThreadPoolSize();
+ if (verifyTargetThreadPoolSize(targetTaskThreadPoolSize)) {
+ return targetTaskThreadPoolSize;
+ }
+ }
+
+ // Fallback to cluster config since instance config doesn't provide the
value
+ ClusterConfig clusterConfig =
configAccessor.getClusterConfig(_manager.getClusterName());
+ if (clusterConfig != null) {
+ int targetTaskThreadPoolSize =
clusterConfig.getDefaultTargetTaskThreadPoolSize();
+ if (verifyTargetThreadPoolSize(targetTaskThreadPoolSize)) {
+ return targetTaskThreadPoolSize;
+ }
+ }
+
+ return TaskConstants.DEFAULT_TASK_THREAD_POOL_SIZE;
+ }
+
+ /*
+ * Checks against the default values of -1 when pool sizes are not defined;
we don't want -1's
+ */
+ private static boolean verifyTargetThreadPoolSize(int
targetTaskThreadPoolSize) {
+ return targetTaskThreadPoolSize > 0;
+ }
+
+ /*
+ * Update LiveInstance with the current used thread pool size
+ */
+ private void updateLiveInstanceWithThreadPoolSize(int taskThreadPoolSize) {
Review comment:
This is a good point. Let me think about this.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]