hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iwasak...@apache.org
Subject hadoop git commit: HADOOP-12588. addendum patch to fix intermittent failure of TestGangliaMetrics. (iwasakims)
Date Wed, 22 Jun 2016 14:39:59 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk d433b16ce -> 67089875f


HADOOP-12588. addendum patch to fix intermittent failure of TestGangliaMetrics. (iwasakims)


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

Branch: refs/heads/trunk
Commit: 67089875f0ea2a47cca0c237fccf239bf6fe2d53
Parents: d433b16
Author: Masatake Iwasaki <iwasakims@apache.org>
Authored: Wed Jun 22 23:38:20 2016 +0900
Committer: Masatake Iwasaki <iwasakims@apache.org>
Committed: Wed Jun 22 23:38:20 2016 +0900

----------------------------------------------------------------------
 .../apache/hadoop/metrics2/impl/TestGangliaMetrics.java  | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/67089875/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestGangliaMetrics.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestGangliaMetrics.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestGangliaMetrics.java
index c386e36..c19d238 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestGangliaMetrics.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestGangliaMetrics.java
@@ -29,7 +29,6 @@ import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.apache.commons.io.Charsets;
 import org.apache.commons.logging.Log;
@@ -99,7 +98,9 @@ public class TestGangliaMetrics {
   }
   
   @Test public void testGangliaMetrics2() throws Exception {
-    ConfigBuilder cb = new ConfigBuilder().add("default.period", 10)
+    // Setting long interval to avoid periodic publishing.
+    // We manually publish metrics by MeticsSystem#publishMetricsNow here.
+    ConfigBuilder cb = new ConfigBuilder().add("*.period", 120)
         .add("test.sink.gsink30.context", "test") // filter out only "test"
         .add("test.sink.gsink31.context", "test") // filter out only "test"
         .save(TestMetricsConfig.getTestFilename("hadoop-metrics2-test"));
@@ -196,14 +197,14 @@ public class TestGangliaMetrics {
      * @throws SocketException
      */
     public MockDatagramSocket() throws SocketException {
-      capture = new CopyOnWriteArrayList<byte[]>();
+      capture = new ArrayList<byte[]>();
     }
 
     /* (non-Javadoc)
      * @see java.net.DatagramSocket#send(java.net.DatagramPacket)
      */
     @Override
-    public void send(DatagramPacket p) throws IOException {
+    public synchronized void send(DatagramPacket p) throws IOException {
       // capture the byte arrays
       byte[] bytes = new byte[p.getLength()];
       System.arraycopy(p.getData(), p.getOffset(), bytes, 0, p.getLength());
@@ -213,7 +214,7 @@ public class TestGangliaMetrics {
     /**
      * @return the captured byte arrays
      */
-    List<byte[]> getCapturedSend() {
+    synchronized List<byte[]> getCapturedSend() {
       return capture;
     }
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message