You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2020/08/05 00:17:53 UTC

[GitHub] [hudi] modi95 opened a new pull request #1916: [HUDI-1025] Meter RPC calls in HoodieWrapperFileSystem

modi95 opened a new pull request #1916:
URL: https://github.com/apache/hudi/pull/1916


   ##  What is the purpose of the pull request
   
   This diff adds a lightweight metrics registry (based on codahale metrics) for Hudi Common. Other modules can use this registry to track their metrics as well. The Hudi Client has been modified to collect and emit the metrics from this registry.
   
   
   ## Verify this pull request
   
   This change added tests and can be verified as follows:
   
     - Added unit tests in `org.apache.hudi.common.TestRegistry`. 
     - Verified change using console logger metrics in Hudi Demo Docker.
     - These changes have been tested in production at Uber. 
   
   ## Committer checklist
   
    - [ ] Has a corresponding JIRA in PR title & commit
    
    - [ ] Commit message is descriptive of the change
    
    - [ ] CI is green
   
    - [ ] Necessary doc changes done or have another open PR
          
    - [ ] For large changes, please consider breaking it into sub-tasks under an umbrella JIRA.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [hudi] modi95 commented on pull request #1916: [HUDI-1025] Meter RPC calls in HoodieWrapperFileSystem

Posted by GitBox <gi...@apache.org>.
modi95 commented on pull request #1916:
URL: https://github.com/apache/hudi/pull/1916#issuecomment-673165008


   Updated the diff. Thanks for the review @leesf :D 


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [hudi] leesf commented on a change in pull request #1916: [HUDI-1025] Meter RPC calls in HoodieWrapperFileSystem

Posted by GitBox <gi...@apache.org>.
leesf commented on a change in pull request #1916:
URL: https://github.com/apache/hudi/pull/1916#discussion_r466395899



##########
File path: hudi-common/src/main/java/org/apache/hudi/common/fs/HoodieWrapperFileSystem.java
##########
@@ -64,10 +65,15 @@
 
   public static final String HOODIE_SCHEME_PREFIX = "hoodie-";
 
