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.namequeues; 019 020import org.apache.yetus.audience.InterfaceAudience; 021 022/** 023 * Base payload to be prepared by client to send various namedQueue events for in-memory ring buffer 024 * storage in either HMaster or RegionServer. e.g slowLog responses 025 */ 026@InterfaceAudience.Private 027public class NamedQueuePayload { 028 029 public enum NamedQueueEvent { 030 SLOW_LOG(0), 031 BALANCE_DECISION(1), 032 BALANCE_REJECTION(2); 033 034 private final int value; 035 036 NamedQueueEvent(int i) { 037 this.value = i; 038 } 039 040 public static NamedQueueEvent getEventByOrdinal(int value) { 041 switch (value) { 042 case 0: { 043 return SLOW_LOG; 044 } 045 case 1: { 046 return BALANCE_DECISION; 047 } 048 case 2: { 049 return BALANCE_REJECTION; 050 } 051 default: { 052 throw new IllegalArgumentException( 053 "NamedQueue event with ordinal " + value + " not defined"); 054 } 055 } 056 } 057 058 public int getValue() { 059 return value; 060 } 061 } 062 063 private final NamedQueueEvent namedQueueEvent; 064 065 public NamedQueuePayload(int eventOrdinal) { 066 this.namedQueueEvent = NamedQueueEvent.getEventByOrdinal(eventOrdinal); 067 } 068 069 public NamedQueueEvent getNamedQueueEvent() { 070 return namedQueueEvent; 071 } 072 073}