hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravip...@apache.org
Subject svn commit: r1605647 - in /hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common: CHANGES.txt src/main/java/org/apache/hadoop/metrics2/sink/GraphiteSink.java src/test/java/org/apache/hadoop/metrics2/impl/TestGraphiteMetrics.java
Date Thu, 26 Jun 2014 01:53:44 GMT
Author: raviprak
Date: Thu Jun 26 01:53:43 2014
New Revision: 1605647

URL: http://svn.apache.org/r1605647
Log:
HADOOP-10715. Remove public GraphiteSink#setWriter()

Modified:
    hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
    hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/GraphiteSink.java
    hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestGraphiteMetrics.java

Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1605647&r1=1605646&r2=1605647&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt Thu Jun
26 01:53:43 2014
@@ -288,6 +288,8 @@ Release 2.5.0 - UNRELEASED
     HADOOP-10479. Fix new findbugs warnings in hadoop-minikdc.
     (Swarnim Kulkarni via wheat9)
 
+    HADOOP-10715. Remove public GraphiteSink#setWriter (Babak Behzad via raviprak)
+
 Release 2.4.1 - 2014-06-23 
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/GraphiteSink.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/GraphiteSink.java?rev=1605647&r1=1605646&r2=1605647&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/GraphiteSink.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/GraphiteSink.java
Thu Jun 26 01:53:43 2014
@@ -50,10 +50,6 @@ public class GraphiteSink implements Met
     private String metricsPrefix = null;
     private Socket socket = null;
 
-    public void setWriter(Writer writer) {
-        this.writer = writer;
-    }
-
     @Override
     public void init(SubsetConfiguration conf) {
         // Get Graphite host configurations.
@@ -68,7 +64,7 @@ public class GraphiteSink implements Met
         try {
             // Open an connection to Graphite server.
             socket = new Socket(serverHost, serverPort);
-            setWriter(new OutputStreamWriter(socket.getOutputStream()));
+            writer = new OutputStreamWriter(socket.getOutputStream());
         } catch (Exception e) {
             throw new MetricsException("Error creating connection, "
                     + serverHost + ":" + serverPort, e);

Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestGraphiteMetrics.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestGraphiteMetrics.java?rev=1605647&r1=1605646&r2=1605647&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestGraphiteMetrics.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestGraphiteMetrics.java
Thu Jun 26 01:53:43 2014
@@ -28,15 +28,16 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import static org.mockito.Mockito.*;
-
 import org.apache.hadoop.metrics2.AbstractMetric;
 import org.apache.hadoop.metrics2.MetricsException;
 import org.apache.hadoop.metrics2.MetricsRecord;
 import org.apache.hadoop.metrics2.MetricsTag;
 import org.apache.hadoop.metrics2.sink.GraphiteSink;
 import org.junit.Test;
+
+import static org.mockito.Mockito.*;
 import org.mockito.ArgumentCaptor;
+import org.mockito.internal.util.reflection.Whitebox;
 
 public class TestGraphiteMetrics {
     private AbstractMetric makeMetric(String name, Number value) {
@@ -57,14 +58,13 @@ public class TestGraphiteMetrics {
         metrics.add(makeMetric("foo2", 2.25));
         MetricsRecord record = new MetricsRecordImpl(MsInfo.Context, (long) 10000, tags,
metrics);
 
-        OutputStreamWriter writer = mock(OutputStreamWriter.class);
+        OutputStreamWriter mockWriter = mock(OutputStreamWriter.class);
         ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class);
-
-        sink.setWriter(writer);
+        Whitebox.setInternalState(sink, "writer", mockWriter);
         sink.putMetrics(record);
 
         try {
-            verify(writer).write(argument.capture());
+            verify(mockWriter).write(argument.capture());
         } catch (IOException e) {
             e.printStackTrace();
         }
@@ -89,14 +89,13 @@ public class TestGraphiteMetrics {
         metrics.add(makeMetric("foo2", 2));
         MetricsRecord record = new MetricsRecordImpl(MsInfo.Context, (long) 10000, tags,
metrics);
 
-        OutputStreamWriter writer = mock(OutputStreamWriter.class);
+        OutputStreamWriter mockWriter = mock(OutputStreamWriter.class);
         ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class);
-
-        sink.setWriter(writer);
+        Whitebox.setInternalState(sink, "writer", mockWriter);
         sink.putMetrics(record);
 
         try {
-            verify(writer).write(argument.capture());
+            verify(mockWriter).write(argument.capture());
         } catch (IOException e) {
             e.printStackTrace();
         }
@@ -122,26 +121,26 @@ public class TestGraphiteMetrics {
 
       OutputStreamWriter writer = mock(OutputStreamWriter.class);
 
-      sink.setWriter(writer);
+      Whitebox.setInternalState(sink, "writer", writer);
       sink.close();
       sink.putMetrics(record);
     }
 
     @Test
     public void testClose(){
-      GraphiteSink sink = new GraphiteSink();
-      Writer mockWriter = mock(Writer.class);
-      sink.setWriter(mockWriter);
-      try {
-        sink.close();
-      } catch (IOException ioe) {
-        ioe.printStackTrace();
-      }
-
-      try {
-        verify(mockWriter).close();
-      } catch (IOException ioe) {
-        ioe.printStackTrace();
-      }
+        GraphiteSink sink = new GraphiteSink();
+        Writer mockWriter = mock(Writer.class);
+        Whitebox.setInternalState(sink, "writer", mockWriter);
+        try {
+            sink.close();
+        } catch (IOException ioe) {
+            ioe.printStackTrace();
+        }
+
+        try {
+            verify(mockWriter).close();
+        } catch (IOException ioe) {
+            ioe.printStackTrace();
+        }
     }
 }



Mime
View raw message