{"action":"created","comment":{"url":"https://api.github.com/repos/apache/storm/pulls/comments/54302011","id":54302011,"diff_hunk":"@@ -0,0 +1,390 @@\n+/**\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License.  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 org.apache.storm.daemon;\n+\n+import com.codahale.metrics.Meter;\n+import com.codahale.metrics.MetricRegistry;\n+import com.sun.net.httpserver.HttpsServer;\n+import com.sun.org.apache.bcel.internal.generic.ARRAYLENGTH;\n+import org.apache.commons.lang.StringUtils;\n+import org.apache.storm.Config;\n+import org.apache.storm.daemon.metrics.MetricsUtils;\n+import org.apache.storm.daemon.metrics.reporters.PreparableReporter;\n+import org.apache.storm.generated.*;\n+import org.apache.storm.logging.ThriftAccessLogger;\n+import org.apache.storm.security.auth.*;\n+import org.apache.storm.security.auth.authorizer.DRPCAuthorizerBase;\n+import org.apache.storm.ui.FilterConfiguration;\n+import org.apache.storm.ui.IConfigurator;\n+import org.apache.storm.ui.UIHelpers;\n+import org.apache.storm.utils.ConfigUtils;\n+import org.apache.storm.utils.Time;\n+import org.apache.storm.utils.Utils;\n+import org.apache.storm.utils.VersionInfo;\n+import org.apache.thrift.TException;\n+import org.eclipse.jetty.server.Server;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import javax.servlet.Servlet;\n+import java.security.Principal;\n+import java.util.*;\n+import java.util.concurrent.*;\n+import java.util.concurrent.atomic.AtomicInteger;\n+\n+public class DrpcServer implements DistributedRPC.Iface, DistributedRPCInvocations.Iface, Shutdownable {\n+\n+    private static final Logger LOG = LoggerFactory.getLogger(DrpcServer.class);\n+    private final Long timeoutCheckSecs = 5L;\n+\n+    private Map conf;\n+\n+    private ThriftServer handlerServer;\n+    private ThriftServer invokeServer;\n+    private IHttpCredentialsPlugin httpCredsHandler;\n+\n+    private Thread clearThread;\n+\n+    private IAuthorizer authorizer;\n+\n+    // To be removed after porting drpc.clj\n+    private Servlet httpServlet;\n+\n+    private AtomicInteger ctr = new AtomicInteger(0);\n+    private ConcurrentHashMap<String, Semaphore> idtoSem = new ConcurrentHashMap<String, Semaphore>();\n+    private ConcurrentHashMap<String, Object> idtoResult = new ConcurrentHashMap<String, Object>();\n+    private ConcurrentHashMap<String, Integer> idtoStart = new ConcurrentHashMap<String, Integer>();\n+    private ConcurrentHashMap<String, String> idtoFunction = new ConcurrentHashMap<String, String>();\n+    private ConcurrentHashMap<String, DRPCRequest> idtoRequest = new ConcurrentHashMap<String, DRPCRequest>();\n+    private ConcurrentHashMap<String, ConcurrentLinkedQueue<DRPCRequest>> requestQueues = new ConcurrentHashMap<String, ConcurrentLinkedQueue<DRPCRequest>>();","path":"storm-core/src/jvm/org/apache/storm/daemon/DrpcServer.java","position":74,"original_position":74,"commit_id":"8e350d1cf1f16b0101d699de0016bb762061f1e3","original_commit_id":"8e350d1cf1f16b0101d699de0016bb762061f1e3","user":{"login":"revans2","id":3441321,"avatar_url":"https://avatars.githubusercontent.com/u/3441321?v=3","gravatar_id":"","url":"https://api.github.com/users/revans2","html_url":"https://github.com/revans2","followers_url":"https://api.github.com/users/revans2/followers","following_url":"https://api.github.com/users/revans2/following{/other_user}","gists_url":"https://api.github.com/users/revans2/gists{/gist_id}","starred_url":"https://api.github.com/users/revans2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/revans2/subscriptions","organizations_url":"https://api.github.com/users/revans2/orgs","repos_url":"https://api.github.com/users/revans2/repos","events_url":"https://api.github.com/users/revans2/events{/privacy}","received_events_url":"https://api.github.com/users/revans2/received_events","type":"User","site_admin":false},"body":"This is a perfect place to actually improve things to make them more object oriented.  The key to almost all of these maps is the same thing.  Why not remove all of the special ordering that we have to do on setup and cleanup.\r\n\r\n```\r\nprivate static class InternalRequest {\r\n    public final Semaphore sem;\r\n    public final long startTimeSecs;\r\n    public final string function;\r\n    public final DRPCRequest request;\r\n    public volatile Object result;\r\n\r\n    public InternalRequest(String function, DRPCRequest request) {\r\n        sem = new Semaphore(0);\r\n        startTimeSecs = Time.currentTimeSecs();\r\n        this.function = function;\r\n        this.request = request;\r\n    }\r\n}\r\n\r\nprivate ConcurrentHashMap<String, InternalRequest> outstandingRequests = new ConcurrentHashMap<>();\r\n```","created_at":"2016-02-26T21:05:37Z","updated_at":"2016-02-26T21:05:37Z","html_url":"https://github.com/apache/storm/pull/1156#discussion_r54302011","pull_request_url":"https://api.github.com/repos/apache/storm/pulls/1156","_links":{"self":{"href":"https://api.github.com/repos/apache/storm/pulls/comments/54302011"},"html":{"href":"https://github.com/apache/storm/pull/1156#discussion_r54302011"},"pull_request":{"href":"https://api.github.com/repos/apache/storm/pulls/1156"}}},"pull_request":{"url":"https://api.github.com/repos/apache/storm/pulls/1156","id":60856121,"html_url":"https://github.com/apache/storm/pull/1156","diff_url":"https://github.com/apache/storm/pull/1156.diff","patch_url":"https://github.com/apache/storm/pull/1156.patch","issue_url":"https://api.github.com/repos/apache/storm/issues/1156","number":1156,"state":"open","locked":false,"title":"[STORM-1270]  [STORM-1274] port drpc&LocalDRPC  to java ","user":{"login":"hustfxj","id":7270212,"avatar_url":"https://avatars.githubusercontent.com/u/7270212?v=3","gravatar_id":"","url":"https://api.github.com/users/hustfxj","html_url":"https://github.com/hustfxj","followers_url":"https://api.github.com/users/hustfxj/followers","following_url":"https://api.github.com/users/hustfxj/following{/other_user}","gists_url":"https://api.github.com/users/hustfxj/gists{/gist_id}","starred_url":"https://api.github.com/users/hustfxj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hustfxj/subscriptions","organizations_url":"https://api.github.com/users/hustfxj/orgs","repos_url":"https://api.github.com/users/hustfxj/repos","events_url":"https://api.github.com/users/hustfxj/events{/privacy}","received_events_url":"https://api.github.com/users/hustfxj/received_events","type":"User","site_admin":false},"body":"1. Port \"org.apache.storm.daemon.drpc\" to java at \"org.apache.storm.daemon.DrpcServer\".\r\n2. Port \"org.apache.storm.LocalDRPC\" to java at \"org.apache.storm.LocalDRPC\".\r\n3. I keep the \"webapp\" of drpc.clj , as it's hard to translate and we will move ring to other REST framework. ","created_at":"2016-02-26T15:17:30Z","updated_at":"2016-02-26T21:05:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f96d1d3a3cae25e2c74e944706933e8e5b85069c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/storm/pulls/1156/commits","review_comments_url":"https://api.github.com/repos/apache/storm/pulls/1156/comments","review_comment_url":"https://api.github.com/repos/apache/storm/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/storm/issues/1156/comments","statuses_url":"https://api.github.com/repos/apache/storm/statuses/8e350d1cf1f16b0101d699de0016bb762061f1e3","head":{"label":"hustfxj:DRPC","ref":"DRPC","sha":"8e350d1cf1f16b0101d699de0016bb762061f1e3","user":{"login":"hustfxj","id":7270212,"avatar_url":"https://avatars.githubusercontent.com/u/7270212?v=3","gravatar_id":"","url":"https://api.github.com/users/hustfxj","html_url":"https://github.com/hustfxj","followers_url":"https://api.github.com/users/hustfxj/followers","following_url":"https://api.github.com/users/hustfxj/following{/other_user}","gists_url":"https://api.github.com/users/hustfxj/gists{/gist_id}","starred_url":"https://api.github.com/users/hustfxj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hustfxj/subscriptions","organizations_url":"https://api.github.com/users/hustfxj/orgs","repos_url":"https://api.github.com/users/hustfxj/repos","events_url":"https://api.github.com/users/hustfxj/events{/privacy}","received_events_url":"https://api.github.com/users/hustfxj/received_events","type":"User","site_admin":false},"repo":{"id":50340543,"name":"storm","full_name":"hustfxj/storm","owner":{"login":"hustfxj","id":7270212,"avatar_url":"https://avatars.githubusercontent.com/u/7270212?v=3","gravatar_id":"","url":"https://api.github.com/users/hustfxj","html_url":"https://github.com/hustfxj","followers_url":"https://api.github.com/users/hustfxj/followers","following_url":"https://api.github.com/users/hustfxj/following{/other_user}","gists_url":"https://api.github.com/users/hustfxj/gists{/gist_id}","starred_url":"https://api.github.com/users/hustfxj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hustfxj/subscriptions","organizations_url":"https://api.github.com/users/hustfxj/orgs","repos_url":"https://api.github.com/users/hustfxj/repos","events_url":"https://api.github.com/users/hustfxj/events{/privacy}","received_events_url":"https://api.github.com/users/hustfxj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hustfxj/storm","description":"Mirror of Apache Storm","fork":true,"url":"https://api.github.com/repos/hustfxj/storm","forks_url":"https://api.github.com/repos/hustfxj/storm/forks","keys_url":"https://api.github.com/repos/hustfxj/storm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hustfxj/storm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hustfxj/storm/teams","hooks_url":"https://api.github.com/repos/hustfxj/storm/hooks","issue_events_url":"https://api.github.com/repos/hustfxj/storm/issues/events{/number}","events_url":"https://api.github.com/repos/hustfxj/storm/events","assignees_url":"https://api.github.com/repos/hustfxj/storm/assignees{/user}","branches_url":"https://api.github.com/repos/hustfxj/storm/branches{/branch}","tags_url":"https://api.github.com/repos/hustfxj/storm/tags","blobs_url":"https://api.github.com/repos/hustfxj/storm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hustfxj/storm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hustfxj/storm/git/refs{/sha}","trees_url":"https://api.github.com/repos/hustfxj/storm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hustfxj/storm/statuses/{sha}","languages_url":"https://api.github.com/repos/hustfxj/storm/languages","stargazers_url":"https://api.github.com/repos/hustfxj/storm/stargazers","contributors_url":"https://api.github.com/repos/hustfxj/storm/contributors","subscribers_url":"https://api.github.com/repos/hustfxj/storm/subscribers","subscription_url":"https://api.github.com/repos/hustfxj/storm/subscription","commits_url":"https://api.github.com/repos/hustfxj/storm/commits{/sha}","git_commits_url":"https://api.github.com/repos/hustfxj/storm/git/commits{/sha}","comments_url":"https://api.github.com/repos/hustfxj/storm/comments{/number}","issue_comment_url":"https://api.github.com/repos/hustfxj/storm/issues/comments{/number}","contents_url":"https://api.github.com/repos/hustfxj/storm/contents/{+path}","compare_url":"https://api.github.com/repos/hustfxj/storm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hustfxj/storm/merges","archive_url":"https://api.github.com/repos/hustfxj/storm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hustfxj/storm/downloads","issues_url":"https://api.github.com/repos/hustfxj/storm/issues{/number}","pulls_url":"https://api.github.com/repos/hustfxj/storm/pulls{/number}","milestones_url":"https://api.github.com/repos/hustfxj/storm/milestones{/number}","notifications_url":"https://api.github.com/repos/hustfxj/storm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hustfxj/storm/labels{/name}","releases_url":"https://api.github.com/repos/hustfxj/storm/releases{/id}","deployments_url":"https://api.github.com/repos/hustfxj/storm/deployments","created_at":"2016-01-25T09:34:58Z","updated_at":"2016-01-25T09:35:02Z","pushed_at":"2016-02-26T14:59:27Z","git_url":"git://github.com/hustfxj/storm.git","ssh_url":"git@github.com:hustfxj/storm.git","clone_url":"https://github.com/hustfxj/storm.git","svn_url":"https://github.com/hustfxj/storm","homepage":null,"size":153847,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"73312ad56060567ffde044515d8193ed94f3b07f","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":14135470,"name":"storm","full_name":"apache/storm","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/storm","description":"Mirror of Apache Storm","fork":false,"url":"https://api.github.com/repos/apache/storm","forks_url":"https://api.github.com/repos/apache/storm/forks","keys_url":"https://api.github.com/repos/apache/storm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/storm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/storm/teams","hooks_url":"https://api.github.com/repos/apache/storm/hooks","issue_events_url":"https://api.github.com/repos/apache/storm/issues/events{/number}","events_url":"https://api.github.com/repos/apache/storm/events","assignees_url":"https://api.github.com/repos/apache/storm/assignees{/user}","branches_url":"https://api.github.com/repos/apache/storm/branches{/branch}","tags_url":"https://api.github.com/repos/apache/storm/tags","blobs_url":"https://api.github.com/repos/apache/storm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/storm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/storm/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/storm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/storm/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/storm/languages","stargazers_url":"https://api.github.com/repos/apache/storm/stargazers","contributors_url":"https://api.github.com/repos/apache/storm/contributors","subscribers_url":"https://api.github.com/repos/apache/storm/subscribers","subscription_url":"https://api.github.com/repos/apache/storm/subscription","commits_url":"https://api.github.com/repos/apache/storm/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/storm/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/storm/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/storm/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/storm/contents/{+path}","compare_url":"https://api.github.com/repos/apache/storm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/storm/merges","archive_url":"https://api.github.com/repos/apache/storm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/storm/downloads","issues_url":"https://api.github.com/repos/apache/storm/issues{/number}","pulls_url":"https://api.github.com/repos/apache/storm/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/storm/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/storm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/storm/labels{/name}","releases_url":"https://api.github.com/repos/apache/storm/releases{/id}","deployments_url":"https://api.github.com/repos/apache/storm/deployments","created_at":"2013-11-05T08:00:14Z","updated_at":"2016-02-26T09:58:16Z","pushed_at":"2016-02-26T17:31:08Z","git_url":"git://github.com/apache/storm.git","ssh_url":"git@github.com:apache/storm.git","clone_url":"https://github.com/apache/storm.git","svn_url":"https://github.com/apache/storm","homepage":null,"size":158528,"stargazers_count":2884,"watchers_count":2884,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":2163,"mirror_url":"git://git.apache.org/storm.git","open_issues_count":89,"forks":2163,"open_issues":89,"watchers":2884,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/storm/pulls/1156"},"html":{"href":"https://github.com/apache/storm/pull/1156"},"issue":{"href":"https://api.github.com/repos/apache/storm/issues/1156"},"comments":{"href":"https://api.github.com/repos/apache/storm/issues/1156/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/storm/pulls/1156/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/storm/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/storm/pulls/1156/commits"},"statuses":{"href":"https://api.github.com/repos/apache/storm/statuses/8e350d1cf1f16b0101d699de0016bb762061f1e3"}}}}