HBASE-26921 Rewrite the counting cells part in TestMultiVersions (#4316)
[hbase.git] / hbase-server / src / main / java / org / apache / hadoop / hbase / master / MetricsAssignmentManager.java
blob4c8926341b69a625110be363a6643ce7fed23990
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 package org.apache.hadoop.hbase.master;
21 import static org.apache.hadoop.hbase.master.MetricsMaster.convertToProcedureMetrics;
23 import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
24 import org.apache.hadoop.hbase.procedure2.ProcedureMetrics;
25 import org.apache.yetus.audience.InterfaceAudience;
27 @InterfaceAudience.Private
28 public class MetricsAssignmentManager {
29 private final MetricsAssignmentManagerSource assignmentManagerSource;
31 private final ProcedureMetrics assignProcMetrics;
32 private final ProcedureMetrics unassignProcMetrics;
33 private final ProcedureMetrics moveProcMetrics;
34 private final ProcedureMetrics reopenProcMetrics;
35 private final ProcedureMetrics openProcMetrics;
36 private final ProcedureMetrics closeProcMetrics;
37 private final ProcedureMetrics splitProcMetrics;
38 private final ProcedureMetrics mergeProcMetrics;
40 public MetricsAssignmentManager() {
41 assignmentManagerSource = CompatibilitySingletonFactory.getInstance(
42 MetricsAssignmentManagerSource.class);
44 assignProcMetrics = convertToProcedureMetrics(assignmentManagerSource.getAssignMetrics());
45 unassignProcMetrics = convertToProcedureMetrics(assignmentManagerSource.getUnassignMetrics());
46 moveProcMetrics = convertToProcedureMetrics(assignmentManagerSource.getMoveMetrics());
47 reopenProcMetrics = convertToProcedureMetrics(assignmentManagerSource.getReopenMetrics());
48 openProcMetrics = convertToProcedureMetrics(assignmentManagerSource.getOpenMetrics());
49 closeProcMetrics = convertToProcedureMetrics(assignmentManagerSource.getCloseMetrics());
50 splitProcMetrics = convertToProcedureMetrics(assignmentManagerSource.getSplitMetrics());
51 mergeProcMetrics = convertToProcedureMetrics(assignmentManagerSource.getMergeMetrics());
54 public MetricsAssignmentManagerSource getMetricsProcSource() {
55 return assignmentManagerSource;
58 /**
59 * set new value for number of regions in transition.
60 * @param ritCount
62 public void updateRITCount(final int ritCount) {
63 assignmentManagerSource.setRIT(ritCount);
66 /**
67 * update RIT count that are in this state for more than the threshold
68 * as defined by the property rit.metrics.threshold.time.
69 * @param ritCountOverThreshold
71 public void updateRITCountOverThreshold(final int ritCountOverThreshold) {
72 assignmentManagerSource.setRITCountOverThreshold(ritCountOverThreshold);
75 /**
76 * update the timestamp for oldest region in transition metrics.
77 * @param timestamp
79 public void updateRITOldestAge(final long timestamp) {
80 assignmentManagerSource.setRITOldestAge(timestamp);
83 /**
84 * update the duration metrics of region is transition
85 * @param duration
87 public void updateRitDuration(long duration) {
88 assignmentManagerSource.updateRitDuration(duration);
92 * TODO: Remove. This may not be required as assign and unassign operations are tracked separately
93 * Increment the count of assignment operation (assign/unassign).
95 public void incrementOperationCounter() {
96 assignmentManagerSource.incrementOperationCounter();
99 public void updateDeadServerOpenRegions(int deadRegions) {
100 assignmentManagerSource.updateDeadServerOpenRegions(deadRegions);
103 public void updateUnknownServerOpenRegions(int unknownRegions) {
104 assignmentManagerSource.updateUnknownServerOpenRegions(unknownRegions);
107 public void updateOrphanRegionsOnRs(int orphanRegionsOnRs) {
108 assignmentManagerSource.setOrphanRegionsOnRs(orphanRegionsOnRs);
111 public void updateOrphanRegionsOnFs(int orphanRegionsOnFs) {
112 assignmentManagerSource.setOrphanRegionsOnFs(orphanRegionsOnFs);
115 public void updateInconsistentRegions(int inconsistentRegions) {
116 assignmentManagerSource.setInconsistentRegions(inconsistentRegions);
119 public void updateHoles(int holes) {
120 assignmentManagerSource.setHoles(holes);
123 public void updateOverlaps(int overlaps) {
124 assignmentManagerSource.setOverlaps(overlaps);
127 public void updateUnknownServerRegions(int unknownServerRegions) {
128 assignmentManagerSource.setUnknownServerRegions(unknownServerRegions);
131 public void updateEmptyRegionInfoRegions(int emptyRegionInfoRegions) {
132 assignmentManagerSource.setEmptyRegionInfoRegions(emptyRegionInfoRegions);
136 * @return Set of common metrics for assign procedure
138 public ProcedureMetrics getAssignProcMetrics() {
139 return assignProcMetrics;
143 * @return Set of common metrics for unassign procedure
145 public ProcedureMetrics getUnassignProcMetrics() {
146 return unassignProcMetrics;
150 * @return Set of common metrics for move procedure
152 public ProcedureMetrics getMoveProcMetrics() {
153 return moveProcMetrics;
157 * @return Set of common metrics for reopen procedure
159 public ProcedureMetrics getReopenProcMetrics() {
160 return reopenProcMetrics;
164 * @return Set of common metrics for OpenRegionProcedure
166 public ProcedureMetrics getOpenProcMetrics() {
167 return openProcMetrics;
171 * @return Set of common metrics for CloseRegionProcedure
173 public ProcedureMetrics getCloseProcMetrics() {
174 return closeProcMetrics;
178 * @return Set of common metrics for split procedure
180 public ProcedureMetrics getSplitProcMetrics() {
181 return splitProcMetrics;
185 * @return Set of common metrics for merge procedure
187 public ProcedureMetrics getMergeProcMetrics() {
188 return mergeProcMetrics;