joshelser commented on a change in pull request #476: HBASE-11062 hbtop
URL: https://github.com/apache/hbase/pull/476#discussion_r317656720
 
 

 ##########
 File path: 
hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/screen/top/TopScreenModel.java
 ##########
 @@ -0,0 +1,202 @@
+/**
+ * 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.hbtop.screen.top;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import org.apache.commons.lang3.time.DateFormatUtils;
+import org.apache.hadoop.hbase.ClusterMetrics;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.hbtop.Record;
+import org.apache.hadoop.hbase.hbtop.RecordFilter;
+import org.apache.hadoop.hbase.hbtop.field.Field;
+import org.apache.hadoop.hbase.hbtop.field.FieldInfo;
+import org.apache.hadoop.hbase.hbtop.field.FieldValue;
+import org.apache.hadoop.hbase.hbtop.mode.DrillDownInfo;
+import org.apache.hadoop.hbase.hbtop.mode.Mode;
+import org.apache.yetus.audience.InterfaceAudience;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The data and business logic for the top screen.
+ */
+@InterfaceAudience.Private
+public class TopScreenModel {
+
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(TopScreenModel.class);
+
+  private final Admin admin;
+
+  private Mode currentMode;
+  private Field currentSortField;
+  private List<FieldInfo> fieldInfos;
+  private List<Field> fields;
+
+  private Summary summary;
+  private List<Record> records;
+
+  private final List<RecordFilter> filters = new ArrayList<>();
+  private final List<String> filterHistories = new ArrayList<>();
+
+  private boolean ascendingSort;
+
+  public TopScreenModel(Admin admin, Mode initialMode) {
+    this.admin = Objects.requireNonNull(admin);
+    switchMode(Objects.requireNonNull(initialMode), null, false);
+  }
+
+  public void switchMode(Mode nextMode, List<RecordFilter> initialFilters,
+    boolean keepSortFieldAndSortOrderIfPossible) {
+
+    currentMode = nextMode;
+    fieldInfos = Collections.unmodifiableList(new 
ArrayList<>(currentMode.getFieldInfos()));
+    fields = Collections.unmodifiableList(new 
ArrayList<>(currentMode.getFieldInfos().stream()
 
 Review comment:
   Unnecessary `new ArrayList`. The Collector will already give us a new list.

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