001/* 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 */ 019 020package org.apache.hadoop.hbase.namequeues; 021 022import org.apache.yetus.audience.InterfaceAudience; 023 024/** 025 * Base payload to be prepared by client to send various namedQueue events for in-memory 026 * ring buffer storage in either HMaster or RegionServer. 027 * e.g slowLog responses 028 */ 029@InterfaceAudience.Private 030public class NamedQueuePayload { 031 032 public enum NamedQueueEvent { 033 SLOW_LOG(0), 034 BALANCE_DECISION(1); 035 036 private final int value; 037 038 NamedQueueEvent(int i) { 039 this.value = i; 040 } 041 042 public static NamedQueueEvent getEventByOrdinal(int value){ 043 switch (value) { 044 case 0: { 045 return SLOW_LOG; 046 } 047 case 1: { 048 return BALANCE_DECISION; 049 } 050 default: { 051 throw new IllegalArgumentException( 052 "NamedQueue event with ordinal " + value + " not defined"); 053 } 054 } 055 } 056 057 public int getValue() { 058 return value; 059 } 060 } 061 062 private final NamedQueueEvent namedQueueEvent; 063 064 public NamedQueuePayload(int eventOrdinal) { 065 this.namedQueueEvent = NamedQueueEvent.getEventByOrdinal(eventOrdinal); 066 } 067 068 public NamedQueueEvent getNamedQueueEvent() { 069 return namedQueueEvent; 070 } 071 072}