tez-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rbalamo...@apache.org
Subject git commit: TEZ-1515. DAGAppMaster : Thread contentions due to org.apache.tez.common.counters.ResourceBundles
Date Sun, 31 Aug 2014 09:32:56 GMT
Repository: tez
Updated Branches:
  refs/heads/master 0f8d2dc05 -> 8e9ee5653


TEZ-1515. DAGAppMaster : Thread contentions due to org.apache.tez.common.counters.ResourceBundles


Project: http://git-wip-us.apache.org/repos/asf/tez/repo
Commit: http://git-wip-us.apache.org/repos/asf/tez/commit/8e9ee565
Tree: http://git-wip-us.apache.org/repos/asf/tez/tree/8e9ee565
Diff: http://git-wip-us.apache.org/repos/asf/tez/diff/8e9ee565

Branch: refs/heads/master
Commit: 8e9ee5653781474a22d9e012c88be2b100c3bab7
Parents: 0f8d2dc
Author: Rajesh Balamohan <rbalamohan@apache.org>
Authored: Sun Aug 31 15:02:24 2014 +0530
Committer: Rajesh Balamohan <rbalamohan@apache.org>
Committed: Sun Aug 31 15:02:24 2014 +0530

----------------------------------------------------------------------
 .../common/counters/AbstractCounterGroup.java   |  4 +-
 .../common/counters/CounterGroupFactory.java    |  3 +-
 .../common/counters/FileSystemCounterGroup.java | 14 +--
 .../common/counters/FrameworkCounterGroup.java  |  5 +-
 .../tez/common/counters/ResourceBundles.java    | 96 --------------------
 5 files changed, 7 insertions(+), 115 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tez/blob/8e9ee565/tez-api/src/main/java/org/apache/tez/common/counters/AbstractCounterGroup.java
----------------------------------------------------------------------
diff --git a/tez-api/src/main/java/org/apache/tez/common/counters/AbstractCounterGroup.java
b/tez-api/src/main/java/org/apache/tez/common/counters/AbstractCounterGroup.java
index e9a291b..7e791d7 100644
--- a/tez-api/src/main/java/org/apache/tez/common/counters/AbstractCounterGroup.java
+++ b/tez-api/src/main/java/org/apache/tez/common/counters/AbstractCounterGroup.java
@@ -115,9 +115,7 @@ public abstract class AbstractCounterGroup<T extends TezCounter>
   private synchronized T findCounterImpl(String counterName, boolean create) {
     T counter = counters.get(counterName);
     if (counter == null && create) {
-      String localized =
-          ResourceBundles.getCounterName(getName(), counterName, counterName);
-      return addCounterImpl(counterName, localized, 0);
+      return addCounterImpl(counterName, counterName, 0);
     }
     return counter;
   }

