steveloughran commented on a change in pull request #2069:
URL: https://github.com/apache/hadoop/pull/2069#discussion_r474654134



##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FSInputStream.java
##########
@@ -134,4 +137,23 @@ public void readFully(long position, byte[] buffer)
     throws IOException {
     readFully(position, buffer, 0, buffer.length);
   }
+
+  /**
+   * toString method returns the superclass toString, but if the subclass
+   * implements {@link IOStatisticsSource} then those statistics are
+   * extracted and included in the output.
+   * That is: statistics of subclasses are automatically reported.
+   * @return a string value.
+   */
+  @Override
+  public String toString() {
+    final StringBuilder sb = new StringBuilder(super.toString());
+    sb.append('{');
+    if (this instanceof IOStatisticsSource) {
+      sb.append(IOStatisticsLogging.ioStatisticsSourceToString(
+          (IOStatisticsSource) this));
+    }
+    sb.append('}');
+    return sb.toString();
+  }

Review comment:
       the logging lets us see what IO downstream apps are doing even without 
them picking up the API -the way S3A and ABFS streams do; The FSDataInputStream 
wrapper class &c do toString passthrough to help here. The IOStreams API Does 
exactly the same thing.
   
   Result
   1. code against this API, all the details, snapshots, java and JSON 
serialization, aggregation etc
   2. just log streams & fs & remoteiterable and anything else @ debug and you 
get to see what is going on without having binaries which only link against 
Hadoop releases with the API
   
   Option #2 is the interim one which you can do for any app today -we just 
have to make sure the hadoop wrapper/aggregate classes all have toString() 
calls which forward/include stats from inner classes, and do it efficiently
   
   




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to