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.field;
019
020import java.util.Objects;
021import org.apache.yetus.audience.InterfaceAudience;
022
023/**
024 * Represents fields that are displayed in the top screen.
025 */
026@InterfaceAudience.Private
027public enum Field {
028  REGION_NAME("RNAME", "Region Name", true, true, FieldValueType.STRING),
029  NAMESPACE("NAMESPACE", "Namespace Name", true, true, FieldValueType.STRING),
030  TABLE("TABLE", "Table Name", true, true, FieldValueType.STRING),
031  START_CODE("SCODE", "Start Code", false, true, FieldValueType.STRING),
032  REPLICA_ID("REPID", "Replica ID", false, false, FieldValueType.STRING),
033  REGION("REGION", "Encoded Region Name", false, true, FieldValueType.STRING),
034  REGION_SERVER("RS", "Short Region Server Name", true, true, FieldValueType.STRING),
035  LONG_REGION_SERVER("LRS", "Long Region Server Name", true, true, FieldValueType.STRING),
036  REQUEST_COUNT_PER_SECOND("#REQ/S", "Request Count per second", false, false, FieldValueType.LONG),
037  READ_REQUEST_COUNT_PER_SECOND("#READ/S", "Read Request Count per second", false, false,
038    FieldValueType.LONG),
039  FILTERED_READ_REQUEST_COUNT_PER_SECOND("#FREAD/S", "Filtered Read Request Count per second",
040    false, false, FieldValueType.LONG),
041  WRITE_REQUEST_COUNT_PER_SECOND("#WRITE/S", "Write Request Count per second", false, false,
042    FieldValueType.LONG),
043  STORE_FILE_SIZE("SF", "StoreFile Size", false, false, FieldValueType.SIZE),
044  UNCOMPRESSED_STORE_FILE_SIZE("USF", "Uncompressed StoreFile Size", false, false,
045    FieldValueType.SIZE),
046  NUM_STORE_FILES("#SF", "Number of StoreFiles", false, false, FieldValueType.INTEGER),
047  MEM_STORE_SIZE("MEMSTORE", "MemStore Size", false, false, FieldValueType.SIZE),
048  LOCALITY("LOCALITY", "Block Locality", false, false, FieldValueType.FLOAT),
049  START_KEY("SKEY", "Start Key", true, true, FieldValueType.STRING),
050  COMPACTING_CELL_COUNT("#COMPingCELL", "Compacting Cell Count", false, false, FieldValueType.LONG),
051  COMPACTED_CELL_COUNT("#COMPedCELL", "Compacted Cell Count", false, false, FieldValueType.LONG),
052  COMPACTION_PROGRESS("%COMP", "Compaction Progress", false, false, FieldValueType.PERCENT),
053  LAST_MAJOR_COMPACTION_TIME("LASTMCOMP", "Last Major Compaction Time", false, true,
054    FieldValueType.STRING),
055  REGION_COUNT("#REGION", "Region Count", false, false, FieldValueType.INTEGER),
056  USED_HEAP_SIZE("UHEAP", "Used Heap Size", false, false, FieldValueType.SIZE),
057  USER("USER", "user Name", true, true, FieldValueType.STRING),
058  MAX_HEAP_SIZE("MHEAP", "Max Heap Size", false, false, FieldValueType.SIZE),
059  CLIENT_COUNT("#CLIENT", "Client Count", false, false, FieldValueType.INTEGER),
060  USER_COUNT("#USER", "User Count", false, false, FieldValueType.INTEGER),
061  CLIENT("CLIENT", "Client Hostname", true, true, FieldValueType.STRING);
062
063  private final String header;
064  private final String description;
065  private final boolean autoAdjust;
066  private final boolean leftJustify;
067  private final FieldValueType fieldValueType;
068
069  Field(String header, String description, boolean autoAdjust, boolean leftJustify,
070    FieldValueType fieldValueType) {
071    this.header = Objects.requireNonNull(header);
072    this.description = Objects.requireNonNull(description);
073    this.autoAdjust = autoAdjust;
074    this.leftJustify = leftJustify;
075    this.fieldValueType = Objects.requireNonNull(fieldValueType);
076  }
077
078  public FieldValue newValue(Object value) {
079    return new FieldValue(value, fieldValueType);
080  }
081
082  public String getHeader() {
083    return header;
084  }
085
086  public String getDescription() {
087    return description;
088  }
089
090  public boolean isAutoAdjust() {
091    return autoAdjust;
092  }
093
094  public boolean isLeftJustify() {
095    return leftJustify;
096  }
097
098  public FieldValueType getFieldValueType() {
099    return fieldValueType;
100  }
101}