{"action":"created","comment":{"url":"https://api.github.com/repos/amplab/tachyon/pulls/comments/28831449","id":28831449,"diff_hunk":"@@ -0,0 +1,188 @@\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.web;\n+\n+import java.io.IOException;\n+import java.util.ArrayList;\n+import java.util.Collections;\n+import java.util.HashSet;\n+import java.util.List;\n+import java.util.Set;\n+\n+import javax.servlet.ServletException;\n+import javax.servlet.http.HttpServlet;\n+import javax.servlet.http.HttpServletRequest;\n+import javax.servlet.http.HttpServletResponse;\n+\n+import tachyon.StorageDirId;\n+import tachyon.StorageLevelAlias;\n+import tachyon.TachyonURI;\n+import tachyon.client.TachyonFS;\n+import tachyon.conf.TachyonConf;\n+import tachyon.master.BlockInfo;\n+import tachyon.thrift.ClientFileInfo;\n+import tachyon.thrift.FileDoesNotExistException;\n+import tachyon.worker.WorkerStorage;\n+import tachyon.worker.hierarchy.StorageDir;\n+\n+/**\n+ * Servlet that provides data for displaying block info of a worker.\n+ */\n+public class WebInterfaceWorkerBlockInfoServlet extends HttpServlet {\n+  private static final long serialVersionUID = 4148506607369321012L;\n+  private final transient WorkerStorage mWorkerStorage;\n+  private final TachyonConf mTachyonConf;\n+\n+  public WebInterfaceWorkerBlockInfoServlet(WorkerStorage workerStorage, TachyonConf conf) {\n+    mWorkerStorage = workerStorage;\n+    mTachyonConf = conf;\n+  }\n+\n+  /**\n+   * Populates attributes before redirecting to a jsp.\n+   *\n+   * @param request The HttpServletRequest object\n+   * @param response The HttpServletReponse object\n+   * @throws ServletException\n+   * @throws IOException\n+   */\n+  @Override\n+  protected void doGet(HttpServletRequest request, HttpServletResponse response)\n+      throws ServletException, IOException {\n+    request.setAttribute(\"fatalError\", \"\");\n+    TachyonFS tachyonClient = TachyonFS.get(mTachyonConf);\n+\n+    String filePath = request.getParameter(\"path\");\n+    if (!(filePath == null || filePath.isEmpty())) {\n+      // Display file block info\n+      try {\n+        UiFileInfo uiFileInfo = getUiFileInfo(tachyonClient, -1, new TachyonURI(filePath));\n+        request.setAttribute(\"fileBlocksOnTier\", uiFileInfo.getBlocksOnTier());\n+        request.setAttribute(\"blockSizeByte\", uiFileInfo.getBlockSizeBytes());\n+        request.setAttribute(\"path\", filePath);\n+\n+        getServletContext().getRequestDispatcher(\"/worker/viewFileBlocks.jsp\").forward(request,\n+            response);\n+        return;\n+      } catch (FileDoesNotExistException fdne) {\n+        request.setAttribute(\"fatalError\", \"Error: Invalid Path \" + fdne.getMessage());\n+        getServletContext().getRequestDispatcher(\"/worker/blockInfo.jsp\").forward(request,\n+            response);\n+        return;\n+      } catch (IOException ie) {\n+        request.setAttribute(\"invalidPathError\", \"Error: File \" + filePath + \" is not available \"\n+            + ie.getMessage());\n+        getServletContext().getRequestDispatcher(\"/worker/blockInfo.jsp\").forward(request,\n+            response);\n+        return;\n+      }\n+    }\n+\n+    List<Integer> fileIds = getFileIds(tachyonClient);\n+    request.setAttribute(\"nTotalFile\", fileIds.size());\n+\n+    // URL can not determine offset and limit, let javascript in jsp determine and redirect\n+    if (request.getParameter(\"offset\") == null && request.getParameter(\"limit\") == null) {\n+      getServletContext().getRequestDispatcher(\"/worker/blockInfo.jsp\").forward(request, response);\n+      return;\n+    }\n+\n+    try {\n+      int offset = Integer.parseInt(request.getParameter(\"offset\"));\n+      int limit = Integer.parseInt(request.getParameter(\"limit\"));\n+      List<Integer> subFileIds = fileIds.subList(offset, offset + limit);\n+      List<UiFileInfo> uiFileInfos = new ArrayList<UiFileInfo>(subFileIds.size());\n+      for (int fileId : subFileIds) {\n+        uiFileInfos.add(getUiFileInfo(tachyonClient, fileId, TachyonURI.EMPTY_URI));\n+      }\n+      request.setAttribute(\"fileInfos\", uiFileInfos);\n+    } catch (FileDoesNotExistException fdne) {\n+      request.setAttribute(\"fatalError\", \"Error: Invalid FileId \" + fdne.getMessage());\n+      getServletContext().getRequestDispatcher(\"/worker/blockInfo.jsp\").forward(request,\n+          response);\n+      return;\n+    } catch (NumberFormatException nfe) {\n+      request.setAttribute(\"fatalError\",\n+          \"Error: offset or limit parse error, \" + nfe.getLocalizedMessage());\n+      getServletContext().getRequestDispatcher(\"/worker/blockInfo.jsp\").forward(request, response);\n+      return;\n+    } catch (IndexOutOfBoundsException iobe) {\n+      request.setAttribute(\"fatalError\", \"Error: offset or offset + limit is out of bound, \"\n+          + iobe.getLocalizedMessage());\n+      getServletContext().getRequestDispatcher(\"/worker/blockInfo.jsp\").forward(request, response);\n+      return;\n+    } catch (IllegalArgumentException iae) {\n+      request.setAttribute(\"fatalError\", iae.getLocalizedMessage());\n+      getServletContext().getRequestDispatcher(\"/worker/blockInfo.jsp\").forward(request, response);\n+      return;\n+    }\n+\n+    getServletContext().getRequestDispatcher(\"/worker/blockInfo.jsp\").forward(request, response);\n+  }\n+\n+  private List<Integer> getFileIds(TachyonFS tachyonClient) {","path":"core/src/main/java/tachyon/web/WebInterfaceWorkerBlockInfoServlet.java","position":136,"original_position":136,"commit_id":"b3a6547af5c1f2f271df0c1865417ade7119851a","original_commit_id":"b3a6547af5c1f2f271df0c1865417ade7119851a","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":"Could this method be renamed to `getSortedFileIds`?","created_at":"2015-04-21T23:07:11Z","updated_at":"2015-04-21T23:07:11Z","html_url":"https://github.com/amplab/tachyon/pull/831#discussion_r28831449","pull_request_url":"https://api.github.com/repos/amplab/tachyon/pulls/831","_links":{"self":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/comments/28831449"},"html":{"href":"https://github.com/amplab/tachyon/pull/831#discussion_r28831449"},"pull_request":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/831"}}},"pull_request":{"url":"https://api.github.com/repos/amplab/tachyon/pulls/831","id":33525037,"html_url":"https://github.com/amplab/tachyon/pull/831","diff_url":"https://github.com/amplab/tachyon/pull/831.diff","patch_url":"https://github.com/amplab/tachyon/pull/831.patch","issue_url":"https://api.github.com/repos/amplab/tachyon/issues/831","number":831,"state":"open","locked":false,"title":"[TACHYON-366] Display Block Info in Worker Web UI","user":{"login":"carsonwang","id":9278199,"avatar_url":"https://avatars.githubusercontent.com/u/9278199?v=3","gravatar_id":"","url":"https://api.github.com/users/carsonwang","html_url":"https://github.com/carsonwang","followers_url":"https://api.github.com/users/carsonwang/followers","following_url":"https://api.github.com/users/carsonwang/following{/other_user}","gists_url":"https://api.github.com/users/carsonwang/gists{/gist_id}","starred_url":"https://api.github.com/users/carsonwang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carsonwang/subscriptions","organizations_url":"https://api.github.com/users/carsonwang/orgs","repos_url":"https://api.github.com/users/carsonwang/repos","events_url":"https://api.github.com/users/carsonwang/events{/privacy}","received_events_url":"https://api.github.com/users/carsonwang/received_events","type":"User","site_admin":false},"body":"https://tachyon.atlassian.net/browse/TACHYON-366\r\n![workerui1](https://cloud.githubusercontent.com/assets/9278199/7198708/6790e2e2-e521-11e4-8b90-972062f27f73.jpg)\r\n![workerui2jpg](https://cloud.githubusercontent.com/assets/9278199/7198721/84ec2a22-e521-11e4-83a7-995230f6e118.jpg)\r\n","created_at":"2015-04-17T08:48:58Z","updated_at":"2015-04-21T23:07:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"83d42e6e3e6f94b6a98731a0d684feec983272d9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/amplab/tachyon/pulls/831/commits","review_comments_url":"https://api.github.com/repos/amplab/tachyon/pulls/831/comments","review_comment_url":"https://api.github.com/repos/amplab/tachyon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/amplab/tachyon/issues/831/comments","statuses_url":"https://api.github.com/repos/amplab/tachyon/statuses/b3a6547af5c1f2f271df0c1865417ade7119851a","head":{"label":"carsonwang:workerUI-blockInfo","ref":"workerUI-blockInfo","sha":"b3a6547af5c1f2f271df0c1865417ade7119851a","user":{"login":"carsonwang","id":9278199,"avatar_url":"https://avatars.githubusercontent.com/u/9278199?v=3","gravatar_id":"","url":"https://api.github.com/users/carsonwang","html_url":"https://github.com/carsonwang","followers_url":"https://api.github.com/users/carsonwang/followers","following_url":"https://api.github.com/users/carsonwang/following{/other_user}","gists_url":"https://api.github.com/users/carsonwang/gists{/gist_id}","starred_url":"https://api.github.com/users/carsonwang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carsonwang/subscriptions","organizations_url":"https://api.github.com/users/carsonwang/orgs","repos_url":"https://api.github.com/users/carsonwang/repos","events_url":"https://api.github.com/users/carsonwang/events{/privacy}","received_events_url":"https://api.github.com/users/carsonwang/received_events","type":"User","site_admin":false},"repo":{"id":29516862,"name":"tachyon","full_name":"carsonwang/tachyon","owner":{"login":"carsonwang","id":9278199,"avatar_url":"https://avatars.githubusercontent.com/u/9278199?v=3","gravatar_id":"","url":"https://api.github.com/users/carsonwang","html_url":"https://github.com/carsonwang","followers_url":"https://api.github.com/users/carsonwang/followers","following_url":"https://api.github.com/users/carsonwang/following{/other_user}","gists_url":"https://api.github.com/users/carsonwang/gists{/gist_id}","starred_url":"https://api.github.com/users/carsonwang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carsonwang/subscriptions","organizations_url":"https://api.github.com/users/carsonwang/orgs","repos_url":"https://api.github.com/users/carsonwang/repos","events_url":"https://api.github.com/users/carsonwang/events{/privacy}","received_events_url":"https://api.github.com/users/carsonwang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/carsonwang/tachyon","description":" A Reliable Memory Centric Distributed Storage System","fork":true,"url":"https://api.github.com/repos/carsonwang/tachyon","forks_url":"https://api.github.com/repos/carsonwang/tachyon/forks","keys_url":"https://api.github.com/repos/carsonwang/tachyon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/carsonwang/tachyon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/carsonwang/tachyon/teams","hooks_url":"https://api.github.com/repos/carsonwang/tachyon/hooks","issue_events_url":"https://api.github.com/repos/carsonwang/tachyon/issues/events{/number}","events_url":"https://api.github.com/repos/carsonwang/tachyon/events","assignees_url":"https://api.github.com/repos/carsonwang/tachyon/assignees{/user}","branches_url":"https://api.github.com/repos/carsonwang/tachyon/branches{/branch}","tags_url":"https://api.github.com/repos/carsonwang/tachyon/tags","blobs_url":"https://api.github.com/repos/carsonwang/tachyon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/carsonwang/tachyon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/carsonwang/tachyon/git/refs{/sha}","trees_url":"https://api.github.com/repos/carsonwang/tachyon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/carsonwang/tachyon/statuses/{sha}","languages_url":"https://api.github.com/repos/carsonwang/tachyon/languages","stargazers_url":"https://api.github.com/repos/carsonwang/tachyon/stargazers","contributors_url":"https://api.github.com/repos/carsonwang/tachyon/contributors","subscribers_url":"https://api.github.com/repos/carsonwang/tachyon/subscribers","subscription_url":"https://api.github.com/repos/carsonwang/tachyon/subscription","commits_url":"https://api.github.com/repos/carsonwang/tachyon/commits{/sha}","git_commits_url":"https://api.github.com/repos/carsonwang/tachyon/git/commits{/sha}","comments_url":"https://api.github.com/repos/carsonwang/tachyon/comments{/number}","issue_comment_url":"https://api.github.com/repos/carsonwang/tachyon/issues/comments{/number}","contents_url":"https://api.github.com/repos/carsonwang/tachyon/contents/{+path}","compare_url":"https://api.github.com/repos/carsonwang/tachyon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/carsonwang/tachyon/merges","archive_url":"https://api.github.com/repos/carsonwang/tachyon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/carsonwang/tachyon/downloads","issues_url":"https://api.github.com/repos/carsonwang/tachyon/issues{/number}","pulls_url":"https://api.github.com/repos/carsonwang/tachyon/pulls{/number}","milestones_url":"https://api.github.com/repos/carsonwang/tachyon/milestones{/number}","notifications_url":"https://api.github.com/repos/carsonwang/tachyon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/carsonwang/tachyon/labels{/name}","releases_url":"https://api.github.com/repos/carsonwang/tachyon/releases{/id}","created_at":"2015-01-20T07:11:16Z","updated_at":"2015-02-06T01:56:29Z","pushed_at":"2015-04-21T08:33:27Z","git_url":"git://github.com/carsonwang/tachyon.git","ssh_url":"git@github.com:carsonwang/tachyon.git","clone_url":"https://github.com/carsonwang/tachyon.git","svn_url":"https://github.com/carsonwang/tachyon","homepage":"http://tachyon-project.org","size":12559,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"amplab:master","ref":"master","sha":"a2da9a9a819bb21d37038f79b295d5651d24067b","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-04-21T14:03:52Z","pushed_at":"2015-04-21T16:32:15Z","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":29480,"stargazers_count":1321,"watchers_count":1321,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":473,"mirror_url":null,"open_issues_count":23,"forks":473,"open_issues":23,"watchers":1321,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/831"},"html":{"href":"https://github.com/amplab/tachyon/pull/831"},"issue":{"href":"https://api.github.com/repos/amplab/tachyon/issues/831"},"comments":{"href":"https://api.github.com/repos/amplab/tachyon/issues/831/comments"},"review_comments":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/831/comments"},"review_comment":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/831/commits"},"statuses":{"href":"https://api.github.com/repos/amplab/tachyon/statuses/b3a6547af5c1f2f271df0c1865417ade7119851a"}}}}