You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2020/01/30 07:12:16 UTC

[GitHub] [hadoop-ozone] supratimdeka commented on a change in pull request #498: HDDS-2940. mkdir : create key table entries for intermediate directories in the path

supratimdeka commented on a change in pull request #498: HDDS-2940. mkdir : create key table entries for intermediate directories in the path
URL: https://github.com/apache/hadoop-ozone/pull/498#discussion_r372788152
 
 

 ##########
 File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/file/OMFileRequest.java
 ##########
 @@ -84,6 +92,70 @@ public static OMDirectoryResult verifyFilesInPath(
     return OMDirectoryResult.NONE;
   }
 
+  /**
+   * generate the object id from the transaction id.
+   * @param id
+   * @return object id
+   */
+  public static long getObjIdFromTxId(long id) {
+    return id << TRANSACTION_ID_SHIFT;
+  }
+
+  /**
+   * Return list of missing parent directories in the given path.
+   * @param omMetadataManager
+   * @param volumeName
+   * @param bucketName
+   * @param keyPath
+   * @return List of keys representing non-existent parent dirs
+   * @throws IOException
+   */
+  public static List<String> getMissingParents(
+      @Nonnull OMMetadataManager omMetadataManager,
+      @Nonnull String volumeName,
+      @Nonnull String bucketName,
+      @Nonnull Path keyPath) throws IOException {
+
+    List<String> missing = new ArrayList<>();
+
+    while (keyPath != null) {
+      String pathName = keyPath.toString();
+
+      String dbKeyName = omMetadataManager.getOzoneKey(volumeName,
+          bucketName, pathName);
+      String dbDirKeyName = omMetadataManager.getOzoneDirKey(volumeName,
+          bucketName, pathName);
+
+      if (omMetadataManager.getKeyTable().isExist(dbKeyName)) {
+        // Found a file in the given path.
+        String errorMsg = "File " + dbKeyName + " exists with same name as " +
+            " directory in path : " + pathName;
+        throw new IOException(errorMsg);
+      } else if (omMetadataManager.getKeyTable().isExist(dbDirKeyName)) {
+        // Found a directory in the given path. Higher parents must exist.
 
 Review comment:
   because clusters are not already deployed, if we introduce this change now, we do not have that problem. Of course we are referring to customer deployments here and not any internal test setups, 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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-issues-help@hadoop.apache.org