[GitHub] [hadoop] slfan1989 commented on a diff in pull request #4457: HADOOP-18302. Remove WhiteBox in hadoop-common module.

2022-09-11 Thread GitBox


slfan1989 commented on code in PR #4457:
URL: https://github.com/apache/hadoop/pull/4457#discussion_r967808189


##
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsRecordImpl.java:
##
@@ -27,7 +27,7 @@
 import org.apache.hadoop.metrics2.MetricsTag;
 import static org.apache.hadoop.metrics2.util.Contracts.*;
 
-class MetricsRecordImpl extends AbstractMetricsRecord {
+public class MetricsRecordImpl extends AbstractMetricsRecord {

Review Comment:
   Thanks for your help reviewing the code, I will modify the code.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org



[GitHub] [hadoop] slfan1989 commented on a diff in pull request #4457: HADOOP-18302. Remove WhiteBox in hadoop-common module.

2022-08-18 Thread GitBox


slfan1989 commented on code in PR #4457:
URL: https://github.com/apache/hadoop/pull/4457#discussion_r949683088


##
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/impl/TestStatsDMetrics.java:
##
@@ -31,13 +31,13 @@
 import java.util.List;
 import java.util.Set;
 
+import org.apache.commons.lang3.reflect.FieldUtils;

Review Comment:
   `org.apache.commons.lang3.reflect.FieldUtils` has been removed, and 
TestStatsDMetrics.java has also been moved to the package 
org.apache.hadoop.metrics2.sink.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org



[GitHub] [hadoop] slfan1989 commented on a diff in pull request #4457: HADOOP-18302. Remove WhiteBox in hadoop-common module.

2022-08-18 Thread GitBox


slfan1989 commented on code in PR #4457:
URL: https://github.com/apache/hadoop/pull/4457#discussion_r949678639


##
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/GraphiteSink.java:
##
@@ -37,171 +37,176 @@
 import java.nio.charset.StandardCharsets;
 
 /**
- * A metrics sink that writes to a Graphite server
+ * A metrics sink that writes to a Graphite server.
  */
 @InterfaceAudience.Public
 @InterfaceStability.Evolving
 public class GraphiteSink implements MetricsSink, Closeable {
-private static final Logger LOG =
-LoggerFactory.getLogger(GraphiteSink.class);
-private static final String SERVER_HOST_KEY = "server_host";
-private static final String SERVER_PORT_KEY = "server_port";
-private static final String METRICS_PREFIX = "metrics_prefix";
-private String metricsPrefix = null;
-private Graphite graphite = null;
-
-@Override
-public void init(SubsetConfiguration conf) {
-// Get Graphite host configurations.
-final String serverHost = conf.getString(SERVER_HOST_KEY);
-final int serverPort = 
Integer.parseInt(conf.getString(SERVER_PORT_KEY));
-
-// Get Graphite metrics graph prefix.
-metricsPrefix = conf.getString(METRICS_PREFIX);
-if (metricsPrefix == null)
-metricsPrefix = "";
-
-graphite = new Graphite(serverHost, serverPort);
-graphite.connect();
+  private static final Logger LOG =
+  LoggerFactory.getLogger(GraphiteSink.class);
+  private static final String SERVER_HOST_KEY = "server_host";
+  private static final String SERVER_PORT_KEY = "server_port";
+  private static final String METRICS_PREFIX = "metrics_prefix";
+  private String metricsPrefix = null;
+  private Graphite graphite = null;
+
+  @Override
+  public void init(SubsetConfiguration conf) {
+// Get Graphite host configurations.
+final String serverHost = conf.getString(SERVER_HOST_KEY);
+final int serverPort = Integer.parseInt(conf.getString(SERVER_PORT_KEY));
+
+// Get Graphite metrics graph prefix.
+metricsPrefix = conf.getString(METRICS_PREFIX);
+if (metricsPrefix == null) {
+  metricsPrefix = "";
 }
 
-@Override
-public void putMetrics(MetricsRecord record) {
-StringBuilder lines = new StringBuilder();
-StringBuilder metricsPathPrefix = new StringBuilder();
-
-// Configure the hierarchical place to display the graph.
-metricsPathPrefix.append(metricsPrefix).append(".")
-.append(record.context()).append(".").append(record.name());
-
-for (MetricsTag tag : record.tags()) {
-if (tag.value() != null) {
-metricsPathPrefix.append(".")
-.append(tag.name())
-.append("=")
-.append(tag.value());
-}
-}
-
-// The record timestamp is in milliseconds while Graphite expects an 
epoc time in seconds.
-long timestamp = record.timestamp() / 1000L;
+graphite = new Graphite(serverHost, serverPort);
+graphite.connect();
+  }
+
+  @Override
+  public void putMetrics(MetricsRecord record) {
+StringBuilder lines = new StringBuilder();
+StringBuilder metricsPathPrefix = new StringBuilder();
+
+// Configure the hierarchical place to display the graph.
+metricsPathPrefix.append(metricsPrefix).append(".")
+.append(record.context()).append(".").append(record.name());
+
+for (MetricsTag tag : record.tags()) {
+  if (tag.value() != null) {
+metricsPathPrefix.append(".")
+.append(tag.name())
+.append("=")
+.append(tag.value());
+  }
+}
 
-// Collect datapoints.
-for (AbstractMetric metric : record.metrics()) {
-lines.append(
-metricsPathPrefix.toString() + "."
-+ metric.name().replace(' ', '.')).append(" ")
-.append(metric.value()).append(" ").append(timestamp)
-.append("\n");
-}
+// The record timestamp is in milliseconds while Graphite expects an epoc 
time in seconds.
+long timestamp = record.timestamp() / 1000L;
 
-try {
-  graphite.write(lines.toString());
-} catch (Exception e) {
-  LOG.warn("Error sending metrics to Graphite", e);
-  try {
-graphite.close();
-  } catch (Exception e1) {
-throw new MetricsException("Error closing connection to Graphite", 
e1);
-  }
-}
+// Collect datapoints.
+for (AbstractMetric metric : record.metrics()) {
+  lines.append(metricsPathPrefix + "." + metric.name().replace(' ', 
'.')).append(" ")
+   .append(metric.value()).append(" ").append(timestamp)
+   .append("\n");
 }
 
-@Override
-public void flush() {
+try {
+  graphite.write(lines.toString());
+} catch (Exception e) {
+   

[GitHub] [hadoop] slfan1989 commented on a diff in pull request #4457: HADOOP-18302. Remove WhiteBox in hadoop-common module.

2022-08-18 Thread GitBox


slfan1989 commented on code in PR #4457:
URL: https://github.com/apache/hadoop/pull/4457#discussion_r949677121


##
hadoop-common-project/hadoop-nfs/src/test/java/org/apache/hadoop/portmap/TestPortmap.java:
##
@@ -76,7 +75,7 @@ public void testIdle() throws InterruptedException, 
IOException {
   }
 
   @Test(timeout = 1)
-  public void testRegistration() throws IOException, InterruptedException {
+  public void testRegistration() throws IOException, InterruptedException, 
IllegalAccessException {

Review Comment:
   I will fix it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org



[GitHub] [hadoop] slfan1989 commented on a diff in pull request #4457: HADOOP-18302. Remove WhiteBox in hadoop-common module.

2022-08-18 Thread GitBox


slfan1989 commented on code in PR #4457:
URL: https://github.com/apache/hadoop/pull/4457#discussion_r949086231


##
hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/portmap/RpcProgramPortmap.java:
##
@@ -208,4 +208,8 @@ public void exceptionCaught(ChannelHandlerContext ctx, 
Throwable t) {
 LOG.warn("Encountered ", t);
 ctx.channel().close();
   }
+
+  public ConcurrentHashMap getMap() {
+return map;
+  }

Review Comment:
   I will fix it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org



[GitHub] [hadoop] slfan1989 commented on a diff in pull request #4457: HADOOP-18302. Remove WhiteBox in hadoop-common module.

2022-08-18 Thread GitBox


slfan1989 commented on code in PR #4457:
URL: https://github.com/apache/hadoop/pull/4457#discussion_r949083968


##
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestIPC.java:
##
@@ -881,9 +880,8 @@ private void checkBlocking(int readers, int readerQ, int 
callQ) throws Exception
 // start server
 final TestServerQueue server =
 new TestServerQueue(clients, readers, callQ, handlers, conf);
-CallQueueManager spy = spy(
-(CallQueueManager)Whitebox.getInternalState(server, 
"callQueue"));
-Whitebox.setInternalState(server, "callQueue", spy);
+CallQueueManager spy = spy(server.getCallQueue());
+server.setCallQueue(spy);

Review Comment:
   I will fix it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org



[GitHub] [hadoop] slfan1989 commented on a diff in pull request #4457: HADOOP-18302. Remove WhiteBox in hadoop-common module.

2022-08-18 Thread GitBox


slfan1989 commented on code in PR #4457:
URL: https://github.com/apache/hadoop/pull/4457#discussion_r949082660


##
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java:
##
@@ -1282,9 +1280,8 @@ public void testClientBackOffByResponseTime() throws 
Exception {
 Server server = setupDecayRpcSchedulerandTestServer(ns + ".");
 
 @SuppressWarnings("unchecked")

Review Comment:
   I will fix it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org



[GitHub] [hadoop] slfan1989 commented on a diff in pull request #4457: HADOOP-18302. Remove WhiteBox in hadoop-common module.

2022-08-16 Thread GitBox


slfan1989 commented on code in PR #4457:
URL: https://github.com/apache/hadoop/pull/4457#discussion_r947366870


##
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java:
##
@@ -1219,9 +1218,8 @@ public void testClientBackOff() throws Exception {
 server = setupTestServer(builder);
 
 @SuppressWarnings("unchecked")

Review Comment:
   I will fix it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org



[GitHub] [hadoop] slfan1989 commented on a diff in pull request #4457: HADOOP-18302. Remove WhiteBox in hadoop-common module.

2022-08-16 Thread GitBox


slfan1989 commented on code in PR #4457:
URL: https://github.com/apache/hadoop/pull/4457#discussion_r947366781


##
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java:
##
@@ -663,8 +662,7 @@ private HttpServer2 checkBindAddress(String host, int port, 
boolean findPort)
 HttpServer2 server = createServer(host, port);
 try {
   // not bound, ephemeral should return requested port (0 for ephemeral)
-  List listeners = (List) Whitebox.getInternalState(server,
-  "listeners");
+  List listeners = server.getListeners();
   ServerConnector listener = (ServerConnector)listeners.get(0);

Review Comment:
   Thank you very much for your help reviewing the code, I will modify the code.



##
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java:
##
@@ -740,8 +738,7 @@ public void testBacklogSize() throws Exception
 Configuration conf = new Configuration();
 conf.setInt(HttpServer2.HTTP_SOCKET_BACKLOG_SIZE_KEY, backlogSize);
 HttpServer2 srv = createServer("test", conf);
-List listeners = (List) Whitebox.getInternalState(srv,
-"listeners");
+List listeners = srv.getListeners();
 ServerConnector listener = (ServerConnector)listeners.get(0);

Review Comment:
   I will fix it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org