architjainjain commented on code in PR #6501:
URL: https://github.com/apache/hive/pull/6501#discussion_r3713614674
##########
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/monitoring/TezJobMonitor.java:
##########
@@ -144,6 +153,99 @@ private RenderStrategy.UpdateFunction updateFunction() {
: new RenderStrategy.LogToFileFunction(this, perfLogger);
}
+ /**
+ * Initializes the YARN queue metrics collector based on configuration.
+ *
+ * <p>This method implements the Null Object pattern - it always returns a
non-null collector.
+ * When metrics collection is disabled or initialization fails, a no-op
collector is returned.
+ *
+ * <p>Metrics collection requires:
+ * <ul>
+ * <li>Positive {@link ConfVars#HIVE_TEZ_QUEUE_METRICS_REFRESH_INTERVAL}
value</li>
+ * <li>Available {@link YarnClient} from Tez session</li>
+ * </ul>
+ *
+ * <p>The refresh interval is validated against {@value
#MIN_QUEUE_METRICS_REFRESH_INTERVAL_MS}ms minimum.
+ * Thread pool management is delegated to {@link QueueMetricsRefreshPool}.
+ *
+ * @return {@link YarnQueueMetricsCollector} if enabled, otherwise {@link
NoOpQueueMetricsCollector#INSTANCE}.
+ * Never returns null.
+ * @see #getValidatedRefreshInterval()
+ * @see #getValidatedQueueName()
+ */
+ private QueueMetricsCollector initializeMetricsCollector() {
+
+ try {
+ // Get and validate refresh interval
+ long refreshInterval = getValidatedRefreshInterval();
+ if (refreshInterval <= 0) {
+ return NoOpQueueMetricsCollector.INSTANCE;
+ }
+
+ // Get YarnClient from session
+ YarnClient yarnClient = session.getYarnClient();
+ if (yarnClient == null) {
+ LOG.warn("YarnClient not available, skipping queue metrics
collection");
+ return NoOpQueueMetricsCollector.INSTANCE;
+ }
+
+ // Get queue name, default to "default" if not specified
+ String queueName = getValidatedQueueName();
+
+ // Get query ID from DAG name
+ String queryId = dag.getName();
+
+ LOG.info("Initializing YARN queue metrics collector for queue: {},
refresh interval: {}ms",
+ queueName, refreshInterval);
+
+ // Pool sizing (topology computation) is delegated to
QueueMetricsRefreshPool.
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]