milleruntime commented on a change in pull request #1558: Resolve relative 
delete markers on upgrade. Closes #1463
URL: https://github.com/apache/accumulo/pull/1558#discussion_r390944429
 
 

 ##########
 File path: 
server/master/src/main/java/org/apache/accumulo/master/upgrade/Upgrader9to10.java
 ##########
 @@ -625,4 +626,39 @@ private static Path resolveRelativePath(String 
metadataEntry, Key key) {
       return new Path(prefix + tableId.canonical() + metadataEntry);
     }
   }
+
+  /**
+   * Resolve old relative delete markers of the form /tableId/tabletDir/[file] 
to
+   * UpgradeVolume/tables/tableId/tabletDir/[file]
+   */
+  static Path resolveRelativeDelete(VolumeManager fs, String oldDelete, String 
upgradeProperty) {
+    Path pathNoVolume = VolumeManager.FileType.TABLE.removeVolume(new 
Path(oldDelete));
+
+    // abs path won't be null so return
+    if (pathNoVolume != null)
+      return pathNoVolume;
+
+    // use Path to check the format is correct
+    Path pathToCheck = new Path(oldDelete);
+    Preconditions.checkState(
+        oldDelete.startsWith("/") && (pathToCheck.depth() == 2 || 
pathToCheck.depth() == 3),
+        "Unrecognized relative delete marker {}", oldDelete);
+
+    // found relative paths so verify the property used to build the absolute 
paths
+    if (upgradeProperty == null || upgradeProperty.isBlank()) {
+      throw new IllegalArgumentException(
+          "Missing required property " + 
Property.INSTANCE_VOLUMES_UPGRADE_RELATIVE.getKey());
+    }
+    Path absPath =
+        new Path(upgradeProperty, VolumeManager.FileType.TABLE.getDirectory() 
+ oldDelete);
+    try {
+      if (!fs.exists(absPath)) {
 
 Review comment:
   Good to know, thanks.  I will remove this check.

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