Apache9 commented on code in PR #5834:
URL: https://github.com/apache/hbase/pull/5834#discussion_r1569899833


##########
hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/SplitTableRegionProcedure.java:
##########
@@ -666,8 +666,9 @@ private Pair<List<Path>, List<Path>> splitStoreFiles(final 
MasterProcedureEnv en
     // table dir. In case of failure, the proc would go through this again, 
already existing
     // region dirs and split files would just be ignored, new split files 
should get created.
     int nbFiles = 0;
-    final Map<String, Collection<StoreFileInfo>> files =
-      new HashMap<String, 
Collection<StoreFileInfo>>(htd.getColumnFamilyCount());
+    final Map<String, Pair<Collection<StoreFileInfo>, StoreFileTracker>> files 
=

Review Comment:
   We need a separate StoreFileTracker for every StoreFile? Seems strange...



##########
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileInfo.java:
##########
@@ -119,12 +120,13 @@ public class StoreFileInfo implements Configurable {
    * @param primaryReplica true if this is a store file for primary replica, 
otherwise false.
    */
   public StoreFileInfo(final Configuration conf, final FileSystem fs, final 
Path initialPath,
-    final boolean primaryReplica) throws IOException {
-    this(conf, fs, null, initialPath, primaryReplica);
+    final boolean primaryReplica, final StoreFileTracker sft) throws 
IOException {

Review Comment:
   I guess a better choice is to move these logics into StoreFileTracker, and 
make the constructor of StoreFileInfo simpler, so we do not need to pass so 
many parameters in...



##########
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/storefiletracker/DefaultStoreFileTracker.java:
##########
@@ -55,12 +65,49 @@ protected void 
doAddCompactionResults(Collection<StoreFileInfo> compactedFiles,
 
   @Override
   protected List<StoreFileInfo> doLoadStoreFiles(boolean readOnly) throws 
IOException {
-    List<StoreFileInfo> files =
-      
ctx.getRegionFileSystem().getStoreFiles(ctx.getFamily().getNameAsString());
+    List<StoreFileInfo> files = 
getStoreFiles(ctx.getFamily().getNameAsString(), true);
     return files != null ? files : Collections.emptyList();
   }
 
   @Override
   protected void doSetStoreFiles(Collection<StoreFileInfo> files) throws 
IOException {
   }
+
+  /**
+   * Returns the store files available for the family. This methods performs 
the filtering based on
+   * the valid store files.
+   * @param familyName Column Family Name
+   * @return a set of {@link StoreFileInfo} for the specified family.
+   */
+  public List<StoreFileInfo> getStoreFiles(final String familyName, final 
boolean validate)

Review Comment:
   Why putting this method here and there is no `@Override` annotation? It is 
for DefaultStoreFileTracker only? Who will call it?



##########
hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/SplitTableRegionProcedure.java:
##########
@@ -822,22 +825,25 @@ private class StoreFileSplitter implements 
Callable<Pair<Path, Path>> {
     private final HRegionFileSystem regionFs;
     private final byte[] family;
     private final HStoreFile sf;
+    private final StoreFileTracker tracker;
 
     /**
      * Constructor that takes what it needs to split
      * @param regionFs the file system
      * @param family   Family that contains the store file
      * @param sf       which file
      */
-    public StoreFileSplitter(HRegionFileSystem regionFs, byte[] family, 
HStoreFile sf) {
+    public StoreFileSplitter(HRegionFileSystem regionFs, StoreFileTracker 
tracker, byte[] family,
+      HStoreFile sf) {
       this.regionFs = regionFs;
       this.sf = sf;
       this.family = family;
+      this.tracker = tracker;
     }
 
     @Override
     public Pair<Path, Path> call() throws IOException {
-      return splitStoreFile(regionFs, family, sf);
+      return splitStoreFile(regionFs, tracker, family, sf);

Review Comment:
   I think here we need to abstract at a higer level. As if we use file based 
store file tracker, we do not need multi threading. So we'd better abstract a 
method for splitting multiple store files in the store file tracker interface, 
and in the implementation, we are free to choose whether to use multi threading.



##########
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/storefiletracker/StoreFileTrackerBase.java:
##########
@@ -189,6 +202,107 @@ public final StoreFileWriter 
createWriter(CreateStoreFileWriterParams params) th
     return builder.build();
   }
 
+  @Override
+  public String createHFileLink(CreateHFileLinkParams params) throws 
IOException {
+    String name = HFileLink.createHFileLinkName(params.getLinkedTable(), 
params.getLinkedRegion(),
+      params.getHfileName());
+    String refName =
+      HFileLink.createBackReferenceName(params.getDstTableName(), 
params.getDstRegionName());
+
+    // Make sure the destination directory exists
+    params.getFs().mkdirs(params.getDstFamilyPath());
+
+    // Make sure the FileLink reference directory exists
+    Path archiveStoreDir = HFileArchiveUtil.getStoreArchivePath(conf, 
params.getLinkedTable(),
+      params.getLinkedRegion(), params.getFamilyName());
+    Path backRefPath = null;
+    if (params.isCreateBackRef()) {
+      Path backRefssDir = HFileLink.getBackReferencesDir(archiveStoreDir, 
params.getHfileName());
+      params.getFs().mkdirs(backRefssDir);

Review Comment:
   So for now, we just move the logic here, but still always create a file on 
filesystem?



##########
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/storefiletracker/StoreFileTrackerBase.java:
##########
@@ -189,6 +202,107 @@ public final StoreFileWriter 
createWriter(CreateStoreFileWriterParams params) th
     return builder.build();
   }
 
+  @Override
+  public String createHFileLink(CreateHFileLinkParams params) throws 
IOException {
+    String name = HFileLink.createHFileLinkName(params.getLinkedTable(), 
params.getLinkedRegion(),
+      params.getHfileName());
+    String refName =
+      HFileLink.createBackReferenceName(params.getDstTableName(), 
params.getDstRegionName());
+
+    // Make sure the destination directory exists
+    params.getFs().mkdirs(params.getDstFamilyPath());
+
+    // Make sure the FileLink reference directory exists
+    Path archiveStoreDir = HFileArchiveUtil.getStoreArchivePath(conf, 
params.getLinkedTable(),
+      params.getLinkedRegion(), params.getFamilyName());
+    Path backRefPath = null;
+    if (params.isCreateBackRef()) {
+      Path backRefssDir = HFileLink.getBackReferencesDir(archiveStoreDir, 
params.getHfileName());
+      params.getFs().mkdirs(backRefssDir);
+
+      // Create the reference for the link
+      backRefPath = new Path(backRefssDir, refName);
+      params.getFs().createNewFile(backRefPath);
+    }
+    try {
+      // Create the link
+      if (params.getFs().createNewFile(new Path(params.getDstFamilyPath(), 
name))) {
+        return name;
+      }
+    } catch (IOException e) {
+      LOG.error("couldn't create the link=" + name + " for " + 
params.getDstFamilyPath(), e);
+      // Revert the reference if the link creation failed
+      if (params.isCreateBackRef()) {
+        params.getFs().delete(backRefPath, false);
+      }
+      throw e;
+    }
+    throw new IOException(
+      "File link=" + name + " already exists under " + 
params.getDstFamilyPath() + " folder.");
+  }
+
+  @Override
+  public Reference createReference(Reference reference, Path path) throws 
IOException {

Review Comment:
   OK, so just a placeholder right? Later we will implement different ways to 
create reference file and check whether there are references right?



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to