1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.hbtop.mode;
19
20 import edu.umd.cs.findbugs.annotations.Nullable;
21 import java.util.List;
22 import java.util.Objects;
23
24 import org.apache.hadoop.hbase.ClusterStatus;
25 import org.apache.hadoop.hbase.classification.InterfaceAudience;
26 import org.apache.hadoop.hbase.hbtop.Record;
27 import org.apache.hadoop.hbase.hbtop.field.Field;
28 import org.apache.hadoop.hbase.hbtop.field.FieldInfo;
29
30
31
32
33 @InterfaceAudience.Private
34 public enum Mode {
35 NAMESPACE("Namespace", "Record per Namespace", new NamespaceModeStrategy()),
36 TABLE("Table", "Record per Table", new TableModeStrategy()),
37 REGION("Region", "Record per Region", new RegionModeStrategy()),
38 REGION_SERVER("RegionServer", "Record per RegionServer", new RegionServerModeStrategy());
39
40 private final String header;
41 private final String description;
42 private final ModeStrategy modeStrategy;
43
44 Mode(String header, String description, ModeStrategy modeStrategy) {
45 this.header = Objects.requireNonNull(header);
46 this.description = Objects.requireNonNull(description);
47 this.modeStrategy = Objects.requireNonNull(modeStrategy);
48 }
49
50 public String getHeader() {
51 return header;
52 }
53
54 public String getDescription() {
55 return description;
56 }
57
58 public List<Record> getRecords(ClusterStatus clusterStatus) {
59 return modeStrategy.getRecords(clusterStatus);
60 }
61
62 public List<FieldInfo> getFieldInfos() {
63 return modeStrategy.getFieldInfos();
64 }
65
66 public Field getDefaultSortField() {
67 return modeStrategy.getDefaultSortField();
68 }
69
70 @Nullable
71 public DrillDownInfo drillDown(Record currentRecord) {
72 return modeStrategy.drillDown(currentRecord);
73 }
74 }