001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.master.balancer; 019 020import java.util.HashMap; 021import java.util.Map; 022 023public class DummyMetricsStochasticBalancer extends MetricsStochasticBalancer { 024 // We use a map to record those metrics that were updated to MetricsStochasticBalancer when 025 // running 026 // unit tests. 027 private Map<String, Double> costsMap; 028 029 public DummyMetricsStochasticBalancer() { 030 // noop 031 } 032 033 @Override 034 protected void initSource() { 035 costsMap = new HashMap<>(); 036 } 037 038 @Override 039 public void balanceCluster(long time) { 040 // noop 041 } 042 043 @Override 044 public void incrMiscInvocations() { 045 // noop 046 } 047 048 @Override 049 public void balancerStatus(boolean status) { 050 // noop 051 } 052 053 @Override 054 public void updateMetricsSize(int size) { 055 // noop 056 } 057 058 @Override 059 public void updateStochasticCost(String tableName, String costFunctionName, 060 String costFunctionDesc, Double value) { 061 String key = tableName + "#" + costFunctionName; 062 costsMap.put(key, value); 063 } 064 065 public Map<String, Double> getDummyCostsMap() { 066 return this.costsMap; 067 } 068 069 /** 070 * Clear all metrics in the cache map then prepare to run the next test 071 */ 072 public void clearDummyMetrics() { 073 this.costsMap.clear(); 074 } 075 076}