You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tez.apache.org by je...@apache.org on 2016/05/12 18:27:30 UTC

tez git commit: TEZ-3256. [Backport HADOOP-11032] Remove Guava Stopwatch dependency (jeagles)

Repository: tez
Updated Branches:
  refs/heads/master 88bd5b9dc -> f70aa172e


TEZ-3256. [Backport HADOOP-11032] Remove Guava Stopwatch dependency (jeagles)


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

Branch: refs/heads/master
Commit: f70aa172e0cfcf7272bda04e4da20e5fc5e96e82
Parents: 88bd5b9
Author: Jonathan Eagles <je...@yahoo-inc.com>
Authored: Thu May 12 13:27:12 2016 -0500
Committer: Jonathan Eagles <je...@yahoo-inc.com>
Committed: Thu May 12 13:27:12 2016 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |   3 +
 .../org/apache/tez/common/TezUtilsInternal.java |  11 +-
 .../java/org/apache/tez/util/StopWatch.java     | 108 +++++++++++++++++++
 .../java/org/apache/tez/util/TestStopWatch.java |  58 ++++++++++
 .../tez/dag/app/TestMemoryWithEvents.java       |   7 +-
 .../tez/service/impl/ContainerRunnerImpl.java   |  13 +--
 .../common/MRInputAMSplitGenerator.java         |  11 +-
 .../common/MRInputSplitDistributor.java         |   7 +-
 .../org/apache/tez/http/HttpConnection.java     |  14 +--
 .../http/async/netty/AsyncHttpConnection.java   |   9 +-
 .../common/sort/impl/PipelinedSorter.java       |   7 +-
 .../tez/mapreduce/examples/RPCLoadGen.java      |   8 +-
 12 files changed, 216 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tez/blob/f70aa172/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 62833dd..d319eb8 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -7,6 +7,7 @@ INCOMPATIBLE CHANGES
 
 ALL CHANGES:
 
+  TEZ-3256. [Backport HADOOP-11032] Remove Guava Stopwatch dependency
   TEZ-2342. Reduce bytearray copy with TezEvent Serialization and deserialization
   TEZ-3251. Allow ability to add custom counters to TaskRunner2Callable.
   TEZ-3250. TezTaskRunner2 should accept ExecutorService.
@@ -35,6 +36,7 @@ INCOMPATIBLE CHANGES
 
 ALL CHANGES:
 
+  TEZ-3256. [Backport HADOOP-11032] Remove Guava Stopwatch dependency
   TEZ-2342. Reduce bytearray copy with TezEvent Serialization and deserialization
   TEZ-3251. Allow ability to add custom counters to TaskRunner2Callable.
   TEZ-3250. TezTaskRunner2 should accept ExecutorService.
@@ -474,6 +476,7 @@ Release 0.7.2: Unreleased
 INCOMPATIBLE CHANGES
 
 ALL CHANGES:
+  TEZ-3256. [Backport HADOOP-11032] Remove Guava Stopwatch dependency
   TEZ-2342. Reduce bytearray copy with TezEvent Serialization and deserialization
 
 Release 0.7.1: Unreleased

http://git-wip-us.apache.org/repos/asf/tez/blob/f70aa172/tez-common/src/main/java/org/apache/tez/common/TezUtilsInternal.java
----------------------------------------------------------------------
diff --git a/tez-common/src/main/java/org/apache/tez/common/TezUtilsInternal.java b/tez-common/src/main/java/org/apache/tez/common/TezUtilsInternal.java
index a99bab4..08a9aa8 100644
--- a/tez-common/src/main/java/org/apache/tez/common/TezUtilsInternal.java
+++ b/tez-common/src/main/java/org/apache/tez/common/TezUtilsInternal.java
@@ -26,6 +26,7 @@ import java.nio.charset.Charset;
 import java.util.BitSet;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.zip.DataFormatException;
@@ -50,10 +51,10 @@ import org.apache.tez.dag.api.TezConstants;
 import org.apache.tez.dag.api.records.DAGProtos;
 import org.apache.tez.dag.api.records.DAGProtos.ConfigurationProto;
 import org.apache.tez.dag.api.records.DAGProtos.PlanKeyValuePair;
+import org.apache.tez.util.StopWatch;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Stopwatch;
 import org.apache.tez.dag.records.TaskAttemptTerminationCause;
 
 @Private
@@ -114,23 +115,23 @@ public class TezUtilsInternal {
 
 
   public static byte[] compressBytes(byte[] inBytes) throws IOException {
-    Stopwatch sw = new Stopwatch().start();
+    StopWatch sw = new StopWatch().start();
     byte[] compressed = compressBytesInflateDeflate(inBytes);
     sw.stop();
     if (LOG.isDebugEnabled()) {
       LOG.debug("UncompressedSize: " + inBytes.length + ", CompressedSize: " + compressed.length
-          + ", CompressTime: " + sw.elapsedMillis());
+          + ", CompressTime: " + sw.now(TimeUnit.MILLISECONDS));
     }
     return compressed;
   }
 
   public static byte[] uncompressBytes(byte[] inBytes) throws IOException {
-    Stopwatch sw = new Stopwatch().start();
+    StopWatch sw = new StopWatch().start();
     byte[] uncompressed = uncompressBytesInflateDeflate(inBytes);
     sw.stop();
     if (LOG.isDebugEnabled()) {
       LOG.debug("CompressedSize: " + inBytes.length + ", UncompressedSize: " + uncompressed.length
-          + ", UncompressTimeTaken: " + sw.elapsedMillis());
+          + ", UncompressTimeTaken: " + sw.now(TimeUnit.MILLISECONDS));
     }
     return uncompressed;
   }

