{"action":"created","comment":{"url":"https://api.github.com/repos/druid-io/druid/pulls/comments/37902738","id":37902738,"diff_hunk":"@@ -206,306 +200,265 @@ public Boolean withHandle(Handle handle) throws Exception\n \n   public List<Pair<EntryType, StatusType>> getActiveEntriesWithStatus()\n   {\n-    return retryingHandle(\n-      new HandleCallback<List<Pair<EntryType, StatusType>>>()\n-      {\n-        @Override\n-        public List<Pair<EntryType, StatusType>> withHandle(Handle handle) throws Exception\n+    return connector.retryWithHandle(\n+        new HandleCallback<List<Pair<EntryType, StatusType>>>()\n         {\n-          return handle\n-              .createQuery(\n-                  String.format(\n-                      \"SELECT id, payload, status_payload FROM %s WHERE active = TRUE ORDER BY created_date\",\n-                      entryTable\n-                  )\n-              )\n-              .map(\n-                  new ResultSetMapper<Pair<EntryType, StatusType>>()\n-                  {\n-                    @Override\n-                    public Pair<EntryType, StatusType> map(int index, ResultSet r, StatementContext ctx)\n-                        throws SQLException\n+          @Override\n+          public List<Pair<EntryType, StatusType>> withHandle(Handle handle) throws Exception\n+          {\n+            return handle\n+                .createQuery(\n+                    String.format(\n+                        \"SELECT id, payload, status_payload FROM %s WHERE active = TRUE ORDER BY created_date\",\n+                        entryTable\n+                    )\n+                )\n+                .map(\n+                    new ResultSetMapper<Pair<EntryType, StatusType>>()\n                     {\n-                      try {\n-                        return Pair.of(\n-                            jsonMapper.<EntryType>readValue(\n-                                r.getBytes(\"payload\"),\n-                                entryType\n-                            ),\n-                            jsonMapper.<StatusType>readValue(\n-                                r.getBytes(\"status_payload\"),\n-                                statusType\n-                            )\n-                        );\n-                      }\n-                      catch (IOException e) {\n-                        log.makeAlert(e, \"Failed to parse entry payload\").addData(\"entry\", r.getString(\"id\")).emit();\n-                        throw new SQLException(e);\n+                      @Override\n+                      public Pair<EntryType, StatusType> map(int index, ResultSet r, StatementContext ctx)\n+                          throws SQLException\n+                      {\n+                        try {\n+                          return Pair.of(\n+                              jsonMapper.<EntryType>readValue(\n+                                  r.getBytes(\"payload\"),\n+                                  entryType\n+                              ),\n+                              jsonMapper.<StatusType>readValue(\n+                                  r.getBytes(\"status_payload\"),\n+                                  statusType\n+                              )\n+                          );\n+                        }\n+                        catch (IOException e) {\n+                          log.makeAlert(e, \"Failed to parse entry payload\").addData(\"entry\", r.getString(\"id\")).emit();\n+                          throw new SQLException(e);\n+                        }\n                       }\n                     }\n-                  }\n-              ).list();\n+                ).list();\n+          }\n         }\n-      }\n     );\n \n   }\n \n   public List<StatusType> getInactiveStatusesSince(final DateTime timestamp)\n   {\n-    return retryingHandle(\n-      new HandleCallback<List<StatusType>>()\n-      {\n-        @Override\n-        public List<StatusType> withHandle(Handle handle) throws Exception\n+    return connector.retryWithHandle(\n+        new HandleCallback<List<StatusType>>()\n         {\n-          return handle\n-              .createQuery(\n-                  String.format(\n-                      \"SELECT id, status_payload FROM %s WHERE active = FALSE AND created_date >= :start ORDER BY created_date DESC\",\n-                      entryTable\n-                  )\n-              ).bind(\"start\", timestamp.toString())\n-              .map(\n-                  new ResultSetMapper<StatusType>()\n-                  {\n-                    @Override\n-                    public StatusType map(int index, ResultSet r, StatementContext ctx) throws SQLException\n+          @Override\n+          public List<StatusType> withHandle(Handle handle) throws Exception\n+          {\n+            return handle\n+                .createQuery(\n+                    String.format(\n+                        \"SELECT id, status_payload FROM %s WHERE active = FALSE AND created_date >= :start ORDER BY created_date DESC\",\n+                        entryTable\n+                    )\n+                ).bind(\"start\", timestamp.toString())\n+                .map(\n+                    new ResultSetMapper<StatusType>()\n                     {\n-                      try {\n-                        return jsonMapper.readValue(\n-                            r.getBytes(\"status_payload\"),\n-                            statusType\n-                        );\n-                      }\n-                      catch (IOException e) {\n-                        log.makeAlert(e, \"Failed to parse status payload\")\n-                           .addData(\"entry\", r.getString(\"id\"))\n-                           .emit();\n-                        throw new SQLException(e);\n+                      @Override\n+                      public StatusType map(int index, ResultSet r, StatementContext ctx) throws SQLException\n+                      {\n+                        try {\n+                          return jsonMapper.readValue(\n+                              r.getBytes(\"status_payload\"),\n+                              statusType\n+                          );\n+                        }\n+                        catch (IOException e) {\n+                          log.makeAlert(e, \"Failed to parse status payload\")\n+                             .addData(\"entry\", r.getString(\"id\"))\n+                             .emit();\n+                          throw new SQLException(e);\n+                        }\n                       }\n                     }\n-                  }\n-              ).list();\n+                ).list();\n+          }\n         }\n-      }\n     );\n   }\n \n   public boolean addLock(final String entryId, final LockType lock)\n   {\n-    return retryingHandle(\n-      new HandleCallback<Boolean>()\n-      {\n-        @Override\n-        public Boolean withHandle(Handle handle) throws Exception\n+    return connector.retryWithHandle(\n+        new HandleCallback<Boolean>()\n         {\n-          return handle.createStatement(\n-                      String.format(\n-                          \"INSERT INTO %1$s (%2$s_id, lock_payload) VALUES (:entryId, :payload)\",\n-                          lockTable, entryTypeName\n-                      )\n-                  )\n-                       .bind(\"entryId\", entryId)\n-                       .bind(\"payload\", jsonMapper.writeValueAsBytes(lock))\n-                       .execute() == 1;\n+          @Override\n+          public Boolean withHandle(Handle handle) throws Exception\n+          {\n+            return handle.createStatement(\n+                String.format(\n+                    \"INSERT INTO %1$s (%2$s_id, lock_payload) VALUES (:entryId, :payload)\",\n+                    lockTable, entryTypeName\n+                )\n+            )\n+                         .bind(\"entryId\", entryId)\n+                         .bind(\"payload\", jsonMapper.writeValueAsBytes(lock))\n+                         .execute() == 1;","path":"server/src/main/java/io/druid/metadata/SQLMetadataStorageActionHandler.java","position":301,"original_position":301,"commit_id":"3ca5ad8b61100b3be0d5237a454c8b21cd8f1c7c","original_commit_id":"3ca5ad8b61100b3be0d5237a454c8b21cd8f1c7c","user":{"login":"drcrallen","id":8213081,"avatar_url":"https://avatars.githubusercontent.com/u/8213081?v=3","gravatar_id":"","url":"https://api.github.com/users/drcrallen","html_url":"https://github.com/drcrallen","followers_url":"https://api.github.com/users/drcrallen/followers","following_url":"https://api.github.com/users/drcrallen/following{/other_user}","gists_url":"https://api.github.com/users/drcrallen/gists{/gist_id}","starred_url":"https://api.github.com/users/drcrallen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drcrallen/subscriptions","organizations_url":"https://api.github.com/users/drcrallen/orgs","repos_url":"https://api.github.com/users/drcrallen/repos","events_url":"https://api.github.com/users/drcrallen/events{/privacy}","received_events_url":"https://api.github.com/users/drcrallen/received_events","type":"User","site_admin":false},"body":"Locking should be transactional though, right?","created_at":"2015-08-25T18:41:11Z","updated_at":"2015-08-25T18:41:11Z","html_url":"https://github.com/druid-io/druid/pull/1665#discussion_r37902738","pull_request_url":"https://api.github.com/repos/druid-io/druid/pulls/1665","_links":{"self":{"href":"https://api.github.com/repos/druid-io/druid/pulls/comments/37902738"},"html":{"href":"https://github.com/druid-io/druid/pull/1665#discussion_r37902738"},"pull_request":{"href":"https://api.github.com/repos/druid-io/druid/pulls/1665"}}},"pull_request":{"url":"https://api.github.com/repos/druid-io/druid/pulls/1665","id":43242221,"html_url":"https://github.com/druid-io/druid/pull/1665","diff_url":"https://github.com/druid-io/druid/pull/1665.diff","patch_url":"https://github.com/druid-io/druid/pull/1665.patch","issue_url":"https://api.github.com/repos/druid-io/druid/issues/1665","number":1665,"state":"open","locked":false,"title":"Consolidate SQL retrying by moving logic into the connectors.","user":{"login":"gianm","id":1214075,"avatar_url":"https://avatars.githubusercontent.com/u/1214075?v=3","gravatar_id":"","url":"https://api.github.com/users/gianm","html_url":"https://github.com/gianm","followers_url":"https://api.github.com/users/gianm/followers","following_url":"https://api.github.com/users/gianm/following{/other_user}","gists_url":"https://api.github.com/users/gianm/gists{/gist_id}","starred_url":"https://api.github.com/users/gianm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gianm/subscriptions","organizations_url":"https://api.github.com/users/gianm/orgs","repos_url":"https://api.github.com/users/gianm/repos","events_url":"https://api.github.com/users/gianm/events{/privacy}","received_events_url":"https://api.github.com/users/gianm/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-25T01:58:14Z","updated_at":"2015-08-25T18:41:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"312c33b9f4b538b8d9a4c8a2195a756d275d689c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/druid-io/druid/pulls/1665/commits","review_comments_url":"https://api.github.com/repos/druid-io/druid/pulls/1665/comments","review_comment_url":"https://api.github.com/repos/druid-io/druid/pulls/comments{/number}","comments_url":"https://api.github.com/repos/druid-io/druid/issues/1665/comments","statuses_url":"https://api.github.com/repos/druid-io/druid/statuses/3ca5ad8b61100b3be0d5237a454c8b21cd8f1c7c","head":{"label":"gianm:consolidate-sql-retrying","ref":"consolidate-sql-retrying","sha":"3ca5ad8b61100b3be0d5237a454c8b21cd8f1c7c","user":{"login":"gianm","id":1214075,"avatar_url":"https://avatars.githubusercontent.com/u/1214075?v=3","gravatar_id":"","url":"https://api.github.com/users/gianm","html_url":"https://github.com/gianm","followers_url":"https://api.github.com/users/gianm/followers","following_url":"https://api.github.com/users/gianm/following{/other_user}","gists_url":"https://api.github.com/users/gianm/gists{/gist_id}","starred_url":"https://api.github.com/users/gianm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gianm/subscriptions","organizations_url":"https://api.github.com/users/gianm/orgs","repos_url":"https://api.github.com/users/gianm/repos","events_url":"https://api.github.com/users/gianm/events{/privacy}","received_events_url":"https://api.github.com/users/gianm/received_events","type":"User","site_admin":false},"repo":{"id":28350072,"name":"druid","full_name":"gianm/druid","owner":{"login":"gianm","id":1214075,"avatar_url":"https://avatars.githubusercontent.com/u/1214075?v=3","gravatar_id":"","url":"https://api.github.com/users/gianm","html_url":"https://github.com/gianm","followers_url":"https://api.github.com/users/gianm/followers","following_url":"https://api.github.com/users/gianm/following{/other_user}","gists_url":"https://api.github.com/users/gianm/gists{/gist_id}","starred_url":"https://api.github.com/users/gianm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gianm/subscriptions","organizations_url":"https://api.github.com/users/gianm/orgs","repos_url":"https://api.github.com/users/gianm/repos","events_url":"https://api.github.com/users/gianm/events{/privacy}","received_events_url":"https://api.github.com/users/gianm/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gianm/druid","description":"Real²time Exploratory Analytics on Large Datasets","fork":true,"url":"https://api.github.com/repos/gianm/druid","forks_url":"https://api.github.com/repos/gianm/druid/forks","keys_url":"https://api.github.com/repos/gianm/druid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gianm/druid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gianm/druid/teams","hooks_url":"https://api.github.com/repos/gianm/druid/hooks","issue_events_url":"https://api.github.com/repos/gianm/druid/issues/events{/number}","events_url":"https://api.github.com/repos/gianm/druid/events","assignees_url":"https://api.github.com/repos/gianm/druid/assignees{/user}","branches_url":"https://api.github.com/repos/gianm/druid/branches{/branch}","tags_url":"https://api.github.com/repos/gianm/druid/tags","blobs_url":"https://api.github.com/repos/gianm/druid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gianm/druid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gianm/druid/git/refs{/sha}","trees_url":"https://api.github.com/repos/gianm/druid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gianm/druid/statuses/{sha}","languages_url":"https://api.github.com/repos/gianm/druid/languages","stargazers_url":"https://api.github.com/repos/gianm/druid/stargazers","contributors_url":"https://api.github.com/repos/gianm/druid/contributors","subscribers_url":"https://api.github.com/repos/gianm/druid/subscribers","subscription_url":"https://api.github.com/repos/gianm/druid/subscription","commits_url":"https://api.github.com/repos/gianm/druid/commits{/sha}","git_commits_url":"https://api.github.com/repos/gianm/druid/git/commits{/sha}","comments_url":"https://api.github.com/repos/gianm/druid/comments{/number}","issue_comment_url":"https://api.github.com/repos/gianm/druid/issues/comments{/number}","contents_url":"https://api.github.com/repos/gianm/druid/contents/{+path}","compare_url":"https://api.github.com/repos/gianm/druid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gianm/druid/merges","archive_url":"https://api.github.com/repos/gianm/druid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gianm/druid/downloads","issues_url":"https://api.github.com/repos/gianm/druid/issues{/number}","pulls_url":"https://api.github.com/repos/gianm/druid/pulls{/number}","milestones_url":"https://api.github.com/repos/gianm/druid/milestones{/number}","notifications_url":"https://api.github.com/repos/gianm/druid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gianm/druid/labels{/name}","releases_url":"https://api.github.com/repos/gianm/druid/releases{/id}","created_at":"2014-12-22T17:32:01Z","updated_at":"2015-05-04T17:52:12Z","pushed_at":"2015-08-25T17:41:43Z","git_url":"git://github.com/gianm/druid.git","ssh_url":"git@github.com:gianm/druid.git","clone_url":"https://github.com/gianm/druid.git","svn_url":"https://github.com/gianm/druid","homepage":"http://druid.io","size":94571,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"druid-io:master","ref":"master","sha":"de8f806cc11d5839537cacdd3a6931c41882458a","user":{"login":"druid-io","id":4203474,"avatar_url":"https://avatars.githubusercontent.com/u/4203474?v=3","gravatar_id":"","url":"https://api.github.com/users/druid-io","html_url":"https://github.com/druid-io","followers_url":"https://api.github.com/users/druid-io/followers","following_url":"https://api.github.com/users/druid-io/following{/other_user}","gists_url":"https://api.github.com/users/druid-io/gists{/gist_id}","starred_url":"https://api.github.com/users/druid-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/druid-io/subscriptions","organizations_url":"https://api.github.com/users/druid-io/orgs","repos_url":"https://api.github.com/users/druid-io/repos","events_url":"https://api.github.com/users/druid-io/events{/privacy}","received_events_url":"https://api.github.com/users/druid-io/received_events","type":"Organization","site_admin":false},"repo":{"id":6358188,"name":"druid","full_name":"druid-io/druid","owner":{"login":"druid-io","id":4203474,"avatar_url":"https://avatars.githubusercontent.com/u/4203474?v=3","gravatar_id":"","url":"https://api.github.com/users/druid-io","html_url":"https://github.com/druid-io","followers_url":"https://api.github.com/users/druid-io/followers","following_url":"https://api.github.com/users/druid-io/following{/other_user}","gists_url":"https://api.github.com/users/druid-io/gists{/gist_id}","starred_url":"https://api.github.com/users/druid-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/druid-io/subscriptions","organizations_url":"https://api.github.com/users/druid-io/orgs","repos_url":"https://api.github.com/users/druid-io/repos","events_url":"https://api.github.com/users/druid-io/events{/privacy}","received_events_url":"https://api.github.com/users/druid-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/druid-io/druid","description":"Column oriented distributed data store ideal for powering interactive applications","fork":false,"url":"https://api.github.com/repos/druid-io/druid","forks_url":"https://api.github.com/repos/druid-io/druid/forks","keys_url":"https://api.github.com/repos/druid-io/druid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/druid-io/druid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/druid-io/druid/teams","hooks_url":"https://api.github.com/repos/druid-io/druid/hooks","issue_events_url":"https://api.github.com/repos/druid-io/druid/issues/events{/number}","events_url":"https://api.github.com/repos/druid-io/druid/events","assignees_url":"https://api.github.com/repos/druid-io/druid/assignees{/user}","branches_url":"https://api.github.com/repos/druid-io/druid/branches{/branch}","tags_url":"https://api.github.com/repos/druid-io/druid/tags","blobs_url":"https://api.github.com/repos/druid-io/druid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/druid-io/druid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/druid-io/druid/git/refs{/sha}","trees_url":"https://api.github.com/repos/druid-io/druid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/druid-io/druid/statuses/{sha}","languages_url":"https://api.github.com/repos/druid-io/druid/languages","stargazers_url":"https://api.github.com/repos/druid-io/druid/stargazers","contributors_url":"https://api.github.com/repos/druid-io/druid/contributors","subscribers_url":"https://api.github.com/repos/druid-io/druid/subscribers","subscription_url":"https://api.github.com/repos/druid-io/druid/subscription","commits_url":"https://api.github.com/repos/druid-io/druid/commits{/sha}","git_commits_url":"https://api.github.com/repos/druid-io/druid/git/commits{/sha}","comments_url":"https://api.github.com/repos/druid-io/druid/comments{/number}","issue_comment_url":"https://api.github.com/repos/druid-io/druid/issues/comments{/number}","contents_url":"https://api.github.com/repos/druid-io/druid/contents/{+path}","compare_url":"https://api.github.com/repos/druid-io/druid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/druid-io/druid/merges","archive_url":"https://api.github.com/repos/druid-io/druid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/druid-io/druid/downloads","issues_url":"https://api.github.com/repos/druid-io/druid/issues{/number}","pulls_url":"https://api.github.com/repos/druid-io/druid/pulls{/number}","milestones_url":"https://api.github.com/repos/druid-io/druid/milestones{/number}","notifications_url":"https://api.github.com/repos/druid-io/druid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/druid-io/druid/labels{/name}","releases_url":"https://api.github.com/repos/druid-io/druid/releases{/id}","created_at":"2012-10-23T19:08:07Z","updated_at":"2015-08-25T14:51:00Z","pushed_at":"2015-08-25T18:22:55Z","git_url":"git://github.com/druid-io/druid.git","ssh_url":"git@github.com:druid-io/druid.git","clone_url":"https://github.com/druid-io/druid.git","svn_url":"https://github.com/druid-io/druid","homepage":"http://druid.io","size":175580,"stargazers_count":1954,"watchers_count":1954,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":438,"mirror_url":null,"open_issues_count":167,"forks":438,"open_issues":167,"watchers":1954,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/druid-io/druid/pulls/1665"},"html":{"href":"https://github.com/druid-io/druid/pull/1665"},"issue":{"href":"https://api.github.com/repos/druid-io/druid/issues/1665"},"comments":{"href":"https://api.github.com/repos/druid-io/druid/issues/1665/comments"},"review_comments":{"href":"https://api.github.com/repos/druid-io/druid/pulls/1665/comments"},"review_comment":{"href":"https://api.github.com/repos/druid-io/druid/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/druid-io/druid/pulls/1665/commits"},"statuses":{"href":"https://api.github.com/repos/druid-io/druid/statuses/3ca5ad8b61100b3be0d5237a454c8b21cd8f1c7c"}}}}