{"action":"created","comment":{"url":"https://api.github.com/repos/crate/crate/pulls/comments/28682061","id":28682061,"diff_hunk":"@@ -0,0 +1,87 @@\n+/*\n+ * Licensed to CRATE Technology GmbH (\"Crate\") under one or more contributor\n+ * license agreements.  See the NOTICE file distributed with this work for\n+ * additional information regarding copyright ownership.  Crate licenses\n+ * this file to you under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.  You may\n+ * 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, WITHOUT\n+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the\n+ * License for the specific language governing permissions and limitations\n+ * under the License.\n+ *\n+ * However, if you have executed another commercial license agreement\n+ * with Crate these terms will supersede the license and you may use the\n+ * software solely pursuant to the terms of the relevant commercial agreement.\n+ */\n+\n+package io.crate.concurrent;\n+\n+import org.elasticsearch.common.settings.ImmutableSettings;\n+import org.elasticsearch.common.util.concurrent.EsExecutors;\n+import org.junit.runner.Description;\n+import org.junit.runners.model.Statement;\n+\n+import java.util.concurrent.*;\n+\n+public class ThreadedStatement extends Statement {\n+\n+    private final Statement statement;\n+    private final int count;\n+\n+    public ThreadedStatement(Statement base, Description description) {\n+        this.statement = base;\n+\n+        Threaded threaded = description.getAnnotation(Threaded.class);\n+        count = threaded != null ? threaded.count() : 0;\n+\n+    }\n+\n+    @Override\n+    public void evaluate() throws Throwable {\n+        if (count <= 0) {\n+            statement.evaluate();\n+        } else {\n+            final CountDownLatch startLatch = new CountDownLatch(count);\n+            ExecutorService service = Executors.newFixedThreadPool(count, EsExecutors.daemonThreadFactory(ImmutableSettings.EMPTY, \"Threaded\"));\n+            ExecutorCompletionService<Void> completionService = new ExecutorCompletionService<>(service);\n+            try {\n+                for (int i = 0; i < count; i++) {\n+                    completionService.submit(new Runnable() {\n+                        @Override\n+                        public void run() {\n+                            try {\n+                                startLatch.await(); // all threads wait for each other","path":"stresstest/src/test/java/io/crate/concurrent/ThreadedStatement.java","position":58,"original_position":58,"commit_id":"95940b2f7c2a3c5e7aebd0a9c7663be2a9fe7d4c","original_commit_id":"95940b2f7c2a3c5e7aebd0a9c7663be2a9fe7d4c","user":{"login":"mfelsche","id":1152667,"avatar_url":"https://avatars.githubusercontent.com/u/1152667?v=3","gravatar_id":"","url":"https://api.github.com/users/mfelsche","html_url":"https://github.com/mfelsche","followers_url":"https://api.github.com/users/mfelsche/followers","following_url":"https://api.github.com/users/mfelsche/following{/other_user}","gists_url":"https://api.github.com/users/mfelsche/gists{/gist_id}","starred_url":"https://api.github.com/users/mfelsche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mfelsche/subscriptions","organizations_url":"https://api.github.com/users/mfelsche/orgs","repos_url":"https://api.github.com/users/mfelsche/repos","events_url":"https://api.github.com/users/mfelsche/events{/privacy}","received_events_url":"https://api.github.com/users/mfelsche/received_events","type":"User","site_admin":false},"body":"in order to increase the possibility that things actually happen concurrently","created_at":"2015-04-20T11:48:46Z","updated_at":"2015-04-20T11:48:46Z","html_url":"https://github.com/crate/crate/pull/1903#discussion_r28682061","pull_request_url":"https://api.github.com/repos/crate/crate/pulls/1903","_links":{"self":{"href":"https://api.github.com/repos/crate/crate/pulls/comments/28682061"},"html":{"href":"https://github.com/crate/crate/pull/1903#discussion_r28682061"},"pull_request":{"href":"https://api.github.com/repos/crate/crate/pulls/1903"}}},"pull_request":{"url":"https://api.github.com/repos/crate/crate/pulls/1903","id":33556310,"html_url":"https://github.com/crate/crate/pull/1903","diff_url":"https://github.com/crate/crate/pull/1903.diff","patch_url":"https://github.com/crate/crate/pull/1903.patch","issue_url":"https://api.github.com/repos/crate/crate/issues/1903","number":1903,"state":"open","locked":false,"title":"move benchmarks to separate module 'stresstest'","user":{"login":"mfelsche","id":1152667,"avatar_url":"https://avatars.githubusercontent.com/u/1152667?v=3","gravatar_id":"","url":"https://api.github.com/users/mfelsche","html_url":"https://github.com/mfelsche","followers_url":"https://api.github.com/users/mfelsche/followers","following_url":"https://api.github.com/users/mfelsche/following{/other_user}","gists_url":"https://api.github.com/users/mfelsche/gists{/gist_id}","starred_url":"https://api.github.com/users/mfelsche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mfelsche/subscriptions","organizations_url":"https://api.github.com/users/mfelsche/orgs","repos_url":"https://api.github.com/users/mfelsche/repos","events_url":"https://api.github.com/users/mfelsche/events{/privacy}","received_events_url":"https://api.github.com/users/mfelsche/received_events","type":"User","site_admin":false},"body":"and created small framework for running tests concurrently","created_at":"2015-04-17T15:42:40Z","updated_at":"2015-04-20T11:48:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"986e4957d26740853fc64c66cb923cd914ae808a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/crate/crate/pulls/1903/commits","review_comments_url":"https://api.github.com/repos/crate/crate/pulls/1903/comments","review_comment_url":"https://api.github.com/repos/crate/crate/pulls/comments{/number}","comments_url":"https://api.github.com/repos/crate/crate/issues/1903/comments","statuses_url":"https://api.github.com/repos/crate/crate/statuses/95940b2f7c2a3c5e7aebd0a9c7663be2a9fe7d4c","head":{"label":"crate:m/stresstest","ref":"m/stresstest","sha":"95940b2f7c2a3c5e7aebd0a9c7663be2a9fe7d4c","user":{"login":"crate","id":4048232,"avatar_url":"https://avatars.githubusercontent.com/u/4048232?v=3","gravatar_id":"","url":"https://api.github.com/users/crate","html_url":"https://github.com/crate","followers_url":"https://api.github.com/users/crate/followers","following_url":"https://api.github.com/users/crate/following{/other_user}","gists_url":"https://api.github.com/users/crate/gists{/gist_id}","starred_url":"https://api.github.com/users/crate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crate/subscriptions","organizations_url":"https://api.github.com/users/crate/orgs","repos_url":"https://api.github.com/users/crate/repos","events_url":"https://api.github.com/users/crate/events{/privacy}","received_events_url":"https://api.github.com/users/crate/received_events","type":"Organization","site_admin":false},"repo":{"id":9342529,"name":"crate","full_name":"crate/crate","owner":{"login":"crate","id":4048232,"avatar_url":"https://avatars.githubusercontent.com/u/4048232?v=3","gravatar_id":"","url":"https://api.github.com/users/crate","html_url":"https://github.com/crate","followers_url":"https://api.github.com/users/crate/followers","following_url":"https://api.github.com/users/crate/following{/other_user}","gists_url":"https://api.github.com/users/crate/gists{/gist_id}","starred_url":"https://api.github.com/users/crate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crate/subscriptions","organizations_url":"https://api.github.com/users/crate/orgs","repos_url":"https://api.github.com/users/crate/repos","events_url":"https://api.github.com/users/crate/events{/privacy}","received_events_url":"https://api.github.com/users/crate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/crate/crate","description":"CRATE: Your Elastic Data Store","fork":false,"url":"https://api.github.com/repos/crate/crate","forks_url":"https://api.github.com/repos/crate/crate/forks","keys_url":"https://api.github.com/repos/crate/crate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crate/crate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crate/crate/teams","hooks_url":"https://api.github.com/repos/crate/crate/hooks","issue_events_url":"https://api.github.com/repos/crate/crate/issues/events{/number}","events_url":"https://api.github.com/repos/crate/crate/events","assignees_url":"https://api.github.com/repos/crate/crate/assignees{/user}","branches_url":"https://api.github.com/repos/crate/crate/branches{/branch}","tags_url":"https://api.github.com/repos/crate/crate/tags","blobs_url":"https://api.github.com/repos/crate/crate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crate/crate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crate/crate/git/refs{/sha}","trees_url":"https://api.github.com/repos/crate/crate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crate/crate/statuses/{sha}","languages_url":"https://api.github.com/repos/crate/crate/languages","stargazers_url":"https://api.github.com/repos/crate/crate/stargazers","contributors_url":"https://api.github.com/repos/crate/crate/contributors","subscribers_url":"https://api.github.com/repos/crate/crate/subscribers","subscription_url":"https://api.github.com/repos/crate/crate/subscription","commits_url":"https://api.github.com/repos/crate/crate/commits{/sha}","git_commits_url":"https://api.github.com/repos/crate/crate/git/commits{/sha}","comments_url":"https://api.github.com/repos/crate/crate/comments{/number}","issue_comment_url":"https://api.github.com/repos/crate/crate/issues/comments{/number}","contents_url":"https://api.github.com/repos/crate/crate/contents/{+path}","compare_url":"https://api.github.com/repos/crate/crate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crate/crate/merges","archive_url":"https://api.github.com/repos/crate/crate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crate/crate/downloads","issues_url":"https://api.github.com/repos/crate/crate/issues{/number}","pulls_url":"https://api.github.com/repos/crate/crate/pulls{/number}","milestones_url":"https://api.github.com/repos/crate/crate/milestones{/number}","notifications_url":"https://api.github.com/repos/crate/crate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crate/crate/labels{/name}","releases_url":"https://api.github.com/repos/crate/crate/releases{/id}","created_at":"2013-04-10T09:17:16Z","updated_at":"2015-04-20T02:36:06Z","pushed_at":"2015-04-20T11:37:49Z","git_url":"git://github.com/crate/crate.git","ssh_url":"git@github.com:crate/crate.git","clone_url":"https://github.com/crate/crate.git","svn_url":"https://github.com/crate/crate","homepage":"https://crate.io","size":100439,"stargazers_count":757,"watchers_count":757,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":75,"mirror_url":null,"open_issues_count":38,"forks":75,"open_issues":38,"watchers":757,"default_branch":"master"}},"base":{"label":"crate:master","ref":"master","sha":"0aa0484a5f4f6f4a9d9770401aed73c2c42c1865","user":{"login":"crate","id":4048232,"avatar_url":"https://avatars.githubusercontent.com/u/4048232?v=3","gravatar_id":"","url":"https://api.github.com/users/crate","html_url":"https://github.com/crate","followers_url":"https://api.github.com/users/crate/followers","following_url":"https://api.github.com/users/crate/following{/other_user}","gists_url":"https://api.github.com/users/crate/gists{/gist_id}","starred_url":"https://api.github.com/users/crate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crate/subscriptions","organizations_url":"https://api.github.com/users/crate/orgs","repos_url":"https://api.github.com/users/crate/repos","events_url":"https://api.github.com/users/crate/events{/privacy}","received_events_url":"https://api.github.com/users/crate/received_events","type":"Organization","site_admin":false},"repo":{"id":9342529,"name":"crate","full_name":"crate/crate","owner":{"login":"crate","id":4048232,"avatar_url":"https://avatars.githubusercontent.com/u/4048232?v=3","gravatar_id":"","url":"https://api.github.com/users/crate","html_url":"https://github.com/crate","followers_url":"https://api.github.com/users/crate/followers","following_url":"https://api.github.com/users/crate/following{/other_user}","gists_url":"https://api.github.com/users/crate/gists{/gist_id}","starred_url":"https://api.github.com/users/crate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crate/subscriptions","organizations_url":"https://api.github.com/users/crate/orgs","repos_url":"https://api.github.com/users/crate/repos","events_url":"https://api.github.com/users/crate/events{/privacy}","received_events_url":"https://api.github.com/users/crate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/crate/crate","description":"CRATE: Your Elastic Data Store","fork":false,"url":"https://api.github.com/repos/crate/crate","forks_url":"https://api.github.com/repos/crate/crate/forks","keys_url":"https://api.github.com/repos/crate/crate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crate/crate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crate/crate/teams","hooks_url":"https://api.github.com/repos/crate/crate/hooks","issue_events_url":"https://api.github.com/repos/crate/crate/issues/events{/number}","events_url":"https://api.github.com/repos/crate/crate/events","assignees_url":"https://api.github.com/repos/crate/crate/assignees{/user}","branches_url":"https://api.github.com/repos/crate/crate/branches{/branch}","tags_url":"https://api.github.com/repos/crate/crate/tags","blobs_url":"https://api.github.com/repos/crate/crate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crate/crate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crate/crate/git/refs{/sha}","trees_url":"https://api.github.com/repos/crate/crate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crate/crate/statuses/{sha}","languages_url":"https://api.github.com/repos/crate/crate/languages","stargazers_url":"https://api.github.com/repos/crate/crate/stargazers","contributors_url":"https://api.github.com/repos/crate/crate/contributors","subscribers_url":"https://api.github.com/repos/crate/crate/subscribers","subscription_url":"https://api.github.com/repos/crate/crate/subscription","commits_url":"https://api.github.com/repos/crate/crate/commits{/sha}","git_commits_url":"https://api.github.com/repos/crate/crate/git/commits{/sha}","comments_url":"https://api.github.com/repos/crate/crate/comments{/number}","issue_comment_url":"https://api.github.com/repos/crate/crate/issues/comments{/number}","contents_url":"https://api.github.com/repos/crate/crate/contents/{+path}","compare_url":"https://api.github.com/repos/crate/crate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crate/crate/merges","archive_url":"https://api.github.com/repos/crate/crate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crate/crate/downloads","issues_url":"https://api.github.com/repos/crate/crate/issues{/number}","pulls_url":"https://api.github.com/repos/crate/crate/pulls{/number}","milestones_url":"https://api.github.com/repos/crate/crate/milestones{/number}","notifications_url":"https://api.github.com/repos/crate/crate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crate/crate/labels{/name}","releases_url":"https://api.github.com/repos/crate/crate/releases{/id}","created_at":"2013-04-10T09:17:16Z","updated_at":"2015-04-20T02:36:06Z","pushed_at":"2015-04-20T11:37:49Z","git_url":"git://github.com/crate/crate.git","ssh_url":"git@github.com:crate/crate.git","clone_url":"https://github.com/crate/crate.git","svn_url":"https://github.com/crate/crate","homepage":"https://crate.io","size":100439,"stargazers_count":757,"watchers_count":757,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":75,"mirror_url":null,"open_issues_count":38,"forks":75,"open_issues":38,"watchers":757,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/crate/crate/pulls/1903"},"html":{"href":"https://github.com/crate/crate/pull/1903"},"issue":{"href":"https://api.github.com/repos/crate/crate/issues/1903"},"comments":{"href":"https://api.github.com/repos/crate/crate/issues/1903/comments"},"review_comments":{"href":"https://api.github.com/repos/crate/crate/pulls/1903/comments"},"review_comment":{"href":"https://api.github.com/repos/crate/crate/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/crate/crate/pulls/1903/commits"},"statuses":{"href":"https://api.github.com/repos/crate/crate/statuses/95940b2f7c2a3c5e7aebd0a9c7663be2a9fe7d4c"}}}}