architjainjain commented on code in PR #6501: URL: https://github.com/apache/hive/pull/6501#discussion_r3713524233
########## ql/src/java/org/apache/hadoop/hive/ql/exec/tez/monitoring/yarnqueue/YarnQueueMetricsCollector.java: ########## @@ -0,0 +1,204 @@ +/* + * 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 org.apache.hadoop.hive.conf.HiveConf; +import org.apache.hadoop.yarn.api.records.QueueInfo; +import org.apache.hadoop.yarn.client.api.YarnClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * Collects YARN queue resource metrics using a shared cache to reduce ResourceManager load. + * Coordinates with other collectors via QueueMetricsCache to prevent duplicate RM calls. + * + * Executor pool management (sizing, lifecycle, JMX) is fully delegated to + * {@link QueueMetricsRefreshPool}. This class focuses solely on per-query/per-queue + * metrics logic: session registration, refresh scheduling, and cache coordination. + */ +public class YarnQueueMetricsCollector implements QueueMetricsCollector { + private static final Logger LOG = LoggerFactory.getLogger(YarnQueueMetricsCollector.class); + + private final YarnClient yarnClient; + private final String queueName; + private final long refreshIntervalMs; + private final String queryId; + + + /** + * Creates a collector for the given queue and query. Non-blocking: metrics are + * fetched asynchronously; the first progress update may show no metrics, subsequent + * updates will once the first fetch completes (within one refreshIntervalMs). + * + * @param yarnClient Live YarnClient from the Tez session + * @param queueName YARN queue this query runs on + * @param refreshIntervalMs How often to poll YARN RM (ms) + * @param queryId DAG name for logging + * @param hiveConf Unused (kept for API compatibility) + */ + public YarnQueueMetricsCollector(YarnClient yarnClient, String queueName, long refreshIntervalMs, String queryId, + HiveConf hiveConf) { + if (yarnClient == null) { + throw new IllegalArgumentException("YarnClient cannot be null"); + } + if (queueName == null) { + throw new IllegalArgumentException("Queue name cannot be null"); + } + if (refreshIntervalMs <= 0) { + throw new IllegalArgumentException("refreshIntervalMs must be > 0, got: " + refreshIntervalMs); + } + + this.yarnClient = yarnClient; + this.queueName = queueName; + this.refreshIntervalMs = refreshIntervalMs; + this.queryId = queryId; + + 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]