http://git-wip-us.apache.org/repos/asf/tez/blob/8e9ee565/tez-api/src/main/java/org/apache/tez/common/counters/CounterGroupFactory.java
----------------------------------------------------------------------
diff --git a/tez-api/src/main/java/org/apache/tez/common/counters/CounterGroupFactory.java
b/tez-api/src/main/java/org/apache/tez/common/counters/CounterGroupFactory.java
index 45da0dd..ee9b45f 100644
--- a/tez-api/src/main/java/org/apache/tez/common/counters/CounterGroupFactory.java
+++ b/tez-api/src/main/java/org/apache/tez/common/counters/CounterGroupFactory.java
@@ -87,8 +87,7 @@ public abstract class CounterGroupFactory<C extends TezCounter,
    * @return a new counter group
    */
   public G newGroup(String name, Limits limits) {
-    return newGroup(name, ResourceBundles.getCounterGroupName(name, name),
-                    limits);
+    return newGroup(name, name, limits);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/tez/blob/8e9ee565/tez-api/src/main/java/org/apache/tez/common/counters/FileSystemCounterGroup.java
----------------------------------------------------------------------
diff --git a/tez-api/src/main/java/org/apache/tez/common/counters/FileSystemCounterGroup.java
b/tez-api/src/main/java/org/apache/tez/common/counters/FileSystemCounterGroup.java
index bb2dc8b..2186c2c 100644
--- a/tez-api/src/main/java/org/apache/tez/common/counters/FileSystemCounterGroup.java
+++ b/tez-api/src/main/java/org/apache/tez/common/counters/FileSystemCounterGroup.java
@@ -54,10 +54,9 @@ public abstract class FileSystemCounterGroup<C extends TezCounter>
   // Just a few local casts probably worth not having to carry it around.
   private final Map<String, Object[]> map =
     new ConcurrentSkipListMap<String, Object[]>();
-  private String displayName;
+  private String displayName = "File System Counters";
 
   private static final Joiner NAME_JOINER = Joiner.on('_');
-  private static final Joiner DISP_JOINER = Joiner.on(": ");
 
   @InterfaceAudience.Private
   public static class FSCounter extends AbstractCounter {
@@ -77,12 +76,7 @@ public abstract class FileSystemCounterGroup<C extends TezCounter>
 
     @Override
     public String getDisplayName() {
-      return DISP_JOINER.join(scheme, localizeCounterName(key.name()));
-    }
-
-    protected String localizeCounterName(String counterName) {
-      return ResourceBundles.getCounterName(FileSystemCounter.class.getName(),
-                                            counterName, counterName);
+      return key.name();
     }
 
     @Override
@@ -123,10 +117,6 @@ public abstract class FileSystemCounterGroup<C extends TezCounter>
 
   @Override
   public String getDisplayName() {
-    if (displayName == null) {
-      displayName = ResourceBundles.getCounterGroupName(getName(),
-          "File System Counters");
-    }
     return displayName;
   }
 

http://git-wip-us.apache.org/repos/asf/tez/blob/8e9ee565/tez-api/src/main/java/org/apache/tez/common/counters/FrameworkCounterGroup.java
----------------------------------------------------------------------
diff --git a/tez-api/src/main/java/org/apache/tez/common/counters/FrameworkCounterGroup.java
b/tez-api/src/main/java/org/apache/tez/common/counters/FrameworkCounterGroup.java
index a99e5a4..66b6e33 100644
--- a/tez-api/src/main/java/org/apache/tez/common/counters/FrameworkCounterGroup.java
+++ b/tez-api/src/main/java/org/apache/tez/common/counters/FrameworkCounterGroup.java
@@ -26,6 +26,7 @@ import java.io.IOException;
 import java.util.Arrays;
 import java.util.Iterator;
 
+import com.google.common.base.Joiner;
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.io.WritableUtils;
 
@@ -69,7 +70,7 @@ public abstract class FrameworkCounterGroup<T extends Enum<T>,
 
     @Override
     public String getDisplayName() {
-      return ResourceBundles.getCounterName(groupName, getName(), getName());
+      return getName();
     }
 
     @Override
@@ -117,7 +118,7 @@ public abstract class FrameworkCounterGroup<T extends Enum<T>,
   @Override
   public String getDisplayName() {
     if (displayName == null) {
-      displayName = ResourceBundles.getCounterGroupName(getName(), getName());
+      displayName = getName();
     }
     return displayName;
   }

http://git-wip-us.apache.org/repos/asf/tez/blob/8e9ee565/tez-api/src/main/java/org/apache/tez/common/counters/ResourceBundles.java
----------------------------------------------------------------------
diff --git a/tez-api/src/main/java/org/apache/tez/common/counters/ResourceBundles.java b/tez-api/src/main/java/org/apache/tez/common/counters/ResourceBundles.java
deleted file mode 100644
index 1742645..0000000
--- a/tez-api/src/main/java/org/apache/tez/common/counters/ResourceBundles.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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.tez.common.counters;
-
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-import org.apache.hadoop.classification.InterfaceAudience.Private;
-
-/**
- * Helper class to handle resource bundles in a saner way
- */
-@Private
-public class ResourceBundles {
-
-  /**
-   * Get a resource bundle
-   * @param bundleName of the resource
-   * @return the resource bundle
-   * @throws MissingResourceException
-   */
-  public static ResourceBundle getBundle(String bundleName) {
-    return ResourceBundle.getBundle(bundleName.replace('$', '_'),
-        Locale.getDefault(), Thread.currentThread().getContextClassLoader());
-  }
-
-  /**
-   * Get a resource given bundle name and key
-   * @param <T> type of the resource
-   * @param bundleName name of the resource bundle
-   * @param key to lookup the resource
-   * @param suffix for the key to lookup
-   * @param defaultValue of the resource
-   * @return the resource or the defaultValue
-   * @throws ClassCastException if the resource found doesn't match T
-   */
-  @SuppressWarnings("unchecked")
-  public static synchronized <T> T getValue(String bundleName, String key,
-                                            String suffix, T defaultValue) {
-    T value;
-    try {
-      ResourceBundle bundle = getBundle(bundleName);
-      value = (T) bundle.getObject(getLookupKey(key, suffix));
-      if (value != null) {
-        return value;
-      }
-    }
-    catch (Exception e) {
-      // Ignore
-    }
-    return defaultValue;
-  }
-
-  private static String getLookupKey(String key, String suffix) {
-    if (suffix == null || suffix.isEmpty()) return key;
-    return key + suffix;
-  }
-
-  /**
-   * Get the counter group display name
-   * @param group the group name to lookup
-   * @param defaultValue of the group
-   * @return the group display name
-   */
-  public static String getCounterGroupName(String group, String defaultValue) {
-    return getValue(group, "CounterGroupName", "", defaultValue);
-  }
-
-  /**
-   * Get the counter display name
-   * @param group the counter group name for the counter
-   * @param counter the counter name to lookup
-   * @param defaultValue of the counter
-   * @return the counter display name
-   */
-  public static String getCounterName(String group, String counter,
-                                      String defaultValue) {
-    return getValue(group, counter, ".name", defaultValue);
-  }
-}


Mime
View raw message