{"action":"created","comment":{"url":"https://api.github.com/repos/grpc/grpc-java/pulls/comments/91441027","pull_request_review_id":11948825,"id":91441027,"diff_hunk":"@@ -0,0 +1,155 @@\n+/*\n+ * Copyright 2016, Google Inc. All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions are\n+ * met:\n+ *\n+ *    * Redistributions of source code must retain the above copyright\n+ * notice, this list of conditions and the following disclaimer.\n+ *    * Redistributions in binary form must reproduce the above\n+ * copyright notice, this list of conditions and the following disclaimer\n+ * in the documentation and/or other materials provided with the\n+ * distribution.\n+ *\n+ *    * Neither the name of Google Inc. nor the names of its\n+ * contributors may be used to endorse or promote products derived from\n+ * this software without specific prior written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+package io.grpc;\n+\n+import com.google.common.annotations.VisibleForTesting;\n+import com.google.common.collect.Lists;\n+\n+import java.net.SocketAddress;\n+import java.util.List;\n+\n+/**\n+ * A {@link LoadBalancer} that provides no load balancing mechanism over the\n+ * addresses from the {@link NameResolver}.  The channel's default behavior\n+ * (currently pick-first) is used for all addresses found.\n+ */\n+@ExperimentalApi(\"https://github.com/grpc/grpc-java/issues/1771\")\n+public final class PickFirstBalancerFactory2 extends LoadBalancer2.Factory {\n+\n+  private static final PickFirstBalancerFactory2 instance = new PickFirstBalancerFactory2();\n+\n+  private PickFirstBalancerFactory2() {\n+  }\n+\n+  public static PickFirstBalancerFactory2 getInstance() {\n+    return instance;\n+  }\n+\n+  @Override\n+  public LoadBalancer2 newLoadBalancer(LoadBalancer2.Helper helper) {\n+    return new PickFirstBalancer(helper);\n+  }\n+\n+  @VisibleForTesting\n+  static class PickFirstBalancer extends LoadBalancer2 {\n+    private final Helper helper;\n+    private Subchannel subchannel;\n+\n+    public PickFirstBalancer(Helper helper) {\n+      this.helper = helper;\n+    }\n+\n+    @Override\n+    public void handleResolvedAddresses(List<ResolvedServerInfoGroup> servers,\n+        Attributes attributes) {\n+      // Flatten servers list received from name resolver into single address group. This means that\n+      // as far as load balancer is concerned, there's virtually one single server with multiple\n+      // addresses so the connection will be created only for the first address (pick first).\n+      EquivalentAddressGroup newEag =\n+          flattenResolvedServerInfoGroupsIntoEquivalentAddressGroup(servers);\n+      if (subchannel == null || !newEag.equals(subchannel.getAddresses())) {\n+        if (subchannel != null) {","path":"core/src/main/java/io/grpc/PickFirstBalancerFactory2.java","position":80,"original_position":80,"commit_id":"a5f63bf9e215e7e5a2086f8bd2b0f1665fd13e45","original_commit_id":"0e36c834cf9eea0d41bb550be9e3db35a2544f1f","user":{"login":"zhangkun83","id":9053690,"avatar_url":"https://avatars.githubusercontent.com/u/9053690?v=3","gravatar_id":"","url":"https://api.github.com/users/zhangkun83","html_url":"https://github.com/zhangkun83","followers_url":"https://api.github.com/users/zhangkun83/followers","following_url":"https://api.github.com/users/zhangkun83/following{/other_user}","gists_url":"https://api.github.com/users/zhangkun83/gists{/gist_id}","starred_url":"https://api.github.com/users/zhangkun83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhangkun83/subscriptions","organizations_url":"https://api.github.com/users/zhangkun83/orgs","repos_url":"https://api.github.com/users/zhangkun83/repos","events_url":"https://api.github.com/users/zhangkun83/events{/privacy}","received_events_url":"https://api.github.com/users/zhangkun83/received_events","type":"User","site_admin":false},"body":"This is not about synchronization. If we shut down the old subchannel here, until the new one becomes READY, RPCs are going to be buffered. If the old subchannel were not shut down that early, those RPCs could have been sent on the old one, which means lower latency seen by the application.","created_at":"2016-12-08T04:22:10Z","updated_at":"2016-12-08T04:22:27Z","html_url":"https://github.com/grpc/grpc-java/pull/2479#discussion_r91441027","pull_request_url":"https://api.github.com/repos/grpc/grpc-java/pulls/2479","_links":{"self":{"href":"https://api.github.com/repos/grpc/grpc-java/pulls/comments/91441027"},"html":{"href":"https://github.com/grpc/grpc-java/pull/2479#discussion_r91441027"},"pull_request":{"href":"https://api.github.com/repos/grpc/grpc-java/pulls/2479"}}},"pull_request":{"url":"https://api.github.com/repos/grpc/grpc-java/pulls/2479","id":96331911,"html_url":"https://github.com/grpc/grpc-java/pull/2479","diff_url":"https://github.com/grpc/grpc-java/pull/2479.diff","patch_url":"https://github.com/grpc/grpc-java/pull/2479.patch","issue_url":"https://api.github.com/repos/grpc/grpc-java/issues/2479","number":2479,"state":"open","locked":false,"title":"Port PickFirst & RoundRobin LBs to v2 API","user":{"login":"lukaszx0","id":11562,"avatar_url":"https://avatars.githubusercontent.com/u/11562?v=3","gravatar_id":"","url":"https://api.github.com/users/lukaszx0","html_url":"https://github.com/lukaszx0","followers_url":"https://api.github.com/users/lukaszx0/followers","following_url":"https://api.github.com/users/lukaszx0/following{/other_user}","gists_url":"https://api.github.com/users/lukaszx0/gists{/gist_id}","starred_url":"https://api.github.com/users/lukaszx0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukaszx0/subscriptions","organizations_url":"https://api.github.com/users/lukaszx0/orgs","repos_url":"https://api.github.com/users/lukaszx0/repos","events_url":"https://api.github.com/users/lukaszx0/events{/privacy}","received_events_url":"https://api.github.com/users/lukaszx0/received_events","type":"User","site_admin":false},"body":"This PR ports existing `PickFirst` and `RoundRobin` LBs to use v2 API.\r\n\r\n@ejona86 @zhangkun83 @kkaneda @maniksurtani ","created_at":"2016-12-02T18:49:08Z","updated_at":"2016-12-08T04:22:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9f950a6a1b0a70ccb600bcf3d70f861160b0fbe8","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/grpc/grpc-java/pulls/2479/commits","review_comments_url":"https://api.github.com/repos/grpc/grpc-java/pulls/2479/comments","review_comment_url":"https://api.github.com/repos/grpc/grpc-java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/grpc/grpc-java/issues/2479/comments","statuses_url":"https://api.github.com/repos/grpc/grpc-java/statuses/a5f63bf9e215e7e5a2086f8bd2b0f1665fd13e45","head":{"label":"lukaszx0:port-lbs","ref":"port-lbs","sha":"a5f63bf9e215e7e5a2086f8bd2b0f1665fd13e45","user":{"login":"lukaszx0","id":11562,"avatar_url":"https://avatars.githubusercontent.com/u/11562?v=3","gravatar_id":"","url":"https://api.github.com/users/lukaszx0","html_url":"https://github.com/lukaszx0","followers_url":"https://api.github.com/users/lukaszx0/followers","following_url":"https://api.github.com/users/lukaszx0/following{/other_user}","gists_url":"https://api.github.com/users/lukaszx0/gists{/gist_id}","starred_url":"https://api.github.com/users/lukaszx0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukaszx0/subscriptions","organizations_url":"https://api.github.com/users/lukaszx0/orgs","repos_url":"https://api.github.com/users/lukaszx0/repos","events_url":"https://api.github.com/users/lukaszx0/events{/privacy}","received_events_url":"https://api.github.com/users/lukaszx0/received_events","type":"User","site_admin":false},"repo":{"id":51521701,"name":"grpc-java","full_name":"lukaszx0/grpc-java","owner":{"login":"lukaszx0","id":11562,"avatar_url":"https://avatars.githubusercontent.com/u/11562?v=3","gravatar_id":"","url":"https://api.github.com/users/lukaszx0","html_url":"https://github.com/lukaszx0","followers_url":"https://api.github.com/users/lukaszx0/followers","following_url":"https://api.github.com/users/lukaszx0/following{/other_user}","gists_url":"https://api.github.com/users/lukaszx0/gists{/gist_id}","starred_url":"https://api.github.com/users/lukaszx0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukaszx0/subscriptions","organizations_url":"https://api.github.com/users/lukaszx0/orgs","repos_url":"https://api.github.com/users/lukaszx0/repos","events_url":"https://api.github.com/users/lukaszx0/events{/privacy}","received_events_url":"https://api.github.com/users/lukaszx0/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lukaszx0/grpc-java","description":"The Java gRPC implementation. HTTP/2 based RPC","fork":true,"url":"https://api.github.com/repos/lukaszx0/grpc-java","forks_url":"https://api.github.com/repos/lukaszx0/grpc-java/forks","keys_url":"https://api.github.com/repos/lukaszx0/grpc-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lukaszx0/grpc-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lukaszx0/grpc-java/teams","hooks_url":"https://api.github.com/repos/lukaszx0/grpc-java/hooks","issue_events_url":"https://api.github.com/repos/lukaszx0/grpc-java/issues/events{/number}","events_url":"https://api.github.com/repos/lukaszx0/grpc-java/events","assignees_url":"https://api.github.com/repos/lukaszx0/grpc-java/assignees{/user}","branches_url":"https://api.github.com/repos/lukaszx0/grpc-java/branches{/branch}","tags_url":"https://api.github.com/repos/lukaszx0/grpc-java/tags","blobs_url":"https://api.github.com/repos/lukaszx0/grpc-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lukaszx0/grpc-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lukaszx0/grpc-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/lukaszx0/grpc-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lukaszx0/grpc-java/statuses/{sha}","languages_url":"https://api.github.com/repos/lukaszx0/grpc-java/languages","stargazers_url":"https://api.github.com/repos/lukaszx0/grpc-java/stargazers","contributors_url":"https://api.github.com/repos/lukaszx0/grpc-java/contributors","subscribers_url":"https://api.github.com/repos/lukaszx0/grpc-java/subscribers","subscription_url":"https://api.github.com/repos/lukaszx0/grpc-java/subscription","commits_url":"https://api.github.com/repos/lukaszx0/grpc-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/lukaszx0/grpc-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/lukaszx0/grpc-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/lukaszx0/grpc-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/lukaszx0/grpc-java/contents/{+path}","compare_url":"https://api.github.com/repos/lukaszx0/grpc-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lukaszx0/grpc-java/merges","archive_url":"https://api.github.com/repos/lukaszx0/grpc-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lukaszx0/grpc-java/downloads","issues_url":"https://api.github.com/repos/lukaszx0/grpc-java/issues{/number}","pulls_url":"https://api.github.com/repos/lukaszx0/grpc-java/pulls{/number}","milestones_url":"https://api.github.com/repos/lukaszx0/grpc-java/milestones{/number}","notifications_url":"https://api.github.com/repos/lukaszx0/grpc-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lukaszx0/grpc-java/labels{/name}","releases_url":"https://api.github.com/repos/lukaszx0/grpc-java/releases{/id}","deployments_url":"https://api.github.com/repos/lukaszx0/grpc-java/deployments","created_at":"2016-02-11T14:56:45Z","updated_at":"2016-02-11T14:56:46Z","pushed_at":"2016-12-08T02:10:17Z","git_url":"git://github.com/lukaszx0/grpc-java.git","ssh_url":"git@github.com:lukaszx0/grpc-java.git","clone_url":"https://github.com/lukaszx0/grpc-java.git","svn_url":"https://github.com/lukaszx0/grpc-java","homepage":"http://grpc.io","size":9807,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":false,"has_wiki":false,"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":"grpc:master","ref":"master","sha":"67ff170b96989022537a4f0735165afdccb6c05f","user":{"login":"grpc","id":7802525,"avatar_url":"https://avatars.githubusercontent.com/u/7802525?v=3","gravatar_id":"","url":"https://api.github.com/users/grpc","html_url":"https://github.com/grpc","followers_url":"https://api.github.com/users/grpc/followers","following_url":"https://api.github.com/users/grpc/following{/other_user}","gists_url":"https://api.github.com/users/grpc/gists{/gist_id}","starred_url":"https://api.github.com/users/grpc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grpc/subscriptions","organizations_url":"https://api.github.com/users/grpc/orgs","repos_url":"https://api.github.com/users/grpc/repos","events_url":"https://api.github.com/users/grpc/events{/privacy}","received_events_url":"https://api.github.com/users/grpc/received_events","type":"Organization","site_admin":false},"repo":{"id":27729926,"name":"grpc-java","full_name":"grpc/grpc-java","owner":{"login":"grpc","id":7802525,"avatar_url":"https://avatars.githubusercontent.com/u/7802525?v=3","gravatar_id":"","url":"https://api.github.com/users/grpc","html_url":"https://github.com/grpc","followers_url":"https://api.github.com/users/grpc/followers","following_url":"https://api.github.com/users/grpc/following{/other_user}","gists_url":"https://api.github.com/users/grpc/gists{/gist_id}","starred_url":"https://api.github.com/users/grpc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grpc/subscriptions","organizations_url":"https://api.github.com/users/grpc/orgs","repos_url":"https://api.github.com/users/grpc/repos","events_url":"https://api.github.com/users/grpc/events{/privacy}","received_events_url":"https://api.github.com/users/grpc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/grpc/grpc-java","description":"The Java gRPC implementation. HTTP/2 based RPC","fork":false,"url":"https://api.github.com/repos/grpc/grpc-java","forks_url":"https://api.github.com/repos/grpc/grpc-java/forks","keys_url":"https://api.github.com/repos/grpc/grpc-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/grpc/grpc-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/grpc/grpc-java/teams","hooks_url":"https://api.github.com/repos/grpc/grpc-java/hooks","issue_events_url":"https://api.github.com/repos/grpc/grpc-java/issues/events{/number}","events_url":"https://api.github.com/repos/grpc/grpc-java/events","assignees_url":"https://api.github.com/repos/grpc/grpc-java/assignees{/user}","branches_url":"https://api.github.com/repos/grpc/grpc-java/branches{/branch}","tags_url":"https://api.github.com/repos/grpc/grpc-java/tags","blobs_url":"https://api.github.com/repos/grpc/grpc-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/grpc/grpc-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/grpc/grpc-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/grpc/grpc-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/grpc/grpc-java/statuses/{sha}","languages_url":"https://api.github.com/repos/grpc/grpc-java/languages","stargazers_url":"https://api.github.com/repos/grpc/grpc-java/stargazers","contributors_url":"https://api.github.com/repos/grpc/grpc-java/contributors","subscribers_url":"https://api.github.com/repos/grpc/grpc-java/subscribers","subscription_url":"https://api.github.com/repos/grpc/grpc-java/subscription","commits_url":"https://api.github.com/repos/grpc/grpc-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/grpc/grpc-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/grpc/grpc-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/grpc/grpc-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/grpc/grpc-java/contents/{+path}","compare_url":"https://api.github.com/repos/grpc/grpc-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/grpc/grpc-java/merges","archive_url":"https://api.github.com/repos/grpc/grpc-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/grpc/grpc-java/downloads","issues_url":"https://api.github.com/repos/grpc/grpc-java/issues{/number}","pulls_url":"https://api.github.com/repos/grpc/grpc-java/pulls{/number}","milestones_url":"https://api.github.com/repos/grpc/grpc-java/milestones{/number}","notifications_url":"https://api.github.com/repos/grpc/grpc-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/grpc/grpc-java/labels{/name}","releases_url":"https://api.github.com/repos/grpc/grpc-java/releases{/id}","deployments_url":"https://api.github.com/repos/grpc/grpc-java/deployments","created_at":"2014-12-08T19:00:00Z","updated_at":"2016-12-07T15:54:44Z","pushed_at":"2016-12-08T02:10:17Z","git_url":"git://github.com/grpc/grpc-java.git","ssh_url":"git@github.com:grpc/grpc-java.git","clone_url":"https://github.com/grpc/grpc-java.git","svn_url":"https://github.com/grpc/grpc-java","homepage":"http://grpc.io","size":29483,"stargazers_count":2245,"watchers_count":2245,"language":"Java","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":true,"forks_count":674,"mirror_url":null,"open_issues_count":277,"forks":674,"open_issues":277,"watchers":2245,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/grpc/grpc-java/pulls/2479"},"html":{"href":"https://github.com/grpc/grpc-java/pull/2479"},"issue":{"href":"https://api.github.com/repos/grpc/grpc-java/issues/2479"},"comments":{"href":"https://api.github.com/repos/grpc/grpc-java/issues/2479/comments"},"review_comments":{"href":"https://api.github.com/repos/grpc/grpc-java/pulls/2479/comments"},"review_comment":{"href":"https://api.github.com/repos/grpc/grpc-java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/grpc/grpc-java/pulls/2479/commits"},"statuses":{"href":"https://api.github.com/repos/grpc/grpc-java/statuses/a5f63bf9e215e7e5a2086f8bd2b0f1665fd13e45"}}}}
{"actor":{"display_login":"zhangkun83"}}