{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/193412957","pull_request_review_id":126375525,"id":193412957,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5MzQxMjk1Nw==","diff_hunk":"@@ -33,36 +34,68 @@\n import java.util.concurrent.Future;\n import java.util.concurrent.atomic.AtomicBoolean;\n import java.util.concurrent.locks.ReentrantLock;\n+import java.util.function.BiConsumer;\n import java.util.stream.Collectors;\n \n /**\n- * This is a basic selector abstraction. This selector wraps a raw nio {@link Selector}. When you call\n+ * This is a nio selector implementation. This selector wraps a raw nio {@link Selector}. When you call\n  * {@link #runLoop()}, the selector will run until {@link #close()} is called. This instance handles closing\n  * of channels. Users should call {@link #queueChannelClose(NioChannel)} to schedule a channel for close by\n  * this selector.\n  * <p>\n  * Children of this class should implement the specific {@link #processKey(SelectionKey)},\n  * {@link #preSelect()}, and {@link #cleanup()} functionality.\n  */\n-public abstract class ESSelector implements Closeable {\n-\n-    final Selector selector;\n-    final ConcurrentLinkedQueue<ChannelContext<?>> channelsToClose = new ConcurrentLinkedQueue<>();\n+public class NioSelector implements Closeable {\n \n+    private final ConcurrentLinkedQueue<WriteOperation> queuedWrites = new ConcurrentLinkedQueue<>();\n+    private final ConcurrentLinkedQueue<ChannelContext<?>> channelsToClose = new ConcurrentLinkedQueue<>();\n+    private final ConcurrentLinkedQueue<ChannelContext<?>> channelsToRegister = new ConcurrentLinkedQueue<>();\n     private final EventHandler eventHandler;\n+    private final Selector selector;\n+\n     private final ReentrantLock runLock = new ReentrantLock();\n     private final CountDownLatch exitedLoop = new CountDownLatch(1);\n     private final AtomicBoolean isClosed = new AtomicBoolean(false);\n     private final CompletableFuture<Void> isRunningFuture = new CompletableFuture<>();\n     private volatile Thread thread;\n \n-    ESSelector(EventHandler eventHandler) throws IOException {\n+    public NioSelector(EventHandler eventHandler) throws IOException {\n         this(eventHandler, Selector.open());\n     }\n \n-    ESSelector(EventHandler eventHandler, Selector selector) {\n-        this.eventHandler = eventHandler;\n+    public NioSelector(EventHandler eventHandler, Selector selector) throws IOException {\n         this.selector = selector;\n+        this.eventHandler = eventHandler;\n+    }\n+\n+    public Selector rawSelector() {\n+        return selector;\n+    }\n+\n+    public boolean isOpen() {\n+        return isClosed.get() == false;\n+    }\n+\n+    public boolean isRunning() {\n+        return runLock.isLocked();\n+    }\n+\n+    Future<Void> isRunningFuture() {\n+        return isRunningFuture;\n+    }\n+\n+    void setThread() {\n+        thread = Thread.currentThread();\n+    }\n+\n+    public boolean isOnCurrentThread() {\n+        return Thread.currentThread() == thread;\n+    }\n+\n+    public void assertOnSelectorThread() {\n+        assert isOnCurrentThread() : \"Must be on selector thread to perform this operation. Currently on thread [\"","path":"libs/elasticsearch-nio/src/main/java/org/elasticsearch/nio/NioSelector.java","position":80,"original_position":80,"commit_id":"bc08583a1c07bf066501b5cb3ffae16fa0f873ba","original_commit_id":"bc08583a1c07bf066501b5cb3ffae16fa0f873ba","user":{"login":"s1monw","id":973334,"node_id":"MDQ6VXNlcjk3MzMzNA==","avatar_url":"https://avatars0.githubusercontent.com/u/973334?v=4","gravatar_id":"","url":"https://api.github.com/users/s1monw","html_url":"https://github.com/s1monw","followers_url":"https://api.github.com/users/s1monw/followers","following_url":"https://api.github.com/users/s1monw/following{/other_user}","gists_url":"https://api.github.com/users/s1monw/gists{/gist_id}","starred_url":"https://api.github.com/users/s1monw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s1monw/subscriptions","organizations_url":"https://api.github.com/users/s1monw/orgs","repos_url":"https://api.github.com/users/s1monw/repos","events_url":"https://api.github.com/users/s1monw/events{/privacy}","received_events_url":"https://api.github.com/users/s1monw/received_events","type":"User","site_admin":false},"body":"should we also include the `thread` to get more information here","created_at":"2018-06-06T13:40:01Z","updated_at":"2018-06-06T13:45:03Z","html_url":"https://github.com/elastic/elasticsearch/pull/31115#discussion_r193412957","pull_request_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/31115","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/193412957"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/31115#discussion_r193412957"},"pull_request":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/31115"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/31115","id":192831437,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkyODMxNDM3","html_url":"https://github.com/elastic/elasticsearch/pull/31115","diff_url":"https://github.com/elastic/elasticsearch/pull/31115.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/31115.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/31115","number":31115,"state":"open","locked":false,"title":" Combine accepting selector and socket selector","user":{"login":"tbrooks8","id":862472,"node_id":"MDQ6VXNlcjg2MjQ3Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/862472?v=4","gravatar_id":"","url":"https://api.github.com/users/tbrooks8","html_url":"https://github.com/tbrooks8","followers_url":"https://api.github.com/users/tbrooks8/followers","following_url":"https://api.github.com/users/tbrooks8/following{/other_user}","gists_url":"https://api.github.com/users/tbrooks8/gists{/gist_id}","starred_url":"https://api.github.com/users/tbrooks8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbrooks8/subscriptions","organizations_url":"https://api.github.com/users/tbrooks8/orgs","repos_url":"https://api.github.com/users/tbrooks8/repos","events_url":"https://api.github.com/users/tbrooks8/events{/privacy}","received_events_url":"https://api.github.com/users/tbrooks8/received_events","type":"User","site_admin":false},"body":"This is related to #27260. This commit combines the `AcceptingSelector`\r\nand `SocketSelector` classes into a single `NioSelector`. This change\r\nallows the same selector to handle both server and socket channels. This\r\nis valuable as we do not necessarily want a dedicated thread running for\r\naccepting channels.\r\n\r\nWith this change, this commit removes the configuration for dedicated\r\naccepting selectors for the normal transport class. The accepting\r\nworkload for new node connections is likely low, meaning that there is\r\nno need to dedicate a thread to this process.","created_at":"2018-06-05T20:46:57Z","updated_at":"2018-06-06T13:45:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"167529eaa8bb3008da446a78e1dd7bf177b85ccb","assignee":null,"assignees":[],"requested_reviewers":[{"login":"jasontedor","id":4744941,"node_id":"MDQ6VXNlcjQ3NDQ5NDE=","avatar_url":"https://avatars3.githubusercontent.com/u/4744941?v=4","gravatar_id":"","url":"https://api.github.com/users/jasontedor","html_url":"https://github.com/jasontedor","followers_url":"https://api.github.com/users/jasontedor/followers","following_url":"https://api.github.com/users/jasontedor/following{/other_user}","gists_url":"https://api.github.com/users/jasontedor/gists{/gist_id}","starred_url":"https://api.github.com/users/jasontedor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasontedor/subscriptions","organizations_url":"https://api.github.com/users/jasontedor/orgs","repos_url":"https://api.github.com/users/jasontedor/repos","events_url":"https://api.github.com/users/jasontedor/events{/privacy}","received_events_url":"https://api.github.com/users/jasontedor/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":146854632,"node_id":"MDU6TGFiZWwxNDY4NTQ2MzI=","url":"https://api.github.com/repos/elastic/elasticsearch/labels/:Core/Network","name":":Core/Network","color":"0e8a16","default":false},{"id":73544,"node_id":"MDU6TGFiZWw3MzU0NA==","url":"https://api.github.com/repos/elastic/elasticsearch/labels/%3Enon-issue","name":">non-issue","color":"cfcfcf","default":false},{"id":94283388,"node_id":"MDU6TGFiZWw5NDI4MzM4OA==","url":"https://api.github.com/repos/elastic/elasticsearch/labels/review","name":"review","color":"0052cc","default":false},{"id":484855464,"node_id":"MDU6TGFiZWw0ODQ4NTU0NjQ=","url":"https://api.github.com/repos/elastic/elasticsearch/labels/v7.0.0","name":"v7.0.0","color":"dddddd","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/31115/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/31115/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/31115/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/bc08583a1c07bf066501b5cb3ffae16fa0f873ba","head":{"label":"tbrooks8:combine_selectors","ref":"combine_selectors","sha":"bc08583a1c07bf066501b5cb3ffae16fa0f873ba","user":{"login":"tbrooks8","id":862472,"node_id":"MDQ6VXNlcjg2MjQ3Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/862472?v=4","gravatar_id":"","url":"https://api.github.com/users/tbrooks8","html_url":"https://github.com/tbrooks8","followers_url":"https://api.github.com/users/tbrooks8/followers","following_url":"https://api.github.com/users/tbrooks8/following{/other_user}","gists_url":"https://api.github.com/users/tbrooks8/gists{/gist_id}","starred_url":"https://api.github.com/users/tbrooks8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbrooks8/subscriptions","organizations_url":"https://api.github.com/users/tbrooks8/orgs","repos_url":"https://api.github.com/users/tbrooks8/repos","events_url":"https://api.github.com/users/tbrooks8/events{/privacy}","received_events_url":"https://api.github.com/users/tbrooks8/received_events","type":"User","site_admin":false},"repo":{"id":66806587,"node_id":"MDEwOlJlcG9zaXRvcnk2NjgwNjU4Nw==","name":"elasticsearch","full_name":"tbrooks8/elasticsearch","owner":{"login":"tbrooks8","id":862472,"node_id":"MDQ6VXNlcjg2MjQ3Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/862472?v=4","gravatar_id":"","url":"https://api.github.com/users/tbrooks8","html_url":"https://github.com/tbrooks8","followers_url":"https://api.github.com/users/tbrooks8/followers","following_url":"https://api.github.com/users/tbrooks8/following{/other_user}","gists_url":"https://api.github.com/users/tbrooks8/gists{/gist_id}","starred_url":"https://api.github.com/users/tbrooks8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbrooks8/subscriptions","organizations_url":"https://api.github.com/users/tbrooks8/orgs","repos_url":"https://api.github.com/users/tbrooks8/repos","events_url":"https://api.github.com/users/tbrooks8/events{/privacy}","received_events_url":"https://api.github.com/users/tbrooks8/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tbrooks8/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/tbrooks8/elasticsearch","forks_url":"https://api.github.com/repos/tbrooks8/elasticsearch/forks","keys_url":"https://api.github.com/repos/tbrooks8/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tbrooks8/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tbrooks8/elasticsearch/teams","hooks_url":"https://api.github.com/repos/tbrooks8/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/tbrooks8/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/tbrooks8/elasticsearch/events","assignees_url":"https://api.github.com/repos/tbrooks8/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/tbrooks8/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/tbrooks8/elasticsearch/tags","blobs_url":"https://api.github.com/repos/tbrooks8/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tbrooks8/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tbrooks8/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/tbrooks8/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tbrooks8/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/tbrooks8/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/tbrooks8/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/tbrooks8/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/tbrooks8/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/tbrooks8/elasticsearch/subscription","commits_url":"https://api.github.com/repos/tbrooks8/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/tbrooks8/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/tbrooks8/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/tbrooks8/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/tbrooks8/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/tbrooks8/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tbrooks8/elasticsearch/merges","archive_url":"https://api.github.com/repos/tbrooks8/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tbrooks8/elasticsearch/downloads","issues_url":"https://api.github.com/repos/tbrooks8/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/tbrooks8/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/tbrooks8/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/tbrooks8/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tbrooks8/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/tbrooks8/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/tbrooks8/elasticsearch/deployments","created_at":"2016-08-29T03:03:10Z","updated_at":"2018-06-04T16:34:38Z","pushed_at":"2018-06-05T21:27:27Z","git_url":"git://github.com/tbrooks8/elasticsearch.git","ssh_url":"git@github.com:tbrooks8/elasticsearch.git","clone_url":"https://github.com/tbrooks8/elasticsearch.git","svn_url":"https://github.com/tbrooks8/elasticsearch","homepage":"https://www.elastic.co/products/elasticsearch","size":469759,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"elastic:master","ref":"master","sha":"a1c9def64ecd09afc80c181b65150375ad8fa23b","user":{"login":"elastic","id":6764390,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY3NjQzOTA=","avatar_url":"https://avatars0.githubusercontent.com/u/6764390?v=4","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"repo":{"id":507775,"node_id":"MDEwOlJlcG9zaXRvcnk1MDc3NzU=","name":"elasticsearch","full_name":"elastic/elasticsearch","owner":{"login":"elastic","id":6764390,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY3NjQzOTA=","avatar_url":"https://avatars0.githubusercontent.com/u/6764390?v=4","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elastic/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":false,"url":"https://api.github.com/repos/elastic/elasticsearch","forks_url":"https://api.github.com/repos/elastic/elasticsearch/forks","keys_url":"https://api.github.com/repos/elastic/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elastic/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elastic/elasticsearch/teams","hooks_url":"https://api.github.com/repos/elastic/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/elastic/elasticsearch/events","assignees_url":"https://api.github.com/repos/elastic/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/elastic/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/elastic/elasticsearch/tags","blobs_url":"https://api.github.com/repos/elastic/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elastic/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elastic/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/elastic/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/elastic/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/elastic/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/elastic/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/elastic/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/elastic/elasticsearch/subscription","commits_url":"https://api.github.com/repos/elastic/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/elastic/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/elastic/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/elastic/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elastic/elasticsearch/merges","archive_url":"https://api.github.com/repos/elastic/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elastic/elasticsearch/downloads","issues_url":"https://api.github.com/repos/elastic/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/elastic/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/elastic/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/elastic/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elastic/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/elastic/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/elastic/elasticsearch/deployments","created_at":"2010-02-08T13:20:56Z","updated_at":"2018-06-06T12:56:58Z","pushed_at":"2018-06-06T13:44:51Z","git_url":"git://github.com/elastic/elasticsearch.git","ssh_url":"git@github.com:elastic/elasticsearch.git","clone_url":"https://github.com/elastic/elasticsearch.git","svn_url":"https://github.com/elastic/elasticsearch","homepage":"https://www.elastic.co/products/elasticsearch","size":484841,"stargazers_count":31518,"watchers_count":31518,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":10867,"mirror_url":null,"archived":false,"open_issues_count":1473,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":10867,"open_issues":1473,"watchers":31518,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/31115"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/31115"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/31115"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/31115/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/31115/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/31115/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/bc08583a1c07bf066501b5cb3ffae16fa0f873ba"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"s1monw"}}