http://git-wip-us.apache.org/repos/asf/tez/blob/f70aa172/tez-common/src/main/java/org/apache/tez/util/StopWatch.java
----------------------------------------------------------------------
diff --git a/tez-common/src/main/java/org/apache/tez/util/StopWatch.java b/tez-common/src/main/java/org/apache/tez/util/StopWatch.java
new file mode 100644
index 0000000..c9a573e
--- /dev/null
+++ b/tez-common/src/main/java/org/apache/tez/util/StopWatch.java
@@ -0,0 +1,108 @@
+/**
+ * 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.util;
+
+import java.io.Closeable;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * A simplified StopWatch implementation which can measure times in nanoseconds.
+ */
+public class StopWatch implements Closeable {
+  private boolean isStarted;
+  private long startNanos;
+  private long currentElapsedNanos;
+
+  public StopWatch() {
+  }
+
+  /**
+   * The method is used to find out if the StopWatch is started.
+   * @return boolean If the StopWatch is started.
+   */
+  public boolean isRunning() {
+    return isStarted;
+  }
+
+  /**
+   * Start to measure times and make the state of stopwatch running.
+   * @return this instance of StopWatch.
+   */
+  public StopWatch start() {
+    if (isStarted) {
+      throw new IllegalStateException("StopWatch is already running");
+    }
+    isStarted = true;
+    startNanos = System.nanoTime();
+    return this;
+  }
+
+  /**
+   * Stop elapsed time and make the state of stopwatch stop.
+   * @return this instance of StopWatch.
+   */
+  public StopWatch stop() {
+    if (!isStarted) {
+      throw new IllegalStateException("StopWatch is already stopped");
+    }
+    long now = System.nanoTime();
+    isStarted = false;
+    currentElapsedNanos += now - startNanos;
+    return this;
+  }
+
+  /**
+   * Reset elapsed time to zero and make the state of stopwatch stop.
+   * @return this instance of StopWatch.
+   */
+  public StopWatch reset() {
+    currentElapsedNanos = 0;
+    isStarted = false;
+    return this;
+  }
+
+  /**
+   * @return current elapsed time in specified timeunit.
+   */
+  public long now(TimeUnit timeUnit) {
+    return timeUnit.convert(now(), TimeUnit.NANOSECONDS);
+
+  }
+
+  /**
+   * @return current elapsed time in nanosecond.
+   */
+  public long now() {
+    return isStarted ?
+        System.nanoTime() - startNanos + currentElapsedNanos :
+        currentElapsedNanos;
+  }
+
+  @Override
+  public String toString() {
+    return String.valueOf(now());
+  }
+
+  @Override
+  public void close() {
+    if (isStarted) {
+      stop();
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/tez/blob/f70aa172/tez-common/src/test/java/org/apache/tez/util/TestStopWatch.java
----------------------------------------------------------------------
diff --git a/tez-common/src/test/java/org/apache/tez/util/TestStopWatch.java b/tez-common/src/test/java/org/apache/tez/util/TestStopWatch.java
new file mode 100644
index 0000000..b8523fd
--- /dev/null
+++ b/tez-common/src/test/java/org/apache/tez/util/TestStopWatch.java
@@ -0,0 +1,58 @@
+/**
+ * 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.util;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestStopWatch {
+
+  @Test
+  public void testStartAndStop() throws Exception {
+    try {
+      StopWatch sw = new StopWatch();
+      Assert.assertFalse(sw.isRunning());
+      sw.start();
+      Assert.assertTrue(sw.isRunning());
+      sw.stop();
+      Assert.assertFalse(sw.isRunning());
+    } catch (Exception e) {
+      Assert.fail("StopWatch should not fail with normal usage");
+    }
+  }
+
+  @Test
+  public void testExceptions() throws Exception {
+    StopWatch sw = new StopWatch();
+    try {
+      sw.stop();
+    } catch (Exception e) {
+      Assert.assertTrue("IllegalStateException is expected",
+          e instanceof IllegalStateException);
+    }
+    sw.reset();
+    sw.start();
+    try {
+      sw.start();
+    } catch (Exception e) {
+      Assert.assertTrue("IllegalStateException is expected",
+          e instanceof IllegalStateException);
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/tez/blob/f70aa172/tez-dag/src/test/java/org/apache/tez/dag/app/TestMemoryWithEvents.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/test/java/org/apache/tez/dag/app/TestMemoryWithEvents.java b/tez-dag/src/test/java/org/apache/tez/dag/app/TestMemoryWithEvents.java
index 9816e20..535e69d 100644
--- a/tez-dag/src/test/java/org/apache/tez/dag/app/TestMemoryWithEvents.java
+++ b/tez-dag/src/test/java/org/apache/tez/dag/app/TestMemoryWithEvents.java
@@ -19,9 +19,9 @@
 package org.apache.tez.dag.app;
 
 import java.io.IOException;
+import java.util.concurrent.TimeUnit;
 import java.util.List;
 
-import com.google.common.base.Stopwatch;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
@@ -48,6 +48,7 @@ import org.apache.tez.runtime.api.InputInitializer;
 import org.apache.tez.runtime.api.InputInitializerContext;
 import org.apache.tez.runtime.api.events.InputDataInformationEvent;
 import org.apache.tez.runtime.api.events.InputInitializerEvent;
+import org.apache.tez.util.StopWatch;
 import org.junit.Assert;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -117,7 +118,7 @@ public class TestMemoryWithEvents {
   }
   
   private void testMemory(DAG dag, boolean sendDMEvents) throws Exception {
-    Stopwatch stopwatch = new Stopwatch();
+    StopWatch stopwatch = new StopWatch();
     stopwatch.start();
     TezConfiguration tezconf = new TezConfiguration(defaultConf);
 
@@ -137,7 +138,7 @@ public class TestMemoryWithEvents {
     Assert.assertEquals(DAGStatus.State.SUCCEEDED, status.getState());
     checkMemory(dag.getName(), mockApp);
     stopwatch.stop();
-    System.out.println("Time taken(ms): " + stopwatch.elapsedMillis());
+    System.out.println("Time taken(ms): " + stopwatch.now(TimeUnit.MILLISECONDS));
     tezClient.stop();
   }
   

http://git-wip-us.apache.org/repos/asf/tez/blob/f70aa172/tez-ext-service-tests/src/test/java/org/apache/tez/service/impl/ContainerRunnerImpl.java
----------------------------------------------------------------------
diff --git a/tez-ext-service-tests/src/test/java/org/apache/tez/service/impl/ContainerRunnerImpl.java b/tez-ext-service-tests/src/test/java/org/apache/tez/service/impl/ContainerRunnerImpl.java
index 07dcc9b..f9de995 100644
--- a/tez-ext-service-tests/src/test/java/org/apache/tez/service/impl/ContainerRunnerImpl.java
+++ b/tez-ext-service-tests/src/test/java/org/apache/tez/service/impl/ContainerRunnerImpl.java
@@ -26,11 +26,11 @@ import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
 
 import com.google.common.base.Preconditions;
-import com.google.common.base.Stopwatch;
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.Multimap;
 import com.google.common.util.concurrent.FutureCallback;
@@ -74,6 +74,7 @@ import org.apache.tez.shufflehandler.ShuffleHandler;
 import org.apache.tez.test.service.rpc.TezTestServiceProtocolProtos.RunContainerRequestProto;
 import org.apache.tez.test.service.rpc.TezTestServiceProtocolProtos.SubmitWorkRequestProto;
 import org.apache.tez.util.ProtoConverters;
+import org.apache.tez.util.StopWatch;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -300,7 +301,7 @@ public class ContainerRunnerImpl extends AbstractService implements ContainerRun
 
     @Override
     public ContainerExecutionResult call() throws Exception {
-      Stopwatch sw = new Stopwatch().start();
+      StopWatch sw = new StopWatch().start();
       tezChild =
           new TezChild(conf, request.getAmHost(), request.getAmPort(),
               request.getContainerIdString(),
@@ -310,7 +311,7 @@ public class ContainerRunnerImpl extends AbstractService implements ContainerRun
               new DefaultHadoopShim());
       ContainerExecutionResult result = tezChild.run();
       LOG.info("ExecutionTime for Container: " + request.getContainerIdString() + "=" +
-          sw.stop().elapsedMillis());
+          sw.stop().now(TimeUnit.MILLISECONDS));
       return result;
     }
 
@@ -410,7 +411,7 @@ public class ContainerRunnerImpl extends AbstractService implements ContainerRun
     public ContainerExecutionResult call() throws Exception {
 
       // TODO Consolidate this code with TezChild.
-      Stopwatch sw = new Stopwatch().start();
+      StopWatch sw = new StopWatch().start();
       UserGroupInformation taskUgi = UserGroupInformation.createRemoteUser(request.getUser());
       taskUgi.addCredentials(credentials);
 
@@ -473,7 +474,7 @@ public class ContainerRunnerImpl extends AbstractService implements ContainerRun
         FileSystem.closeAllForUGI(taskUgi);
       }
       LOG.info("ExecutionTime for Container: " + request.getContainerIdString() + "=" +
-          sw.stop().elapsedMillis());
+          sw.stop().now(TimeUnit.MILLISECONDS));
       return new ContainerExecutionResult(ContainerExecutionResult.ExitStatus.SUCCESS, null,
           null);
     }
@@ -555,4 +556,4 @@ public class ContainerRunnerImpl extends AbstractService implements ContainerRun
           taskSpec.getTaskAttemptID());
     }
   }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/tez/blob/f70aa172/tez-mapreduce/src/main/java/org/apache/tez/mapreduce/common/MRInputAMSplitGenerator.java
----------------------------------------------------------------------
diff --git a/tez-mapreduce/src/main/java/org/apache/tez/mapreduce/common/MRInputAMSplitGenerator.java b/tez-mapreduce/src/main/java/org/apache/tez/mapreduce/common/MRInputAMSplitGenerator.java
index ac64bf7..c109664 100644
--- a/tez-mapreduce/src/main/java/org/apache/tez/mapreduce/common/MRInputAMSplitGenerator.java
+++ b/tez-mapreduce/src/main/java/org/apache/tez/mapreduce/common/MRInputAMSplitGenerator.java
@@ -19,8 +19,8 @@
 package org.apache.tez.mapreduce.common;
 
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
-import com.google.common.base.Stopwatch;
 import com.google.common.collect.Lists;
 
 import org.apache.tez.mapreduce.grouper.TezSplitGrouper;
@@ -47,6 +47,7 @@ import org.apache.tez.runtime.api.InputInitializerContext;
 import org.apache.tez.runtime.api.events.InputConfigureVertexTasksEvent;
 import org.apache.tez.runtime.api.events.InputDataInformationEvent;
 import org.apache.tez.runtime.api.events.InputInitializerEvent;
+import org.apache.tez.util.StopWatch;
 
 /**
  * Implements an {@link InputInitializer} that generates Map Reduce 
@@ -70,13 +71,13 @@ public class MRInputAMSplitGenerator extends InputInitializer {
 
   @Override
   public List<Event> initialize() throws Exception {
-    Stopwatch sw = new Stopwatch().start();
+    StopWatch sw = new StopWatch().start();
     MRInputUserPayloadProto userPayloadProto = MRInputHelpers
         .parseMRInputPayload(getContext().getInputUserPayload());
     sw.stop();
     if (LOG.isDebugEnabled()) {
       LOG.debug("Time to parse MRInput payload into prot: "
-          + sw.elapsedMillis());
+          + sw.now(TimeUnit.MILLISECONDS));
     }
     sw.reset().start();
     Configuration conf = TezUtils.createConfFromByteString(userPayloadProto
@@ -90,7 +91,7 @@ public class MRInputAMSplitGenerator extends InputInitializer {
     if (LOG.isDebugEnabled()) {
       LOG.debug("Emitting serialized splits: " + sendSerializedEvents + " for input " +
           getContext().getInputName());
-      LOG.debug("Time converting ByteString to configuration: " + sw.elapsedMillis());
+      LOG.debug("Time converting ByteString to configuration: " + sw.now(TimeUnit.MILLISECONDS));
     }
 
     sw.reset().start();
@@ -123,7 +124,7 @@ public class MRInputAMSplitGenerator extends InputInitializer {
     }
     sw.stop();
     if (LOG.isDebugEnabled()) {
-      LOG.debug("Time to create splits to mem: " + sw.elapsedMillis());
+      LOG.debug("Time to create splits to mem: " + sw.now(TimeUnit.MILLISECONDS));
     }
 
     List<Event> events = Lists.newArrayListWithCapacity(inputSplitInfo

http://git-wip-us.apache.org/repos/asf/tez/blob/f70aa172/tez-mapreduce/src/main/java/org/apache/tez/mapreduce/common/MRInputSplitDistributor.java
----------------------------------------------------------------------
diff --git a/tez-mapreduce/src/main/java/org/apache/tez/mapreduce/common/MRInputSplitDistributor.java b/tez-mapreduce/src/main/java/org/apache/tez/mapreduce/common/MRInputSplitDistributor.java
index 28d108e..c60e5d4 100644
--- a/tez-mapreduce/src/main/java/org/apache/tez/mapreduce/common/MRInputSplitDistributor.java
+++ b/tez-mapreduce/src/main/java/org/apache/tez/mapreduce/common/MRInputSplitDistributor.java
@@ -20,6 +20,7 @@ package org.apache.tez.mapreduce.common;
 
 import java.io.IOException;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -41,8 +42,8 @@ import org.apache.tez.runtime.api.InputInitializerContext;
 import org.apache.tez.runtime.api.events.InputDataInformationEvent;
 import org.apache.tez.runtime.api.events.InputInitializerEvent;
 import org.apache.tez.runtime.api.events.InputUpdatePayloadEvent;
+import org.apache.tez.util.StopWatch;
 
-import com.google.common.base.Stopwatch;
 import com.google.common.collect.Lists;
 
 /**
@@ -69,13 +70,13 @@ public class MRInputSplitDistributor extends InputInitializer {
 
   @Override
   public List<Event> initialize() throws IOException {
-    Stopwatch sw = new Stopwatch().start();
+    StopWatch sw = new StopWatch().start();
     MRInputUserPayloadProto userPayloadProto = MRInputHelpers
         .parseMRInputPayload(getContext().getInputUserPayload());
     sw.stop();
     if (LOG.isDebugEnabled()) {
       LOG.debug("Time to parse MRInput payload into prot: "
-          + sw.elapsedMillis());  
+          + sw.now(TimeUnit.MILLISECONDS));
     }
     Configuration conf = TezUtils.createConfFromByteString(userPayloadProto
         .getConfigurationBytes());

http://git-wip-us.apache.org/repos/asf/tez/blob/f70aa172/tez-runtime-library/src/main/java/org/apache/tez/http/HttpConnection.java
----------------------------------------------------------------------
diff --git a/tez-runtime-library/src/main/java/org/apache/tez/http/HttpConnection.java b/tez-runtime-library/src/main/java/org/apache/tez/http/HttpConnection.java
index c94262a..d781e64 100644
--- a/tez-runtime-library/src/main/java/org/apache/tez/http/HttpConnection.java
+++ b/tez-runtime-library/src/main/java/org/apache/tez/http/HttpConnection.java
@@ -20,12 +20,12 @@ package org.apache.tez.http;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
-import com.google.common.base.Stopwatch;
 import org.apache.hadoop.io.DataOutputBuffer;
 import org.apache.hadoop.io.IOUtils;
 import org.apache.tez.common.security.JobTokenSecretManager;
 import org.apache.tez.runtime.library.common.security.SecureShuffleUtils;
 import org.apache.tez.runtime.library.common.shuffle.orderedgrouped.ShuffleHeader;
+import org.apache.tez.util.StopWatch;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -55,7 +55,7 @@ public class HttpConnection extends BaseHttpConnection {
   private String msgToEncode;
 
   private final HttpConnectionParams httpConnParams;
-  private final Stopwatch stopWatch;
+  private final StopWatch stopWatch;
 
   /**
    * HttpConnection
@@ -72,7 +72,7 @@ public class HttpConnection extends BaseHttpConnection {
     this.jobTokenSecretMgr = jobTokenSecretManager;
     this.httpConnParams = connParams;
     this.url = url;
-    this.stopWatch = new Stopwatch();
+    this.stopWatch = new StopWatch();
     if (LOG.isDebugEnabled()) {
       LOG.debug("MapOutput URL :" + url.toString());
     }
@@ -191,7 +191,7 @@ public class HttpConnection extends BaseHttpConnection {
     }
     if (LOG.isDebugEnabled()) {
       LOG.debug("Time taken to connect to " + url.toString() +
-          " " + stopWatch.elapsedTime(TimeUnit.MILLISECONDS) + " ms; connectionFailures="
+          " " + stopWatch.now(TimeUnit.MILLISECONDS) + " ms; connectionFailures="
           + connectionFailures);
     }
     return true;
@@ -231,7 +231,7 @@ public class HttpConnection extends BaseHttpConnection {
     SecureShuffleUtils.verifyReply(replyHash, encHash, jobTokenSecretMgr);
     //Following log statement will be used by tez-tool perf-analyzer for mapping attempt to NM host
     LOG.info("for url=" + url +
-        " sent hash and receievd reply " + stopWatch.elapsedTime(TimeUnit.MILLISECONDS) + " ms");
+        " sent hash and receievd reply " + stopWatch.now(TimeUnit.MILLISECONDS) + " ms");
   }
 
   /**
@@ -249,7 +249,7 @@ public class HttpConnection extends BaseHttpConnection {
     }
     if (LOG.isDebugEnabled()) {
       LOG.debug("Time taken to getInputStream (connect) " + url +
-          " " + stopWatch.elapsedTime(TimeUnit.MILLISECONDS) + " ms");
+          " " + stopWatch.now(TimeUnit.MILLISECONDS) + " ms");
     }
     return input;
   }
@@ -294,7 +294,7 @@ public class HttpConnection extends BaseHttpConnection {
     }
     if (LOG.isDebugEnabled()) {
       LOG.debug("Time taken to cleanup connection to " + url +
-          " " + stopWatch.elapsedTime(TimeUnit.MILLISECONDS) + " ms");
+          " " + stopWatch.now(TimeUnit.MILLISECONDS) + " ms");
     }
   }
 

http://git-wip-us.apache.org/repos/asf/tez/blob/f70aa172/tez-runtime-library/src/main/java/org/apache/tez/http/async/netty/AsyncHttpConnection.java
----------------------------------------------------------------------
diff --git a/tez-runtime-library/src/main/java/org/apache/tez/http/async/netty/AsyncHttpConnection.java b/tez-runtime-library/src/main/java/org/apache/tez/http/async/netty/AsyncHttpConnection.java
index f46939d..5adfc3c 100644
--- a/tez-runtime-library/src/main/java/org/apache/tez/http/async/netty/AsyncHttpConnection.java
+++ b/tez-runtime-library/src/main/java/org/apache/tez/http/async/netty/AsyncHttpConnection.java
@@ -20,7 +20,6 @@ package org.apache.tez.http.async.netty;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
-import com.google.common.base.Stopwatch;
 import com.ning.http.client.AsyncHttpClient;
 import com.ning.http.client.AsyncHttpClientConfig;
 import com.ning.http.client.ListenableFuture;
@@ -35,6 +34,7 @@ import org.apache.tez.common.security.JobTokenSecretManager;
 import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
 import org.apache.tez.runtime.library.common.security.SecureShuffleUtils;
 import org.apache.tez.runtime.library.common.shuffle.orderedgrouped.ShuffleHeader;
+import org.apache.tez.util.StopWatch;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -44,6 +44,7 @@ import java.io.PipedInputStream;
 import java.io.PipedOutputStream;
 import java.net.HttpURLConnection;
 import java.net.URL;
+import java.util.concurrent.TimeUnit;
 
 public class AsyncHttpConnection extends BaseHttpConnection {
 
@@ -54,7 +55,7 @@ public class AsyncHttpConnection extends BaseHttpConnection {
   private String msgToEncode;
 
   private final HttpConnectionParams httpConnParams;
-  private final Stopwatch stopWatch;
+  private final StopWatch stopWatch;
   private final URL url;
 
   private static volatile AsyncHttpClient httpAsyncClient;
@@ -112,7 +113,7 @@ public class AsyncHttpConnection extends BaseHttpConnection {
     this.jobTokenSecretMgr = jobTokenSecretManager;
     this.httpConnParams = connParams;
     this.url = url;
-    this.stopWatch = new Stopwatch();
+    this.stopWatch = new StopWatch();
     if (LOG.isDebugEnabled()) {
       LOG.debug("MapOutput URL :" + url.toString());
     }
@@ -193,7 +194,7 @@ public class AsyncHttpConnection extends BaseHttpConnection {
     // verify that replyHash is HMac of encHash
     SecureShuffleUtils.verifyReply(replyHash, encHash, jobTokenSecretMgr);
     //Following log statement will be used by tez-tool perf-analyzer for mapping attempt to NM host
-    LOG.info("for url={} sent hash and receievd reply {} ms", url, stopWatch.elapsedMillis());
+    LOG.info("for url={} sent hash and receievd reply {} ms", url, stopWatch.now(TimeUnit.MILLISECONDS));
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/tez/blob/f70aa172/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/sort/impl/PipelinedSorter.java
----------------------------------------------------------------------
diff --git a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/sort/impl/PipelinedSorter.java b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/sort/impl/PipelinedSorter.java
index c698e12..5695bde 100644
--- a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/sort/impl/PipelinedSorter.java
+++ b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/sort/impl/PipelinedSorter.java
@@ -31,10 +31,10 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
-import com.google.common.base.Stopwatch;
 import com.google.common.collect.Lists;
 
 import org.apache.tez.runtime.library.api.IOInterruptedException;
@@ -60,6 +60,7 @@ import org.apache.tez.runtime.library.common.sort.impl.IFile.Writer;
 import org.apache.tez.runtime.library.common.sort.impl.TezMerger.DiskSegment;
 import org.apache.tez.runtime.library.common.sort.impl.TezMerger.Segment;
 import org.apache.tez.runtime.library.utils.LocalProgress;
+import org.apache.tez.util.StopWatch;
 
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
 
@@ -302,14 +303,14 @@ public class PipelinedSorter extends ExternalSorter {
 
     if(newSpan == null) {
       //avoid sort/spill of empty span
-      Stopwatch stopWatch = new Stopwatch();
+      StopWatch stopWatch = new StopWatch();
       stopWatch.start();
       // sort in the same thread, do not wait for the thread pool
       merger.add(span.sort(sorter));
       boolean ret = spill(true);
       stopWatch.stop();
       if (LOG.isDebugEnabled()) {
-        LOG.debug(outputContext.getDestinationVertexName() + ": Time taken for spill " + (stopWatch.elapsedMillis()) + " ms");
+        LOG.debug(outputContext.getDestinationVertexName() + ": Time taken for spill " + (stopWatch.now(TimeUnit.MILLISECONDS)) + " ms");
       }
       if (pipelinedShuffle && ret) {
         sendPipelinedShuffleEvents();

http://git-wip-us.apache.org/repos/asf/tez/blob/f70aa172/tez-tests/src/main/java/org/apache/tez/mapreduce/examples/RPCLoadGen.java
----------------------------------------------------------------------
diff --git a/tez-tests/src/main/java/org/apache/tez/mapreduce/examples/RPCLoadGen.java b/tez-tests/src/main/java/org/apache/tez/mapreduce/examples/RPCLoadGen.java
index 600790c..1e53540 100644
--- a/tez-tests/src/main/java/org/apache/tez/mapreduce/examples/RPCLoadGen.java
+++ b/tez-tests/src/main/java/org/apache/tez/mapreduce/examples/RPCLoadGen.java
@@ -23,8 +23,7 @@ import java.nio.ByteBuffer;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Random;
-
-import com.google.common.base.Stopwatch;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.io.IOUtils;
 import org.slf4j.Logger;
@@ -50,6 +49,7 @@ import org.apache.tez.dag.api.Vertex;
 import org.apache.tez.examples.TezExampleBase;
 import org.apache.tez.runtime.api.ProcessorContext;
 import org.apache.tez.runtime.library.processor.SimpleProcessor;
+import org.apache.tez.util.StopWatch;
 
 public class RPCLoadGen extends TezExampleBase {
 
@@ -187,7 +187,7 @@ public class RPCLoadGen extends TezExampleBase {
 
     @Override
     public void run() throws Exception {
-      Stopwatch sw = new Stopwatch().start();
+      StopWatch sw = new StopWatch().start();
       long sleepTime = random.nextInt(sleepTimeMax);
       if (modeByte == VIA_RPC_BYTE) {
         LOG.info("Received via RPC.");
@@ -204,7 +204,7 @@ public class RPCLoadGen extends TezExampleBase {
       } else {
         throw new IllegalArgumentException("Unknown execution mode: [" + modeByte + "]");
       }
-      LOG.info("TimeTakenToAccessPayload=" + sw.stop().elapsedMillis());
+      LOG.info("TimeTakenToAccessPayload=" + sw.stop().now(TimeUnit.MILLISECONDS));
       LOG.info("Sleeping for: " + sleepTime);
       Thread.sleep(sleepTime);
     }