|
@@ -22,7 +22,9 @@ import static org.apache.hadoop.metrics2.lib.Interns.info;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
+import java.util.HashSet;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.Set;
|
|
|
|
|
|
import org.apache.hadoop.classification.InterfaceAudience;
|
|
import org.apache.hadoop.classification.InterfaceAudience;
|
|
import org.apache.hadoop.classification.InterfaceAudience.Private;
|
|
import org.apache.hadoop.classification.InterfaceAudience.Private;
|
|
@@ -40,12 +42,14 @@ import org.apache.hadoop.metrics2.lib.MutableCounterLong;
|
|
import org.apache.hadoop.metrics2.lib.MutableGaugeInt;
|
|
import org.apache.hadoop.metrics2.lib.MutableGaugeInt;
|
|
import org.apache.hadoop.metrics2.lib.MutableGaugeLong;
|
|
import org.apache.hadoop.metrics2.lib.MutableGaugeLong;
|
|
import org.apache.hadoop.metrics2.lib.MutableRate;
|
|
import org.apache.hadoop.metrics2.lib.MutableRate;
|
|
|
|
+import org.apache.hadoop.util.Sets;
|
|
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
|
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
|
import org.apache.hadoop.yarn.api.records.Resource;
|
|
import org.apache.hadoop.yarn.api.records.Resource;
|
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
import org.apache.hadoop.yarn.metrics.CustomResourceMetricValue;
|
|
import org.apache.hadoop.yarn.metrics.CustomResourceMetricValue;
|
|
import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
|
|
import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
|
|
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
|
|
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
|
|
|
|
+import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppAttemptsInfo;
|
|
import org.apache.hadoop.yarn.util.resource.ResourceUtils;
|
|
import org.apache.hadoop.yarn.util.resource.ResourceUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -133,7 +137,7 @@ public class QueueMetrics implements MetricsSource {
|
|
protected final MetricsRegistry registry;
|
|
protected final MetricsRegistry registry;
|
|
protected final String queueName;
|
|
protected final String queueName;
|
|
private QueueMetrics parent;
|
|
private QueueMetrics parent;
|
|
- private final Queue parentQueue;
|
|
|
|
|
|
+ private Queue parentQueue;
|
|
protected final MetricsSystem metricsSystem;
|
|
protected final MetricsSystem metricsSystem;
|
|
protected final Map<String, QueueMetrics> users;
|
|
protected final Map<String, QueueMetrics> users;
|
|
protected final Configuration conf;
|
|
protected final Configuration conf;
|
|
@@ -177,6 +181,7 @@ public class QueueMetrics implements MetricsSource {
|
|
"AggregatePreemptedSeconds.";
|
|
"AggregatePreemptedSeconds.";
|
|
private static final String AGGREGATE_PREEMPTED_SECONDS_METRIC_DESC =
|
|
private static final String AGGREGATE_PREEMPTED_SECONDS_METRIC_DESC =
|
|
"Aggregate Preempted Seconds for NAME";
|
|
"Aggregate Preempted Seconds for NAME";
|
|
|
|
+ protected Set<String> storedPartitionMetrics = Sets.newConcurrentHashSet();
|
|
|
|
|
|
public QueueMetrics(MetricsSystem ms, String queueName, Queue parent,
|
|
public QueueMetrics(MetricsSystem ms, String queueName, Queue parent,
|
|
boolean enableUserMetrics, Configuration conf) {
|
|
boolean enableUserMetrics, Configuration conf) {
|
|
@@ -338,6 +343,7 @@ public class QueueMetrics implements MetricsSource {
|
|
queueMetrics.tag(PARTITION_INFO, partitionJMXStr).tag(QUEUE_INFO,
|
|
queueMetrics.tag(PARTITION_INFO, partitionJMXStr).tag(QUEUE_INFO,
|
|
this.queueName));
|
|
this.queueName));
|
|
getQueueMetrics().put(metricName, queueMetrics);
|
|
getQueueMetrics().put(metricName, queueMetrics);
|
|
|
|
+ registerPartitionMetricsCreation(metricName);
|
|
return queueMetrics;
|
|
return queueMetrics;
|
|
} else {
|
|
} else {
|
|
return metrics;
|
|
return metrics;
|
|
@@ -380,6 +386,7 @@ public class QueueMetrics implements MetricsSource {
|
|
partitionJMXStr));
|
|
partitionJMXStr));
|
|
}
|
|
}
|
|
getQueueMetrics().put(metricName, metrics);
|
|
getQueueMetrics().put(metricName, metrics);
|
|
|
|
+ registerPartitionMetricsCreation(metricName);
|
|
}
|
|
}
|
|
return metrics;
|
|
return metrics;
|
|
}
|
|
}
|
|
@@ -1332,4 +1339,26 @@ public class QueueMetrics implements MetricsSource {
|
|
public Queue getParentQueue() {
|
|
public Queue getParentQueue() {
|
|
return parentQueue;
|
|
return parentQueue;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ protected void registerPartitionMetricsCreation(String metricName) {
|
|
|
|
+ if (storedPartitionMetrics != null) {
|
|
|
|
+ storedPartitionMetrics.add(metricName);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setParentQueue(Queue parentQueue) {
|
|
|
|
+ this.parentQueue = parentQueue;
|
|
|
|
+
|
|
|
|
+ if (storedPartitionMetrics == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (String partitionMetric : storedPartitionMetrics) {
|
|
|
|
+ QueueMetrics metric = getQueueMetrics().get(partitionMetric);
|
|
|
|
+
|
|
|
|
+ if (metric != null && metric.parentQueue != null) {
|
|
|
|
+ metric.parentQueue = parentQueue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|