hadoop-yarn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ka...@apache.org
Subject svn commit: r1616784 - /hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSOpDurations.java
Date Fri, 08 Aug 2014 14:38:18 GMT
Author: kasha
Date: Fri Aug  8 14:38:18 2014
New Revision: 1616784

URL: http://svn.apache.org/r1616784
Log:
YARN-2352. Add missing file. FairScheduler: Collect metrics on duration of critical methods
that affect performance. (kasha)

Added:
    hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSOpDurations.java

Added: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSOpDurations.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSOpDurations.java?rev=1616784&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSOpDurations.java
(added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSOpDurations.java
Fri Aug  8 14:38:18 2014
@@ -0,0 +1,119 @@
+/**
+ * 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.yarn.server.resourcemanager.scheduler.fair;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.metrics2.MetricsCollector;
+import org.apache.hadoop.metrics2.MetricsInfo;
+import org.apache.hadoop.metrics2.MetricsSource;
+import org.apache.hadoop.metrics2.MetricsSystem;
+import org.apache.hadoop.metrics2.annotation.Metric;
+import org.apache.hadoop.metrics2.annotation.Metrics;
+import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
+import org.apache.hadoop.metrics2.lib.MetricsRegistry;
+
+import static org.apache.hadoop.metrics2.lib.Interns.info;
+import org.apache.hadoop.metrics2.lib.MutableRate;
+
+/**
+ * Class to capture the performance metrics of FairScheduler.
+ * This should be a singleton.
+ */
+@InterfaceAudience.Private
+@InterfaceStability.Unstable
+@Metrics(context="fairscheduler-op-durations")
+public class FSOpDurations implements MetricsSource {
+
+  @Metric("Duration for a continuous scheduling run")
+  MutableRate continuousSchedulingRun;
+
+  @Metric("Duration to handle a node update")
+  MutableRate nodeUpdateCall;
+
+  @Metric("Duration for a update thread run")
+  MutableRate updateThreadRun;
+
+  @Metric("Duration for an update call")
+  MutableRate updateCall;
+
+  @Metric("Duration for a preempt call")
+  MutableRate preemptCall;
+
+  private static final MetricsInfo RECORD_INFO =
+      info("FSOpDurations", "Durations of FairScheduler calls or thread-runs");
+
+  private final MetricsRegistry registry;
+
+  private boolean isExtended = false;
+
+  private static final FSOpDurations INSTANCE = new FSOpDurations();
+
+  public static FSOpDurations getInstance(boolean isExtended) {
+    INSTANCE.setExtended(isExtended);
+    return INSTANCE;
+  }
+
+  private FSOpDurations() {
+    registry = new MetricsRegistry(RECORD_INFO);
+    registry.tag(RECORD_INFO, "FSOpDurations");
+
+    MetricsSystem ms = DefaultMetricsSystem.instance();
+    if (ms != null) {
+      ms.register(RECORD_INFO.name(), RECORD_INFO.description(), this);
+    }
+  }
+
+  private synchronized void setExtended(boolean isExtended) {
+    if (isExtended == INSTANCE.isExtended)
+      return;
+
+    continuousSchedulingRun.setExtended(isExtended);
+    nodeUpdateCall.setExtended(isExtended);
+    updateThreadRun.setExtended(isExtended);
+    updateCall.setExtended(isExtended);
+    preemptCall.setExtended(isExtended);
+
+    INSTANCE.isExtended = isExtended;
+  }
+
+  @Override
+  public synchronized void getMetrics(MetricsCollector collector, boolean all) {
+    registry.snapshot(collector.addRecord(registry.info()), all);
+  }
+
+  public void addContinuousSchedulingRunDuration(long value) {
+    continuousSchedulingRun.add(value);
+  }
+
+  public void addNodeUpdateDuration(long value) {
+    nodeUpdateCall.add(value);
+  }
+
+  public void addUpdateThreadRunDuration(long value) {
+    updateThreadRun.add(value);
+  }
+
+  public void addUpdateCallDuration(long value) {
+    updateCall.add(value);
+  }
+
+  public void addPreemptCallDuration(long value) {
+    preemptCall.add(value);
+  }
+}



Mime
View raw message