001/** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.hbtop.mode; 019 020import edu.umd.cs.findbugs.annotations.Nullable; 021import java.util.List; 022import java.util.Objects; 023import org.apache.hadoop.hbase.ClusterMetrics; 024import org.apache.hadoop.hbase.hbtop.Record; 025import org.apache.hadoop.hbase.hbtop.field.Field; 026import org.apache.hadoop.hbase.hbtop.field.FieldInfo; 027import org.apache.yetus.audience.InterfaceAudience; 028 029 030/** 031 * Represents a display mode in the top screen. 032 */ 033@InterfaceAudience.Private 034public enum Mode { 035 NAMESPACE("Namespace", "Record per Namespace", new NamespaceModeStrategy()), 036 TABLE("Table", "Record per Table", new TableModeStrategy()), 037 REGION("Region", "Record per Region", new RegionModeStrategy()), 038 REGION_SERVER("RegionServer", "Record per RegionServer", new RegionServerModeStrategy()); 039 040 private final String header; 041 private final String description; 042 private final ModeStrategy modeStrategy; 043 044 Mode(String header, String description, ModeStrategy modeStrategy) { 045 this.header = Objects.requireNonNull(header); 046 this.description = Objects.requireNonNull(description); 047 this.modeStrategy = Objects.requireNonNull(modeStrategy); 048 } 049 050 public String getHeader() { 051 return header; 052 } 053 054 public String getDescription() { 055 return description; 056 } 057 058 public List<Record> getRecords(ClusterMetrics clusterMetrics) { 059 return modeStrategy.getRecords(clusterMetrics); 060 } 061 062 public List<FieldInfo> getFieldInfos() { 063 return modeStrategy.getFieldInfos(); 064 } 065 066 public Field getDefaultSortField() { 067 return modeStrategy.getDefaultSortField(); 068 } 069 070 @Nullable 071 public DrillDownInfo drillDown(Record currentRecord) { 072 return modeStrategy.drillDown(currentRecord); 073 } 074}