You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@reef.apache.org by we...@apache.org on 2014/11/14 18:57:15 UTC

incubator-reef git commit: [REEF-40] Replace trivial Guava uses

Repository: incubator-reef
Updated Branches:
  refs/heads/master 3ae9a3a0d -> 9bf956cdb


[REEF-40] Replace trivial Guava uses

  * Replace Guava code with equivalent Apache Commons in LoggingScope.
  * Remove unnecessary imports.
  * Replace Guava ImmutableSet with unmodifiableSet on LinkedHashSet
    shallow copy.

The code was written by Brian (Sunghoon) Cho <ch...@gmail.com>

Closes #16


Project: http://git-wip-us.apache.org/repos/asf/incubator-reef/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-reef/commit/9bf956cd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-reef/tree/9bf956cd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-reef/diff/9bf956cd

Branch: refs/heads/master
Commit: 9bf956cdb0c6ccb40d7bf7884eb3f684ecc87567
Parents: 3ae9a3a
Author: Brian (Sunghoon) Cho <ch...@gmail.com>
Authored: Thu Nov 13 18:05:59 2014 +0900
Committer: Markus Weimer <we...@apache.org>
Committed: Fri Nov 14 09:33:02 2014 -0800

----------------------------------------------------------------------
 pom.xml                                                   |  5 +++++
 reef-common/pom.xml                                       |  4 ++++
 .../common/evaluator/context/ContextLifeCycle.java        |  5 +++--
 .../java/org/apache/reef/util/logging/LoggingScope.java   |  4 ----
 .../org/apache/reef/util/logging/LoggingScopeImpl.java    | 10 +++-------
 5 files changed, 15 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/9bf956cd/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index f7c26bb..bad6169 100644
--- a/pom.xml
+++ b/pom.xml
@@ -449,6 +449,11 @@ under the License.
                 <artifactId>commons-math3</artifactId>
                 <version>3.3</version>
             </dependency>
+            <dependency>
+                <groupId>org.apache.commons</groupId>
+                <artifactId>commons-lang3</artifactId>
+                <version>3.3.2</version>
+            </dependency>
             <!-- End of Apache Commons -->
 
             <!-- AVRO -->

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/9bf956cd/reef-common/pom.xml
----------------------------------------------------------------------
diff --git a/reef-common/pom.xml b/reef-common/pom.xml
index a9a9000..eb9549d 100644
--- a/reef-common/pom.xml
+++ b/reef-common/pom.xml
@@ -117,6 +117,10 @@ under the License.
             <groupId>net.jcip</groupId>
             <artifactId>jcip-annotations</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+        </dependency>
     </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/9bf956cd/reef-common/src/main/java/org/apache/reef/runtime/common/evaluator/context/ContextLifeCycle.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/runtime/common/evaluator/context/ContextLifeCycle.java b/reef-common/src/main/java/org/apache/reef/runtime/common/evaluator/context/ContextLifeCycle.java
index c110d3e..586ef89 100644
--- a/reef-common/src/main/java/org/apache/reef/runtime/common/evaluator/context/ContextLifeCycle.java
+++ b/reef-common/src/main/java/org/apache/reef/runtime/common/evaluator/context/ContextLifeCycle.java
@@ -18,7 +18,6 @@
  */
 package org.apache.reef.runtime.common.evaluator.context;
 
-import com.google.common.collect.ImmutableSet;
 import org.apache.reef.evaluator.context.ContextMessageSource;
 import org.apache.reef.evaluator.context.events.ContextStart;
 import org.apache.reef.evaluator.context.events.ContextStop;
@@ -28,6 +27,8 @@ import org.apache.reef.tang.annotations.Parameter;
 import org.apache.reef.wake.EventHandler;
 
 import javax.inject.Inject;
+import java.util.Collections;
+import java.util.LinkedHashSet;
 import java.util.Set;
 
 /**
@@ -87,7 +88,7 @@ final class ContextLifeCycle {
    * @return (a shallow copy of) the set of ContextMessageSources configured.
    */
   final Set<ContextMessageSource> getContextMessageSources() {
-    return ImmutableSet.<ContextMessageSource>builder().addAll(this.contextMessageSources).build();
+    return Collections.unmodifiableSet(new LinkedHashSet<>(this.contextMessageSources));
   }
 
   final String getIdentifier() {

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/9bf956cd/reef-common/src/main/java/org/apache/reef/util/logging/LoggingScope.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/util/logging/LoggingScope.java b/reef-common/src/main/java/org/apache/reef/util/logging/LoggingScope.java
index c67edd7..56cb779 100644
--- a/reef-common/src/main/java/org/apache/reef/util/logging/LoggingScope.java
+++ b/reef-common/src/main/java/org/apache/reef/util/logging/LoggingScope.java
@@ -19,10 +19,6 @@
 
 package org.apache.reef.util.logging;
 
-import com.google.common.base.Stopwatch;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
 /**
  * Log time elapsed for a scope
  */

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/9bf956cd/reef-common/src/main/java/org/apache/reef/util/logging/LoggingScopeImpl.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/util/logging/LoggingScopeImpl.java b/reef-common/src/main/java/org/apache/reef/util/logging/LoggingScopeImpl.java
index f8743dd..8475532 100644
--- a/reef-common/src/main/java/org/apache/reef/util/logging/LoggingScopeImpl.java
+++ b/reef-common/src/main/java/org/apache/reef/util/logging/LoggingScopeImpl.java
@@ -19,13 +19,9 @@
 
 package org.apache.reef.util.logging;
 
-import com.google.common.base.Stopwatch;
-import org.apache.reef.tang.annotations.Name;
-import org.apache.reef.tang.annotations.NamedParameter;
-import org.apache.reef.tang.annotations.Parameter;
+import org.apache.commons.lang3.time.StopWatch;
 import org.apache.reef.util.Optional;
 
-import javax.inject.Inject;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -38,7 +34,7 @@ public class LoggingScopeImpl implements LoggingScope {
   public static final String EXIT_PREFIX = "EXIT" + TOKEN;
   public static final String DURATION = " Duration = ";
 
-  private final Stopwatch stopWatch = new Stopwatch();
+  private final StopWatch stopWatch = new StopWatch();
 
   private final Logger logger;
 
@@ -90,7 +86,7 @@ public class LoggingScopeImpl implements LoggingScope {
 
     if (logger.isLoggable(logLevel)) {
       final StringBuilder sb = new StringBuilder();
-      log(sb.append(EXIT_PREFIX).append(msg).append(DURATION).append(stopWatch.elapsedMillis()).toString());
+      log(sb.append(EXIT_PREFIX).append(msg).append(DURATION).append(stopWatch.getTime()).toString());
     }
   }