busbey commented on a change in pull request #921: HBASE-22749: Distributed MOB 
compactions
URL: https://github.com/apache/hbase/pull/921#discussion_r375522161
 
 

 ##########
 File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/mob/DefaultMobStoreCompactor.java
 ##########
 @@ -99,59 +145,85 @@ public DefaultMobStoreCompactor(Configuration conf, 
HStore store) {
     if (!(store instanceof HMobStore)) {
       throw new IllegalArgumentException("The store " + store + " is not a 
HMobStore");
     }
-    mobStore = (HMobStore) store;
-    mobSizeThreshold = store.getColumnFamilyDescriptor().getMobThreshold();
+    this.mobStore = (HMobStore) store;
+    this.mobSizeThreshold = 
store.getColumnFamilyDescriptor().getMobThreshold();
+    this.ioOptimizedMode = conf.get(MobConstants.MOB_COMPACTION_TYPE_KEY,
+      MobConstants.DEFAULT_MOB_COMPACTION_TYPE).
+        equals(MobConstants.OPTIMIZED_MOB_COMPACTION_TYPE);
+
   }
 
   @Override
-  public List<Path> compact(CompactionRequestImpl request, 
ThroughputController throughputController,
-      User user) throws IOException {
+  public List<Path> compact(CompactionRequestImpl request,
+      ThroughputController throughputController, User user) throws IOException 
{
+    String tableName = store.getTableName().toString();
+    String regionName = store.getRegionInfo().getRegionNameAsString();
+    String familyName = store.getColumnFamilyName();
+    LOG.info("MOB compaction: major={} isAll={} priority={} throughput 
controller={}" +
+      " table={} cf={} region={}",
+      request.isMajor(), request.isAllFiles(), request.getPriority(),
+      throughputController, tableName, familyName, regionName);
+    if (request.getPriority() == HStore.PRIORITY_USER) {
+      userRequest.set(Boolean.TRUE);
+    } else {
+      userRequest.set(Boolean.FALSE);
+    }
+    LOG.debug("MOB compaction table={} cf={} region={} files: ", tableName, 
familyName,
+      regionName, request.getFiles());
+    // Check if I/O optimized MOB compaction
+    if (ioOptimizedMode) {
+      if (request.isMajor() && request.getPriority() == HStore.PRIORITY_USER) {
+        Path mobDir =
+            MobUtils.getMobFamilyPath(conf, store.getTableName(), 
store.getColumnFamilyName());
+        List<Path> mobFiles = 
MobUtils.getReferencedMobFiles(request.getFiles(), mobDir);
+        if (mobFiles.size() > 0) {
+          calculateMobLengthMap(mobFiles);
+        }
+        LOG.info("Table={} cf={} region={}. I/O optimized MOB compaction. "+
+            "Total referenced MOB files: {}", tableName, familyName, 
regionName, mobFiles.size());
+      }
+    }
+
     return compact(request, scannerFactory, writerFactory, 
throughputController, user);
   }
 
+  private void calculateMobLengthMap(List<Path> mobFiles) throws IOException {
+    FileSystem fs = mobFiles.get(0).getFileSystem(this.conf);
 
 Review comment:
   we should avoid creating new FileSystem objects. use `store.getFileSystem()`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to