HBASE-26921 Rewrite the counting cells part in TestMultiVersions (#4316)
[hbase.git] / hbase-client / src / main / java / org / apache / hadoop / hbase / CacheEvictionStatsBuilder.java
blobd9e1400da16b1c9c6f17833f8b851ca1ee21cc4d
1 /**
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 package org.apache.hadoop.hbase;
21 import java.util.HashMap;
22 import java.util.Map;
24 import org.apache.yetus.audience.InterfaceAudience;
26 @InterfaceAudience.Private
27 public final class CacheEvictionStatsBuilder {
28 long evictedBlocks = 0;
29 long maxCacheSize = 0;
30 Map<byte[], Throwable> exceptions = new HashMap<>();
32 CacheEvictionStatsBuilder() {
35 public CacheEvictionStatsBuilder withEvictedBlocks(long evictedBlocks) {
36 this.evictedBlocks = evictedBlocks;
37 return this;
40 public CacheEvictionStatsBuilder withMaxCacheSize(long maxCacheSize) {
41 this.maxCacheSize = maxCacheSize;
42 return this;
45 public void addException(byte[] regionName, Throwable ie){
46 exceptions.put(regionName, ie);
49 public CacheEvictionStatsBuilder append(CacheEvictionStats stats) {
50 this.evictedBlocks += stats.getEvictedBlocks();
51 this.maxCacheSize += stats.getMaxCacheSize();
52 this.exceptions.putAll(stats.getExceptions());
53 return this;
56 public CacheEvictionStats build() {
57 return new CacheEvictionStats(this);