{"action":"created","comment":{"url":"https://api.github.com/repos/amplab/tachyon/pulls/comments/36951507","id":36951507,"diff_hunk":"@@ -0,0 +1,242 @@\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.master;\n+\n+import java.io.DataInputStream;\n+import java.io.File;\n+import java.io.FileInputStream;\n+import java.io.IOException;\n+import java.nio.ByteBuffer;\n+import java.util.Arrays;\n+import java.util.List;\n+\n+import org.apache.commons.codec.binary.Base64;\n+import org.junit.After;\n+import org.junit.Assert;\n+import org.junit.Before;\n+import org.junit.Test;\n+\n+import com.fasterxml.jackson.core.JsonParser;\n+import com.fasterxml.jackson.core.type.TypeReference;\n+\n+import tachyon.TachyonURI;\n+import tachyon.conf.TachyonConf;\n+\n+/**\n+ * Unit Test for EditLog. Test the read/write correctness of each operation.\n+ */\n+public class EditLogTest {\n+  private EditLog mEditLog = null;\n+  private TachyonConf mTachyonConf = new TachyonConf();\n+  private String mTmpPath = null;\n+\n+  @Test\n+  public void addBlockTest() throws IOException {\n+    // Write ADD_BLOCK\n+    mEditLog.addBlock(1, 2, 128L, 1409349750338L);\n+    mEditLog.flush();\n+    mEditLog.close();\n+\n+    // Read ADD_BLOCK and check\n+    EditLogOperation op = getSingleOpFromFile(mTmpPath);\n+    Assert.assertEquals(101, op.mTransId);\n+    Assert.assertEquals(EditLogOperationType.ADD_BLOCK, op.mType);\n+    Assert.assertEquals(1, op.getInt(\"fileId\").intValue());\n+    Assert.assertEquals(2, op.getInt(\"blockIndex\").intValue());\n+    Assert.assertEquals(128L, op.getLong(\"blockLength\").longValue());\n+    Assert.assertEquals(1409349750338L, op.getLong(\"opTimeMs\").longValue());\n+  }\n+\n+  @Test\n+  public void addCheckpointTest() throws IOException {\n+    // Write ADD_CHECKPOINT\n+    TachyonURI checkpointPath = new TachyonURI(\"/test/checkpoint\");\n+    mEditLog.addCheckpoint(1, 256L, checkpointPath, 1409349750338L);\n+    mEditLog.flush();\n+    mEditLog.close();\n+\n+    // Read ADD_CHECKPOINT and check\n+    EditLogOperation op = getSingleOpFromFile(mTmpPath);\n+    Assert.assertEquals(101, op.mTransId);\n+    Assert.assertEquals(EditLogOperationType.ADD_CHECKPOINT, op.mType);\n+    Assert.assertEquals(1, op.getInt(\"fileId\").intValue());\n+    Assert.assertEquals(256L, op.getLong(\"length\").longValue());\n+    Assert.assertEquals(checkpointPath.toString(), op.getString(\"path\"));\n+    Assert.assertEquals(1409349750338L, op.getLong(\"opTimeMs\").longValue());\n+  }\n+\n+  @After\n+  public final void after() throws Exception {\n+    new File(mTmpPath).delete();\n+  }\n+\n+  @Before\n+  public final void before() throws Exception {\n+    mTmpPath = File.createTempFile(\"Tachyon\", \"U\" + System.currentTimeMillis()).getAbsolutePath();\n+    mEditLog = new EditLog(mTmpPath, false, 100, mTachyonConf);","path":"servers/src/test/java/tachyon/master/EditLogTest.java","position":89,"original_position":89,"commit_id":"f392e7e0235ca09ee2399fd360f8c545cb3bec2b","original_commit_id":"f392e7e0235ca09ee2399fd360f8c545cb3bec2b","user":{"login":"swatDong","id":7642967,"avatar_url":"https://avatars.githubusercontent.com/u/7642967?v=3","gravatar_id":"","url":"https://api.github.com/users/swatDong","html_url":"https://github.com/swatDong","followers_url":"https://api.github.com/users/swatDong/followers","following_url":"https://api.github.com/users/swatDong/following{/other_user}","gists_url":"https://api.github.com/users/swatDong/gists{/gist_id}","starred_url":"https://api.github.com/users/swatDong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swatDong/subscriptions","organizations_url":"https://api.github.com/users/swatDong/orgs","repos_url":"https://api.github.com/users/swatDong/repos","events_url":"https://api.github.com/users/swatDong/events{/privacy}","received_events_url":"https://api.github.com/users/swatDong/received_events","type":"User","site_admin":false},"body":"Thanks. I'll make it constant and also check if some other variables can be constant.","created_at":"2015-08-13T08:37:32Z","updated_at":"2015-08-13T08:37:32Z","html_url":"https://github.com/amplab/tachyon/pull/1277#discussion_r36951507","pull_request_url":"https://api.github.com/repos/amplab/tachyon/pulls/1277","_links":{"self":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/comments/36951507"},"html":{"href":"https://github.com/amplab/tachyon/pull/1277#discussion_r36951507"},"pull_request":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/1277"}}},"pull_request":{"url":"https://api.github.com/repos/amplab/tachyon/pulls/1277","id":42100832,"html_url":"https://github.com/amplab/tachyon/pull/1277","diff_url":"https://github.com/amplab/tachyon/pull/1277.diff","patch_url":"https://github.com/amplab/tachyon/pull/1277.patch","issue_url":"https://api.github.com/repos/amplab/tachyon/issues/1277","number":1277,"state":"open","locked":false,"title":"[TACHYON-774] Test the read/write correctness of EditLog","user":{"login":"swatDong","id":7642967,"avatar_url":"https://avatars.githubusercontent.com/u/7642967?v=3","gravatar_id":"","url":"https://api.github.com/users/swatDong","html_url":"https://github.com/swatDong","followers_url":"https://api.github.com/users/swatDong/followers","following_url":"https://api.github.com/users/swatDong/following{/other_user}","gists_url":"https://api.github.com/users/swatDong/gists{/gist_id}","starred_url":"https://api.github.com/users/swatDong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swatDong/subscriptions","organizations_url":"https://api.github.com/users/swatDong/orgs","repos_url":"https://api.github.com/users/swatDong/repos","events_url":"https://api.github.com/users/swatDong/events{/privacy}","received_events_url":"https://api.github.com/users/swatDong/received_events","type":"User","site_admin":false},"body":"https://tachyon.atlassian.net/browse/TACHYON-774\r\n\r\nTest the read/write correctness of each editlog operation. Also remove the previous `EditLogOperationTest` since it's a sub-part of the new `EditLogTest`.","created_at":"2015-08-11T07:42:31Z","updated_at":"2015-08-13T08:37:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"93abb2048fcc4cedc5407dc2b6091b3e153d6b47","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/amplab/tachyon/pulls/1277/commits","review_comments_url":"https://api.github.com/repos/amplab/tachyon/pulls/1277/comments","review_comment_url":"https://api.github.com/repos/amplab/tachyon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/amplab/tachyon/issues/1277/comments","statuses_url":"https://api.github.com/repos/amplab/tachyon/statuses/f392e7e0235ca09ee2399fd360f8c545cb3bec2b","head":{"label":"PasaLab:TACHYON-774","ref":"TACHYON-774","sha":"f392e7e0235ca09ee2399fd360f8c545cb3bec2b","user":{"login":"PasaLab","id":6230048,"avatar_url":"https://avatars.githubusercontent.com/u/6230048?v=3","gravatar_id":"","url":"https://api.github.com/users/PasaLab","html_url":"https://github.com/PasaLab","followers_url":"https://api.github.com/users/PasaLab/followers","following_url":"https://api.github.com/users/PasaLab/following{/other_user}","gists_url":"https://api.github.com/users/PasaLab/gists{/gist_id}","starred_url":"https://api.github.com/users/PasaLab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PasaLab/subscriptions","organizations_url":"https://api.github.com/users/PasaLab/orgs","repos_url":"https://api.github.com/users/PasaLab/repos","events_url":"https://api.github.com/users/PasaLab/events{/privacy}","received_events_url":"https://api.github.com/users/PasaLab/received_events","type":"Organization","site_admin":false},"repo":{"id":21603565,"name":"tachyon","full_name":"PasaLab/tachyon","owner":{"login":"PasaLab","id":6230048,"avatar_url":"https://avatars.githubusercontent.com/u/6230048?v=3","gravatar_id":"","url":"https://api.github.com/users/PasaLab","html_url":"https://github.com/PasaLab","followers_url":"https://api.github.com/users/PasaLab/followers","following_url":"https://api.github.com/users/PasaLab/following{/other_user}","gists_url":"https://api.github.com/users/PasaLab/gists{/gist_id}","starred_url":"https://api.github.com/users/PasaLab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PasaLab/subscriptions","organizations_url":"https://api.github.com/users/PasaLab/orgs","repos_url":"https://api.github.com/users/PasaLab/repos","events_url":"https://api.github.com/users/PasaLab/events{/privacy}","received_events_url":"https://api.github.com/users/PasaLab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PasaLab/tachyon","description":"Memory-centric Storage System for Big Data Analytics","fork":true,"url":"https://api.github.com/repos/PasaLab/tachyon","forks_url":"https://api.github.com/repos/PasaLab/tachyon/forks","keys_url":"https://api.github.com/repos/PasaLab/tachyon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PasaLab/tachyon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PasaLab/tachyon/teams","hooks_url":"https://api.github.com/repos/PasaLab/tachyon/hooks","issue_events_url":"https://api.github.com/repos/PasaLab/tachyon/issues/events{/number}","events_url":"https://api.github.com/repos/PasaLab/tachyon/events","assignees_url":"https://api.github.com/repos/PasaLab/tachyon/assignees{/user}","branches_url":"https://api.github.com/repos/PasaLab/tachyon/branches{/branch}","tags_url":"https://api.github.com/repos/PasaLab/tachyon/tags","blobs_url":"https://api.github.com/repos/PasaLab/tachyon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PasaLab/tachyon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PasaLab/tachyon/git/refs{/sha}","trees_url":"https://api.github.com/repos/PasaLab/tachyon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PasaLab/tachyon/statuses/{sha}","languages_url":"https://api.github.com/repos/PasaLab/tachyon/languages","stargazers_url":"https://api.github.com/repos/PasaLab/tachyon/stargazers","contributors_url":"https://api.github.com/repos/PasaLab/tachyon/contributors","subscribers_url":"https://api.github.com/repos/PasaLab/tachyon/subscribers","subscription_url":"https://api.github.com/repos/PasaLab/tachyon/subscription","commits_url":"https://api.github.com/repos/PasaLab/tachyon/commits{/sha}","git_commits_url":"https://api.github.com/repos/PasaLab/tachyon/git/commits{/sha}","comments_url":"https://api.github.com/repos/PasaLab/tachyon/comments{/number}","issue_comment_url":"https://api.github.com/repos/PasaLab/tachyon/issues/comments{/number}","contents_url":"https://api.github.com/repos/PasaLab/tachyon/contents/{+path}","compare_url":"https://api.github.com/repos/PasaLab/tachyon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PasaLab/tachyon/merges","archive_url":"https://api.github.com/repos/PasaLab/tachyon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PasaLab/tachyon/downloads","issues_url":"https://api.github.com/repos/PasaLab/tachyon/issues{/number}","pulls_url":"https://api.github.com/repos/PasaLab/tachyon/pulls{/number}","milestones_url":"https://api.github.com/repos/PasaLab/tachyon/milestones{/number}","notifications_url":"https://api.github.com/repos/PasaLab/tachyon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PasaLab/tachyon/labels{/name}","releases_url":"https://api.github.com/repos/PasaLab/tachyon/releases{/id}","created_at":"2014-07-08T07:42:41Z","updated_at":"2015-07-22T07:03:21Z","pushed_at":"2015-08-13T07:26:41Z","git_url":"git://github.com/PasaLab/tachyon.git","ssh_url":"git@github.com:PasaLab/tachyon.git","clone_url":"https://github.com/PasaLab/tachyon.git","svn_url":"https://github.com/PasaLab/tachyon","homepage":"http://tachyon-project.org","size":16913,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"amplab:master","ref":"master","sha":"924c3f456365ecbfcff288af38a55df666fe4ed5","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-08-13T06:58:23Z","pushed_at":"2015-08-13T07:26:41Z","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":39025,"stargazers_count":1500,"watchers_count":1500,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":577,"mirror_url":null,"open_issues_count":24,"forks":577,"open_issues":24,"watchers":1500,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/1277"},"html":{"href":"https://github.com/amplab/tachyon/pull/1277"},"issue":{"href":"https://api.github.com/repos/amplab/tachyon/issues/1277"},"comments":{"href":"https://api.github.com/repos/amplab/tachyon/issues/1277/comments"},"review_comments":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/1277/comments"},"review_comment":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/1277/commits"},"statuses":{"href":"https://api.github.com/repos/amplab/tachyon/statuses/f392e7e0235ca09ee2399fd360f8c545cb3bec2b"}}}}