diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HMobStore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HMobStore.java index 929309e..0bf6c9a 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HMobStore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HMobStore.java @@ -62,6 +62,7 @@ import org.apache.hadoop.hbase.mob.MobUtils; import org.apache.hadoop.hbase.regionserver.compactions.CompactionContext; import org.apache.hadoop.hbase.regionserver.throttle.ThroughputController; +import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.util.HFileArchiveUtil; @@ -463,28 +464,24 @@ public Path getPath() { } /** - * The compaction in the store of mob. + * The compaction in the mob store. * The cells in this store contains the path of the mob files. There might be race - * condition between the major compaction and the sweeping in mob files. - * In order to avoid this, we need mutually exclude the running of the major compaction and - * sweeping in mob files. + * condition between the major compaction and the mob major compaction. + * In order to avoid this, we need mutually exclude the running of the major compaction + * and the mob major compaction. * The minor compaction is not affected. - * The major compaction is marked as retainDeleteMarkers when a sweeping is in progress. + * The major compaction is marked as retainDeleteMarkers when a mob major + * compaction is in progress. */ @Override public List compact(CompactionContext compaction, - ThroughputController throughputController) throws IOException { - // If it's major compaction, try to find whether there's a sweeper is running + ThroughputController throughputController, User user) throws IOException { + // If it's major compaction, try to find whether there's a mob major compaction is running // If yes, mark the major compaction as retainDeleteMarkers if (compaction.getRequest().isAllFiles()) { - // Use the ZooKeeper to coordinate. - // 1. Acquire a operation lock. - // 1.1. If no, mark the major compaction as retainDeleteMarkers and continue the compaction. - // 1.2. If the lock is obtained, search the node of sweeping. - // 1.2.1. If the node is there, the sweeping is in progress, mark the major - // compaction as retainDeleteMarkers and continue the compaction. - // 1.2.2. If the node is not there, add a child to the major compaction node, and - // run the compaction directly. + // Acquire a table lock to coordinate. + // 1. If no, mark the major compaction as retainDeleteMarkers and continue the compaction. + // 2. If the lock is obtained, run the compaction directly. TableLock lock = null; if (tableLockManager != null) { lock = tableLockManager.readLock(tableLockName, "Major compaction in HMobStore"); @@ -510,7 +507,7 @@ public Path getPath() { + tableName + "], forcing the delete markers to be retained"); compaction.getRequest().forceRetainDeleteMarkers(); } - return super.compact(compaction, throughputController); + return super.compact(compaction, throughputController, user); } finally { if (tableLocked && lock != null) { try { @@ -522,7 +519,7 @@ public Path getPath() { } } else { // If it's not a major compaction, continue the compaction. - return super.compact(compaction, throughputController); + return super.compact(compaction, throughputController, user); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHMobStore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHMobStore.java index 41879e9..2accf41 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHMobStore.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHMobStore.java @@ -537,7 +537,7 @@ public void testMOBStoreEncryption() throws Exception { // Trigger major compaction this.store.triggerMajorCompaction(); CompactionContext requestCompaction = this.store.requestCompaction(1, null); - this.store.compact(requestCompaction, NoLimitThroughputController.INSTANCE); + this.store.compact(requestCompaction, NoLimitThroughputController.INSTANCE, null); Assert.assertEquals(1, this.store.getStorefiles().size()); //Check encryption after compaction diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStore.java index 3f05381..46c1dd5 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStore.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStore.java @@ -381,7 +381,7 @@ public void testLowestModificationTime() throws Exception { Assert.assertEquals(lowestTimeStampFromManager,lowestTimeStampFromFS); // after compact; check the lowest time stamp - store.compact(store.requestCompaction(), NoLimitThroughputController.INSTANCE); + store.compact(store.requestCompaction(), NoLimitThroughputController.INSTANCE, null); lowestTimeStampFromManager = StoreUtils.getLowestTimestamp(store.getStorefiles()); lowestTimeStampFromFS = getLowestTimeStampFromFS(fs, store.getStorefiles()); Assert.assertEquals(lowestTimeStampFromManager, lowestTimeStampFromFS);