1 /*
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20 package org.apache.hadoop.hbase.namequeues;
21
22 import org.apache.hadoop.hbase.classification.InterfaceAudience;
23
24 /**
25 * Base payload to be prepared by client to send various namedQueue events for in-memory
26 * ring buffer storage in either HMaster or RegionServer.
27 * e.g slowLog responses
28 */
29 @InterfaceAudience.Private
30 public class NamedQueuePayload {
31
32 public enum NamedQueueEvent {
33 SLOW_LOG(0),
34 BALANCE_DECISION(1);
35
36 private final int value;
37
38 NamedQueueEvent(int i) {
39 this.value = i;
40 }
41
42 public static NamedQueueEvent getEventByOrdinal(int value){
43 switch (value) {
44 case 0: {
45 return SLOW_LOG;
46 }
47 case 1: {
48 return BALANCE_DECISION;
49 }
50 default: {
51 throw new IllegalArgumentException(
52 "NamedQueue event with ordinal " + value + " not defined");
53 }
54 }
55 }
56
57 public int getValue() {
58 return value;
59 }
60 }
61
62 private final NamedQueueEvent namedQueueEvent;
63
64 public NamedQueuePayload(int eventOrdinal) {
65 this.namedQueueEvent = NamedQueueEvent.getEventByOrdinal(eventOrdinal);
66 }
67
68 public NamedQueueEvent getNamedQueueEvent() {
69 return namedQueueEvent;
70 }
71
72 }