+  private enum MetricNames {

Review comment:
       MetricName?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [hudi] leesf commented on pull request #1916: [HUDI-1025] Meter RPC calls in HoodieWrapperFileSystem

Posted by GitBox <gi...@apache.org>.
leesf commented on pull request #1916:
URL: https://github.com/apache/hudi/pull/1916#issuecomment-669622104


   > @leesf can you help review this ?
   
   ack, will review today.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [hudi] leesf commented on a change in pull request #1916: [HUDI-1025] Meter RPC calls in HoodieWrapperFileSystem

Posted by GitBox <gi...@apache.org>.
leesf commented on a change in pull request #1916:
URL: https://github.com/apache/hudi/pull/1916#discussion_r466396853



##########
File path: hudi-common/src/main/java/org/apache/hudi/common/metrics/Counter.java
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.hudi.common.metrics;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * Lightweight Counter for Hudi Metrics.
+ */
+public class Counter implements Metric {
+
+  private final AtomicLong count = new AtomicLong();
+
+  public void increment() {
+    this.add(1);
+  }
+
+  public void add(long n) {
+    this.count.addAndGet(n);
+  }
+
+  public Long getValue() {

Review comment:
       missing @Override? 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [hudi] n3nash commented on pull request #1916: [HUDI-1025] Meter RPC calls in HoodieWrapperFileSystem

Posted by GitBox <gi...@apache.org>.
n3nash commented on pull request #1916:
URL: https://github.com/apache/hudi/pull/1916#issuecomment-669285955


   @leesf can you help review this ?


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [hudi] vinothchandar commented on pull request #1916: [HUDI-1025] Meter RPC calls in HoodieWrapperFileSystem

Posted by GitBox <gi...@apache.org>.
vinothchandar commented on pull request #1916:
URL: https://github.com/apache/hudi/pull/1916#issuecomment-673209399


   Seems innocuous. Would not cause conflicts with any blocker PRs per se. We can land if you are comfortable. 
   
   cc @bvaradar notice how CI passes on all the PRs. (udit's presto bootstrap PR also for e.g,) . This branch for e,g has upto the bootstrap PR merge that I did :| .is this some travis/bad box issue,for master branch only?


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [hudi] leesf merged pull request #1916: [HUDI-1025] Meter RPC calls in HoodieWrapperFileSystem

Posted by GitBox <gi...@apache.org>.
leesf merged pull request #1916:
URL: https://github.com/apache/hudi/pull/1916


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [hudi] leesf commented on a change in pull request #1916: [HUDI-1025] Meter RPC calls in HoodieWrapperFileSystem

Posted by GitBox <gi...@apache.org>.
leesf commented on a change in pull request #1916:
URL: https://github.com/apache/hudi/pull/1916#discussion_r466397854



##########
File path: hudi-common/src/main/java/org/apache/hudi/common/metrics/Registry.java
##########
@@ -0,0 +1,104 @@
+/*
+ * 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.hudi.common.metrics;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+/**
+ * Lightweight Metrics Registry to track Hudi events.
+ */
+public class Registry {
+  ConcurrentHashMap<String, Counter> counters = new ConcurrentHashMap<>();
+  final String name;
+
+  private static ConcurrentHashMap<String, Registry> registryMap = new ConcurrentHashMap<>();
+
+  private Registry(String name) {
+    this.name = name;
+  }
+
+  /**
+   * Get (or create) the registry for a provided name.
+   */
+  public static synchronized Registry getRegistry(String registryName) {
+    if (!registryMap.containsKey(registryName)) {
+      registryMap.put(registryName, new Registry(registryName));
+    }
+    return registryMap.get(registryName);
+  }
+
+  /**
+   * Get all registered metrics.
+   * @param flush clean all metrics as part of this operation.
+   * @param prefixWithRegistryName prefix each metric name with the registry name.
+   * @return
+   */
+  public static synchronized Map<String, Long> getAllMetrics(boolean flush, boolean prefixWithRegistryName) {
+    HashMap allMetrics = new HashMap<String, Long>();

Review comment:
       change to HashMap<String, Long> allMetrics = new HashMap<>(); 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [hudi] leesf commented on a change in pull request #1916: [HUDI-1025] Meter RPC calls in HoodieWrapperFileSystem

Posted by GitBox <gi...@apache.org>.
leesf commented on a change in pull request #1916:
URL: https://github.com/apache/hudi/pull/1916#discussion_r466398471



##########
File path: hudi-common/src/main/java/org/apache/hudi/common/metrics/Registry.java
##########
@@ -0,0 +1,104 @@
+/*
+ * 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.hudi.common.metrics;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+/**
+ * Lightweight Metrics Registry to track Hudi events.
+ */
+public class Registry {
+  ConcurrentHashMap<String, Counter> counters = new ConcurrentHashMap<>();
+  final String name;
+
+  private static ConcurrentHashMap<String, Registry> registryMap = new ConcurrentHashMap<>();
+
+  private Registry(String name) {
+    this.name = name;
+  }
+
+  /**
+   * Get (or create) the registry for a provided name.
+   */
+  public static synchronized Registry getRegistry(String registryName) {
+    if (!registryMap.containsKey(registryName)) {
+      registryMap.put(registryName, new Registry(registryName));
+    }
+    return registryMap.get(registryName);
+  }
+
+  /**
+   * Get all registered metrics.
+   * @param flush clean all metrics as part of this operation.
+   * @param prefixWithRegistryName prefix each metric name with the registry name.
+   * @return
+   */
+  public static synchronized Map<String, Long> getAllMetrics(boolean flush, boolean prefixWithRegistryName) {
+    HashMap allMetrics = new HashMap<String, Long>();
+    registryMap.forEach((registryName, registry) -> {
+      allMetrics.putAll(registry.getAllCounts(prefixWithRegistryName));
+      if (flush) {
+        registry.flush();
+      }
+    });
+    return allMetrics;
+  }
+
+  public void flush() {

Review comment:
       would be rename to clear? 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org