All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.hadoop.hbase.master.MetricsAssignmentManager Maven / Gradle / Ivy

There is a newer version: 3.0.0-beta-1
Show newest version
/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.hadoop.hbase.master;

import static org.apache.hadoop.hbase.master.MetricsMaster.convertToProcedureMetrics;

import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
import org.apache.hadoop.hbase.procedure2.ProcedureMetrics;
import org.apache.yetus.audience.InterfaceAudience;

@InterfaceAudience.Private
public class MetricsAssignmentManager {
  private final MetricsAssignmentManagerSource assignmentManagerSource;

  private final ProcedureMetrics assignProcMetrics;
  private final ProcedureMetrics unassignProcMetrics;
  private final ProcedureMetrics splitProcMetrics;
  private final ProcedureMetrics mergeProcMetrics;

  public MetricsAssignmentManager() {
    assignmentManagerSource = CompatibilitySingletonFactory.getInstance(
        MetricsAssignmentManagerSource.class);

    assignProcMetrics = convertToProcedureMetrics(assignmentManagerSource.getAssignMetrics());
    unassignProcMetrics = convertToProcedureMetrics(assignmentManagerSource.getUnassignMetrics());
    splitProcMetrics = convertToProcedureMetrics(assignmentManagerSource.getSplitMetrics());
    mergeProcMetrics = convertToProcedureMetrics(assignmentManagerSource.getMergeMetrics());
  }

  public MetricsAssignmentManagerSource getMetricsProcSource() {
    return assignmentManagerSource;
  }

  /**
   * set new value for number of regions in transition.
   * @param ritCount
   */
  public void updateRITCount(final int ritCount) {
    assignmentManagerSource.setRIT(ritCount);
  }

  /**
   * update RIT count that are in this state for more than the threshold
   * as defined by the property rit.metrics.threshold.time.
   * @param ritCountOverThreshold
   */
  public void updateRITCountOverThreshold(final int ritCountOverThreshold) {
    assignmentManagerSource.setRITCountOverThreshold(ritCountOverThreshold);
  }

  /**
   * update the timestamp for oldest region in transition metrics.
   * @param timestamp
   */
  public void updateRITOldestAge(final long timestamp) {
    assignmentManagerSource.setRITOldestAge(timestamp);
  }

  /**
   * update the duration metrics of region is transition
   * @param duration
   */
  public void updateRitDuration(long duration) {
    assignmentManagerSource.updateRitDuration(duration);
  }

  /*
   * TODO: Remove. This may not be required as assign and unassign operations are tracked separately
   * Increment the count of assignment operation (assign/unassign).
   */
  public void incrementOperationCounter() {
    assignmentManagerSource.incrementOperationCounter();
  }

  /**
   * @return Set of common metrics for assign procedure
   */
  public ProcedureMetrics getAssignProcMetrics() {
    return assignProcMetrics;
  }

  /**
   * @return Set of common metrics for unassign procedure
   */
  public ProcedureMetrics getUnassignProcMetrics() {
    return unassignProcMetrics;
  }

  /**
   * @return Set of common metrics for split procedure
   */
  public ProcedureMetrics getSplitProcMetrics() {
    return splitProcMetrics;
  }

  /**
   * @return Set of common metrics for merge procedure
   */
  public ProcedureMetrics getMergeProcMetrics() {
    return mergeProcMetrics;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy