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 splitProcMetrics
;
34 private final ProcedureMetrics mergeProcMetrics
;
36 public MetricsAssignmentManager() {
37 assignmentManagerSource
= CompatibilitySingletonFactory
.getInstance(
38 MetricsAssignmentManagerSource
.class);
40 assignProcMetrics
= convertToProcedureMetrics(assignmentManagerSource
.getAssignMetrics());
41 unassignProcMetrics
= convertToProcedureMetrics(assignmentManagerSource
.getUnassignMetrics());
42 splitProcMetrics
= convertToProcedureMetrics(assignmentManagerSource
.getSplitMetrics());
43 mergeProcMetrics
= convertToProcedureMetrics(assignmentManagerSource
.getMergeMetrics());
46 public MetricsAssignmentManagerSource
getMetricsProcSource() {
47 return assignmentManagerSource
;
51 * set new value for number of regions in transition.
54 public void updateRITCount(final int ritCount
) {
55 assignmentManagerSource
.setRIT(ritCount
);
59 * update RIT count that are in this state for more than the threshold
60 * as defined by the property rit.metrics.threshold.time.
61 * @param ritCountOverThreshold
63 public void updateRITCountOverThreshold(final int ritCountOverThreshold
) {
64 assignmentManagerSource
.setRITCountOverThreshold(ritCountOverThreshold
);
68 * update the timestamp for oldest region in transition metrics.
71 public void updateRITOldestAge(final long timestamp
) {
72 assignmentManagerSource
.setRITOldestAge(timestamp
);
76 * update the duration metrics of region is transition
79 public void updateRitDuration(long duration
) {
80 assignmentManagerSource
.updateRitDuration(duration
);
84 * TODO: Remove. This may not be required as assign and unassign operations are tracked separately
85 * Increment the count of assignment operation (assign/unassign).
87 public void incrementOperationCounter() {
88 assignmentManagerSource
.incrementOperationCounter();
92 * @return Set of common metrics for assign procedure
94 public ProcedureMetrics
getAssignProcMetrics() {
95 return assignProcMetrics
;
99 * @return Set of common metrics for unassign procedure
101 public ProcedureMetrics
getUnassignProcMetrics() {
102 return unassignProcMetrics
;
106 * @return Set of common metrics for split procedure
108 public ProcedureMetrics
getSplitProcMetrics() {
109 return splitProcMetrics
;
113 * @return Set of common metrics for merge procedure
115 public ProcedureMetrics
getMergeProcMetrics() {
116 return mergeProcMetrics
;