{"action":"created","comment":{"url":"https://api.github.com/repos/Alluxio/alluxio/pulls/comments/92271327","pull_request_review_id":12784023,"id":92271327,"diff_hunk":"@@ -292,34 +298,57 @@ public void persistFile(long fileId, List<Long> blockIds) throws IOException {\n    *\n    * @param fileId the file id\n    * @return the path for persistence\n+   * @throws AlluxioException if an unexpected Alluxio exception is thrown\n    * @throws IOException if the folder creation fails\n    */\n-  private String prepareUfsFilePath(long fileId) throws IOException {\n+  private String prepareUfsFilePath(long fileId) throws AlluxioException, IOException {\n     String ufsRoot = Configuration.get(PropertyKey.UNDERFS_ADDRESS);\n     FileInfo fileInfo = mBlockWorker.getFileInfo(fileId);\n     AlluxioURI uri = new AlluxioURI(fileInfo.getPath());\n-    String dstPath = PathUtils.concatPath(ufsRoot, fileInfo.getPath());\n+    AlluxioURI dstPath = new AlluxioURI(PathUtils.concatPath(ufsRoot, fileInfo.getPath()));\n     LOG.info(\"persist file {} at {}\", fileId, dstPath);\n     String parentPath = PathUtils.concatPath(ufsRoot, uri.getParent().getPath());\n     // creates the parent folder if it does not exist\n     if (!mUfs.isDirectory(parentPath)) {\n-      final int maxRetry = 10;\n-      int numRetry = 0;\n-      // TODO(peis): Retry only if we are making progress.\n-      // TODO(chaomin): figure out a way to get parent permission in Alluxio namespace.\n-      for (; numRetry < maxRetry; numRetry++) {\n-        if (mUfs.mkdirs(parentPath) || mUfs.isDirectory(parentPath)) {\n-          break;\n+      FileSystem fs = FileSystem.Factory.get();\n+      // Create ancestor directories from top to the bottom. We cannot use recursive create parents\n+      // here because the permission for the ancestors can be different.\n+      Stack<Pair<String, MkdirsOptions>> ufsDirsToMakeWithOptions = new Stack<>();\n+      AlluxioURI curAlluxioPath = uri.getParent();\n+      AlluxioURI curUfsPath = dstPath.getParent();\n+      // Stop at the Alluxio root because the mapped directory of Alluxio root in UFS may not exist.\n+      while (!mUfs.isDirectory(curUfsPath.toString()) && curAlluxioPath != null) {\n+        URIStatus curDirStatus;\n+        curDirStatus = fs.getStatus(curAlluxioPath);\n+        Permission perm = new Permission(curDirStatus.getOwner(), curDirStatus.getGroup(),\n+            (short) curDirStatus.getMode());\n+        ufsDirsToMakeWithOptions.push(new Pair<>(curUfsPath.toString(),\n+            MkdirsOptions.defaults().setCreateParent(false).setPermission(perm)));\n+        curAlluxioPath = curAlluxioPath.getParent();\n+        curUfsPath = curUfsPath.getParent();\n+      }\n+      while (!ufsDirsToMakeWithOptions.empty()) {\n+        Pair<String, MkdirsOptions> ufsDirAndPerm = ufsDirsToMakeWithOptions.pop();\n+        if (!createUfsDirWithRetry(ufsDirAndPerm.getFirst(), ufsDirAndPerm.getSecond())) {\n+          throw new IOException(\"Failed to create dir: \" + ufsDirAndPerm.getFirst());\n         }\n-        // The parentPath can be created between the exists check and mkdirs call by other threads.\n-        LOG.warn(\"Failed to create dir: {}, retrying\", parentPath);\n       }\n-      if (numRetry == maxRetry && !mUfs.isDirectory(parentPath)) {\n-        throw new IOException(\n-            String.format(\"Failed to create dir: %s after %d retries.\", parentPath, numRetry));\n+    }\n+    return dstPath.toString();\n+  }\n+\n+  private boolean createUfsDirWithRetry(String dirPath, MkdirsOptions options) throws IOException {\n+    final int maxRetry = 10;\n+    int numRetry = 0;\n+    // TODO(peis): Retry only if we are making progress.\n+    for (; numRetry < maxRetry; numRetry++) {\n+      if (mUfs.isDirectory(dirPath) || mUfs.mkdirs(dirPath, options)) {","path":"core/server/src/main/java/alluxio/worker/file/FileDataManager.java","position":107,"original_position":107,"commit_id":"a79f2a10f5c1b7bc6dc46de34646ead1becfb900","original_commit_id":"9c9a1f7b949c8b1ce1cde86f54fbfdbec62ab955","user":{"login":"ifcharming","id":4342151,"avatar_url":"https://avatars.githubusercontent.com/u/4342151?v=3","gravatar_id":"","url":"https://api.github.com/users/ifcharming","html_url":"https://github.com/ifcharming","followers_url":"https://api.github.com/users/ifcharming/followers","following_url":"https://api.github.com/users/ifcharming/following{/other_user}","gists_url":"https://api.github.com/users/ifcharming/gists{/gist_id}","starred_url":"https://api.github.com/users/ifcharming/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ifcharming/subscriptions","organizations_url":"https://api.github.com/users/ifcharming/orgs","repos_url":"https://api.github.com/users/ifcharming/repos","events_url":"https://api.github.com/users/ifcharming/events{/privacy}","received_events_url":"https://api.github.com/users/ifcharming/received_events","type":"User","site_admin":false},"body":"I think we still might want to keep retry here, because other commands might be creating the dir at the same time?","created_at":"2016-12-13T21:33:46Z","updated_at":"2016-12-13T21:33:46Z","html_url":"https://github.com/Alluxio/alluxio/pull/4432#discussion_r92271327","pull_request_url":"https://api.github.com/repos/Alluxio/alluxio/pulls/4432","_links":{"self":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/comments/92271327"},"html":{"href":"https://github.com/Alluxio/alluxio/pull/4432#discussion_r92271327"},"pull_request":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/4432"}}},"pull_request":{"url":"https://api.github.com/repos/Alluxio/alluxio/pulls/4432","id":97633189,"html_url":"https://github.com/Alluxio/alluxio/pull/4432","diff_url":"https://github.com/Alluxio/alluxio/pull/4432.diff","patch_url":"https://github.com/Alluxio/alluxio/pull/4432.patch","issue_url":"https://api.github.com/repos/Alluxio/alluxio/issues/4432","number":4432,"state":"open","locked":false,"title":"[SMALLFIX] Make persist shell command go though Alluxio worker","user":{"login":"ifcharming","id":4342151,"avatar_url":"https://avatars.githubusercontent.com/u/4342151?v=3","gravatar_id":"","url":"https://api.github.com/users/ifcharming","html_url":"https://github.com/ifcharming","followers_url":"https://api.github.com/users/ifcharming/followers","following_url":"https://api.github.com/users/ifcharming/following{/other_user}","gists_url":"https://api.github.com/users/ifcharming/gists{/gist_id}","starred_url":"https://api.github.com/users/ifcharming/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ifcharming/subscriptions","organizations_url":"https://api.github.com/users/ifcharming/orgs","repos_url":"https://api.github.com/users/ifcharming/repos","events_url":"https://api.github.com/users/ifcharming/events{/privacy}","received_events_url":"https://api.github.com/users/ifcharming/received_events","type":"User","site_admin":false},"body":"Leverage `AsyncPersist` to remove the UFS dependency of persist shell command.\r\n\r\nThis PR fixes the ancestor permission propagation in AsyncPersist.\r\nIt also enables deprecation the Persist bit in `SetAttributeOptions`.","created_at":"2016-12-12T21:06:04Z","updated_at":"2016-12-13T21:33:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9e4a133dd605f7a9680c0dd8dc4e0e9657fe2d10","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Alluxio/alluxio/pulls/4432/commits","review_comments_url":"https://api.github.com/repos/Alluxio/alluxio/pulls/4432/comments","review_comment_url":"https://api.github.com/repos/Alluxio/alluxio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Alluxio/alluxio/issues/4432/comments","statuses_url":"https://api.github.com/repos/Alluxio/alluxio/statuses/a79f2a10f5c1b7bc6dc46de34646ead1becfb900","head":{"label":"ifcharming:persist-delegation","ref":"persist-delegation","sha":"a79f2a10f5c1b7bc6dc46de34646ead1becfb900","user":{"login":"ifcharming","id":4342151,"avatar_url":"https://avatars.githubusercontent.com/u/4342151?v=3","gravatar_id":"","url":"https://api.github.com/users/ifcharming","html_url":"https://github.com/ifcharming","followers_url":"https://api.github.com/users/ifcharming/followers","following_url":"https://api.github.com/users/ifcharming/following{/other_user}","gists_url":"https://api.github.com/users/ifcharming/gists{/gist_id}","starred_url":"https://api.github.com/users/ifcharming/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ifcharming/subscriptions","organizations_url":"https://api.github.com/users/ifcharming/orgs","repos_url":"https://api.github.com/users/ifcharming/repos","events_url":"https://api.github.com/users/ifcharming/events{/privacy}","received_events_url":"https://api.github.com/users/ifcharming/received_events","type":"User","site_admin":false},"repo":{"id":50484991,"name":"tachyon","full_name":"ifcharming/tachyon","owner":{"login":"ifcharming","id":4342151,"avatar_url":"https://avatars.githubusercontent.com/u/4342151?v=3","gravatar_id":"","url":"https://api.github.com/users/ifcharming","html_url":"https://github.com/ifcharming","followers_url":"https://api.github.com/users/ifcharming/followers","following_url":"https://api.github.com/users/ifcharming/following{/other_user}","gists_url":"https://api.github.com/users/ifcharming/gists{/gist_id}","starred_url":"https://api.github.com/users/ifcharming/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ifcharming/subscriptions","organizations_url":"https://api.github.com/users/ifcharming/orgs","repos_url":"https://api.github.com/users/ifcharming/repos","events_url":"https://api.github.com/users/ifcharming/events{/privacy}","received_events_url":"https://api.github.com/users/ifcharming/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ifcharming/tachyon","description":"Memory Centric Reliable Distributed Storage","fork":true,"url":"https://api.github.com/repos/ifcharming/tachyon","forks_url":"https://api.github.com/repos/ifcharming/tachyon/forks","keys_url":"https://api.github.com/repos/ifcharming/tachyon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ifcharming/tachyon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ifcharming/tachyon/teams","hooks_url":"https://api.github.com/repos/ifcharming/tachyon/hooks","issue_events_url":"https://api.github.com/repos/ifcharming/tachyon/issues/events{/number}","events_url":"https://api.github.com/repos/ifcharming/tachyon/events","assignees_url":"https://api.github.com/repos/ifcharming/tachyon/assignees{/user}","branches_url":"https://api.github.com/repos/ifcharming/tachyon/branches{/branch}","tags_url":"https://api.github.com/repos/ifcharming/tachyon/tags","blobs_url":"https://api.github.com/repos/ifcharming/tachyon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ifcharming/tachyon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ifcharming/tachyon/git/refs{/sha}","trees_url":"https://api.github.com/repos/ifcharming/tachyon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ifcharming/tachyon/statuses/{sha}","languages_url":"https://api.github.com/repos/ifcharming/tachyon/languages","stargazers_url":"https://api.github.com/repos/ifcharming/tachyon/stargazers","contributors_url":"https://api.github.com/repos/ifcharming/tachyon/contributors","subscribers_url":"https://api.github.com/repos/ifcharming/tachyon/subscribers","subscription_url":"https://api.github.com/repos/ifcharming/tachyon/subscription","commits_url":"https://api.github.com/repos/ifcharming/tachyon/commits{/sha}","git_commits_url":"https://api.github.com/repos/ifcharming/tachyon/git/commits{/sha}","comments_url":"https://api.github.com/repos/ifcharming/tachyon/comments{/number}","issue_comment_url":"https://api.github.com/repos/ifcharming/tachyon/issues/comments{/number}","contents_url":"https://api.github.com/repos/ifcharming/tachyon/contents/{+path}","compare_url":"https://api.github.com/repos/ifcharming/tachyon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ifcharming/tachyon/merges","archive_url":"https://api.github.com/repos/ifcharming/tachyon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ifcharming/tachyon/downloads","issues_url":"https://api.github.com/repos/ifcharming/tachyon/issues{/number}","pulls_url":"https://api.github.com/repos/ifcharming/tachyon/pulls{/number}","milestones_url":"https://api.github.com/repos/ifcharming/tachyon/milestones{/number}","notifications_url":"https://api.github.com/repos/ifcharming/tachyon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ifcharming/tachyon/labels{/name}","releases_url":"https://api.github.com/repos/ifcharming/tachyon/releases{/id}","deployments_url":"https://api.github.com/repos/ifcharming/tachyon/deployments","created_at":"2016-01-27T05:50:36Z","updated_at":"2016-01-27T05:50:40Z","pushed_at":"2016-12-13T21:23:08Z","git_url":"git://github.com/ifcharming/tachyon.git","ssh_url":"git@github.com:ifcharming/tachyon.git","clone_url":"https://github.com/ifcharming/tachyon.git","svn_url":"https://github.com/ifcharming/tachyon","homepage":"http://tachyon-project.org","size":64355,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Alluxio:master","ref":"master","sha":"840b0c8fc0c2548f070d05f6ea134253207d8016","user":{"login":"Alluxio","id":16203694,"avatar_url":"https://avatars.githubusercontent.com/u/16203694?v=3","gravatar_id":"","url":"https://api.github.com/users/Alluxio","html_url":"https://github.com/Alluxio","followers_url":"https://api.github.com/users/Alluxio/followers","following_url":"https://api.github.com/users/Alluxio/following{/other_user}","gists_url":"https://api.github.com/users/Alluxio/gists{/gist_id}","starred_url":"https://api.github.com/users/Alluxio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alluxio/subscriptions","organizations_url":"https://api.github.com/users/Alluxio/orgs","repos_url":"https://api.github.com/users/Alluxio/repos","events_url":"https://api.github.com/users/Alluxio/events{/privacy}","received_events_url":"https://api.github.com/users/Alluxio/received_events","type":"Organization","site_admin":false},"repo":{"id":7276954,"name":"alluxio","full_name":"Alluxio/alluxio","owner":{"login":"Alluxio","id":16203694,"avatar_url":"https://avatars.githubusercontent.com/u/16203694?v=3","gravatar_id":"","url":"https://api.github.com/users/Alluxio","html_url":"https://github.com/Alluxio","followers_url":"https://api.github.com/users/Alluxio/followers","following_url":"https://api.github.com/users/Alluxio/following{/other_user}","gists_url":"https://api.github.com/users/Alluxio/gists{/gist_id}","starred_url":"https://api.github.com/users/Alluxio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alluxio/subscriptions","organizations_url":"https://api.github.com/users/Alluxio/orgs","repos_url":"https://api.github.com/users/Alluxio/repos","events_url":"https://api.github.com/users/Alluxio/events{/privacy}","received_events_url":"https://api.github.com/users/Alluxio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Alluxio/alluxio","description":"Alluxio, formerly Tachyon, A Virtual Distributed Storage at Memory Speed","fork":false,"url":"https://api.github.com/repos/Alluxio/alluxio","forks_url":"https://api.github.com/repos/Alluxio/alluxio/forks","keys_url":"https://api.github.com/repos/Alluxio/alluxio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Alluxio/alluxio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Alluxio/alluxio/teams","hooks_url":"https://api.github.com/repos/Alluxio/alluxio/hooks","issue_events_url":"https://api.github.com/repos/Alluxio/alluxio/issues/events{/number}","events_url":"https://api.github.com/repos/Alluxio/alluxio/events","assignees_url":"https://api.github.com/repos/Alluxio/alluxio/assignees{/user}","branches_url":"https://api.github.com/repos/Alluxio/alluxio/branches{/branch}","tags_url":"https://api.github.com/repos/Alluxio/alluxio/tags","blobs_url":"https://api.github.com/repos/Alluxio/alluxio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Alluxio/alluxio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Alluxio/alluxio/git/refs{/sha}","trees_url":"https://api.github.com/repos/Alluxio/alluxio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Alluxio/alluxio/statuses/{sha}","languages_url":"https://api.github.com/repos/Alluxio/alluxio/languages","stargazers_url":"https://api.github.com/repos/Alluxio/alluxio/stargazers","contributors_url":"https://api.github.com/repos/Alluxio/alluxio/contributors","subscribers_url":"https://api.github.com/repos/Alluxio/alluxio/subscribers","subscription_url":"https://api.github.com/repos/Alluxio/alluxio/subscription","commits_url":"https://api.github.com/repos/Alluxio/alluxio/commits{/sha}","git_commits_url":"https://api.github.com/repos/Alluxio/alluxio/git/commits{/sha}","comments_url":"https://api.github.com/repos/Alluxio/alluxio/comments{/number}","issue_comment_url":"https://api.github.com/repos/Alluxio/alluxio/issues/comments{/number}","contents_url":"https://api.github.com/repos/Alluxio/alluxio/contents/{+path}","compare_url":"https://api.github.com/repos/Alluxio/alluxio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Alluxio/alluxio/merges","archive_url":"https://api.github.com/repos/Alluxio/alluxio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Alluxio/alluxio/downloads","issues_url":"https://api.github.com/repos/Alluxio/alluxio/issues{/number}","pulls_url":"https://api.github.com/repos/Alluxio/alluxio/pulls{/number}","milestones_url":"https://api.github.com/repos/Alluxio/alluxio/milestones{/number}","notifications_url":"https://api.github.com/repos/Alluxio/alluxio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Alluxio/alluxio/labels{/name}","releases_url":"https://api.github.com/repos/Alluxio/alluxio/releases{/id}","deployments_url":"https://api.github.com/repos/Alluxio/alluxio/deployments","created_at":"2012-12-21T17:43:46Z","updated_at":"2016-12-13T17:20:15Z","pushed_at":"2016-12-13T21:23:09Z","git_url":"git://github.com/Alluxio/alluxio.git","ssh_url":"git@github.com:Alluxio/alluxio.git","clone_url":"https://github.com/Alluxio/alluxio.git","svn_url":"https://github.com/Alluxio/alluxio","homepage":"http://www.alluxio.org/","size":63863,"stargazers_count":2759,"watchers_count":2759,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1251,"mirror_url":null,"open_issues_count":22,"forks":1251,"open_issues":22,"watchers":2759,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/4432"},"html":{"href":"https://github.com/Alluxio/alluxio/pull/4432"},"issue":{"href":"https://api.github.com/repos/Alluxio/alluxio/issues/4432"},"comments":{"href":"https://api.github.com/repos/Alluxio/alluxio/issues/4432/comments"},"review_comments":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/4432/comments"},"review_comment":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/4432/commits"},"statuses":{"href":"https://api.github.com/repos/Alluxio/alluxio/statuses/a79f2a10f5c1b7bc6dc46de34646ead1becfb900"}}}}
{"actor":{"display_login":"ifcharming"}}