Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Drill, mail # dev - [1/8] git commit: DRILL-227: implement simple metrics framework


Copy link to this message
-
[1/8] git commit: DRILL-227: implement simple metrics framework
jacques@... 2013-10-11, 18:50
Updated Branches:
  refs/heads/master 7af77a2f3 -> 251022f84
DRILL-227: implement simple metrics framework
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/82a7b8fd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/82a7b8fd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/82a7b8fd

Branch: refs/heads/master
Commit: 82a7b8fd8300696979dbba62f466a15e23fb94ca
Parents: 7af77a2
Author: Steven Phillips <[EMAIL PROTECTED]>
Authored: Tue Sep 10 16:01:51 2013 -0700
Committer: Steven Phillips <[EMAIL PROTECTED]>
Committed: Fri Sep 20 12:09:50 2013 -0700

----------------------------------------------------------------------
 .../org/apache/drill/exec/ExecConstants.java    |  3 +
 .../apache/drill/exec/metrics/DrillMetrics.java | 67 ++++++++++++++++++++
 .../drill/exec/store/AffinityCalculator.java    | 16 ++---
 .../exec/store/parquet/ParquetGroupScan.java    | 31 +++++++--
 .../src/main/resources/drill-module.conf        |  9 ++-
 exec/java-exec/src/test/sh/logback.xml          |  4 +-
 6 files changed, 113 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/82a7b8fd/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java b/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
index 78d8ac6..42abf54 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/ExecConstants.java
@@ -34,4 +34,7 @@ public interface ExecConstants {
   public static final String METRICS_CONTEXT_NAME = "drill.exec.metrics.context";
   public static final String FUNCTION_PACKAGES = "drill.exec.functions";
   public static final String USE_IP_ADDRESS = "drill.exec.rpc.use.ip";
+  public static final String METRICS_JMX_OUTPUT_ENABLED = "drill.exec.metrics.jmx.enabled";
+  public static final String METRICS_LOG_OUTPUT_ENABLED = "drill.exec.metrics.log.enabled";
+  public static final String METRICS_LOG_OUTPUT_INTERVAL = "drill.exec.metrics.log.interval";
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/82a7b8fd/exec/java-exec/src/main/java/org/apache/drill/exec/metrics/DrillMetrics.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/metrics/DrillMetrics.java b/exec/java-exec/src/main/java/org/apache/drill/exec/metrics/DrillMetrics.java
new file mode 100644
index 0000000..878c088
--- /dev/null
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/metrics/DrillMetrics.java
@@ -0,0 +1,67 @@
+/**
+ * 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.drill.exec.metrics;
+
+import com.yammer.metrics.JmxReporter;
+import com.yammer.metrics.MetricRegistry;
+import com.yammer.metrics.Slf4jReporter;
+import org.apache.drill.common.config.DrillConfig;
+import org.apache.drill.exec.ExecConstants;
+import org.apache.drill.exec.client.DrillClient;
+
+import java.util.concurrent.TimeUnit;
+
+public class DrillMetrics {
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillMetrics.class);
+  static final DrillConfig config = DrillConfig.create();
+
+  private DrillMetrics() {}
+
+  private static class RegistryHolder {
+    public static final MetricRegistry REGISTRY = new MetricRegistry("Drill Metrics");
+    private static JmxReporter jmxReporter = getJmxReporter();
+    private static Slf4jReporter logReporter = getLogReporter();
+
+    private static JmxReporter getJmxReporter() {
+      if (config.getBoolean(ExecConstants.METRICS_JMX_OUTPUT_ENABLED)) {
+        JmxReporter reporter = JmxReporter.forRegistry(getInstance()).build();
+        reporter.start();
+
+        return reporter;
+      } else return null;
+    }
+     private static Slf4jReporter getLogReporter() {
+       if(config.getBoolean(ExecConstants.METRICS_LOG_OUTPUT_ENABLED)) {
+         Slf4jReporter reporter = Slf4jReporter.forRegistry(getInstance())
+                 .outputTo(logger)
+                 .convertRatesTo(TimeUnit.SECONDS)
+                 .convertDurationsTo(TimeUnit.MILLISECONDS)
+                 .build();
+         reporter.start(config.getInt(ExecConstants.METRICS_LOG_OUTPUT_INTERVAL), TimeUnit.SECONDS);
+
+         return reporter;
+       } else return null;
+     }
+  }
+
+  public static MetricRegistry getInstance() {
+    return RegistryHolder.REGISTRY;
+  }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/82a7b8fd/exec/java-exec/src/main/java/org/apache/drill/exec/store/AffinityCalculator.java
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/AffinityCalculator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/AffinityCalculator.java
index 2fffab7..2383463 100644
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/AffinityCalculator.java
@@ -21,6 +21,9 @@ package org.apache.drill.