{"action":"created","comment":{"url":"https://api.github.com/repos/apache/helix/pulls/comments/34328588","id":34328588,"diff_hunk":"@@ -235,8 +376,94 @@ PartitionInfo get(String stateUnitKey) {\n     }\n   }\n \n+  class ResourceGroupInfo {\n+    // store PartitionInfo for each partition for all resources in the resource group\n+    HashMap<String, PartitionInfo> partitionInfoMap;\n+    // stores the Set of Instances in a given state for all resources in the resource group\n+    HashMap<String, Set<InstanceConfig>> stateInfoMap;\n+    // stores the ResourceInfo for each resource with different instance tag.\n+    HashMap<String, ResourceInfo> tagResourceInfoMap;\n+\n+    public ResourceGroupInfo() {\n+      partitionInfoMap = new HashMap<String, RoutingTableProvider.PartitionInfo>();\n+      stateInfoMap = new HashMap<String, Set<InstanceConfig>>();\n+      tagResourceInfoMap = new HashMap<String, ResourceInfo>();\n+    }\n+\n+    public void addEntry(String resourceTag, String stateUnitKey, String state, InstanceConfig config) {\n+      // add\n+      if (!stateInfoMap.containsKey(state)) {\n+        Comparator<InstanceConfig> comparator = new Comparator<InstanceConfig>() {\n+\n+          @Override\n+          public int compare(InstanceConfig o1, InstanceConfig o2) {\n+            if (o1 == o2) {\n+              return 0;\n+            }\n+            if (o1 == null) {\n+              return -1;\n+            }\n+            if (o2 == null) {\n+              return 1;\n+            }\n+\n+            int compareTo = o1.getHostName().compareTo(o2.getHostName());\n+            if (compareTo == 0) {\n+              return o1.getPort().compareTo(o2.getPort());\n+            } else {\n+              return compareTo;\n+            }\n+\n+          }\n+        };\n+        stateInfoMap.put(state, new TreeSet<InstanceConfig>(comparator));\n+      }\n+      Set<InstanceConfig> set = stateInfoMap.get(state);\n+      set.add(config);\n+\n+      if (!partitionInfoMap.containsKey(stateUnitKey)) {\n+        partitionInfoMap.put(stateUnitKey, new PartitionInfo());\n+      }\n+      PartitionInfo stateUnitKeyInfo = partitionInfoMap.get(stateUnitKey);\n+      stateUnitKeyInfo.addEntry(state, config);\n+\n+      if (!tagResourceInfoMap.containsKey(resourceTag)) {\n+        tagResourceInfoMap.put(resourceTag, new ResourceInfo());\n+      }\n+      ResourceInfo resourceInfo = tagResourceInfoMap.get(resourceTag);\n+      resourceInfo.addEntry(stateUnitKey, state, config);\n+    }\n+\n+    public Set<InstanceConfig> getInstances(String state) {\n+      Set<InstanceConfig> instanceSet = stateInfoMap.get(state);\n+      return instanceSet;\n+    }\n+\n+    public Set<InstanceConfig> getInstances(String state, String resourceTag) {\n+      ResourceInfo resourceInfo = tagResourceInfoMap.get(resourceTag);","path":"helix-core/src/main/java/org/apache/helix/spectator/RoutingTableProvider.java","position":274,"original_position":274,"commit_id":"2f88e070fb698c1420873c1bffa63640638de1ba","original_commit_id":"2f88e070fb698c1420873c1bffa63640638de1ba","user":{"login":"lei-xia","id":9325494,"avatar_url":"https://avatars.githubusercontent.com/u/9325494?v=3","gravatar_id":"","url":"https://api.github.com/users/lei-xia","html_url":"https://github.com/lei-xia","followers_url":"https://api.github.com/users/lei-xia/followers","following_url":"https://api.github.com/users/lei-xia/following{/other_user}","gists_url":"https://api.github.com/users/lei-xia/gists{/gist_id}","starred_url":"https://api.github.com/users/lei-xia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lei-xia/subscriptions","organizations_url":"https://api.github.com/users/lei-xia/orgs","repos_url":"https://api.github.com/users/lei-xia/repos","events_url":"https://api.github.com/users/lei-xia/events{/privacy}","received_events_url":"https://api.github.com/users/lei-xia/received_events","type":"User","site_admin":false},"body":"Resources in the same group will never have the same tags, otherwise it will be rejected since their idealstate name will be same.","created_at":"2015-07-10T05:32:28Z","updated_at":"2015-07-10T05:32:28Z","html_url":"https://github.com/apache/helix/pull/31#discussion_r34328588","pull_request_url":"https://api.github.com/repos/apache/helix/pulls/31","_links":{"self":{"href":"https://api.github.com/repos/apache/helix/pulls/comments/34328588"},"html":{"href":"https://github.com/apache/helix/pull/31#discussion_r34328588"},"pull_request":{"href":"https://api.github.com/repos/apache/helix/pulls/31"}}},"pull_request":{"url":"https://api.github.com/repos/apache/helix/pulls/31","id":38262379,"html_url":"https://github.com/apache/helix/pull/31","diff_url":"https://github.com/apache/helix/pull/31.diff","patch_url":"https://github.com/apache/helix/pull/31.patch","issue_url":"https://api.github.com/repos/apache/helix/issues/31","number":31,"state":"open","locked":false,"title":"[HELIX-599] Support creating/maintaining/routing resources with same names in different instance groups.","user":{"login":"lei-xia","id":9325494,"avatar_url":"https://avatars.githubusercontent.com/u/9325494?v=3","gravatar_id":"","url":"https://api.github.com/users/lei-xia","html_url":"https://github.com/lei-xia","followers_url":"https://api.github.com/users/lei-xia/followers","following_url":"https://api.github.com/users/lei-xia/following{/other_user}","gists_url":"https://api.github.com/users/lei-xia/gists{/gist_id}","starred_url":"https://api.github.com/users/lei-xia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lei-xia/subscriptions","organizations_url":"https://api.github.com/users/lei-xia/orgs","repos_url":"https://api.github.com/users/lei-xia/repos","events_url":"https://api.github.com/users/lei-xia/events{/privacy}","received_events_url":"https://api.github.com/users/lei-xia/received_events","type":"User","site_admin":false},"body":"\r\nMore details on the problems and our proposed solution is on the jira description: https://issues.apache.org/jira/browse/HELIX-599","created_at":"2015-06-22T18:40:34Z","updated_at":"2015-07-10T05:32:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b0fef4f46db2cbaaba4e61b32b167b77080fe9f5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/helix/pulls/31/commits","review_comments_url":"https://api.github.com/repos/apache/helix/pulls/31/comments","review_comment_url":"https://api.github.com/repos/apache/helix/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/helix/issues/31/comments","statuses_url":"https://api.github.com/repos/apache/helix/statuses/2f88e070fb698c1420873c1bffa63640638de1ba","head":{"label":"lei-xia:helix-0.6.x","ref":"helix-0.6.x","sha":"2f88e070fb698c1420873c1bffa63640638de1ba","user":{"login":"lei-xia","id":9325494,"avatar_url":"https://avatars.githubusercontent.com/u/9325494?v=3","gravatar_id":"","url":"https://api.github.com/users/lei-xia","html_url":"https://github.com/lei-xia","followers_url":"https://api.github.com/users/lei-xia/followers","following_url":"https://api.github.com/users/lei-xia/following{/other_user}","gists_url":"https://api.github.com/users/lei-xia/gists{/gist_id}","starred_url":"https://api.github.com/users/lei-xia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lei-xia/subscriptions","organizations_url":"https://api.github.com/users/lei-xia/orgs","repos_url":"https://api.github.com/users/lei-xia/repos","events_url":"https://api.github.com/users/lei-xia/events{/privacy}","received_events_url":"https://api.github.com/users/lei-xia/received_events","type":"User","site_admin":false},"repo":{"id":25483071,"name":"helix","full_name":"lei-xia/helix","owner":{"login":"lei-xia","id":9325494,"avatar_url":"https://avatars.githubusercontent.com/u/9325494?v=3","gravatar_id":"","url":"https://api.github.com/users/lei-xia","html_url":"https://github.com/lei-xia","followers_url":"https://api.github.com/users/lei-xia/followers","following_url":"https://api.github.com/users/lei-xia/following{/other_user}","gists_url":"https://api.github.com/users/lei-xia/gists{/gist_id}","starred_url":"https://api.github.com/users/lei-xia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lei-xia/subscriptions","organizations_url":"https://api.github.com/users/lei-xia/orgs","repos_url":"https://api.github.com/users/lei-xia/repos","events_url":"https://api.github.com/users/lei-xia/events{/privacy}","received_events_url":"https://api.github.com/users/lei-xia/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lei-xia/helix","description":"Mirror of Apache Helix","fork":true,"url":"https://api.github.com/repos/lei-xia/helix","forks_url":"https://api.github.com/repos/lei-xia/helix/forks","keys_url":"https://api.github.com/repos/lei-xia/helix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lei-xia/helix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lei-xia/helix/teams","hooks_url":"https://api.github.com/repos/lei-xia/helix/hooks","issue_events_url":"https://api.github.com/repos/lei-xia/helix/issues/events{/number}","events_url":"https://api.github.com/repos/lei-xia/helix/events","assignees_url":"https://api.github.com/repos/lei-xia/helix/assignees{/user}","branches_url":"https://api.github.com/repos/lei-xia/helix/branches{/branch}","tags_url":"https://api.github.com/repos/lei-xia/helix/tags","blobs_url":"https://api.github.com/repos/lei-xia/helix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lei-xia/helix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lei-xia/helix/git/refs{/sha}","trees_url":"https://api.github.com/repos/lei-xia/helix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lei-xia/helix/statuses/{sha}","languages_url":"https://api.github.com/repos/lei-xia/helix/languages","stargazers_url":"https://api.github.com/repos/lei-xia/helix/stargazers","contributors_url":"https://api.github.com/repos/lei-xia/helix/contributors","subscribers_url":"https://api.github.com/repos/lei-xia/helix/subscribers","subscription_url":"https://api.github.com/repos/lei-xia/helix/subscription","commits_url":"https://api.github.com/repos/lei-xia/helix/commits{/sha}","git_commits_url":"https://api.github.com/repos/lei-xia/helix/git/commits{/sha}","comments_url":"https://api.github.com/repos/lei-xia/helix/comments{/number}","issue_comment_url":"https://api.github.com/repos/lei-xia/helix/issues/comments{/number}","contents_url":"https://api.github.com/repos/lei-xia/helix/contents/{+path}","compare_url":"https://api.github.com/repos/lei-xia/helix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lei-xia/helix/merges","archive_url":"https://api.github.com/repos/lei-xia/helix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lei-xia/helix/downloads","issues_url":"https://api.github.com/repos/lei-xia/helix/issues{/number}","pulls_url":"https://api.github.com/repos/lei-xia/helix/pulls{/number}","milestones_url":"https://api.github.com/repos/lei-xia/helix/milestones{/number}","notifications_url":"https://api.github.com/repos/lei-xia/helix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lei-xia/helix/labels{/name}","releases_url":"https://api.github.com/repos/lei-xia/helix/releases{/id}","created_at":"2014-10-20T19:32:38Z","updated_at":"2015-04-27T00:26:12Z","pushed_at":"2015-06-29T20:50:20Z","git_url":"git://github.com/lei-xia/helix.git","ssh_url":"git@github.com:lei-xia/helix.git","clone_url":"https://github.com/lei-xia/helix.git","svn_url":"https://github.com/lei-xia/helix","homepage":null,"size":73838,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:helix-0.6.x","ref":"helix-0.6.x","sha":"2775e1566df7ceb67edd7587b81d4c245aedab38","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":15861701,"name":"helix","full_name":"apache/helix","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/helix","description":"Mirror of Apache Helix","fork":false,"url":"https://api.github.com/repos/apache/helix","forks_url":"https://api.github.com/repos/apache/helix/forks","keys_url":"https://api.github.com/repos/apache/helix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/helix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/helix/teams","hooks_url":"https://api.github.com/repos/apache/helix/hooks","issue_events_url":"https://api.github.com/repos/apache/helix/issues/events{/number}","events_url":"https://api.github.com/repos/apache/helix/events","assignees_url":"https://api.github.com/repos/apache/helix/assignees{/user}","branches_url":"https://api.github.com/repos/apache/helix/branches{/branch}","tags_url":"https://api.github.com/repos/apache/helix/tags","blobs_url":"https://api.github.com/repos/apache/helix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/helix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/helix/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/helix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/helix/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/helix/languages","stargazers_url":"https://api.github.com/repos/apache/helix/stargazers","contributors_url":"https://api.github.com/repos/apache/helix/contributors","subscribers_url":"https://api.github.com/repos/apache/helix/subscribers","subscription_url":"https://api.github.com/repos/apache/helix/subscription","commits_url":"https://api.github.com/repos/apache/helix/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/helix/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/helix/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/helix/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/helix/contents/{+path}","compare_url":"https://api.github.com/repos/apache/helix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/helix/merges","archive_url":"https://api.github.com/repos/apache/helix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/helix/downloads","issues_url":"https://api.github.com/repos/apache/helix/issues{/number}","pulls_url":"https://api.github.com/repos/apache/helix/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/helix/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/helix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/helix/labels{/name}","releases_url":"https://api.github.com/repos/apache/helix/releases{/id}","created_at":"2014-01-13T08:00:06Z","updated_at":"2015-07-02T22:08:06Z","pushed_at":"2015-06-22T18:40:34Z","git_url":"git://github.com/apache/helix.git","ssh_url":"git@github.com:apache/helix.git","clone_url":"https://github.com/apache/helix.git","svn_url":"https://github.com/apache/helix","homepage":null,"size":78750,"stargazers_count":38,"watchers_count":38,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":33,"mirror_url":"git://git.apache.org/helix.git","open_issues_count":5,"forks":33,"open_issues":5,"watchers":38,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/helix/pulls/31"},"html":{"href":"https://github.com/apache/helix/pull/31"},"issue":{"href":"https://api.github.com/repos/apache/helix/issues/31"},"comments":{"href":"https://api.github.com/repos/apache/helix/issues/31/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/helix/pulls/31/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/helix/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/helix/pulls/31/commits"},"statuses":{"href":"https://api.github.com/repos/apache/helix/statuses/2f88e070fb698c1420873c1bffa63640638de1ba"}}}}