1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 package org.apache.hadoop.hbase.metrics;
20
21 /**
22 * BaseSource for dynamic metrics to announce to Metrics2.
23 * In hbase-hadoop{1|2}-compat there is an implementation of this interface.
24 */
25 public interface BaseSource {
26
27 String HBASE_METRICS_SYSTEM_NAME = "HBase";
28
29 /**
30 * Clear out the metrics and re-prepare the source.
31 */
32 void init();
33
34 /**
35 * Set a gauge to a specific value.
36 *
37 * @param gaugeName the name of the gauge
38 * @param value the value
39 */
40 void setGauge(String gaugeName, long value);
41
42 /**
43 * Add some amount to a gauge.
44 *
45 * @param gaugeName the name of the gauge
46 * @param delta the amount to change the gauge by.
47 */
48 void incGauge(String gaugeName, long delta);
49
50 /**
51 * Subtract some amount from a gauge.
52 *
53 * @param gaugeName the name of the gauge
54 * @param delta the amount to change the gauge by.
55 */
56 void decGauge(String gaugeName, long delta);
57
58 /**
59 * Remove a metric and no longer announce it.
60 *
61 * @param key Name of the gauge to remove.
62 */
63 void removeMetric(String key);
64
65 /**
66 * Add some amount to a counter.
67 *
68 * @param counterName the name of the counter
69 * @param delta the amount to change the counter by.
70 */
71 void incCounters(String counterName, long delta);
72
73 /**
74 * Add some value to a histogram.
75 *
76 * @param name the name of the histogram
77 * @param value the value to add to the histogram
78 */
79 void updateHistogram(String name, long value);
80
81
82 /**
83 * Add some value to a Quantile (An accurate histogram).
84 *
85 * @param name the name of the quantile
86 * @param value the value to add to the quantile
87 */
88 void updateQuantile(String name, long value);
89
90 /**
91 * Get the metrics context. For hadoop metrics2 system this is usually an all lowercased string.
92 * eg. regionserver, master, thriftserver
93 *
94 * @return The string context used to register this source to hadoop's metrics2 system.
95 */
96 String getMetricsContext();
97
98 /**
99 * Get the description of what this source exposes.
100 */
101 String getMetricsDescription();
102
103 /**
104 * Get the name of the context in JMX that this source will be exposed through.
105 * This is in ObjectName format. With the default context being Hadoop -> HBase
106 */
107 String getMetricsJmxContext();
108
109 /**
110 * Get the name of the metrics that are being exported by this source.
111 * Eg. IPC, GC, WAL
112 */
113 String getMetricsName();
114
115 }