View Javadoc

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
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
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.
17   */
18  package org.apache.hadoop.hbase.regionserver;
19  
20  import java.util.Collection;
21  import java.util.List;
22  import java.util.concurrent.ScheduledExecutorService;
23  import java.util.concurrent.TimeUnit;
24  
25  import org.apache.commons.lang.StringUtils;
26  import org.apache.commons.logging.Log;
27  import org.apache.commons.logging.LogFactory;
28  import org.apache.hadoop.hbase.classification.InterfaceAudience;
29  import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
30  import org.apache.hadoop.hbase.HConstants;
31  import org.apache.hadoop.hbase.HDFSBlocksDistribution;
32  import org.apache.hadoop.hbase.HRegionInfo;
33  import org.apache.hadoop.hbase.ServerName;
34  import org.apache.hadoop.hbase.io.hfile.BlockCache;
35  import org.apache.hadoop.hbase.io.hfile.CacheConfig;
36  import org.apache.hadoop.hbase.io.hfile.CacheStats;
37  import org.apache.hadoop.hbase.mob.MobCacheConfig;
38  import org.apache.hadoop.hbase.mob.MobFileCache;
39  import org.apache.hadoop.hbase.wal.BoundedRegionGroupingProvider;
40  import org.apache.hadoop.hbase.wal.DefaultWALProvider;
41  import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
42  import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
43  import org.apache.hadoop.metrics2.MetricsExecutor;
44  
45  /**
46   * Impl for exposing HRegionServer Information through Hadoop's metrics 2 system.
47   */
48  @InterfaceAudience.Private
49  class MetricsRegionServerWrapperImpl
50      implements MetricsRegionServerWrapper {
51  
52    public static final Log LOG = LogFactory.getLog(MetricsRegionServerWrapperImpl.class);
53  
54    private final HRegionServer regionServer;
55  
56    private BlockCache blockCache;
57    private MobFileCache mobFileCache;
58  
59    private volatile long numStores = 0;
60    private volatile long numWALFiles = 0;
61    private volatile long walFileSize = 0;
62    private volatile long numStoreFiles = 0;
63    private volatile long memstoreSize = 0;
64    private volatile long storeFileSize = 0;
65    private volatile long maxStoreFileAge = 0;
66    private volatile long minStoreFileAge = 0;
67    private volatile long avgStoreFileAge = 0;
68    private volatile long numReferenceFiles = 0;
69    private volatile double requestsPerSecond = 0.0;
70    private volatile long readRequestsCount = 0;
71    private volatile long writeRequestsCount = 0;
72    private volatile long checkAndMutateChecksFailed = 0;
73    private volatile long checkAndMutateChecksPassed = 0;
74    private volatile long storefileIndexSize = 0;
75    private volatile long totalStaticIndexSize = 0;
76    private volatile long totalStaticBloomSize = 0;
77    private volatile long numMutationsWithoutWAL = 0;
78    private volatile long dataInMemoryWithoutWAL = 0;
79    private volatile double percentFileLocal = 0;
80    private volatile double percentFileLocalSecondaryRegions = 0;
81    private volatile long flushedCellsCount = 0;
82    private volatile long compactedCellsCount = 0;
83    private volatile long majorCompactedCellsCount = 0;
84    private volatile long flushedCellsSize = 0;
85    private volatile long compactedCellsSize = 0;
86    private volatile long majorCompactedCellsSize = 0;
87    private volatile long cellsCountCompactedToMob = 0;
88    private volatile long cellsCountCompactedFromMob = 0;
89    private volatile long cellsSizeCompactedToMob = 0;
90    private volatile long cellsSizeCompactedFromMob = 0;
91    private volatile long mobFlushCount = 0;
92    private volatile long mobFlushedCellsCount = 0;
93    private volatile long mobFlushedCellsSize = 0;
94    private volatile long mobScanCellsCount = 0;
95    private volatile long mobScanCellsSize = 0;
96    private volatile long mobFileCacheAccessCount = 0;
97    private volatile long mobFileCacheMissCount = 0;
98    private volatile double mobFileCacheHitRatio = 0;
99    private volatile long mobFileCacheEvictedCount = 0;
100   private volatile long mobFileCacheCount = 0;
101   private volatile long blockedRequestsCount = 0L;
102   private volatile long averageRegionSize = 0L;
103 
104   private CacheStats cacheStats;
105   private ScheduledExecutorService executor;
106   private Runnable runnable;
107   private long period;
108 
109   public MetricsRegionServerWrapperImpl(final HRegionServer regionServer) {
110     this.regionServer = regionServer;
111     initBlockCache();
112     initMobFileCache();
113 
114     this.period =
115         regionServer.conf.getLong(HConstants.REGIONSERVER_METRICS_PERIOD,
116           HConstants.DEFAULT_REGIONSERVER_METRICS_PERIOD);
117 
118     this.executor = CompatibilitySingletonFactory.getInstance(MetricsExecutor.class).getExecutor();
119     this.runnable = new RegionServerMetricsWrapperRunnable();
120     this.executor.scheduleWithFixedDelay(this.runnable, this.period, this.period,
121       TimeUnit.MILLISECONDS);
122 
123     if (LOG.isInfoEnabled()) {
124       LOG.info("Computing regionserver metrics every " + this.period + " milliseconds");
125     }
126   }
127 
128   /**
129    * It's possible that due to threading the block cache could not be initialized
130    * yet (testing multiple region servers in one jvm).  So we need to try and initialize
131    * the blockCache and cacheStats reference multiple times until we succeed.
132    */
133   private synchronized  void initBlockCache() {
134     CacheConfig cacheConfig = this.regionServer.cacheConfig;
135     if (cacheConfig != null && this.blockCache == null) {
136       this.blockCache = cacheConfig.getBlockCache();
137     }
138 
139     if (this.blockCache != null && this.cacheStats == null) {
140       this.cacheStats = blockCache.getStats();
141     }
142   }
143 
144   /**
145    * Initializes the mob file cache.
146    */
147   private synchronized void initMobFileCache() {
148     MobCacheConfig mobCacheConfig = this.regionServer.mobCacheConfig;
149     if (mobCacheConfig != null && this.mobFileCache == null) {
150       this.mobFileCache = mobCacheConfig.getMobFileCache();
151     }
152   }
153 
154   @Override
155   public String getClusterId() {
156     return regionServer.getClusterId();
157   }
158 
159   @Override
160   public long getStartCode() {
161     return regionServer.getStartcode();
162   }
163 
164   @Override
165   public String getZookeeperQuorum() {
166     ZooKeeperWatcher zk = regionServer.getZooKeeper();
167     if (zk == null) {
168       return "";
169     }
170     return zk.getQuorum();
171   }
172 
173   @Override
174   public String getCoprocessors() {
175     String[] coprocessors = regionServer.getRegionServerCoprocessors();
176     if (coprocessors == null || coprocessors.length == 0) {
177       return "";
178     }
179     return StringUtils.join(coprocessors, ", ");
180   }
181 
182   @Override
183   public String getServerName() {
184     ServerName serverName = regionServer.getServerName();
185     if (serverName == null) {
186       return "";
187     }
188     return serverName.getServerName();
189   }
190 
191   @Override
192   public long getNumOnlineRegions() {
193     Collection<Region> onlineRegionsLocalContext = regionServer.getOnlineRegionsLocalContext();
194     if (onlineRegionsLocalContext == null) {
195       return 0;
196     }
197     return onlineRegionsLocalContext.size();
198   }
199 
200   @Override
201   public long getTotalRequestCount() {
202     return regionServer.rpcServices.requestCount.get();
203   }
204 
205   @Override
206   public int getSplitQueueSize() {
207     if (this.regionServer.compactSplitThread == null) {
208       return 0;
209     }
210     return this.regionServer.compactSplitThread.getSplitQueueSize();
211   }
212 
213   @Override
214   public int getCompactionQueueSize() {
215     //The thread could be zero.  if so assume there is no queue.
216     if (this.regionServer.compactSplitThread == null) {
217       return 0;
218     }
219     return this.regionServer.compactSplitThread.getCompactionQueueSize();
220   }
221 
222   @Override
223   public int getSmallCompactionQueueSize() {
224     //The thread could be zero.  if so assume there is no queue.
225     if (this.regionServer.compactSplitThread == null) {
226       return 0;
227     }
228     return this.regionServer.compactSplitThread.getSmallCompactionQueueSize();
229   }
230 
231   @Override
232   public int getLargeCompactionQueueSize() {
233     //The thread could be zero.  if so assume there is no queue.
234     if (this.regionServer.compactSplitThread == null) {
235       return 0;
236     }
237     return this.regionServer.compactSplitThread.getLargeCompactionQueueSize();
238   }
239 
240   @Override
241   public int getFlushQueueSize() {
242     //If there is no flusher there should be no queue.
243     if (this.regionServer.cacheFlusher == null) {
244       return 0;
245     }
246     return this.regionServer.cacheFlusher.getFlushQueueSize();
247   }
248 
249   @Override
250   public long getBlockCacheCount() {
251     if (this.blockCache == null) {
252       return 0;
253     }
254     return this.blockCache.getBlockCount();
255   }
256 
257   @Override
258   public long getBlockCacheSize() {
259     if (this.blockCache == null) {
260       return 0;
261     }
262     return this.blockCache.getCurrentSize();
263   }
264 
265   @Override
266   public long getBlockCacheFreeSize() {
267     if (this.blockCache == null) {
268       return 0;
269     }
270     return this.blockCache.getFreeSize();
271   }
272 
273   @Override
274   public long getBlockCacheHitCount() {
275     if (this.cacheStats == null) {
276       return 0;
277     }
278     return this.cacheStats.getHitCount();
279   }
280 
281   @Override
282   public long getBlockCachePrimaryHitCount() {
283     if (this.cacheStats == null) {
284       return 0;
285     }
286     return this.cacheStats.getPrimaryHitCount();
287   }
288 
289   @Override
290   public long getBlockCacheMissCount() {
291     if (this.cacheStats == null) {
292       return 0;
293     }
294     return this.cacheStats.getMissCount();
295   }
296 
297   @Override
298   public long getBlockCachePrimaryMissCount() {
299     if (this.cacheStats == null) {
300       return 0;
301     }
302     return this.cacheStats.getPrimaryMissCount();
303   }
304 
305   @Override
306   public long getBlockCacheEvictedCount() {
307     if (this.cacheStats == null) {
308       return 0;
309     }
310     return this.cacheStats.getEvictedCount();
311   }
312 
313   @Override
314   public long getBlockCachePrimaryEvictedCount() {
315     if (this.cacheStats == null) {
316       return 0;
317     }
318     return this.cacheStats.getPrimaryEvictedCount();
319   }
320 
321   @Override
322   public double getBlockCacheHitPercent() {
323     if (this.cacheStats == null) {
324       return 0;
325     }
326     double ratio = this.cacheStats.getHitRatio();
327     if (Double.isNaN(ratio)) {
328       ratio = 0;
329     }
330     return (ratio * 100);
331   }
332 
333   @Override
334   public double getBlockCacheHitCachingPercent() {
335     if (this.cacheStats == null) {
336       return 0;
337     }
338 
339     double ratio = this.cacheStats.getHitCachingRatio();
340 
341     if (Double.isNaN(ratio)) {
342       ratio = 0;
343     }
344     return (ratio * 100);
345   }
346 
347   @Override public void forceRecompute() {
348     this.runnable.run();
349   }
350 
351   @Override
352   public long getNumStores() {
353     return numStores;
354   }
355   
356   @Override
357   public long getNumWALFiles() {
358     return numWALFiles;
359   }
360 
361   @Override
362   public long getWALFileSize() {
363     return walFileSize;
364   }
365   
366   @Override
367   public long getNumStoreFiles() {
368     return numStoreFiles;
369   }
370 
371   @Override
372   public long getMaxStoreFileAge() {
373     return maxStoreFileAge;
374   }
375 
376   @Override
377   public long getMinStoreFileAge() {
378     return minStoreFileAge;
379   }
380 
381   @Override
382   public long getAvgStoreFileAge() {
383     return avgStoreFileAge;
384   }
385 
386   @Override
387   public long getNumReferenceFiles() {
388     return numReferenceFiles;
389   }
390 
391   @Override
392   public long getMemstoreSize() {
393     return memstoreSize;
394   }
395 
396   @Override
397   public long getStoreFileSize() {
398     return storeFileSize;
399   }
400 
401   @Override public double getRequestsPerSecond() {
402     return requestsPerSecond;
403   }
404 
405   @Override
406   public long getReadRequestsCount() {
407     return readRequestsCount;
408   }
409 
410   @Override
411   public long getWriteRequestsCount() {
412     return writeRequestsCount;
413   }
414 
415   @Override
416   public long getRpcGetRequestsCount() {
417     return regionServer.rpcServices.rpcGetRequestCount.get();
418   }
419 
420   @Override
421   public long getRpcScanRequestsCount() {
422     return regionServer.rpcServices.rpcScanRequestCount.get();
423   }
424 
425   @Override
426   public long getRpcMultiRequestsCount() {
427     return regionServer.rpcServices.rpcMultiRequestCount.get();
428   }
429 
430   @Override
431   public long getRpcMutateRequestsCount() {
432     return regionServer.rpcServices.rpcMutateRequestCount.get();
433   }
434 
435   @Override
436   public long getCheckAndMutateChecksFailed() {
437     return checkAndMutateChecksFailed;
438   }
439 
440   @Override
441   public long getCheckAndMutateChecksPassed() {
442     return checkAndMutateChecksPassed;
443   }
444 
445   @Override
446   public long getStoreFileIndexSize() {
447     return storefileIndexSize;
448   }
449 
450   @Override
451   public long getTotalStaticIndexSize() {
452     return totalStaticIndexSize;
453   }
454 
455   @Override
456   public long getTotalStaticBloomSize() {
457     return totalStaticBloomSize;
458   }
459 
460   @Override
461   public long getNumMutationsWithoutWAL() {
462     return numMutationsWithoutWAL;
463   }
464 
465   @Override
466   public long getDataInMemoryWithoutWAL() {
467     return dataInMemoryWithoutWAL;
468   }
469 
470   @Override
471   public double getPercentFileLocal() {
472     return percentFileLocal;
473   }
474 
475   @Override
476   public double getPercentFileLocalSecondaryRegions() {
477     return percentFileLocalSecondaryRegions;
478   }
479 
480   @Override
481   public long getUpdatesBlockedTime() {
482     if (this.regionServer.cacheFlusher == null) {
483       return 0;
484     }
485     return this.regionServer.cacheFlusher.getUpdatesBlockedMsHighWater().get();
486   }
487 
488   @Override
489   public long getFlushedCellsCount() {
490     return flushedCellsCount;
491   }
492 
493   @Override
494   public long getCompactedCellsCount() {
495     return compactedCellsCount;
496   }
497 
498   @Override
499   public long getMajorCompactedCellsCount() {
500     return majorCompactedCellsCount;
501   }
502 
503   @Override
504   public long getFlushedCellsSize() {
505     return flushedCellsSize;
506   }
507 
508   @Override
509   public long getCompactedCellsSize() {
510     return compactedCellsSize;
511   }
512 
513   @Override
514   public long getMajorCompactedCellsSize() {
515     return majorCompactedCellsSize;
516   }
517 
518   @Override
519   public long getCellsCountCompactedFromMob() {
520     return cellsCountCompactedFromMob;
521   }
522 
523   @Override
524   public long getCellsCountCompactedToMob() {
525     return cellsCountCompactedToMob;
526   }
527 
528   @Override
529   public long getCellsSizeCompactedFromMob() {
530     return cellsSizeCompactedFromMob;
531   }
532 
533   @Override
534   public long getCellsSizeCompactedToMob() {
535     return cellsSizeCompactedToMob;
536   }
537 
538   @Override
539   public long getMobFlushCount() {
540     return mobFlushCount;
541   }
542 
543   @Override
544   public long getMobFlushedCellsCount() {
545     return mobFlushedCellsCount;
546   }
547 
548   @Override
549   public long getMobFlushedCellsSize() {
550     return mobFlushedCellsSize;
551   }
552 
553   @Override
554   public long getMobScanCellsCount() {
555     return mobScanCellsCount;
556   }
557 
558   @Override
559   public long getMobScanCellsSize() {
560     return mobScanCellsSize;
561   }
562 
563   @Override
564   public long getMobFileCacheAccessCount() {
565     return mobFileCacheAccessCount;
566   }
567 
568   @Override
569   public long getMobFileCacheMissCount() {
570     return mobFileCacheMissCount;
571   }
572 
573   @Override
574   public long getMobFileCacheCount() {
575     return mobFileCacheCount;
576   }
577 
578   @Override
579   public long getMobFileCacheEvictedCount() {
580     return mobFileCacheEvictedCount;
581   }
582 
583   @Override
584   public int getMobFileCacheHitPercent() {
585     return (int) (mobFileCacheHitRatio * 100);
586   }
587 
588   /**
589    * This is the runnable that will be executed on the executor every PERIOD number of seconds
590    * It will take metrics/numbers from all of the regions and use them to compute point in
591    * time metrics.
592    */
593   public class RegionServerMetricsWrapperRunnable implements Runnable {
594 
595     private long lastRan = 0;
596     private long lastRequestCount = 0;
597 
598     @Override
599     synchronized public void run() {
600       try {
601         initBlockCache();
602         initMobFileCache();
603         cacheStats = blockCache.getStats();
604 
605         HDFSBlocksDistribution hdfsBlocksDistribution = new HDFSBlocksDistribution();
606         HDFSBlocksDistribution hdfsBlocksDistributionSecondaryRegions =
607             new HDFSBlocksDistribution();
608 
609         long tempNumStores = 0;
610         long tempNumStoreFiles = 0;
611         long tempMemstoreSize = 0;
612         long tempStoreFileSize = 0;
613         long tempMaxStoreFileAge = 0;
614         long tempNumReferenceFiles = 0;
615         long avgAgeNumerator = 0;
616         long numHFiles = 0;
617         long tempMinStoreFileAge = Long.MAX_VALUE;
618         long tempReadRequestsCount = 0;
619         long tempWriteRequestsCount = 0;
620         long tempCheckAndMutateChecksFailed = 0;
621         long tempCheckAndMutateChecksPassed = 0;
622         long tempStorefileIndexSize = 0;
623         long tempTotalStaticIndexSize = 0;
624         long tempTotalStaticBloomSize = 0;
625         long tempNumMutationsWithoutWAL = 0;
626         long tempDataInMemoryWithoutWAL = 0;
627         double tempPercentFileLocal = 0;
628         double tempPercentFileLocalSecondaryRegions = 0;
629         long tempFlushedCellsCount = 0;
630         long tempCompactedCellsCount = 0;
631         long tempMajorCompactedCellsCount = 0;
632         long tempCellsCountCompactedToMob = 0;
633         long tempCellsCountCompactedFromMob = 0;
634         long tempCellsSizeCompactedToMob = 0;
635         long tempCellsSizeCompactedFromMob = 0;
636         long tempMobFlushCount = 0;
637         long tempMobFlushedCellsCount = 0;
638         long tempMobFlushedCellsSize = 0;
639         long tempMobScanCellsCount = 0;
640         long tempMobScanCellsSize = 0;
641         long tempFlushedCellsSize = 0;
642         long tempCompactedCellsSize = 0;
643         long tempMajorCompactedCellsSize = 0;
644         long tempBlockedRequestsCount = 0L;
645 
646         int regionCount = 0;
647         for (Region r : regionServer.getOnlineRegionsLocalContext()) {
648           tempNumMutationsWithoutWAL += r.getNumMutationsWithoutWAL();
649           tempDataInMemoryWithoutWAL += r.getDataInMemoryWithoutWAL();
650           tempReadRequestsCount += r.getReadRequestsCount();
651           tempWriteRequestsCount += r.getWriteRequestsCount();
652           tempCheckAndMutateChecksFailed += r.getCheckAndMutateChecksFailed();
653           tempCheckAndMutateChecksPassed += r.getCheckAndMutateChecksPassed();
654           tempBlockedRequestsCount += r.getBlockedRequestsCount();
655           List<Store> storeList = r.getStores();
656           tempNumStores += storeList.size();
657           for (Store store : storeList) {
658             tempNumStoreFiles += store.getStorefilesCount();
659             tempMemstoreSize += store.getMemStoreSize();
660             tempStoreFileSize += store.getStorefilesSize();
661 
662             long storeMaxStoreFileAge = store.getMaxStoreFileAge();
663             tempMaxStoreFileAge = (storeMaxStoreFileAge > tempMaxStoreFileAge) ?
664               storeMaxStoreFileAge : tempMaxStoreFileAge;
665 
666             long storeMinStoreFileAge = store.getMinStoreFileAge();
667             tempMinStoreFileAge = (storeMinStoreFileAge < tempMinStoreFileAge) ?
668               storeMinStoreFileAge : tempMinStoreFileAge;
669 
670             long storeHFiles = store.getNumHFiles();
671             avgAgeNumerator += store.getAvgStoreFileAge() * storeHFiles;
672             numHFiles += storeHFiles;
673             tempNumReferenceFiles += store.getNumReferenceFiles();
674 
675             tempStorefileIndexSize += store.getStorefilesIndexSize();
676             tempTotalStaticBloomSize += store.getTotalStaticBloomSize();
677             tempTotalStaticIndexSize += store.getTotalStaticIndexSize();
678             tempFlushedCellsCount += store.getFlushedCellsCount();
679             tempCompactedCellsCount += store.getCompactedCellsCount();
680             tempMajorCompactedCellsCount += store.getMajorCompactedCellsCount();
681             tempFlushedCellsSize += store.getFlushedCellsSize();
682             tempCompactedCellsSize += store.getCompactedCellsSize();
683             tempMajorCompactedCellsSize += store.getMajorCompactedCellsSize();
684             if (store instanceof HMobStore) {
685               HMobStore mobStore = (HMobStore) store;
686               tempCellsCountCompactedToMob += mobStore.getCellsCountCompactedToMob();
687               tempCellsCountCompactedFromMob += mobStore.getCellsCountCompactedFromMob();
688               tempCellsSizeCompactedToMob += mobStore.getCellsSizeCompactedToMob();
689               tempCellsSizeCompactedFromMob += mobStore.getCellsSizeCompactedFromMob();
690               tempMobFlushCount += mobStore.getMobFlushCount();
691               tempMobFlushedCellsCount += mobStore.getMobFlushedCellsCount();
692               tempMobFlushedCellsSize += mobStore.getMobFlushedCellsSize();
693               tempMobScanCellsCount += mobStore.getMobScanCellsCount();
694               tempMobScanCellsSize += mobStore.getMobScanCellsSize();
695             }
696           }
697 
698           HDFSBlocksDistribution distro = r.getHDFSBlocksDistribution();
699           hdfsBlocksDistribution.add(distro);
700           if (r.getRegionInfo().getReplicaId() != HRegionInfo.DEFAULT_REPLICA_ID) {
701             hdfsBlocksDistributionSecondaryRegions.add(distro);
702           }
703           regionCount++;
704         }
705 
706         float localityIndex =
707             hdfsBlocksDistribution
708                 .getBlockLocalityIndex(regionServer.getServerName().getHostname());
709         tempPercentFileLocal = Double.isNaN(tempBlockedRequestsCount) ? 0 : (localityIndex * 100);
710 
711         float localityIndexSecondaryRegions =
712             hdfsBlocksDistributionSecondaryRegions.getBlockLocalityIndex(regionServer
713                 .getServerName().getHostname());
714         tempPercentFileLocalSecondaryRegions = Double
715             .isNaN(localityIndexSecondaryRegions) ? 0 : (localityIndexSecondaryRegions * 100);
716 
717         // Compute the number of requests per second
718         long currentTime = EnvironmentEdgeManager.currentTime();
719 
720         // assume that it took PERIOD seconds to start the executor.
721         // this is a guess but it's a pretty good one.
722         if (lastRan == 0) {
723           lastRan = currentTime - period;
724         }
725 
726         // If we've time traveled keep the last requests per second.
727         if ((currentTime - lastRan) > 0) {
728           long currentRequestCount = getTotalRequestCount();
729           requestsPerSecond =
730               (currentRequestCount - lastRequestCount) / ((currentTime - lastRan) / 1000.0);
731           lastRequestCount = currentRequestCount;
732         }
733         lastRan = currentTime;
734 
735         numWALFiles = DefaultWALProvider.getNumLogFiles(regionServer.walFactory) +
736           BoundedRegionGroupingProvider.getNumLogFiles(regionServer.walFactory);
737         walFileSize = DefaultWALProvider.getLogFileSize(regionServer.walFactory) +
738           BoundedRegionGroupingProvider.getLogFileSize(regionServer.walFactory);
739         // Copy over computed values so that no thread sees half computed values.
740         numStores = tempNumStores;
741         numStoreFiles = tempNumStoreFiles;
742         memstoreSize = tempMemstoreSize;
743         storeFileSize = tempStoreFileSize;
744         maxStoreFileAge = tempMaxStoreFileAge;
745         if (regionCount > 0) {
746           averageRegionSize = (memstoreSize + storeFileSize) / regionCount;
747         }
748         if (tempMinStoreFileAge != Long.MAX_VALUE) {
749           minStoreFileAge = tempMinStoreFileAge;
750         }
751 
752         if (numHFiles != 0) {
753           avgStoreFileAge = avgAgeNumerator / numHFiles;
754         }
755 
756         numReferenceFiles= tempNumReferenceFiles;
757         readRequestsCount = tempReadRequestsCount;
758         writeRequestsCount = tempWriteRequestsCount;
759         checkAndMutateChecksFailed = tempCheckAndMutateChecksFailed;
760         checkAndMutateChecksPassed = tempCheckAndMutateChecksPassed;
761         storefileIndexSize = tempStorefileIndexSize;
762         totalStaticIndexSize = tempTotalStaticIndexSize;
763         totalStaticBloomSize = tempTotalStaticBloomSize;
764         numMutationsWithoutWAL = tempNumMutationsWithoutWAL;
765         dataInMemoryWithoutWAL = tempDataInMemoryWithoutWAL;
766         percentFileLocal = tempPercentFileLocal;
767         percentFileLocalSecondaryRegions = tempPercentFileLocalSecondaryRegions;
768         flushedCellsCount = tempFlushedCellsCount;
769         compactedCellsCount = tempCompactedCellsCount;
770         majorCompactedCellsCount = tempMajorCompactedCellsCount;
771         flushedCellsSize = tempFlushedCellsSize;
772         compactedCellsSize = tempCompactedCellsSize;
773         majorCompactedCellsSize = tempMajorCompactedCellsSize;
774         cellsCountCompactedToMob = tempCellsCountCompactedToMob;
775         cellsCountCompactedFromMob = tempCellsCountCompactedFromMob;
776         cellsSizeCompactedToMob = tempCellsSizeCompactedToMob;
777         cellsSizeCompactedFromMob = tempCellsSizeCompactedFromMob;
778         mobFlushCount = tempMobFlushCount;
779         mobFlushedCellsCount = tempMobFlushedCellsCount;
780         mobFlushedCellsSize = tempMobFlushedCellsSize;
781         mobScanCellsCount = tempMobScanCellsCount;
782         mobScanCellsSize = tempMobScanCellsSize;
783         mobFileCacheAccessCount = mobFileCache.getAccessCount();
784         mobFileCacheMissCount = mobFileCache.getMissCount();
785         mobFileCacheHitRatio = mobFileCache.getHitRatio();
786         mobFileCacheEvictedCount = mobFileCache.getEvictedFileCount();
787         mobFileCacheCount = mobFileCache.getCacheSize();
788         blockedRequestsCount = tempBlockedRequestsCount;
789       } catch (Throwable e) {
790         LOG.warn("Caught exception! Will suppress and retry.", e);
791       }
792     }
793   }
794 
795   @Override
796   public long getBlockedRequestsCount() {
797     return blockedRequestsCount;
798   }
799 
800   @Override
801   public long getAverageRegionSize() {
802     return averageRegionSize;
803   }
804 
805   public long getDataMissCount() {
806     if (this.cacheStats == null) {
807       return 0;
808     }
809     return cacheStats.getDataMissCount();
810   }
811 
812   @Override
813   public long getLeafIndexMissCount() {
814     if (this.cacheStats == null) {
815       return 0;
816     }
817     return cacheStats.getLeafIndexMissCount();
818   }
819 
820   @Override
821   public long getBloomChunkMissCount() {
822     if (this.cacheStats == null) {
823       return 0;
824     }
825     return cacheStats.getBloomChunkMissCount();
826   }
827 
828   @Override
829   public long getMetaMissCount() {
830     if (this.cacheStats == null) {
831       return 0;
832     }
833     return cacheStats.getMetaMissCount();
834   }
835 
836   @Override
837   public long getRootIndexMissCount() {
838     if (this.cacheStats == null) {
839       return 0;
840     }
841     return cacheStats.getRootIndexMissCount();
842   }
843 
844   @Override
845   public long getIntermediateIndexMissCount() {
846     if (this.cacheStats == null) {
847       return 0;
848     }
849     return cacheStats.getIntermediateIndexMissCount();
850   }
851 
852   @Override
853   public long getFileInfoMissCount() {
854     if (this.cacheStats == null) {
855       return 0;
856     }
857     return cacheStats.getFileInfoMissCount();
858   }
859 
860   @Override
861   public long getGeneralBloomMetaMissCount() {
862     if (this.cacheStats == null) {
863       return 0;
864     }
865     return cacheStats.getGeneralBloomMetaMissCount();
866   }
867 
868   @Override
869   public long getDeleteFamilyBloomMissCount() {
870     if (this.cacheStats == null) {
871       return 0;
872     }
873     return cacheStats.getDeleteFamilyBloomMissCount();
874   }
875 
876   @Override
877   public long getTrailerMissCount() {
878     if (this.cacheStats == null) {
879       return 0;
880     }
881     return cacheStats.getTrailerMissCount();
882   }
883 
884   @Override
885   public long getDataHitCount() {
886     if (this.cacheStats == null) {
887       return 0;
888     }
889     return cacheStats.getDataHitCount();
890   }
891 
892   @Override
893   public long getLeafIndexHitCount() {
894     if (this.cacheStats == null) {
895       return 0;
896     }
897     return cacheStats.getLeafIndexHitCount();
898   }
899 
900   @Override
901   public long getBloomChunkHitCount() {
902     if (this.cacheStats == null) {
903       return 0;
904     }
905     return cacheStats.getBloomChunkHitCount();
906   }
907 
908   @Override
909   public long getMetaHitCount() {
910     if (this.cacheStats == null) {
911       return 0;
912     }
913     return cacheStats.getMetaHitCount();
914   }
915 
916   @Override
917   public long getRootIndexHitCount() {
918     if (this.cacheStats == null) {
919       return 0;
920     }
921     return cacheStats.getRootIndexHitCount();
922   }
923 
924   @Override
925   public long getIntermediateIndexHitCount() {
926     if (this.cacheStats == null) {
927       return 0;
928     }
929     return cacheStats.getIntermediateIndexHitCount();
930   }
931 
932   @Override
933   public long getFileInfoHitCount() {
934     if (this.cacheStats == null) {
935       return 0;
936     }
937     return cacheStats.getFileInfoHitCount();
938   }
939 
940   @Override
941   public long getGeneralBloomMetaHitCount() {
942     if (this.cacheStats == null) {
943       return 0;
944     }
945     return cacheStats.getGeneralBloomMetaHitCount();
946   }
947 
948   @Override
949   public long getDeleteFamilyBloomHitCount() {
950     if (this.cacheStats == null) {
951       return 0;
952     }
953     return cacheStats.getDeleteFamilyBloomHitCount();
954   }
955 
956   @Override
957   public long getTrailerHitCount() {
958     if (this.cacheStats == null) {
959       return 0;
960     }
961     return cacheStats.getTrailerHitCount();
962   }
963 }