accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [09/12] accumulo git commit: ACCUMULO-4013 Clean up resources in tracer test
Date Tue, 29 Sep 2015 23:12:45 GMT
ACCUMULO-4013 Clean up resources in tracer test

Use try-with-resources to clean up resources in AsyncSpanReceiverTest, and apply
automatic formatting.


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

Branch: refs/heads/1.7
Commit: 22b5258b30e1db7301be64165f14d47730919a8c
Parents: abcbf0c
Author: Christopher Tubbs <ctubbsii@apache.org>
Authored: Tue Sep 29 18:57:14 2015 -0400
Committer: Christopher Tubbs <ctubbsii@apache.org>
Committed: Tue Sep 29 18:57:14 2015 -0400

----------------------------------------------------------------------
 .../accumulo/server/util/SendLogToChainsaw.java |  4 +-
 .../accumulo/tracer/AsyncSpanReceiverTest.java  | 87 ++++++++++----------
 2 files changed, 47 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/22b5258b/server/base/src/main/java/org/apache/accumulo/server/util/SendLogToChainsaw.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/SendLogToChainsaw.java
b/server/base/src/main/java/org/apache/accumulo/server/util/SendLogToChainsaw.java
index 2be1335..d06bc4e 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/SendLogToChainsaw.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/SendLogToChainsaw.java
@@ -56,8 +56,8 @@ import com.beust.jcommander.Parameter;
 
 public class SendLogToChainsaw extends XMLLayout {
 
-  private static Pattern logPattern = Pattern
-      .compile("^(\\d\\d)\\s(\\d\\d):(\\d\\d):(\\d\\d),(\\d\\d\\d)\\s\\[(.*)\\]\\s(TRACE|DEBUG|INFO|WARN|FATAL|ERROR)\\s*?:(.*)$",
Pattern.UNIX_LINES);
+  private static Pattern logPattern = Pattern.compile(
+      "^(\\d\\d)\\s(\\d\\d):(\\d\\d):(\\d\\d),(\\d\\d\\d)\\s\\[(.*)\\]\\s(TRACE|DEBUG|INFO|WARN|FATAL|ERROR)\\s*?:(.*)$",
Pattern.UNIX_LINES);
 
   private File[] logFiles = null;
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/22b5258b/server/tracer/src/test/java/org/apache/accumulo/tracer/AsyncSpanReceiverTest.java
----------------------------------------------------------------------
diff --git a/server/tracer/src/test/java/org/apache/accumulo/tracer/AsyncSpanReceiverTest.java
b/server/tracer/src/test/java/org/apache/accumulo/tracer/AsyncSpanReceiverTest.java
index e735373..06e3099 100644
--- a/server/tracer/src/test/java/org/apache/accumulo/tracer/AsyncSpanReceiverTest.java
+++ b/server/tracer/src/test/java/org/apache/accumulo/tracer/AsyncSpanReceiverTest.java
@@ -72,58 +72,61 @@ public class AsyncSpanReceiverTest {
 
   @Test
   public void test() throws InterruptedException {
-    TestReceiver receiver = new TestReceiver();
-
-    receiver.receiveSpan(createSpan(0));
-    while (receiver.getQueueSize() > 0) {
-      Thread.sleep(500);
-    }
-    assertEquals(0, receiver.getQueueSize());
-    assertEquals(0, receiver.getSpansSent());
-
-    receiver.receiveSpan(createSpan(1));
-    while (receiver.getQueueSize() > 0) {
-      Thread.sleep(500);
+    try (TestReceiver receiver = new TestReceiver()) {
+
+      receiver.receiveSpan(createSpan(0));
+      while (receiver.getQueueSize() > 0) {
+        Thread.sleep(500);
+      }
+      assertEquals(0, receiver.getQueueSize());
+      assertEquals(0, receiver.getSpansSent());
+
+      receiver.receiveSpan(createSpan(1));
+      while (receiver.getQueueSize() > 0) {
+        Thread.sleep(500);
+      }
+      assertEquals(0, receiver.getQueueSize());
+      assertEquals(1, receiver.getSpansSent());
     }
-    assertEquals(0, receiver.getQueueSize());
-    assertEquals(1, receiver.getSpansSent());
   }
 
   @Test
   public void testKeepAll() throws InterruptedException {
-    TestReceiver receiver = new TestReceiver(HTraceConfiguration.fromMap(Collections.singletonMap(AsyncSpanReceiver.SPAN_MIN_MS,
"0")));
-
-    receiver.receiveSpan(createSpan(0));
-    while (receiver.getQueueSize() > 0) {
-      Thread.sleep(500);
+    try (TestReceiver receiver = new TestReceiver(HTraceConfiguration.fromMap(Collections.singletonMap(AsyncSpanReceiver.SPAN_MIN_MS,
"0")))) {
+
+      receiver.receiveSpan(createSpan(0));
+      while (receiver.getQueueSize() > 0) {
+        Thread.sleep(500);
+      }
+      assertEquals(0, receiver.getQueueSize());
+      assertEquals(1, receiver.getSpansSent());
     }
-    assertEquals(0, receiver.getQueueSize());
-    assertEquals(1, receiver.getSpansSent());
   }
 
   @Test
   public void testExcludeMore() throws InterruptedException {
-    TestReceiver receiver = new TestReceiver(HTraceConfiguration.fromMap(Collections.singletonMap(AsyncSpanReceiver.SPAN_MIN_MS,
"10")));
-
-    receiver.receiveSpan(createSpan(0));
-    while (receiver.getQueueSize() > 0) {
-      Thread.sleep(500);
-    }
-    assertEquals(0, receiver.getQueueSize());
-    assertEquals(0, receiver.getSpansSent());
-
-    receiver.receiveSpan(createSpan(9));
-    while (receiver.getQueueSize() > 0) {
-      Thread.sleep(500);
-    }
-    assertEquals(0, receiver.getQueueSize());
-    assertEquals(0, receiver.getSpansSent());
-
-    receiver.receiveSpan(createSpan(10));
-    while (receiver.getQueueSize() > 0) {
-      Thread.sleep(500);
+    try (TestReceiver receiver = new TestReceiver(HTraceConfiguration.fromMap(Collections.singletonMap(AsyncSpanReceiver.SPAN_MIN_MS,
"10")))) {
+
+      receiver.receiveSpan(createSpan(0));
+      while (receiver.getQueueSize() > 0) {
+        Thread.sleep(500);
+      }
+      assertEquals(0, receiver.getQueueSize());
+      assertEquals(0, receiver.getSpansSent());
+
+      receiver.receiveSpan(createSpan(9));
+      while (receiver.getQueueSize() > 0) {
+        Thread.sleep(500);
+      }
+      assertEquals(0, receiver.getQueueSize());
+      assertEquals(0, receiver.getSpansSent());
+
+      receiver.receiveSpan(createSpan(10));
+      while (receiver.getQueueSize() > 0) {
+        Thread.sleep(500);
+      }
+      assertEquals(0, receiver.getQueueSize());
+      assertEquals(1, receiver.getSpansSent());
     }
-    assertEquals(0, receiver.getQueueSize());
-    assertEquals(1, receiver.getSpansSent());
   }
 }


Mime
View raw message