{"action":"created","comment":{"url":"https://api.github.com/repos/amplab/tachyon/pulls/comments/44955791","id":44955791,"diff_hunk":"@@ -0,0 +1,149 @@\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.client.block;\n+\n+import java.io.File;\n+import java.net.InetSocketAddress;\n+import java.util.Arrays;\n+\n+import org.junit.Assert;\n+import org.junit.Before;\n+import org.junit.Rule;\n+import org.junit.Test;\n+import org.junit.rules.TemporaryFolder;\n+import org.junit.runner.RunWith;\n+import org.mockito.Mockito;\n+import org.powermock.api.mockito.PowerMockito;\n+import org.powermock.core.classloader.annotations.PrepareForTest;\n+import org.powermock.modules.junit4.PowerMockRunner;\n+import org.powermock.reflect.Whitebox;\n+\n+import tachyon.client.BlockMasterClient;\n+import tachyon.client.ClientContext;\n+import tachyon.conf.TachyonConf;\n+import tachyon.thrift.BlockInfo;\n+import tachyon.thrift.BlockLocation;\n+import tachyon.thrift.NetAddress;\n+import tachyon.util.network.NetworkAddressUtils;\n+import tachyon.worker.WorkerClient;\n+\n+/**\n+ * Tests for {@link TachyonBlockStore}.\n+ */\n+@RunWith(PowerMockRunner.class)\n+@PrepareForTest({BlockMasterClient.class, BlockStoreContext.class, NetworkAddressUtils.class,\n+    WorkerClient.class})\n+public final class TachyonBlockStoreTest {\n+  private static final long BLOCK_ID = 3L;\n+  private static final long BLOCK_LENGTH = 1000L;\n+  private static final long WORKER_ID_LOCAL = 5L;\n+  private static final long WORKER_ID_REMOTE = 6L;\n+  private static final String WORKER_HOSTNAME_LOCAL = \"localhost\";\n+  private static final String WORKER_HOSTNAME_REMOTE = \"remote\";\n+  private static final int WORKER_RPC_PORT = 7;\n+  private static final int WORKER_DATA_PORT = 9;\n+  private static final NetAddress WORKER_NET_ADDRESS_LOCAL =\n+      new NetAddress(WORKER_HOSTNAME_LOCAL, WORKER_RPC_PORT, WORKER_DATA_PORT);\n+  private static final NetAddress WORKER_NET_ADDRESS_REMOTE =\n+      new NetAddress(WORKER_HOSTNAME_REMOTE, WORKER_RPC_PORT, WORKER_DATA_PORT);\n+  private static final String STORAGE_TIER = \"mem\";\n+  private static final BlockLocation BLOCK_LOCATION_LOCAL =\n+      new BlockLocation(WORKER_ID_LOCAL, WORKER_NET_ADDRESS_LOCAL, STORAGE_TIER);\n+  private static final BlockLocation BLOCK_LOCATION_REMOTE =\n+      new BlockLocation(WORKER_ID_REMOTE, WORKER_NET_ADDRESS_REMOTE, STORAGE_TIER);\n+  /** {@link BlockInfo} representing a block stored both remotely and locally. */\n+  private static final BlockInfo BLOCK_INFO = new BlockInfo(BLOCK_ID, BLOCK_LENGTH,\n+      Arrays.asList(BLOCK_LOCATION_REMOTE, BLOCK_LOCATION_LOCAL));\n+\n+  @Rule\n+  public TemporaryFolder mTestFolder = new TemporaryFolder();\n+\n+  private File mTestFile;\n+  private TachyonBlockStore mBlockStore;\n+  private BlockStoreContext mBlockStoreContext;\n+  private BlockMasterClient mMasterClient;\n+  private WorkerClient mWorkerClient;\n+\n+  /**\n+   * Sets up a testable {@link TachyonBlockStore}. Setup consists of the following:\n+   *\n+   * 1. The singleton {@link BlockStoreContext} is replaced with mBlockStoreContext<br>\n+   * 2. mBlockStoreContext will return mMasterClient and mWorkerClient when asked for master/worker\n+   * clients<br>\n+   * 3. mTestFile is created inside mTestFolder<br>\n+   * 4. mWorkerClient is made to understand that locking BLOCK_ID should return the path to\n+   * mTestFile.\n+   */\n+  @Before\n+  public void before() throws Exception {\n+    mTestFile = mTestFolder.newFile(\"testFile\");\n+\n+    ClientContext.reset();\n+    mBlockStoreContext = PowerMockito.mock(BlockStoreContext.class);\n+    Whitebox.setInternalState(BlockStoreContext.class, \"INSTANCE\", mBlockStoreContext);\n+    mBlockStore = TachyonBlockStore.get();\n+    Whitebox.setInternalState(mBlockStore, \"mContext\", mBlockStoreContext);\n+\n+    mMasterClient = PowerMockito.mock(BlockMasterClient.class);\n+    Mockito.when(mBlockStoreContext.acquireMasterClient()).thenReturn(mMasterClient);\n+\n+    mWorkerClient = PowerMockito.mock(WorkerClient.class);\n+    Mockito.when(mWorkerClient.lockBlock(BLOCK_ID)).thenReturn(mTestFile.getAbsolutePath());\n+    Mockito.when(mBlockStoreContext.acquireWorkerClient(Mockito.anyString()))\n+        .thenReturn(mWorkerClient);\n+  }\n+\n+  /**\n+   * Tests getInStream when a local block exists, making sure that the local block is preferred.\n+   */\n+  @Test\n+  public void testGetInStreamLocal() throws Exception {","path":"clients/unshaded/src/test/java/tachyon/client/block/TachyonBlockStoreTest.java","position":null,"original_position":113,"commit_id":"23824f1cafbeb953f2b3e62e1d8fcf89b621aac2","original_commit_id":"038cdafc437173d8925e5d23fdc94ab978deb943","user":{"login":"aaudiber","id":3455177,"avatar_url":"https://avatars.githubusercontent.com/u/3455177?v=3","gravatar_id":"","url":"https://api.github.com/users/aaudiber","html_url":"https://github.com/aaudiber","followers_url":"https://api.github.com/users/aaudiber/followers","following_url":"https://api.github.com/users/aaudiber/following{/other_user}","gists_url":"https://api.github.com/users/aaudiber/gists{/gist_id}","starred_url":"https://api.github.com/users/aaudiber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaudiber/subscriptions","organizations_url":"https://api.github.com/users/aaudiber/orgs","repos_url":"https://api.github.com/users/aaudiber/repos","events_url":"https://api.github.com/users/aaudiber/events{/privacy}","received_events_url":"https://api.github.com/users/aaudiber/received_events","type":"User","site_admin":false},"body":"Done","created_at":"2015-11-16T17:43:45Z","updated_at":"2015-11-16T17:43:45Z","html_url":"https://github.com/amplab/tachyon/pull/2047#discussion_r44955791","pull_request_url":"https://api.github.com/repos/amplab/tachyon/pulls/2047","_links":{"self":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/comments/44955791"},"html":{"href":"https://github.com/amplab/tachyon/pull/2047#discussion_r44955791"},"pull_request":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/2047"}}},"pull_request":{"url":"https://api.github.com/repos/amplab/tachyon/pulls/2047","id":50595105,"html_url":"https://github.com/amplab/tachyon/pull/2047","diff_url":"https://github.com/amplab/tachyon/pull/2047.diff","patch_url":"https://github.com/amplab/tachyon/pull/2047.patch","issue_url":"https://api.github.com/repos/amplab/tachyon/issues/2047","number":2047,"state":"open","locked":false,"title":"[SMALLFIX] Add unit tests for TachyonBlockStore.getInStream","user":{"login":"aaudiber","id":3455177,"avatar_url":"https://avatars.githubusercontent.com/u/3455177?v=3","gravatar_id":"","url":"https://api.github.com/users/aaudiber","html_url":"https://github.com/aaudiber","followers_url":"https://api.github.com/users/aaudiber/followers","following_url":"https://api.github.com/users/aaudiber/following{/other_user}","gists_url":"https://api.github.com/users/aaudiber/gists{/gist_id}","starred_url":"https://api.github.com/users/aaudiber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaudiber/subscriptions","organizations_url":"https://api.github.com/users/aaudiber/orgs","repos_url":"https://api.github.com/users/aaudiber/repos","events_url":"https://api.github.com/users/aaudiber/events{/privacy}","received_events_url":"https://api.github.com/users/aaudiber/received_events","type":"User","site_admin":false},"body":"This is not meant to be comprehensive. This should make it easier to fill out the rest of the unit tests for `TachyonBlockStore` in the future.","created_at":"2015-11-13T01:51:03Z","updated_at":"2015-11-16T17:43:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3776a2d0cefd7289dababf0156fa2be1c824e896","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/amplab/tachyon/pulls/2047/commits","review_comments_url":"https://api.github.com/repos/amplab/tachyon/pulls/2047/comments","review_comment_url":"https://api.github.com/repos/amplab/tachyon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/amplab/tachyon/issues/2047/comments","statuses_url":"https://api.github.com/repos/amplab/tachyon/statuses/23824f1cafbeb953f2b3e62e1d8fcf89b621aac2","head":{"label":"aaudiber:getInStreamTests","ref":"getInStreamTests","sha":"23824f1cafbeb953f2b3e62e1d8fcf89b621aac2","user":{"login":"aaudiber","id":3455177,"avatar_url":"https://avatars.githubusercontent.com/u/3455177?v=3","gravatar_id":"","url":"https://api.github.com/users/aaudiber","html_url":"https://github.com/aaudiber","followers_url":"https://api.github.com/users/aaudiber/followers","following_url":"https://api.github.com/users/aaudiber/following{/other_user}","gists_url":"https://api.github.com/users/aaudiber/gists{/gist_id}","starred_url":"https://api.github.com/users/aaudiber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaudiber/subscriptions","organizations_url":"https://api.github.com/users/aaudiber/orgs","repos_url":"https://api.github.com/users/aaudiber/repos","events_url":"https://api.github.com/users/aaudiber/events{/privacy}","received_events_url":"https://api.github.com/users/aaudiber/received_events","type":"User","site_admin":false},"repo":{"id":42785459,"name":"tachyon","full_name":"aaudiber/tachyon","owner":{"login":"aaudiber","id":3455177,"avatar_url":"https://avatars.githubusercontent.com/u/3455177?v=3","gravatar_id":"","url":"https://api.github.com/users/aaudiber","html_url":"https://github.com/aaudiber","followers_url":"https://api.github.com/users/aaudiber/followers","following_url":"https://api.github.com/users/aaudiber/following{/other_user}","gists_url":"https://api.github.com/users/aaudiber/gists{/gist_id}","starred_url":"https://api.github.com/users/aaudiber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaudiber/subscriptions","organizations_url":"https://api.github.com/users/aaudiber/orgs","repos_url":"https://api.github.com/users/aaudiber/repos","events_url":"https://api.github.com/users/aaudiber/events{/privacy}","received_events_url":"https://api.github.com/users/aaudiber/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aaudiber/tachyon","description":"Memory Centric Reliable Distributed Storage","fork":true,"url":"https://api.github.com/repos/aaudiber/tachyon","forks_url":"https://api.github.com/repos/aaudiber/tachyon/forks","keys_url":"https://api.github.com/repos/aaudiber/tachyon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aaudiber/tachyon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aaudiber/tachyon/teams","hooks_url":"https://api.github.com/repos/aaudiber/tachyon/hooks","issue_events_url":"https://api.github.com/repos/aaudiber/tachyon/issues/events{/number}","events_url":"https://api.github.com/repos/aaudiber/tachyon/events","assignees_url":"https://api.github.com/repos/aaudiber/tachyon/assignees{/user}","branches_url":"https://api.github.com/repos/aaudiber/tachyon/branches{/branch}","tags_url":"https://api.github.com/repos/aaudiber/tachyon/tags","blobs_url":"https://api.github.com/repos/aaudiber/tachyon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aaudiber/tachyon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aaudiber/tachyon/git/refs{/sha}","trees_url":"https://api.github.com/repos/aaudiber/tachyon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aaudiber/tachyon/statuses/{sha}","languages_url":"https://api.github.com/repos/aaudiber/tachyon/languages","stargazers_url":"https://api.github.com/repos/aaudiber/tachyon/stargazers","contributors_url":"https://api.github.com/repos/aaudiber/tachyon/contributors","subscribers_url":"https://api.github.com/repos/aaudiber/tachyon/subscribers","subscription_url":"https://api.github.com/repos/aaudiber/tachyon/subscription","commits_url":"https://api.github.com/repos/aaudiber/tachyon/commits{/sha}","git_commits_url":"https://api.github.com/repos/aaudiber/tachyon/git/commits{/sha}","comments_url":"https://api.github.com/repos/aaudiber/tachyon/comments{/number}","issue_comment_url":"https://api.github.com/repos/aaudiber/tachyon/issues/comments{/number}","contents_url":"https://api.github.com/repos/aaudiber/tachyon/contents/{+path}","compare_url":"https://api.github.com/repos/aaudiber/tachyon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aaudiber/tachyon/merges","archive_url":"https://api.github.com/repos/aaudiber/tachyon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aaudiber/tachyon/downloads","issues_url":"https://api.github.com/repos/aaudiber/tachyon/issues{/number}","pulls_url":"https://api.github.com/repos/aaudiber/tachyon/pulls{/number}","milestones_url":"https://api.github.com/repos/aaudiber/tachyon/milestones{/number}","notifications_url":"https://api.github.com/repos/aaudiber/tachyon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aaudiber/tachyon/labels{/name}","releases_url":"https://api.github.com/repos/aaudiber/tachyon/releases{/id}","created_at":"2015-09-19T18:48:47Z","updated_at":"2015-09-19T18:48:49Z","pushed_at":"2015-11-16T17:43:29Z","git_url":"git://github.com/aaudiber/tachyon.git","ssh_url":"git@github.com:aaudiber/tachyon.git","clone_url":"https://github.com/aaudiber/tachyon.git","svn_url":"https://github.com/aaudiber/tachyon","homepage":"http://tachyon-project.org","size":29566,"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":"963a8ef643c68d5e11a2db6faba14d0a7de2647d","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":"Memory Centric Reliable Distributed Storage","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-11-16T06:40:17Z","pushed_at":"2015-11-16T17:43:29Z","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":60711,"stargazers_count":1737,"watchers_count":1737,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":685,"mirror_url":null,"open_issues_count":33,"forks":685,"open_issues":33,"watchers":1737,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/2047"},"html":{"href":"https://github.com/amplab/tachyon/pull/2047"},"issue":{"href":"https://api.github.com/repos/amplab/tachyon/issues/2047"},"comments":{"href":"https://api.github.com/repos/amplab/tachyon/issues/2047/comments"},"review_comments":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/2047/comments"},"review_comment":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/amplab/tachyon/pulls/2047/commits"},"statuses":{"href":"https://api.github.com/repos/amplab/tachyon/statuses/23824f1cafbeb953f2b3e62e1d8fcf89b621aac2"}}}}