Apache9 commented on a change in pull request #3350:
URL: https://github.com/apache/hbase/pull/3350#discussion_r648289833



##########
File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/CompactionServerMetricsBuilder.java
##########
@@ -0,0 +1,231 @@
+/**
+ * Copyright The Apache Software Foundation
+ * 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;
+
+import edu.umd.cs.findbugs.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.hadoop.hbase.util.Strings;
+import org.apache.yetus.audience.InterfaceAudience;
+import org.apache.hbase.thirdparty.com.google.common.base.Preconditions;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos;
+
+
[email protected]
+public final class CompactionServerMetricsBuilder {
+
+  /**
+   * @param sn the server name
+   * @return a empty metrics
+   */
+  public static CompactionServerMetrics of(ServerName sn) {
+    return newBuilder(sn).build();
+  }
+
+  public static CompactionServerMetrics of(ServerName sn, int versionNumber, 
String version) {
+    return 
newBuilder(sn).setVersionNumber(versionNumber).setVersion(version).build();
+  }
+
+  public static CompactionServerMetrics toCompactionServerMetrics(ServerName 
serverName,
+      ClusterStatusProtos.CompactionServerLoad serverLoadPB) {
+    return toCompactionServerMetrics(serverName, 0, "0.0.0", serverLoadPB);
+  }
+
+  public static CompactionServerMetrics toCompactionServerMetrics(ServerName 
serverName,
+    int versionNumber, String version, 
ClusterStatusProtos.CompactionServerLoad serverLoadPB) {
+    return CompactionServerMetricsBuilder.newBuilder(serverName)
+      .setInfoServerPort(serverLoadPB.getInfoServerPort())
+      .setCompactedCellCount(serverLoadPB.getCompactedCells())
+      .setCompactingCellCount(serverLoadPB.getCompactingCells())
+      .addCompactionTasks(serverLoadPB.getCompactionTasksList())
+      .setTotalNumberOfRequests(serverLoadPB.getTotalNumberOfRequests())
+      
.setLastReportTimestamp(serverLoadPB.getReportStartTime()).setVersionNumber(versionNumber)
+      .setVersion(version).build();
+  }
+
+  public static CompactionServerMetricsBuilder newBuilder(ServerName sn) {
+    return new CompactionServerMetricsBuilder(sn);
+  }
+
+  private final ServerName serverName;
+  private int versionNumber;
+  private String version = "0.0.0";
+  private int infoServerPort;
+  private long compactingCellCount;
+  private long compactedCellCount;
+  private long totalNumberOfRequests;
+  @Nullable

Review comment:
       Nullable but we initialize it with an empty array?

