{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/27416484","id":27416484,"diff_hunk":"@@ -168,7 +168,20 @@ public static boolean awaitBusy(Predicate<?> breakPredicate) throws InterruptedE\n     }\n \n     public static boolean awaitBusy(Predicate<?> breakPredicate, long maxWaitTime, TimeUnit unit) throws InterruptedException {\n+        return awaitBusy(breakPredicate, maxWaitTime, 0, unit);\n+    }\n+\n+    /**\n+     * Repeat a task until it returns true or after a given wait time.\n+     * By default, it will increase by 2 the sleep time between two runs\n+     * @param breakPredicate test you want to run\n+     * @param maxWaitTime maximum time you want to wait\n+     * @param maxSleepTime if >0 maximum sleep time before two runs\n+     * @param unit time unit used for maxWaitTime and maxSleepTime\n+     */\n+    public static boolean awaitBusy(Predicate<?> breakPredicate, long maxWaitTime, long maxSleepTime, TimeUnit unit) throws InterruptedException {","path":"src/test/java/org/elasticsearch/test/ElasticsearchTestCase.java","position":15,"original_position":15,"commit_id":"83df29466203200bf98f3e3f7c5bce758101572d","original_commit_id":"83df29466203200bf98f3e3f7c5bce758101572d","user":{"login":"jpountz","id":299848,"avatar_url":"https://avatars.githubusercontent.com/u/299848?v=3","gravatar_id":"","url":"https://api.github.com/users/jpountz","html_url":"https://github.com/jpountz","followers_url":"https://api.github.com/users/jpountz/followers","following_url":"https://api.github.com/users/jpountz/following{/other_user}","gists_url":"https://api.github.com/users/jpountz/gists{/gist_id}","starred_url":"https://api.github.com/users/jpountz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpountz/subscriptions","organizations_url":"https://api.github.com/users/jpountz/orgs","repos_url":"https://api.github.com/users/jpountz/repos","events_url":"https://api.github.com/users/jpountz/events{/privacy}","received_events_url":"https://api.github.com/users/jpountz/received_events","type":"User","site_admin":false},"body":"I think I would just hardcode the parameter to a reasonable value (eg. 1s) instead of making the API more complex with a new parameter?","created_at":"2015-03-30T18:12:56Z","updated_at":"2015-03-30T18:12:56Z","html_url":"https://github.com/elastic/elasticsearch/pull/10325#discussion_r27416484","pull_request_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/10325","_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/27416484"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/10325#discussion_r27416484"},"pull_request":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/10325"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/10325","id":32242594,"html_url":"https://github.com/elastic/elasticsearch/pull/10325","diff_url":"https://github.com/elastic/elasticsearch/pull/10325.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/10325.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/10325","number":10325,"state":"open","locked":false,"title":"[test] awaitBusy: add a ceiling to max sleep time","user":{"login":"dadoonet","id":274222,"avatar_url":"https://avatars.githubusercontent.com/u/274222?v=3","gravatar_id":"","url":"https://api.github.com/users/dadoonet","html_url":"https://github.com/dadoonet","followers_url":"https://api.github.com/users/dadoonet/followers","following_url":"https://api.github.com/users/dadoonet/following{/other_user}","gists_url":"https://api.github.com/users/dadoonet/gists{/gist_id}","starred_url":"https://api.github.com/users/dadoonet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dadoonet/subscriptions","organizations_url":"https://api.github.com/users/dadoonet/orgs","repos_url":"https://api.github.com/users/dadoonet/repos","events_url":"https://api.github.com/users/dadoonet/events{/privacy}","received_events_url":"https://api.github.com/users/dadoonet/received_events","type":"User","site_admin":false},"body":"When using `awaitBusy`, sometimes, you might not want to double time between two runs in an infinitive manner.\r\n\r\nFor example, let's say it will probably take 30 seconds to run a test.\r\nWhen doubling all the time, you will most likely wait for a bigger time than needed:\r\n\r\n|iteration|ms           |s            |duration (ms)|duration (s)|\r\n|-----------|-------------|-----------|-----------|-----------|\r\n|1|1|0,001|1|0,001|\r\n|2|2|0,002|3|0,003|\r\n|3|4|0,004|7|0,007|\r\n|4|8|0,008|15|0,015|\r\n|5|16|0,016|31|0,031|\r\n|6|32|0,032|63|0,063|\r\n|7|64|0,064|127|0,127|\r\n|8|128|0,128|255|0,255|\r\n|9|256|0,256|511|0,511|\r\n|10|512|0,512|1023|1,023|\r\n|11|1024|1,024|2047|2,047|\r\n|12|2048|2,048|4095|4,095|\r\n|13|4096|4,096|8191|8,191|\r\n|14|8192|8,192|16383|16,383|\r\n|15|16384|16,384|32767|32,767|\r\n|16|32768|32,768|65535|65,535|\r\n|17|65536|65,536|131071|131,071|\r\n|18|131072|131,072|262143|262,143|\r\n|19|262144|262,144|524287|524,287|\r\n|20|524288|524,288|1048575|1048,575|\r\n|21|1048576|1048,576|2097151|2097,151|\r\n\r\nFor example here, if the task is successful after 35 seconds, we will most likely have to wait for 32s more before the Predicate is run again.\r\n\r\nWith ths patch, developers can define a maximum sleep time, so in the previous example, if we define `maxSleepTime` to `10` seconds, then the test will end after 36s.\r\n\r\nNew sleep table will be:\r\n\r\n|iteration|ms           |s            |duration (ms)|duration (s)|\r\n|-----------|-------------|-----------|-----------|-----------|\r\n|1|1|0,001|1|0,001|\r\n|2|2|0,002|3|0,003|\r\n|3|4|0,004|7|0,007|\r\n|4|8|0,008|15|0,015|\r\n|5|16|0,016|31|0,031|\r\n|6|32|0,032|63|0,063|\r\n|7|64|0,064|127|0,127|\r\n|8|128|0,128|255|0,255|\r\n|9|256|0,256|511|0,511|\r\n|10|512|0,512|1023|1,023|\r\n|11|1024|1,024|2047|2,047|\r\n|12|2048|2,048|4095|4,095|\r\n|13|4096|4,096|8191|8,191|\r\n|14|8192|8,192|16383|16,383|\r\n|15|10000|10|26383|26,383|\r\n|16|10000|10|36383|36,383|\r\n|17|10000|10|46383|46,383|\r\n|18|10000|10|56383|56,383|\r\n|19|10000|10|66383|66,383|\r\n|20|10000|10|76383|76,383|\r\n|21|10000|10|86383|86,383|\r\n\r\nNote: this could be used in plugins as well such as rivers. We could also implement this method only there if no other one needs that method.","created_at":"2015-03-30T16:22:18Z","updated_at":"2015-03-30T18:12:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2eb55127cc9802662649ae734705913193d709ef","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/10325/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/10325/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/10325/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/83df29466203200bf98f3e3f7c5bce758101572d","head":{"label":"dadoonet:pr/test-add-awaitbusy-ceiling","ref":"pr/test-add-awaitbusy-ceiling","sha":"83df29466203200bf98f3e3f7c5bce758101572d","user":{"login":"dadoonet","id":274222,"avatar_url":"https://avatars.githubusercontent.com/u/274222?v=3","gravatar_id":"","url":"https://api.github.com/users/dadoonet","html_url":"https://github.com/dadoonet","followers_url":"https://api.github.com/users/dadoonet/followers","following_url":"https://api.github.com/users/dadoonet/following{/other_user}","gists_url":"https://api.github.com/users/dadoonet/gists{/gist_id}","starred_url":"https://api.github.com/users/dadoonet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dadoonet/subscriptions","organizations_url":"https://api.github.com/users/dadoonet/orgs","repos_url":"https://api.github.com/users/dadoonet/repos","events_url":"https://api.github.com/users/dadoonet/events{/privacy}","received_events_url":"https://api.github.com/users/dadoonet/received_events","type":"User","site_admin":false},"repo":{"id":2521491,"name":"elasticsearch","full_name":"dadoonet/elasticsearch","owner":{"login":"dadoonet","id":274222,"avatar_url":"https://avatars.githubusercontent.com/u/274222?v=3","gravatar_id":"","url":"https://api.github.com/users/dadoonet","html_url":"https://github.com/dadoonet","followers_url":"https://api.github.com/users/dadoonet/followers","following_url":"https://api.github.com/users/dadoonet/following{/other_user}","gists_url":"https://api.github.com/users/dadoonet/gists{/gist_id}","starred_url":"https://api.github.com/users/dadoonet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dadoonet/subscriptions","organizations_url":"https://api.github.com/users/dadoonet/orgs","repos_url":"https://api.github.com/users/dadoonet/repos","events_url":"https://api.github.com/users/dadoonet/events{/privacy}","received_events_url":"https://api.github.com/users/dadoonet/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dadoonet/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/dadoonet/elasticsearch","forks_url":"https://api.github.com/repos/dadoonet/elasticsearch/forks","keys_url":"https://api.github.com/repos/dadoonet/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dadoonet/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dadoonet/elasticsearch/teams","hooks_url":"https://api.github.com/repos/dadoonet/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/dadoonet/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/dadoonet/elasticsearch/events","assignees_url":"https://api.github.com/repos/dadoonet/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/dadoonet/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/dadoonet/elasticsearch/tags","blobs_url":"https://api.github.com/repos/dadoonet/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dadoonet/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dadoonet/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/dadoonet/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dadoonet/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/dadoonet/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/dadoonet/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/dadoonet/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/dadoonet/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/dadoonet/elasticsearch/subscription","commits_url":"https://api.github.com/repos/dadoonet/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/dadoonet/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/dadoonet/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/dadoonet/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/dadoonet/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/dadoonet/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dadoonet/elasticsearch/merges","archive_url":"https://api.github.com/repos/dadoonet/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dadoonet/elasticsearch/downloads","issues_url":"https://api.github.com/repos/dadoonet/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/dadoonet/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/dadoonet/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/dadoonet/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dadoonet/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/dadoonet/elasticsearch/releases{/id}","created_at":"2011-10-05T19:24:28Z","updated_at":"2015-03-10T00:44:50Z","pushed_at":"2015-03-30T16:13:04Z","git_url":"git://github.com/dadoonet/elasticsearch.git","ssh_url":"git@github.com:dadoonet/elasticsearch.git","clone_url":"https://github.com/dadoonet/elasticsearch.git","svn_url":"https://github.com/dadoonet/elasticsearch","homepage":"http://elasticsearch.org","size":92780,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"elastic:master","ref":"master","sha":"77418ecdbd5eecf20acedfce59995bd25034c716","user":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","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,"name":"elasticsearch","full_name":"elastic/elasticsearch","owner":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","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}","created_at":"2010-02-08T13:20:56Z","updated_at":"2015-03-30T17:14:46Z","pushed_at":"2015-03-30T18:05:26Z","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":"http://elasticsearch.org","size":312813,"stargazers_count":10552,"watchers_count":10552,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3275,"mirror_url":null,"open_issues_count":1069,"forks":3275,"open_issues":1069,"watchers":10552,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/10325"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/10325"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/10325"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/10325/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/10325/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/10325/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/83df29466203200bf98f3e3f7c5bce758101572d"}}}}