{"action":"created","comment":{"url":"https://api.github.com/repos/datastax/java-driver/pulls/comments/84092161","pull_request_review_id":4882135,"id":84092161,"diff_hunk":"@@ -0,0 +1,143 @@\n+/*\n+ *      Copyright (C) 2012-2015 DataStax Inc.\n+ *\n+ *   Licensed under the Apache License, Version 2.0 (the \"License\");\n+ *   you may not use this file except in compliance with the License.\n+ *   You may obtain a 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\n+ *   distributed under the License is distributed on an \"AS IS\" BASIS,\n+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ *   See the License for the specific language governing permissions and\n+ *   limitations under the License.\n+ */\n+package com.datastax.driver.core;\n+\n+import com.google.common.util.concurrent.ThreadFactoryBuilder;\n+import io.netty.util.concurrent.DefaultThreadFactory;\n+\n+import java.util.concurrent.*;\n+\n+/**\n+ * A set of hooks that allow clients to customize the driver's internal executors.\n+ * <p/>\n+ * The methods in this class are invoked when the cluster initializes. To customize the behavior, extend the class and\n+ * override the appropriate methods.\n+ * <p/>\n+ * This is mainly intended to allow customization and instrumentation of driver threads. Keep the executors separate, as\n+ * using a common one could introduce unintended consequences like deadlocks (we're working to simplify the driver's\n+ * architecture and reduce the number of executors in a future release). The default implementations use unbounded\n+ * queues, which is appropriate when the driver is properly configured; the only reason you would want to use bounded\n+ * queues is to limit memory consumption in case of a bug or bad configuration. In that case, make sure to use a\n+ * {@link RejectedExecutionHandler} that throws, such as {@link java.util.concurrent.ThreadPoolExecutor.AbortPolicy}; a\n+ * blocking handler could introduce deadlocks.\n+ * <p/>\n+ * Netty uses a separate pool for I/O operations, that can be configured via {@link NettyOptions}.\n+ */\n+public class ThreadingOptions {\n+    // Kept for backward compatibility, but this should be customized via this class now\n+    private static final int NON_BLOCKING_EXECUTOR_SIZE = SystemProperties.getInt(\n+            \"com.datastax.driver.NON_BLOCKING_EXECUTOR_SIZE\", Runtime.getRuntime().availableProcessors());\n+    private static final int DEFAULT_THREAD_KEEP_ALIVE_SECONDS = 30;\n+\n+    /**\n+     * Builds a thread factory for the threads created by a given executor.\n+     * <p/>\n+     * This is used by the default implementations in this class, and also internally to create the Netty I/O pool.\n+     *\n+     * @param clusterName  the name of the cluster, as specified by\n+     *                     {@link com.datastax.driver.core.Cluster.Builder#withClusterName(String)}.\n+     * @param executorName a name that identifies the executor.\n+     * @return the thread factory.\n+     */\n+    public ThreadFactory threadFactory(String clusterName, String executorName) {\n+        return new ThreadFactoryBuilder()\n+                .setNameFormat(clusterName + \"-\" + executorName + \"-%d\")\n+                // Back with Netty's thread factory in order to create FastThreadLocalThread instances. This allows\n+                // an optimization around ThreadLocals (we could use DefaultThreadFactory directly but it creates\n+                // slightly different thread names, so keep we keep a ThreadFactoryBuilder wrapper for backward\n+                // compatibility).\n+                .setThreadFactory(new DefaultThreadFactory(\"ignored name\"))\n+                .build();\n+    }\n+\n+    /**\n+     * Builds the generic administration executor, used for tasks such as triggering registered\n+     * {@link SchemaChangeListener}s, reacting to node state changes, and metadata updates.\n+     * <p/>\n+     * The default implementation sets the pool size to the number of available cores.\n+     *\n+     * @param clusterName the name of the cluster, as specified by\n+     *                    {@link com.datastax.driver.core.Cluster.Builder#withClusterName(String)}.\n+     * @return the executor.\n+     */\n+    public ThreadPoolExecutor executor(String clusterName) {\n+        ThreadPoolExecutor executor = new ThreadPoolExecutor(\n+                NON_BLOCKING_EXECUTOR_SIZE, NON_BLOCKING_EXECUTOR_SIZE,\n+                DEFAULT_THREAD_KEEP_ALIVE_SECONDS, TimeUnit.SECONDS,\n+                new LinkedBlockingQueue<Runnable>(),\n+                threadFactory(clusterName, \"worker\"));\n+        executor.allowCoreThreadTimeOut(true);\n+        return executor;\n+    }\n+\n+    /**\n+     * Builds the executor used to block on new connections before they are added to a pool.\n+     * <p/>\n+     * The default implementation uses 2 threads.\n+     *\n+     * @param clusterName the name of the cluster, as specified by\n+     *                    {@link com.datastax.driver.core.Cluster.Builder#withClusterName(String)}.\n+     * @return the executor.\n+     */\n+    public ThreadPoolExecutor blockingExecutor(String clusterName) {","path":"driver-core/src/main/java/com/datastax/driver/core/ThreadingOptions.java","position":95,"original_position":95,"commit_id":"d561d1f5a5bc06084d684d03418eca1d57e8a719","original_commit_id":"d561d1f5a5bc06084d684d03418eca1d57e8a719","user":{"login":"adutra","id":463876,"avatar_url":"https://avatars.githubusercontent.com/u/463876?v=3","gravatar_id":"","url":"https://api.github.com/users/adutra","html_url":"https://github.com/adutra","followers_url":"https://api.github.com/users/adutra/followers","following_url":"https://api.github.com/users/adutra/following{/other_user}","gists_url":"https://api.github.com/users/adutra/gists{/gist_id}","starred_url":"https://api.github.com/users/adutra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adutra/subscriptions","organizations_url":"https://api.github.com/users/adutra/orgs","repos_url":"https://api.github.com/users/adutra/repos","events_url":"https://api.github.com/users/adutra/events{/privacy}","received_events_url":"https://api.github.com/users/adutra/received_events","type":"User","site_admin":false},"body":"Same here, the name is a bit vague, why not `connectionCreationExecutor`?","created_at":"2016-10-19T15:06:35Z","updated_at":"2016-10-19T15:11:04Z","html_url":"https://github.com/datastax/java-driver/pull/760#discussion_r84092161","pull_request_url":"https://api.github.com/repos/datastax/java-driver/pulls/760","_links":{"self":{"href":"https://api.github.com/repos/datastax/java-driver/pulls/comments/84092161"},"html":{"href":"https://github.com/datastax/java-driver/pull/760#discussion_r84092161"},"pull_request":{"href":"https://api.github.com/repos/datastax/java-driver/pulls/760"}}},"pull_request":{"url":"https://api.github.com/repos/datastax/java-driver/pulls/760","id":89911836,"html_url":"https://github.com/datastax/java-driver/pull/760","diff_url":"https://github.com/datastax/java-driver/pull/760.diff","patch_url":"https://github.com/datastax/java-driver/pull/760.patch","issue_url":"https://api.github.com/repos/datastax/java-driver/issues/760","number":760,"state":"open","locked":false,"title":"JAVA-262: Make internal executors customizable","user":{"login":"olim7t","id":259423,"avatar_url":"https://avatars.githubusercontent.com/u/259423?v=3","gravatar_id":"","url":"https://api.github.com/users/olim7t","html_url":"https://github.com/olim7t","followers_url":"https://api.github.com/users/olim7t/followers","following_url":"https://api.github.com/users/olim7t/following{/other_user}","gists_url":"https://api.github.com/users/olim7t/gists{/gist_id}","starred_url":"https://api.github.com/users/olim7t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olim7t/subscriptions","organizations_url":"https://api.github.com/users/olim7t/orgs","repos_url":"https://api.github.com/users/olim7t/repos","events_url":"https://api.github.com/users/olim7t/events{/privacy}","received_events_url":"https://api.github.com/users/olim7t/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-18T22:38:09Z","updated_at":"2016-10-19T15:11:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ccc92dd22f86685c6800bca140645f0dfefc7876","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/datastax/java-driver/milestones/21","html_url":"https://github.com/datastax/java-driver/milestones/3.0.5","labels_url":"https://api.github.com/repos/datastax/java-driver/milestones/21/labels","id":2065061,"number":21,"title":"3.0.5","description":null,"creator":{"login":"adutra","id":463876,"avatar_url":"https://avatars.githubusercontent.com/u/463876?v=3","gravatar_id":"","url":"https://api.github.com/users/adutra","html_url":"https://github.com/adutra","followers_url":"https://api.github.com/users/adutra/followers","following_url":"https://api.github.com/users/adutra/following{/other_user}","gists_url":"https://api.github.com/users/adutra/gists{/gist_id}","starred_url":"https://api.github.com/users/adutra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adutra/subscriptions","organizations_url":"https://api.github.com/users/adutra/orgs","repos_url":"https://api.github.com/users/adutra/repos","events_url":"https://api.github.com/users/adutra/events{/privacy}","received_events_url":"https://api.github.com/users/adutra/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":0,"state":"open","created_at":"2016-10-12T14:29:03Z","updated_at":"2016-10-18T22:47:24Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/datastax/java-driver/pulls/760/commits","review_comments_url":"https://api.github.com/repos/datastax/java-driver/pulls/760/comments","review_comment_url":"https://api.github.com/repos/datastax/java-driver/pulls/comments{/number}","comments_url":"https://api.github.com/repos/datastax/java-driver/issues/760/comments","statuses_url":"https://api.github.com/repos/datastax/java-driver/statuses/d561d1f5a5bc06084d684d03418eca1d57e8a719","head":{"label":"datastax:java262","ref":"java262","sha":"d561d1f5a5bc06084d684d03418eca1d57e8a719","user":{"login":"datastax","id":573369,"avatar_url":"https://avatars.githubusercontent.com/u/573369?v=3","gravatar_id":"","url":"https://api.github.com/users/datastax","html_url":"https://github.com/datastax","followers_url":"https://api.github.com/users/datastax/followers","following_url":"https://api.github.com/users/datastax/following{/other_user}","gists_url":"https://api.github.com/users/datastax/gists{/gist_id}","starred_url":"https://api.github.com/users/datastax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/datastax/subscriptions","organizations_url":"https://api.github.com/users/datastax/orgs","repos_url":"https://api.github.com/users/datastax/repos","events_url":"https://api.github.com/users/datastax/events{/privacy}","received_events_url":"https://api.github.com/users/datastax/received_events","type":"Organization","site_admin":false},"repo":{"id":6765281,"name":"java-driver","full_name":"datastax/java-driver","owner":{"login":"datastax","id":573369,"avatar_url":"https://avatars.githubusercontent.com/u/573369?v=3","gravatar_id":"","url":"https://api.github.com/users/datastax","html_url":"https://github.com/datastax","followers_url":"https://api.github.com/users/datastax/followers","following_url":"https://api.github.com/users/datastax/following{/other_user}","gists_url":"https://api.github.com/users/datastax/gists{/gist_id}","starred_url":"https://api.github.com/users/datastax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/datastax/subscriptions","organizations_url":"https://api.github.com/users/datastax/orgs","repos_url":"https://api.github.com/users/datastax/repos","events_url":"https://api.github.com/users/datastax/events{/privacy}","received_events_url":"https://api.github.com/users/datastax/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/datastax/java-driver","description":"DataStax Java Driver for Apache Cassandra","fork":false,"url":"https://api.github.com/repos/datastax/java-driver","forks_url":"https://api.github.com/repos/datastax/java-driver/forks","keys_url":"https://api.github.com/repos/datastax/java-driver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/datastax/java-driver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/datastax/java-driver/teams","hooks_url":"https://api.github.com/repos/datastax/java-driver/hooks","issue_events_url":"https://api.github.com/repos/datastax/java-driver/issues/events{/number}","events_url":"https://api.github.com/repos/datastax/java-driver/events","assignees_url":"https://api.github.com/repos/datastax/java-driver/assignees{/user}","branches_url":"https://api.github.com/repos/datastax/java-driver/branches{/branch}","tags_url":"https://api.github.com/repos/datastax/java-driver/tags","blobs_url":"https://api.github.com/repos/datastax/java-driver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/datastax/java-driver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/datastax/java-driver/git/refs{/sha}","trees_url":"https://api.github.com/repos/datastax/java-driver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/datastax/java-driver/statuses/{sha}","languages_url":"https://api.github.com/repos/datastax/java-driver/languages","stargazers_url":"https://api.github.com/repos/datastax/java-driver/stargazers","contributors_url":"https://api.github.com/repos/datastax/java-driver/contributors","subscribers_url":"https://api.github.com/repos/datastax/java-driver/subscribers","subscription_url":"https://api.github.com/repos/datastax/java-driver/subscription","commits_url":"https://api.github.com/repos/datastax/java-driver/commits{/sha}","git_commits_url":"https://api.github.com/repos/datastax/java-driver/git/commits{/sha}","comments_url":"https://api.github.com/repos/datastax/java-driver/comments{/number}","issue_comment_url":"https://api.github.com/repos/datastax/java-driver/issues/comments{/number}","contents_url":"https://api.github.com/repos/datastax/java-driver/contents/{+path}","compare_url":"https://api.github.com/repos/datastax/java-driver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/datastax/java-driver/merges","archive_url":"https://api.github.com/repos/datastax/java-driver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/datastax/java-driver/downloads","issues_url":"https://api.github.com/repos/datastax/java-driver/issues{/number}","pulls_url":"https://api.github.com/repos/datastax/java-driver/pulls{/number}","milestones_url":"https://api.github.com/repos/datastax/java-driver/milestones{/number}","notifications_url":"https://api.github.com/repos/datastax/java-driver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/datastax/java-driver/labels{/name}","releases_url":"https://api.github.com/repos/datastax/java-driver/releases{/id}","deployments_url":"https://api.github.com/repos/datastax/java-driver/deployments","created_at":"2012-11-19T18:44:41Z","updated_at":"2016-10-15T02:34:30Z","pushed_at":"2016-10-18T22:47:24Z","git_url":"git://github.com/datastax/java-driver.git","ssh_url":"git@github.com:datastax/java-driver.git","clone_url":"https://github.com/datastax/java-driver.git","svn_url":"https://github.com/datastax/java-driver","homepage":null,"size":34201,"stargazers_count":702,"watchers_count":702,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":514,"mirror_url":null,"open_issues_count":30,"forks":514,"open_issues":30,"watchers":702,"default_branch":"3.x"}},"base":{"label":"datastax:3.0.x","ref":"3.0.x","sha":"73522da7f3fa5748659b9423c5c6c63418cb70f9","user":{"login":"datastax","id":573369,"avatar_url":"https://avatars.githubusercontent.com/u/573369?v=3","gravatar_id":"","url":"https://api.github.com/users/datastax","html_url":"https://github.com/datastax","followers_url":"https://api.github.com/users/datastax/followers","following_url":"https://api.github.com/users/datastax/following{/other_user}","gists_url":"https://api.github.com/users/datastax/gists{/gist_id}","starred_url":"https://api.github.com/users/datastax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/datastax/subscriptions","organizations_url":"https://api.github.com/users/datastax/orgs","repos_url":"https://api.github.com/users/datastax/repos","events_url":"https://api.github.com/users/datastax/events{/privacy}","received_events_url":"https://api.github.com/users/datastax/received_events","type":"Organization","site_admin":false},"repo":{"id":6765281,"name":"java-driver","full_name":"datastax/java-driver","owner":{"login":"datastax","id":573369,"avatar_url":"https://avatars.githubusercontent.com/u/573369?v=3","gravatar_id":"","url":"https://api.github.com/users/datastax","html_url":"https://github.com/datastax","followers_url":"https://api.github.com/users/datastax/followers","following_url":"https://api.github.com/users/datastax/following{/other_user}","gists_url":"https://api.github.com/users/datastax/gists{/gist_id}","starred_url":"https://api.github.com/users/datastax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/datastax/subscriptions","organizations_url":"https://api.github.com/users/datastax/orgs","repos_url":"https://api.github.com/users/datastax/repos","events_url":"https://api.github.com/users/datastax/events{/privacy}","received_events_url":"https://api.github.com/users/datastax/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/datastax/java-driver","description":"DataStax Java Driver for Apache Cassandra","fork":false,"url":"https://api.github.com/repos/datastax/java-driver","forks_url":"https://api.github.com/repos/datastax/java-driver/forks","keys_url":"https://api.github.com/repos/datastax/java-driver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/datastax/java-driver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/datastax/java-driver/teams","hooks_url":"https://api.github.com/repos/datastax/java-driver/hooks","issue_events_url":"https://api.github.com/repos/datastax/java-driver/issues/events{/number}","events_url":"https://api.github.com/repos/datastax/java-driver/events","assignees_url":"https://api.github.com/repos/datastax/java-driver/assignees{/user}","branches_url":"https://api.github.com/repos/datastax/java-driver/branches{/branch}","tags_url":"https://api.github.com/repos/datastax/java-driver/tags","blobs_url":"https://api.github.com/repos/datastax/java-driver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/datastax/java-driver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/datastax/java-driver/git/refs{/sha}","trees_url":"https://api.github.com/repos/datastax/java-driver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/datastax/java-driver/statuses/{sha}","languages_url":"https://api.github.com/repos/datastax/java-driver/languages","stargazers_url":"https://api.github.com/repos/datastax/java-driver/stargazers","contributors_url":"https://api.github.com/repos/datastax/java-driver/contributors","subscribers_url":"https://api.github.com/repos/datastax/java-driver/subscribers","subscription_url":"https://api.github.com/repos/datastax/java-driver/subscription","commits_url":"https://api.github.com/repos/datastax/java-driver/commits{/sha}","git_commits_url":"https://api.github.com/repos/datastax/java-driver/git/commits{/sha}","comments_url":"https://api.github.com/repos/datastax/java-driver/comments{/number}","issue_comment_url":"https://api.github.com/repos/datastax/java-driver/issues/comments{/number}","contents_url":"https://api.github.com/repos/datastax/java-driver/contents/{+path}","compare_url":"https://api.github.com/repos/datastax/java-driver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/datastax/java-driver/merges","archive_url":"https://api.github.com/repos/datastax/java-driver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/datastax/java-driver/downloads","issues_url":"https://api.github.com/repos/datastax/java-driver/issues{/number}","pulls_url":"https://api.github.com/repos/datastax/java-driver/pulls{/number}","milestones_url":"https://api.github.com/repos/datastax/java-driver/milestones{/number}","notifications_url":"https://api.github.com/repos/datastax/java-driver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/datastax/java-driver/labels{/name}","releases_url":"https://api.github.com/repos/datastax/java-driver/releases{/id}","deployments_url":"https://api.github.com/repos/datastax/java-driver/deployments","created_at":"2012-11-19T18:44:41Z","updated_at":"2016-10-15T02:34:30Z","pushed_at":"2016-10-18T22:47:24Z","git_url":"git://github.com/datastax/java-driver.git","ssh_url":"git@github.com:datastax/java-driver.git","clone_url":"https://github.com/datastax/java-driver.git","svn_url":"https://github.com/datastax/java-driver","homepage":null,"size":34201,"stargazers_count":702,"watchers_count":702,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":514,"mirror_url":null,"open_issues_count":30,"forks":514,"open_issues":30,"watchers":702,"default_branch":"3.x"}},"_links":{"self":{"href":"https://api.github.com/repos/datastax/java-driver/pulls/760"},"html":{"href":"https://github.com/datastax/java-driver/pull/760"},"issue":{"href":"https://api.github.com/repos/datastax/java-driver/issues/760"},"comments":{"href":"https://api.github.com/repos/datastax/java-driver/issues/760/comments"},"review_comments":{"href":"https://api.github.com/repos/datastax/java-driver/pulls/760/comments"},"review_comment":{"href":"https://api.github.com/repos/datastax/java-driver/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/datastax/java-driver/pulls/760/commits"},"statuses":{"href":"https://api.github.com/repos/datastax/java-driver/statuses/d561d1f5a5bc06084d684d03418eca1d57e8a719"}}}}
{"actor":{"display_login":"adutra"}}