You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2021/02/03 22:13:06 UTC

[GitHub] [hudi] prashantwason commented on a change in pull request #2495: [HUDI-1553] Configuration and metrics for the TimelineService.

prashantwason commented on a change in pull request #2495:
URL: https://github.com/apache/hudi/pull/2495#discussion_r569788497



##########
File path: hudi-timeline-service/src/main/java/org/apache/hudi/timeline/service/FileSystemViewHandler.java
##########
@@ -130,26 +147,54 @@ private boolean syncIfLocalViewBehind(Context ctx) {
   }
 
   private void writeValueAsString(Context ctx, Object obj) throws JsonProcessingException {
+    if (useAsync) {
+      writeValueAsStringAsync(ctx, obj);
+      return;
+    }
+
+    HoodieTimer timer = new HoodieTimer().startTimer();
     boolean prettyPrint = ctx.queryParam("pretty") != null;
     long beginJsonTs = System.currentTimeMillis();
     String result =
         prettyPrint ? OBJECT_MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(obj) : OBJECT_MAPPER.writeValueAsString(obj);
     long endJsonTs = System.currentTimeMillis();
     LOG.debug("Jsonify TimeTaken=" + (endJsonTs - beginJsonTs));
     ctx.result(result);
+    metricsRegistry.add("WRITE_VALUE_CNT", 1);
+    metricsRegistry.add("WRITE_VALUE_TIME", timer.endTimer());
+  }
+
+  private void writeValueAsStringAsync(Context ctx, Object obj) throws JsonProcessingException {
+    ctx.result(CompletableFuture.supplyAsync(() -> {
+      HoodieTimer timer = new HoodieTimer().startTimer();
+      boolean prettyPrint = ctx.queryParam("pretty") != null;
+      long beginJsonTs = System.currentTimeMillis();
+      try {
+        String result = prettyPrint ? OBJECT_MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(obj) : OBJECT_MAPPER.writeValueAsString(obj);
+        long endJsonTs = System.currentTimeMillis();
+        LOG.debug("Jsonify TimeTaken=" + (endJsonTs - beginJsonTs));

Review comment:
       Done

##########
File path: hudi-timeline-service/src/main/java/org/apache/hudi/timeline/service/FileSystemViewHandler.java
##########
@@ -130,26 +147,54 @@ private boolean syncIfLocalViewBehind(Context ctx) {
   }
 
   private void writeValueAsString(Context ctx, Object obj) throws JsonProcessingException {
+    if (useAsync) {
+      writeValueAsStringAsync(ctx, obj);
+      return;
+    }
+
+    HoodieTimer timer = new HoodieTimer().startTimer();
     boolean prettyPrint = ctx.queryParam("pretty") != null;
     long beginJsonTs = System.currentTimeMillis();
     String result =
         prettyPrint ? OBJECT_MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(obj) : OBJECT_MAPPER.writeValueAsString(obj);
     long endJsonTs = System.currentTimeMillis();
     LOG.debug("Jsonify TimeTaken=" + (endJsonTs - beginJsonTs));
     ctx.result(result);
+    metricsRegistry.add("WRITE_VALUE_CNT", 1);
+    metricsRegistry.add("WRITE_VALUE_TIME", timer.endTimer());
+  }
+
+  private void writeValueAsStringAsync(Context ctx, Object obj) throws JsonProcessingException {
+    ctx.result(CompletableFuture.supplyAsync(() -> {
+      HoodieTimer timer = new HoodieTimer().startTimer();
+      boolean prettyPrint = ctx.queryParam("pretty") != null;
+      long beginJsonTs = System.currentTimeMillis();
+      try {
+        String result = prettyPrint ? OBJECT_MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(obj) : OBJECT_MAPPER.writeValueAsString(obj);
+        long endJsonTs = System.currentTimeMillis();

Review comment:
       Yep.




----------------------------------------------------------------
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:
users@infra.apache.org