bharathv commented on a change in pull request #754: HBASE-22978 : Online slow 
response log
URL: https://github.com/apache/hbase/pull/754#discussion_r379692118
 
 

 ##########
 File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/client/SlowLogRecord.java
 ##########
 @@ -0,0 +1,317 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hbase.client;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.hadoop.hbase.util.GsonUtil;
+import org.apache.yetus.audience.InterfaceAudience;
+
+import org.apache.hbase.thirdparty.com.google.gson.Gson;
+import org.apache.hbase.thirdparty.com.google.gson.JsonObject;
+import org.apache.hbase.thirdparty.com.google.gson.JsonSerializer;
+
+/**
+ * SlowLog payload for client
+ */
+@InterfaceAudience.Private
+final public class SlowLogRecord {
+
+  private static final Gson GSON = GsonUtil.createGson()
+    .setPrettyPrinting()
+    .registerTypeAdapter(SlowLogRecord.class, (JsonSerializer<SlowLogRecord>)
+      (slowLogPayload, type, jsonSerializationContext) -> {
+        Gson gson = new Gson();
+        JsonObject jsonObj = (JsonObject) gson.toJsonTree(slowLogPayload);
+        if (slowLogPayload.getMultiGetsCount() == 0) {
+          jsonObj.remove("multiGetsCount");
+        }
+        if (slowLogPayload.getMultiMutationsCount() == 0) {
+          jsonObj.remove("multiMutationsCount");
+        }
+        if (slowLogPayload.getMultiServiceCalls() == 0) {
+          jsonObj.remove("multiServiceCalls");
+        }
+        return jsonObj;
+      }).create();
+
+  private long startTime;
+  private int processingTime;
+  private int queueTime;
+  private long responseSize;
+  private String clientAddress;
+  private String serverClass;
+  private String methodName;
+  private String callDetails;
+  private String param;
+  // we don't want to serialize region name, it is just for the filter purpose
+  // hence avoiding deserialization
+  private transient String regionName;
+  private String userName;
+  private int multiGetsCount;
+  private int multiMutationsCount;
+  private int multiServiceCalls;
+
+  public long getStartTime() {
+    return startTime;
+  }
+
+  public int getProcessingTime() {
+    return processingTime;
+  }
+
+  public int getQueueTime() {
+    return queueTime;
+  }
+
+  public long getResponseSize() {
+    return responseSize;
+  }
+
+  public String getClientAddress() {
+    return clientAddress;
+  }
+
+  public String getServerClass() {
+    return serverClass;
+  }
+
+  public String getMethodName() {
+    return methodName;
+  }
+
+  public String getCallDetails() {
+    return callDetails;
+  }
+
+  public String getParam() {
+    return param;
+  }
+
+  public String getRegionName() {
+    return regionName;
+  }
+
+  public String getUserName() {
+    return userName;
+  }
+
+  public int getMultiGetsCount() {
+    return multiGetsCount;
+  }
+
+  public int getMultiMutationsCount() {
+    return multiMutationsCount;
+  }
+
+  public int getMultiServiceCalls() {
+    return multiServiceCalls;
+  }
+
+  private SlowLogRecord(final long startTime, final int processingTime, final 
int queueTime,
 
 Review comment:
   nit: use a builder?

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


With regards,
Apache Git Services

Reply via email to