From 2440f807bf7d077def819c616d4afa97a4e2539e Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Wed, 21 Feb 2018 18:02:25 -0800 Subject: [PATCH] Revert "HBASE-19767 Fix for Master web UI shows negative values for Remaining KVs" Applied prematurely. This reverts commit 61b55166bf7fe9edc4e8105f217463ed6e693d17. --- .../hadoop/hbase/regionserver/HRegionServer.java | 2 +- .../apache/hadoop/hbase/regionserver/HStore.java | 4 ++-- .../compactions/CompactionProgress.java | 16 ++++------------ .../hbase/regionserver/TestMajorCompaction.java | 2 +- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index a76dec20770..49b7b806cd4 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -1623,7 +1623,7 @@ public class HRegionServer extends HasThread implements storefileIndexSizeKB += store.getStorefilesRootLevelIndexSize() / 1024; CompactionProgress progress = store.getCompactionProgress(); if (progress != null) { - totalCompactingKVs += progress.getTotalCompactingKVs(); + totalCompactingKVs += progress.totalCompactingKVs; currentCompactedKVs += progress.currentCompactedKVs; } rootLevelIndexSizeKB += (int) (store.getStorefilesRootLevelIndexSize() / 1024); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java index c0ef3ef2968..bef50b4878e 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HStore.java @@ -1373,10 +1373,10 @@ public class HStore implements Store, HeapSize, StoreConfigInformation, Propagat writeCompactionWalRecord(filesToCompact, sfs); replaceStoreFiles(filesToCompact, sfs); if (cr.isMajor()) { - majorCompactedCellsCount += getCompactionProgress().getTotalCompactingKVs(); + majorCompactedCellsCount += getCompactionProgress().totalCompactingKVs; majorCompactedCellsSize += getCompactionProgress().totalCompactedSize; } else { - compactedCellsCount += getCompactionProgress().getTotalCompactingKVs(); + compactedCellsCount += getCompactionProgress().totalCompactingKVs; compactedCellsSize += getCompactionProgress().totalCompactedSize; } long outputBytes = getTotalSize(sfs); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/CompactionProgress.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/CompactionProgress.java index 577276e85ed..d40651aa9d7 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/CompactionProgress.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/CompactionProgress.java @@ -20,8 +20,6 @@ package org.apache.hadoop.hbase.regionserver.compactions; import org.apache.yetus.audience.InterfaceAudience; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * This class holds information relevant for tracking the progress of a @@ -34,10 +32,9 @@ import org.slf4j.LoggerFactory; */ @InterfaceAudience.Private public class CompactionProgress { - private static final Logger LOG = LoggerFactory.getLogger(CompactionProgress.class); /** the total compacting key values in currently running compaction */ - private long totalCompactingKVs; + public long totalCompactingKVs; /** the completed count of key values in currently running compaction */ public long currentCompactedKVs = 0; /** the total size of data processed by the currently running compaction, in bytes */ @@ -54,7 +51,7 @@ public class CompactionProgress { * @return float */ public float getProgressPct() { - return (float)currentCompactedKVs / getTotalCompactingKVs(); + return (float)currentCompactedKVs / totalCompactingKVs; } /** @@ -75,12 +72,7 @@ public class CompactionProgress { /** * @return the total compacting key values in currently running compaction */ - public long getTotalCompactingKVs() { - if (totalCompactingKVs < currentCompactedKVs) { - LOG.warn("totalCompactingKVs={} less than currentCompactedKVs={}", - totalCompactingKVs, currentCompactedKVs); - return currentCompactedKVs; - } + public long getTotalCompactingKvs() { return totalCompactingKVs; } @@ -100,7 +92,7 @@ public class CompactionProgress { @Override public String toString() { - return String.format("%d/%d (%.2f%%)", currentCompactedKVs, getTotalCompactingKVs(), + return String.format("%d/%d (%.2f%%)", currentCompactedKVs, totalCompactingKVs, 100 * getProgressPct()); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMajorCompaction.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMajorCompaction.java index 4fdd6b337f6..ee717f911bf 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMajorCompaction.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMajorCompaction.java @@ -221,7 +221,7 @@ public class TestMajorCompaction { if( progress != null ) { ++storeCount; assertTrue(progress.currentCompactedKVs > 0); - assertTrue(progress.getTotalCompactingKVs() > 0); + assertTrue(progress.totalCompactingKVs > 0); } assertTrue(storeCount > 0); }