architjainjain commented on code in PR #6501:
URL: https://github.com/apache/hive/pull/6501#discussion_r3674397511
##########
common/src/java/org/apache/hadoop/hive/conf/HiveConf.java:
##########
@@ -4006,6 +4006,15 @@ public static enum ConfVars {
HIVE_SERVER2_TEZ_QUEUE_ACCESS_CHECK("hive.server2.tez.queue.access.check",
false,
"Whether to check user access to explicitly specified YARN queues. " +
"yarn.resourcemanager.webapp.address must be configured to use
this."),
+
HIVE_TEZ_QUEUE_METRICS_REFRESH_INTERVAL("hive.tez.queue.metrics.refresh.interval",
"0s",
+ new TimeValidator(TimeUnit.SECONDS),
+ "Interval for refreshing YARN queue resource metrics during Tez query
execution. " +
+ "When set to a positive value (e.g. 10s), displays real-time memory,
vCore, capacity " +
+ "and application metrics for the YARN queue being used. " +
+ "Set to 0 or negative to disable. Minimum effective value is 1
second."),
Review Comment:
done
##########
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/monitoring/yarnqueue/QueueMetricsRefreshPool.java:
##########
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.exec.tez.monitoring.yarnqueue;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * Singleton manager for the JVM-wide refresh executor pool used by queue
metrics collection.
+ * Provides a shared {@link ScheduledExecutorService} that fires periodic YARN
RM refresh tasks
+ * across all queries in the HiveServer2 process.
+ * <p>
+ * Initialized during HiveServer2 startup via {@link #init(int)} when Tez
session pool is set up.
+ * Pool size is configured via {@code
hive.server2.tez.queue.metrics.refresh.threads} (default: 4).
+ * <p>
+ * All {@link YarnQueueMetricsCollector} instances share this single pool,
ensuring efficient
+ * resource usage and preventing thread explosion when many queries run
concurrently.
+ * <p>
+ * Thread-safe singleton implementation using double-check locking pattern.
+ */
+public final class QueueMetricsRefreshPool {
+ private static final Logger LOG =
LoggerFactory.getLogger(QueueMetricsRefreshPool.class);
+
+ private static final int DEFAULT_THREAD_COUNT = 4;
+ public static final int JITTER_PERCENT = 10;
Review Comment:
done
##########
service/src/java/org/apache/hive/service/server/HiveServer2.java:
##########
@@ -966,6 +970,20 @@ private void initAndStartWorkloadManager(final
WMFullResourcePlan resourcePlan)
}
}
+ /**
+ * Initializes the queue metrics refresh pool and HTTP exporter.
+ * Failures are non-fatal — logged as warnings so the server can start
without queue metrics.
+ */
+ private void initializeQueueMetricsPool(HiveConf hiveConf) {
+ try {
+ int refreshThreads =
hiveConf.getIntVar(ConfVars.HIVE_SERVER2_TEZ_QUEUE_METRICS_REFRESH_THREADS);
+ QueueMetricsRefreshPool.init(refreshThreads);
+ LOG.info("Queue metrics refresh pool initialized with {} threads",
refreshThreads);
+ } catch (Exception e) {
+ LOG.warn("Failed to initialize queue metrics refresh pool: {}",
e.getMessage());
+ }
Review Comment:
done
--
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]