{"action":"created","comment":{"url":"https://api.github.com/repos/amplab/tachyon/pulls/comments/33829492","id":33829492,"diff_hunk":"@@ -0,0 +1,204 @@\n+/*\n+ * Licensed to the University of California, Berkeley under one or more contributor license\n+ * agreements. See the NOTICE file distributed with this work for additional information regarding\n+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance with the License. You may obtain a\n+ * copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software distributed under the License\n+ * is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\n+ * or implied. See the License for the specific language governing permissions and limitations under\n+ * the License.\n+ */\n+\n+package tachyon.worker.block;\n+\n+import java.io.IOException;\n+import java.util.List;\n+\n+import org.apache.thrift.TException;\n+\n+import tachyon.Users;\n+import tachyon.thrift.FileDoesNotExistException;\n+import tachyon.thrift.OutOfSpaceException;\n+import tachyon.thrift.WorkerService;\n+\n+/**\n+ * Handles all thrift RPC calls to the worker. This class is a thrift server implementation and is\n+ * thread safe.\n+ */\n+public class BlockServiceHandler implements WorkerService.Iface {\n+\n+  private final BlockDataManager mWorker;\n+\n+  public BlockServiceHandler(BlockDataManager worker) {\n+    mWorker = worker;\n+  }\n+\n+  public void accessBlock(long blockId) throws TException {\n+    try {\n+      mWorker.accessBlock(Users.ACCESS_BLOCK_USER_ID, blockId);\n+    } catch (IOException ioe) {\n+      throw new TException(ioe);\n+    }\n+  }\n+\n+  public void addCheckpoint(long userId, int fileId) throws TException {\n+    try {\n+      mWorker.addCheckpoint(userId, fileId);\n+    } catch (IOException ioe) {\n+      throw new TException(ioe);\n+    }\n+  }\n+\n+  // TODO: Make this supported again\n+  public boolean asyncCheckpoint(int fileId) throws TException {\n+    return false;\n+  }\n+\n+  /**\n+   * Used to cache a block into Tachyon space, worker will move the temporary block file from user\n+   * folder to data folder, and update the space usage information related. then update the block\n+   * information to master.\n+   *\n+   * @param userId\n+   * @param blockId\n+   */\n+  // TODO: Reconsider this exception handling\n+  public void cacheBlock(long userId, long blockId) throws TException {\n+    try {\n+      if (!mWorker.commitBlock(userId, blockId)) {\n+        throw new TException(\"Failed to commit block: \" + blockId);\n+      }\n+    } catch (IOException ioe) {\n+      throw new TException(ioe);\n+    }\n+  }\n+\n+  /**\n+   * Used to cancel a block which is being written. worker will delete the temporary block file and\n+   * the location and space information related, then reclaim space allocated to the block.\n+   *\n+   * @param userId\n+   * @param blockId\n+   */\n+  public void cancelBlock(long userId, long blockId) throws TException {\n+    try {\n+      mWorker.abortBlock(userId, blockId);\n+    } catch (IOException ioe) {\n+      throw new TException(ioe);\n+    }\n+  }\n+\n+  /**\n+   * Used to get user's temporary folder on under file system, and the path of the user's temporary\n+   * folder will be returned.\n+   *\n+   * @param userId\n+   */\n+  public String getUserUfsTempFolder(long userId) throws TException {\n+    return mWorker.getUserUfsTmpFolder(userId);\n+  }\n+\n+  /**\n+   * Lock the file in Tachyon's space while the user is reading it, and the path of the block file\n+   * locked will be returned, if the block file is not found, FileDoesNotExistException will be\n+   * thrown.\n+   *\n+   * @param blockId\n+   * @param userId\n+   */\n+  public String lockBlock(long blockId, long userId) throws TException {\n+    try {\n+      long lockId = mWorker.lockBlock(userId, blockId);\n+      return mWorker.readBlock(userId, blockId, lockId);\n+    } catch (IOException ioe) {\n+      throw new FileDoesNotExistException(\"Block \" + blockId + \" does not exist on this worker.\");\n+    }\n+  }\n+\n+  /**\n+   * Used to promote block on under storage layer to top storage layer when there are more than one\n+   * storage layers in Tachyon's space. return true if the block is successfully promoted, false\n+   * otherwise.\n+   *\n+   * @param blockId\n+   */\n+  public boolean promoteBlock(long blockId) throws TException {\n+    try {\n+      // TODO: Maybe add constant location for First Tier?\n+      mWorker.moveBlock(Users.MIGRATE_DATA_USER_ID, blockId, 1);","path":"servers/src/main/java/tachyon/worker/block/BlockServiceHandler.java","position":132,"original_position":132,"commit_id":"411d9b30619a15c32f3686d5934fcae467a857e9","original_commit_id":"4488e308bd1abe08206fb76c969aa2f1b0321744","user":{"login":"apc999","id":1413748,"avatar_url":"https://avatars.githubusercontent.com/u/1413748?v=3","gravatar_id":"","url":"https://api.github.com/users/apc999","html_url":"https://github.com/apc999","followers_url":"https://api.github.com/users/apc999/followers","following_url":"https://api.github.com/users/apc999/following{/other_user}","gists_url":"https://api.github.com/users/apc999/gists{/gist_id}","starred_url":"https://api.github.com/users/apc999/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apc999/subscriptions","organizations_url":"https://api.github.com/users/apc999/orgs","repos_url":"https://api.github.com/users/apc999/repos","events_url":"https://api.github.com/users/apc999/events{/privacy}","received_events_url":"https://api.github.com/users/apc999/received_events","type":"User","site_admin":false},"body":"`1` -> `StorageLevelAlias.MEM.getValue()` ?","created_at":"2015-07-02T22:35:57Z","updated_at":"2015-07-02T22:35:57Z","html_url":"https://github.com/amplab/tachyon/pull/1017#discussion_r33829492","pull_request_url":"https://api.github.com/repos/amplab/tachyon/pulls/1017","_links":{"self":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/comments/33829492"},"html":{"href":"https://github.com/amplab/tachyon/pull/1017#discussion_r33829492"},"pull_request":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/1017"}}},"pull_request":{"url":"https://api.github.com/repos/amplab/tachyon/pulls/1017","id":38702106,"html_url":"https://github.com/amplab/tachyon/pull/1017","diff_url":"https://github.com/amplab/tachyon/pull/1017.diff","patch_url":"https://github.com/amplab/tachyon/pull/1017.patch","issue_url":"https://api.github.com/repos/amplab/tachyon/issues/1017","number":1017,"state":"open","locked":false,"title":"[WIP] [TACHYON-515] Tachyon Worker Improvement","user":{"login":"calvinjia","id":2223813,"avatar_url":"https://avatars.githubusercontent.com/u/2223813?v=3","gravatar_id":"","url":"https://api.github.com/users/calvinjia","html_url":"https://github.com/calvinjia","followers_url":"https://api.github.com/users/calvinjia/followers","following_url":"https://api.github.com/users/calvinjia/following{/other_user}","gists_url":"https://api.github.com/users/calvinjia/gists{/gist_id}","starred_url":"https://api.github.com/users/calvinjia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calvinjia/subscriptions","organizations_url":"https://api.github.com/users/calvinjia/orgs","repos_url":"https://api.github.com/users/calvinjia/repos","events_url":"https://api.github.com/users/calvinjia/events{/privacy}","received_events_url":"https://api.github.com/users/calvinjia/received_events","type":"User","site_admin":false},"body":"https://tachyon.atlassian.net/browse/TACHYON-515\r\n\r\nThis is a rebased version of the worker_wip branch.","created_at":"2015-06-27T02:02:10Z","updated_at":"2015-07-02T22:35:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3cbe65b7ebf84afda360988bac2dbe1802987b78","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/amplab/tachyon/pulls/1017/commits","review_comments_url":"https://api.github.com/repos/amplab/tachyon/pulls/1017/comments","review_comment_url":"https://api.github.com/repos/amplab/tachyon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/amplab/tachyon/issues/1017/comments","statuses_url":"https://api.github.com/repos/amplab/tachyon/statuses/411d9b30619a15c32f3686d5934fcae467a857e9","head":{"label":"amplab:rebased_worker_wip","ref":"rebased_worker_wip","sha":"411d9b30619a15c32f3686d5934fcae467a857e9","user":{"login":"amplab","id":1438454,"avatar_url":"https://avatars.githubusercontent.com/u/1438454?v=3","gravatar_id":"","url":"https://api.github.com/users/amplab","html_url":"https://github.com/amplab","followers_url":"https://api.github.com/users/amplab/followers","following_url":"https://api.github.com/users/amplab/following{/other_user}","gists_url":"https://api.github.com/users/amplab/gists{/gist_id}","starred_url":"https://api.github.com/users/amplab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amplab/subscriptions","organizations_url":"https://api.github.com/users/amplab/orgs","repos_url":"https://api.github.com/users/amplab/repos","events_url":"https://api.github.com/users/amplab/events{/privacy}","received_events_url":"https://api.github.com/users/amplab/received_events","type":"Organization","site_admin":false},"repo":{"id":7276954,"name":"tachyon","full_name":"amplab/tachyon","owner":{"login":"amplab","id":1438454,"avatar_url":"https://avatars.githubusercontent.com/u/1438454?v=3","gravatar_id":"","url":"https://api.github.com/users/amplab","html_url":"https://github.com/amplab","followers_url":"https://api.github.com/users/amplab/followers","following_url":"https://api.github.com/users/amplab/following{/other_user}","gists_url":"https://api.github.com/users/amplab/gists{/gist_id}","starred_url":"https://api.github.com/users/amplab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amplab/subscriptions","organizations_url":"https://api.github.com/users/amplab/orgs","repos_url":"https://api.github.com/users/amplab/repos","events_url":"https://api.github.com/users/amplab/events{/privacy}","received_events_url":"https://api.github.com/users/amplab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/amplab/tachyon","description":" A Reliable Memory Centric Distributed Storage System","fork":false,"url":"https://api.github.com/repos/amplab/tachyon","forks_url":"https://api.github.com/repos/amplab/tachyon/forks","keys_url":"https://api.github.com/repos/amplab/tachyon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amplab/tachyon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amplab/tachyon/teams","hooks_url":"https://api.github.com/repos/amplab/tachyon/hooks","issue_events_url":"https://api.github.com/repos/amplab/tachyon/issues/events{/number}","events_url":"https://api.github.com/repos/amplab/tachyon/events","assignees_url":"https://api.github.com/repos/amplab/tachyon/assignees{/user}","branches_url":"https://api.github.com/repos/amplab/tachyon/branches{/branch}","tags_url":"https://api.github.com/repos/amplab/tachyon/tags","blobs_url":"https://api.github.com/repos/amplab/tachyon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amplab/tachyon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amplab/tachyon/git/refs{/sha}","trees_url":"https://api.github.com/repos/amplab/tachyon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amplab/tachyon/statuses/{sha}","languages_url":"https://api.github.com/repos/amplab/tachyon/languages","stargazers_url":"https://api.github.com/repos/amplab/tachyon/stargazers","contributors_url":"https://api.github.com/repos/amplab/tachyon/contributors","subscribers_url":"https://api.github.com/repos/amplab/tachyon/subscribers","subscription_url":"https://api.github.com/repos/amplab/tachyon/subscription","commits_url":"https://api.github.com/repos/amplab/tachyon/commits{/sha}","git_commits_url":"https://api.github.com/repos/amplab/tachyon/git/commits{/sha}","comments_url":"https://api.github.com/repos/amplab/tachyon/comments{/number}","issue_comment_url":"https://api.github.com/repos/amplab/tachyon/issues/comments{/number}","contents_url":"https://api.github.com/repos/amplab/tachyon/contents/{+path}","compare_url":"https://api.github.com/repos/amplab/tachyon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amplab/tachyon/merges","archive_url":"https://api.github.com/repos/amplab/tachyon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amplab/tachyon/downloads","issues_url":"https://api.github.com/repos/amplab/tachyon/issues{/number}","pulls_url":"https://api.github.com/repos/amplab/tachyon/pulls{/number}","milestones_url":"https://api.github.com/repos/amplab/tachyon/milestones{/number}","notifications_url":"https://api.github.com/repos/amplab/tachyon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amplab/tachyon/labels{/name}","releases_url":"https://api.github.com/repos/amplab/tachyon/releases{/id}","created_at":"2012-12-21T17:43:46Z","updated_at":"2015-07-02T05:42:16Z","pushed_at":"2015-07-02T22:22:39Z","git_url":"git://github.com/amplab/tachyon.git","ssh_url":"git@github.com:amplab/tachyon.git","clone_url":"https://github.com/amplab/tachyon.git","svn_url":"https://github.com/amplab/tachyon","homepage":"http://tachyon-project.org","size":34472,"stargazers_count":1461,"watchers_count":1461,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":539,"mirror_url":null,"open_issues_count":23,"forks":539,"open_issues":23,"watchers":1461,"default_branch":"master"}},"base":{"label":"amplab:master","ref":"master","sha":"d6054a7be4506610280514f9c4192849f63e0d8d","user":{"login":"amplab","id":1438454,"avatar_url":"https://avatars.githubusercontent.com/u/1438454?v=3","gravatar_id":"","url":"https://api.github.com/users/amplab","html_url":"https://github.com/amplab","followers_url":"https://api.github.com/users/amplab/followers","following_url":"https://api.github.com/users/amplab/following{/other_user}","gists_url":"https://api.github.com/users/amplab/gists{/gist_id}","starred_url":"https://api.github.com/users/amplab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amplab/subscriptions","organizations_url":"https://api.github.com/users/amplab/orgs","repos_url":"https://api.github.com/users/amplab/repos","events_url":"https://api.github.com/users/amplab/events{/privacy}","received_events_url":"https://api.github.com/users/amplab/received_events","type":"Organization","site_admin":false},"repo":{"id":7276954,"name":"tachyon","full_name":"amplab/tachyon","owner":{"login":"amplab","id":1438454,"avatar_url":"https://avatars.githubusercontent.com/u/1438454?v=3","gravatar_id":"","url":"https://api.github.com/users/amplab","html_url":"https://github.com/amplab","followers_url":"https://api.github.com/users/amplab/followers","following_url":"https://api.github.com/users/amplab/following{/other_user}","gists_url":"https://api.github.com/users/amplab/gists{/gist_id}","starred_url":"https://api.github.com/users/amplab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amplab/subscriptions","organizations_url":"https://api.github.com/users/amplab/orgs","repos_url":"https://api.github.com/users/amplab/repos","events_url":"https://api.github.com/users/amplab/events{/privacy}","received_events_url":"https://api.github.com/users/amplab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/amplab/tachyon","description":" A Reliable Memory Centric Distributed Storage System","fork":false,"url":"https://api.github.com/repos/amplab/tachyon","forks_url":"https://api.github.com/repos/amplab/tachyon/forks","keys_url":"https://api.github.com/repos/amplab/tachyon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amplab/tachyon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amplab/tachyon/teams","hooks_url":"https://api.github.com/repos/amplab/tachyon/hooks","issue_events_url":"https://api.github.com/repos/amplab/tachyon/issues/events{/number}","events_url":"https://api.github.com/repos/amplab/tachyon/events","assignees_url":"https://api.github.com/repos/amplab/tachyon/assignees{/user}","branches_url":"https://api.github.com/repos/amplab/tachyon/branches{/branch}","tags_url":"https://api.github.com/repos/amplab/tachyon/tags","blobs_url":"https://api.github.com/repos/amplab/tachyon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amplab/tachyon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amplab/tachyon/git/refs{/sha}","trees_url":"https://api.github.com/repos/amplab/tachyon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amplab/tachyon/statuses/{sha}","languages_url":"https://api.github.com/repos/amplab/tachyon/languages","stargazers_url":"https://api.github.com/repos/amplab/tachyon/stargazers","contributors_url":"https://api.github.com/repos/amplab/tachyon/contributors","subscribers_url":"https://api.github.com/repos/amplab/tachyon/subscribers","subscription_url":"https://api.github.com/repos/amplab/tachyon/subscription","commits_url":"https://api.github.com/repos/amplab/tachyon/commits{/sha}","git_commits_url":"https://api.github.com/repos/amplab/tachyon/git/commits{/sha}","comments_url":"https://api.github.com/repos/amplab/tachyon/comments{/number}","issue_comment_url":"https://api.github.com/repos/amplab/tachyon/issues/comments{/number}","contents_url":"https://api.github.com/repos/amplab/tachyon/contents/{+path}","compare_url":"https://api.github.com/repos/amplab/tachyon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amplab/tachyon/merges","archive_url":"https://api.github.com/repos/amplab/tachyon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amplab/tachyon/downloads","issues_url":"https://api.github.com/repos/amplab/tachyon/issues{/number}","pulls_url":"https://api.github.com/repos/amplab/tachyon/pulls{/number}","milestones_url":"https://api.github.com/repos/amplab/tachyon/milestones{/number}","notifications_url":"https://api.github.com/repos/amplab/tachyon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amplab/tachyon/labels{/name}","releases_url":"https://api.github.com/repos/amplab/tachyon/releases{/id}","created_at":"2012-12-21T17:43:46Z","updated_at":"2015-07-02T05:42:16Z","pushed_at":"2015-07-02T22:22:39Z","git_url":"git://github.com/amplab/tachyon.git","ssh_url":"git@github.com:amplab/tachyon.git","clone_url":"https://github.com/amplab/tachyon.git","svn_url":"https://github.com/amplab/tachyon","homepage":"http://tachyon-project.org","size":34472,"stargazers_count":1461,"watchers_count":1461,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":539,"mirror_url":null,"open_issues_count":23,"forks":539,"open_issues":23,"watchers":1461,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/1017"},"html":{"href":"https://github.com/amplab/tachyon/pull/1017"},"issue":{"href":"https://api.github.com/repos/amplab/tachyon/issues/1017"},"comments":{"href":"https://api.github.com/repos/amplab/tachyon/issues/1017/comments"},"review_comments":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/1017/comments"},"review_comment":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/1017/commits"},"statuses":{"href":"https://api.github.com/repos/amplab/tachyon/statuses/411d9b30619a15c32f3686d5934fcae467a857e9"}}}}