{"action":"created","comment":{"url":"https://api.github.com/repos/grpc/grpc-java/pulls/comments/90083296","pull_request_review_id":10589449,"id":90083296,"diff_hunk":"@@ -359,22 +368,94 @@ public void run() {\n    * Is only called at the beginning of the callback function of {@code endOfCurrentBackoff} in the\n    * {@link TransportSet#scheduleBackoff} method.\n    */\n-  void endBackoff() {\n+  // TODO(zhangkun83): remove it once the LBv2 refactor is done.\n+  final void endBackoff() {\n     synchronized (lock) {\n       Preconditions.checkState(backoffStatus != null,\n           \"Error when calling endBackoff: transport is not in backoff period\");\n       backoffStatus = null;\n     }\n   }\n \n+  /**\n+   * Use the picker to try picking a transport for every pending stream and pending ping, proceed\n+   * the stream or ping if the pick is successful, otherwise keep it pending.\n+   *\n+   * <p>If new pending streams are created while reprocess() is in progress, there is no guarantee\n+   * that the pending streams will or will not be processed by this picker.\n+   */\n+  final void reprocess(LoadBalancer2.SubchannelPicker picker) {\n+    ArrayList<PendingStream> toProcess;\n+    ArrayList<PendingStream> toRemove = new ArrayList<PendingStream>();\n+    synchronized (lock) {\n+      if (pendingStreams == null || pendingStreams.isEmpty()) {\n+        return;\n+      }\n+      toProcess = new ArrayList<PendingStream>(pendingStreams);\n+    }\n+\n+    for (final PendingStream stream : toProcess) {\n+      PickResult pickResult = picker.pickSubchannel(\n+          stream.callOptions.getAffinity(), stream.headers);\n+      final ClientTransport realTransport;\n+      Subchannel subchannel = pickResult.getSubchannel();\n+      if (subchannel != null) {\n+        realTransport = obtainActiveTransport(subchannel);\n+      } else {\n+        realTransport = null;\n+      }\n+      if (realTransport != null) {\n+        Executor executor = streamCreationExecutor;\n+        // createRealStream may be expensive. It will start real streams on the transport. If\n+        // there are pending requests, they will be serialized too, which may be expensive. Since\n+        // we are now on transport thread, we need to offload the work to an executor.\n+        if (stream.callOptions.getExecutor() != null) {\n+          executor = stream.callOptions.getExecutor();\n+        }\n+        executor.execute(new Runnable() {\n+            @Override\n+            public void run() {\n+              stream.createRealStream(realTransport);\n+            }\n+          });\n+        toRemove.add(stream);\n+      } else if (!pickResult.getStatus().isOk() && !stream.callOptions.isWaitForReady()) {\n+        stream.setStream(new FailingClientStream(pickResult.getStatus()));\n+        toRemove.add(stream);\n+      }  // other cases: stay pending\n+    }\n+\n+    synchronized (lock) {\n+      if (pendingStreams == null || pendingStreams.isEmpty()) {\n+        return;\n+      }\n+      pendingStreams.removeAll(toRemove);\n+      if (pendingStreams.isEmpty()) {\n+        pendingStreams = null;\n+        // There may be a brief gap between delayed transport clearing in-use state, and first real\n+        // transport starting streams and setting in-use state.  During the gap the whole channel's\n+        // in-use state may be false. However, it shouldn't cause spurious switching to idleness\n+        // (which would shutdown the transports and LoadBalancer) because the gap should be shorter\n+        // than IDLE_MODE_DEFAULT_TIMEOUT_MILLIS (1 second).\n+        listener.transportInUse(false);\n+      }\n+    }\n+  }\n+\n+  // To be implemented by ManagedChannelImpl2 and unit test\n+  @Nullable\n+  ClientTransport obtainActiveTransport(Subchannel subchannel) {\n+    throw new UnsupportedOperationException(\"Not implemented\");","path":"core/src/main/java/io/grpc/internal/DelayedClientTransport.java","position":212,"original_position":212,"commit_id":"feee7c0383cec91718ba6af15738ac39ea5a2cb6","original_commit_id":"feee7c0383cec91718ba6af15738ac39ea5a2cb6","user":{"login":"ejona86","id":2811396,"avatar_url":"https://avatars.githubusercontent.com/u/2811396?v=3","gravatar_id":"","url":"https://api.github.com/users/ejona86","html_url":"https://github.com/ejona86","followers_url":"https://api.github.com/users/ejona86/followers","following_url":"https://api.github.com/users/ejona86/following{/other_user}","gists_url":"https://api.github.com/users/ejona86/gists{/gist_id}","starred_url":"https://api.github.com/users/ejona86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ejona86/subscriptions","organizations_url":"https://api.github.com/users/ejona86/orgs","repos_url":"https://api.github.com/users/ejona86/repos","events_url":"https://api.github.com/users/ejona86/events{/privacy}","received_events_url":"https://api.github.com/users/ejona86/received_events","type":"User","site_admin":false},"body":"This seems strange, but I'm willing to wait and see how it all fits together.","created_at":"2016-11-29T19:05:11Z","updated_at":"2016-11-29T19:13:49Z","html_url":"https://github.com/grpc/grpc-java/pull/2443#discussion_r90083296","pull_request_url":"https://api.github.com/repos/grpc/grpc-java/pulls/2443","_links":{"self":{"href":"https://api.github.com/repos/grpc/grpc-java/pulls/comments/90083296"},"html":{"href":"https://github.com/grpc/grpc-java/pull/2443#discussion_r90083296"},"pull_request":{"href":"https://api.github.com/repos/grpc/grpc-java/pulls/2443"}}},"pull_request":{"url":"https://api.github.com/repos/grpc/grpc-java/pulls/2443","id":95108259,"html_url":"https://github.com/grpc/grpc-java/pull/2443","diff_url":"https://github.com/grpc/grpc-java/pull/2443.diff","patch_url":"https://github.com/grpc/grpc-java/pull/2443.patch","issue_url":"https://api.github.com/repos/grpc/grpc-java/issues/2443","number":2443,"state":"open","locked":false,"title":"core: LoadBalancer2 and DelayedClientTransport.reprocess().","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 the second step of a major refactor for the LoadBalancer-related\r\npart of Channel impl (#1600).\r\n\r\nPlease review the PR as an entirety.","created_at":"2016-11-24T02:27:43Z","updated_at":"2016-11-29T19:13:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a0637b77fdd2133a1289b13d378b6f9f64a9f09f","assignee":{"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},"assignees":[{"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},{"login":"ejona86","id":2811396,"avatar_url":"https://avatars.githubusercontent.com/u/2811396?v=3","gravatar_id":"","url":"https://api.github.com/users/ejona86","html_url":"https://github.com/ejona86","followers_url":"https://api.github.com/users/ejona86/followers","following_url":"https://api.github.com/users/ejona86/following{/other_user}","gists_url":"https://api.github.com/users/ejona86/gists{/gist_id}","starred_url":"https://api.github.com/users/ejona86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ejona86/subscriptions","organizations_url":"https://api.github.com/users/ejona86/orgs","repos_url":"https://api.github.com/users/ejona86/repos","events_url":"https://api.github.com/users/ejona86/events{/privacy}","received_events_url":"https://api.github.com/users/ejona86/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/grpc/grpc-java/pulls/2443/commits","review_comments_url":"https://api.github.com/repos/grpc/grpc-java/pulls/2443/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/2443/comments","statuses_url":"https://api.github.com/repos/grpc/grpc-java/statuses/feee7c0383cec91718ba6af15738ac39ea5a2cb6","head":{"label":"zhangkun83:lbv2_delayedtransport","ref":"lbv2_delayedtransport","sha":"feee7c0383cec91718ba6af15738ac39ea5a2cb6","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},"repo":{"id":31399597,"name":"grpc-java","full_name":"zhangkun83/grpc-java","owner":{"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},"private":false,"html_url":"https://github.com/zhangkun83/grpc-java","description":"The Java gRPC implementation. HTTP/2 based RPC","fork":true,"url":"https://api.github.com/repos/zhangkun83/grpc-java","forks_url":"https://api.github.com/repos/zhangkun83/grpc-java/forks","keys_url":"https://api.github.com/repos/zhangkun83/grpc-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zhangkun83/grpc-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zhangkun83/grpc-java/teams","hooks_url":"https://api.github.com/repos/zhangkun83/grpc-java/hooks","issue_events_url":"https://api.github.com/repos/zhangkun83/grpc-java/issues/events{/number}","events_url":"https://api.github.com/repos/zhangkun83/grpc-java/events","assignees_url":"https://api.github.com/repos/zhangkun83/grpc-java/assignees{/user}","branches_url":"https://api.github.com/repos/zhangkun83/grpc-java/branches{/branch}","tags_url":"https://api.github.com/repos/zhangkun83/grpc-java/tags","blobs_url":"https://api.github.com/repos/zhangkun83/grpc-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zhangkun83/grpc-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zhangkun83/grpc-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/zhangkun83/grpc-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zhangkun83/grpc-java/statuses/{sha}","languages_url":"https://api.github.com/repos/zhangkun83/grpc-java/languages","stargazers_url":"https://api.github.com/repos/zhangkun83/grpc-java/stargazers","contributors_url":"https://api.github.com/repos/zhangkun83/grpc-java/contributors","subscribers_url":"https://api.github.com/repos/zhangkun83/grpc-java/subscribers","subscription_url":"https://api.github.com/repos/zhangkun83/grpc-java/subscription","commits_url":"https://api.github.com/repos/zhangkun83/grpc-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/zhangkun83/grpc-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/zhangkun83/grpc-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/zhangkun83/grpc-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/zhangkun83/grpc-java/contents/{+path}","compare_url":"https://api.github.com/repos/zhangkun83/grpc-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zhangkun83/grpc-java/merges","archive_url":"https://api.github.com/repos/zhangkun83/grpc-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zhangkun83/grpc-java/downloads","issues_url":"https://api.github.com/repos/zhangkun83/grpc-java/issues{/number}","pulls_url":"https://api.github.com/repos/zhangkun83/grpc-java/pulls{/number}","milestones_url":"https://api.github.com/repos/zhangkun83/grpc-java/milestones{/number}","notifications_url":"https://api.github.com/repos/zhangkun83/grpc-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zhangkun83/grpc-java/labels{/name}","releases_url":"https://api.github.com/repos/zhangkun83/grpc-java/releases{/id}","deployments_url":"https://api.github.com/repos/zhangkun83/grpc-java/deployments","created_at":"2015-02-27T02:25:11Z","updated_at":"2016-01-22T23:33:39Z","pushed_at":"2016-11-29T02:05:46Z","git_url":"git://github.com/zhangkun83/grpc-java.git","ssh_url":"git@github.com:zhangkun83/grpc-java.git","clone_url":"https://github.com/zhangkun83/grpc-java.git","svn_url":"https://github.com/zhangkun83/grpc-java","homepage":"","size":9084,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"grpc:master","ref":"master","sha":"18e628ab1d9273aefe337f1144e38efb53c1b156","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-11-29T05:04:20Z","pushed_at":"2016-11-29T17:39:56Z","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":29266,"stargazers_count":2226,"watchers_count":2226,"language":"Java","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":true,"forks_count":664,"mirror_url":null,"open_issues_count":271,"forks":664,"open_issues":271,"watchers":2226,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/grpc/grpc-java/pulls/2443"},"html":{"href":"https://github.com/grpc/grpc-java/pull/2443"},"issue":{"href":"https://api.github.com/repos/grpc/grpc-java/issues/2443"},"comments":{"href":"https://api.github.com/repos/grpc/grpc-java/issues/2443/comments"},"review_comments":{"href":"https://api.github.com/repos/grpc/grpc-java/pulls/2443/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/2443/commits"},"statuses":{"href":"https://api.github.com/repos/grpc/grpc-java/statuses/feee7c0383cec91718ba6af15738ac39ea5a2cb6"}}}}
{"actor":{"display_login":"ejona86"}}