{"action":"created","comment":{"url":"https://api.github.com/repos/Alluxio/alluxio/pulls/comments/91459284","pull_request_review_id":11966719,"id":91459284,"diff_hunk":"@@ -0,0 +1,88 @@\n+/*\n+ * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0\n+ * (the \"License\"). You may not use this work except in compliance with the License, which is\n+ * available at www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * This software is distributed on an \"AS IS\" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n+ * either express or implied, as more fully set forth in the License.\n+ *\n+ * See the NOTICE file distributed with this work for information regarding copyright ownership.\n+ */\n+\n+package alluxio.client.file.policy;\n+\n+import alluxio.client.block.BlockWorkerInfo;\n+import alluxio.util.network.NetworkAddressUtils;\n+import alluxio.wire.WorkerNetAddress;\n+\n+import com.google.common.base.Objects;\n+import com.google.common.collect.Lists;\n+\n+import java.util.Collections;\n+import java.util.List;\n+\n+import javax.annotation.concurrent.ThreadSafe;\n+/**\n+ * A policy that returns local host first, and if the local worker doesn't have enough availability,\n+ * it randomly picks a worker from the active workers list for each block write.\n+ * If No worker meet the demands, return local host.\n+ */\n+@ThreadSafe\n+public class LocalFirstWithoutEvictionPolicy implements FileWriteLocationPolicy {\n+  private String mLocalHostName;\n+  /**\n+   * Constructs a {@link LocalFirstWithoutEvictionPolicy}.\n+   */\n+  public LocalFirstWithoutEvictionPolicy() {\n+    mLocalHostName = NetworkAddressUtils.getLocalHostName();\n+  }\n+\n+  @Override\n+  public WorkerNetAddress getWorkerForNextBlock(Iterable<BlockWorkerInfo> workerInfoList,\n+      long blockSizeBytes) {\n+    // try the local host first\n+    WorkerNetAddress localWorkerNetAddress = null;\n+    for (BlockWorkerInfo workerInfo : workerInfoList) {\n+      if (workerInfo.getNetAddress().getHost().equals(mLocalHostName)) {\n+        localWorkerNetAddress = workerInfo.getNetAddress();\n+        if (workerInfo.getAvailableBytes() >= blockSizeBytes) {\n+          return localWorkerNetAddress;\n+        }\n+      }\n+    }\n+\n+    // otherwise randomly pick a worker that has enough availability\n+    List<BlockWorkerInfo> shuffledWorkers = Lists.newArrayList(workerInfoList);\n+    Collections.shuffle(shuffledWorkers);\n+    for (BlockWorkerInfo workerInfo : shuffledWorkers) {\n+      if (workerInfo.getAvailableBytes() >= blockSizeBytes) {\n+        return workerInfo.getNetAddress();\n+      }\n+    }\n+    return localWorkerNetAddress;","path":"core/client/src/main/java/alluxio/client/file/policy/LocalFirstWithoutEvictionPolicy.java","position":62,"original_position":62,"commit_id":"470e791ffc4767e66e6701c1a59f20b478d71da9","original_commit_id":"470e791ffc4767e66e6701c1a59f20b478d71da9","user":{"login":"bissont","id":509759,"avatar_url":"https://avatars.githubusercontent.com/u/509759?v=3","gravatar_id":"","url":"https://api.github.com/users/bissont","html_url":"https://github.com/bissont","followers_url":"https://api.github.com/users/bissont/followers","following_url":"https://api.github.com/users/bissont/following{/other_user}","gists_url":"https://api.github.com/users/bissont/gists{/gist_id}","starred_url":"https://api.github.com/users/bissont/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bissont/subscriptions","organizations_url":"https://api.github.com/users/bissont/orgs","repos_url":"https://api.github.com/users/bissont/repos","events_url":"https://api.github.com/users/bissont/events{/privacy}","received_events_url":"https://api.github.com/users/bissont/received_events","type":"User","site_admin":false},"body":"If we can't satisfy the write at all, what about throwing an Alluxio exception instead? ","created_at":"2016-12-08T07:41:09Z","updated_at":"2016-12-08T07:41:53Z","html_url":"https://github.com/Alluxio/alluxio/pull/4423#discussion_r91459284","pull_request_url":"https://api.github.com/repos/Alluxio/alluxio/pulls/4423","_links":{"self":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/comments/91459284"},"html":{"href":"https://github.com/Alluxio/alluxio/pull/4423#discussion_r91459284"},"pull_request":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/4423"}}},"pull_request":{"url":"https://api.github.com/repos/Alluxio/alluxio/pulls/4423","id":97062669,"html_url":"https://github.com/Alluxio/alluxio/pull/4423","diff_url":"https://github.com/Alluxio/alluxio/pull/4423.diff","patch_url":"https://github.com/Alluxio/alluxio/pull/4423.patch","issue_url":"https://api.github.com/repos/Alluxio/alluxio/issues/4423","number":4423,"state":"open","locked":false,"title":"[ALLUXIO-2226] Add a LocalFirstPolicy that without evict action","user":{"login":"gjhkael","id":10809317,"avatar_url":"https://avatars.githubusercontent.com/u/10809317?v=3","gravatar_id":"","url":"https://api.github.com/users/gjhkael","html_url":"https://github.com/gjhkael","followers_url":"https://api.github.com/users/gjhkael/followers","following_url":"https://api.github.com/users/gjhkael/following{/other_user}","gists_url":"https://api.github.com/users/gjhkael/gists{/gist_id}","starred_url":"https://api.github.com/users/gjhkael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gjhkael/subscriptions","organizations_url":"https://api.github.com/users/gjhkael/orgs","repos_url":"https://api.github.com/users/gjhkael/repos","events_url":"https://api.github.com/users/gjhkael/events{/privacy}","received_events_url":"https://api.github.com/users/gjhkael/received_events","type":"User","site_admin":false},"body":"https://alluxio.atlassian.net/browse/ALLUXIO-2226","created_at":"2016-12-08T05:45:10Z","updated_at":"2016-12-08T07:41:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c6fc3d3d1917023594cdbfc7bbbbd1d96c8376f8","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Alluxio/alluxio/pulls/4423/commits","review_comments_url":"https://api.github.com/repos/Alluxio/alluxio/pulls/4423/comments","review_comment_url":"https://api.github.com/repos/Alluxio/alluxio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Alluxio/alluxio/issues/4423/comments","statuses_url":"https://api.github.com/repos/Alluxio/alluxio/statuses/470e791ffc4767e66e6701c1a59f20b478d71da9","head":{"label":"gjhkael:newLocalPolicy","ref":"newLocalPolicy","sha":"470e791ffc4767e66e6701c1a59f20b478d71da9","user":{"login":"gjhkael","id":10809317,"avatar_url":"https://avatars.githubusercontent.com/u/10809317?v=3","gravatar_id":"","url":"https://api.github.com/users/gjhkael","html_url":"https://github.com/gjhkael","followers_url":"https://api.github.com/users/gjhkael/followers","following_url":"https://api.github.com/users/gjhkael/following{/other_user}","gists_url":"https://api.github.com/users/gjhkael/gists{/gist_id}","starred_url":"https://api.github.com/users/gjhkael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gjhkael/subscriptions","organizations_url":"https://api.github.com/users/gjhkael/orgs","repos_url":"https://api.github.com/users/gjhkael/repos","events_url":"https://api.github.com/users/gjhkael/events{/privacy}","received_events_url":"https://api.github.com/users/gjhkael/received_events","type":"User","site_admin":false},"repo":{"id":73160896,"name":"alluxio","full_name":"gjhkael/alluxio","owner":{"login":"gjhkael","id":10809317,"avatar_url":"https://avatars.githubusercontent.com/u/10809317?v=3","gravatar_id":"","url":"https://api.github.com/users/gjhkael","html_url":"https://github.com/gjhkael","followers_url":"https://api.github.com/users/gjhkael/followers","following_url":"https://api.github.com/users/gjhkael/following{/other_user}","gists_url":"https://api.github.com/users/gjhkael/gists{/gist_id}","starred_url":"https://api.github.com/users/gjhkael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gjhkael/subscriptions","organizations_url":"https://api.github.com/users/gjhkael/orgs","repos_url":"https://api.github.com/users/gjhkael/repos","events_url":"https://api.github.com/users/gjhkael/events{/privacy}","received_events_url":"https://api.github.com/users/gjhkael/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gjhkael/alluxio","description":"Alluxio, formerly Tachyon, Memory Speed Virtual Distributed Storage System","fork":true,"url":"https://api.github.com/repos/gjhkael/alluxio","forks_url":"https://api.github.com/repos/gjhkael/alluxio/forks","keys_url":"https://api.github.com/repos/gjhkael/alluxio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gjhkael/alluxio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gjhkael/alluxio/teams","hooks_url":"https://api.github.com/repos/gjhkael/alluxio/hooks","issue_events_url":"https://api.github.com/repos/gjhkael/alluxio/issues/events{/number}","events_url":"https://api.github.com/repos/gjhkael/alluxio/events","assignees_url":"https://api.github.com/repos/gjhkael/alluxio/assignees{/user}","branches_url":"https://api.github.com/repos/gjhkael/alluxio/branches{/branch}","tags_url":"https://api.github.com/repos/gjhkael/alluxio/tags","blobs_url":"https://api.github.com/repos/gjhkael/alluxio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gjhkael/alluxio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gjhkael/alluxio/git/refs{/sha}","trees_url":"https://api.github.com/repos/gjhkael/alluxio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gjhkael/alluxio/statuses/{sha}","languages_url":"https://api.github.com/repos/gjhkael/alluxio/languages","stargazers_url":"https://api.github.com/repos/gjhkael/alluxio/stargazers","contributors_url":"https://api.github.com/repos/gjhkael/alluxio/contributors","subscribers_url":"https://api.github.com/repos/gjhkael/alluxio/subscribers","subscription_url":"https://api.github.com/repos/gjhkael/alluxio/subscription","commits_url":"https://api.github.com/repos/gjhkael/alluxio/commits{/sha}","git_commits_url":"https://api.github.com/repos/gjhkael/alluxio/git/commits{/sha}","comments_url":"https://api.github.com/repos/gjhkael/alluxio/comments{/number}","issue_comment_url":"https://api.github.com/repos/gjhkael/alluxio/issues/comments{/number}","contents_url":"https://api.github.com/repos/gjhkael/alluxio/contents/{+path}","compare_url":"https://api.github.com/repos/gjhkael/alluxio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gjhkael/alluxio/merges","archive_url":"https://api.github.com/repos/gjhkael/alluxio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gjhkael/alluxio/downloads","issues_url":"https://api.github.com/repos/gjhkael/alluxio/issues{/number}","pulls_url":"https://api.github.com/repos/gjhkael/alluxio/pulls{/number}","milestones_url":"https://api.github.com/repos/gjhkael/alluxio/milestones{/number}","notifications_url":"https://api.github.com/repos/gjhkael/alluxio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gjhkael/alluxio/labels{/name}","releases_url":"https://api.github.com/repos/gjhkael/alluxio/releases{/id}","deployments_url":"https://api.github.com/repos/gjhkael/alluxio/deployments","created_at":"2016-11-08T07:33:26Z","updated_at":"2016-11-08T07:33:31Z","pushed_at":"2016-12-08T05:42:20Z","git_url":"git://github.com/gjhkael/alluxio.git","ssh_url":"git@github.com:gjhkael/alluxio.git","clone_url":"https://github.com/gjhkael/alluxio.git","svn_url":"https://github.com/gjhkael/alluxio","homepage":"http://www.alluxio.org/","size":63782,"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":"4e5d5a9a5ba2a4978bece50e486657438da744aa","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-08T07:13:01Z","pushed_at":"2016-12-08T06:56:30Z","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":100633,"stargazers_count":2756,"watchers_count":2756,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1247,"mirror_url":null,"open_issues_count":22,"forks":1247,"open_issues":22,"watchers":2756,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/4423"},"html":{"href":"https://github.com/Alluxio/alluxio/pull/4423"},"issue":{"href":"https://api.github.com/repos/Alluxio/alluxio/issues/4423"},"comments":{"href":"https://api.github.com/repos/Alluxio/alluxio/issues/4423/comments"},"review_comments":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/4423/comments"},"review_comment":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/4423/commits"},"statuses":{"href":"https://api.github.com/repos/Alluxio/alluxio/statuses/470e791ffc4767e66e6701c1a59f20b478d71da9"}}}}
{"actor":{"display_login":"bissont"}}