##########
File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/CompactionServerMetricsBuilder.java
##########
@@ -0,0 +1,231 @@
+/**
+ * Copyright The Apache Software Foundation
+ * 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;
+
+import edu.umd.cs.findbugs.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.hadoop.hbase.util.Strings;
+import org.apache.yetus.audience.InterfaceAudience;
+import org.apache.hbase.thirdparty.com.google.common.base.Preconditions;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos;
+
+
[email protected]
+public final class CompactionServerMetricsBuilder {
+
+  /**
+   * @param sn the server name
+   * @return a empty metrics
+   */
+  public static CompactionServerMetrics of(ServerName sn) {
+    return newBuilder(sn).build();
+  }
+
+  public static CompactionServerMetrics of(ServerName sn, int versionNumber, 
String version) {
+    return 
newBuilder(sn).setVersionNumber(versionNumber).setVersion(version).build();
+  }
+
+  public static CompactionServerMetrics toCompactionServerMetrics(ServerName 
serverName,
+      ClusterStatusProtos.CompactionServerLoad serverLoadPB) {
+    return toCompactionServerMetrics(serverName, 0, "0.0.0", serverLoadPB);
+  }
+
+  public static CompactionServerMetrics toCompactionServerMetrics(ServerName 
serverName,
+    int versionNumber, String version, 
ClusterStatusProtos.CompactionServerLoad serverLoadPB) {
+    return CompactionServerMetricsBuilder.newBuilder(serverName)
+      .setInfoServerPort(serverLoadPB.getInfoServerPort())
+      .setCompactedCellCount(serverLoadPB.getCompactedCells())
+      .setCompactingCellCount(serverLoadPB.getCompactingCells())
+      .addCompactionTasks(serverLoadPB.getCompactionTasksList())
+      .setTotalNumberOfRequests(serverLoadPB.getTotalNumberOfRequests())
+      
.setLastReportTimestamp(serverLoadPB.getReportStartTime()).setVersionNumber(versionNumber)
+      .setVersion(version).build();
+  }
+
+  public static CompactionServerMetricsBuilder newBuilder(ServerName sn) {
+    return new CompactionServerMetricsBuilder(sn);
+  }
+
+  private final ServerName serverName;
+  private int versionNumber;
+  private String version = "0.0.0";
+  private int infoServerPort;
+  private long compactingCellCount;
+  private long compactedCellCount;
+  private long totalNumberOfRequests;
+  @Nullable
+  private List<String> compactionTasks = new ArrayList<>();
+  private long reportTimestamp = System.currentTimeMillis();
+  private long lastReportTimestamp = 0;
+  private CompactionServerMetricsBuilder(ServerName serverName) {
+    this.serverName = serverName;
+  }
+
+  public CompactionServerMetricsBuilder setVersionNumber(int versionNumber) {
+    this.versionNumber = versionNumber;
+    return this;
+  }
+
+  public CompactionServerMetricsBuilder setVersion(String version) {
+    this.version = version;
+    return this;
+  }
+
+
+  public CompactionServerMetricsBuilder addCompactionTasks(List<String> 
compactionTasks) {
+    this.compactionTasks.addAll(compactionTasks);
+    return this;
+  }
+
+  public CompactionServerMetricsBuilder setTotalNumberOfRequests(long 
totalNumberOfRequests) {
+    this.totalNumberOfRequests = totalNumberOfRequests;
+    return this;
+  }
+
+  public CompactionServerMetricsBuilder setInfoServerPort(int value) {
+    this.infoServerPort = value;
+    return this;
+  }
+
+
+  public CompactionServerMetricsBuilder setCompactingCellCount(long value) {
+    this.compactingCellCount = value;
+    return this;
+  }
+
+  public CompactionServerMetricsBuilder setCompactedCellCount(long value) {
+    this.compactedCellCount = value;
+    return this;
+  }
+
+  public CompactionServerMetricsBuilder setReportTimestamp(long value) {
+    this.reportTimestamp = value;
+    return this;
+  }
+
+  public CompactionServerMetricsBuilder setLastReportTimestamp(long value) {
+    this.lastReportTimestamp = value;
+    return this;
+  }
+
+  public CompactionServerMetrics build() {
+    return new CompactionServerMetricsImpl(
+      serverName,
+      versionNumber,
+      version,
+      infoServerPort,
+      compactingCellCount,
+      compactedCellCount,
+      compactionTasks,
+      totalNumberOfRequests,
+      reportTimestamp,
+      lastReportTimestamp);
+  }
+
+  private static class CompactionServerMetricsImpl implements 
CompactionServerMetrics {
+    private final ServerName serverName;
+    private final int versionNumber;
+    private final String version;
+    private final int infoServerPort;
+    private final long compactingCellCount;
+    private final long compactedCellCount;
+    private final List<String> compactionTasks = new ArrayList<>();
+    private final long totalNumberOfRequests;
+    @Nullable
+    private final long reportTimestamp;

Review comment:
       How could a long be nullable?

##########
File path: 
hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/CompactionServerListTmpl.jamon
##########
@@ -72,27 +74,18 @@ Arrays.sort(serverNames);
 </thead>
 <tbody>
 <%java>
-    int totalRegions = 0;
-    int totalRequestsPerSecond = 0;
     int inconsistentNodeNum = 0;
     String masterVersion = VersionInfo.getVersion();
-    for (ServerName serverName: serverNames) {
 
-    ServerMetrics sl = master.getServerManager().getLoad(serverName);
+    for (ServerName serverName: serverNames) {
+    CompactionServerMetrics sl = 
master.getCompactionOffloadManager().getLoad(serverName);

Review comment:
       Indent?




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


Reply via email to