{"action":"created","comment":{"url":"https://api.github.com/repos/linkedin/gobblin/pulls/comments/47980939","id":47980939,"diff_hunk":"@@ -0,0 +1,151 @@\n+/*\n+ * Copyright (C) 2015 LinkedIn Corp. All rights reserved.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use\n+ * this file except in compliance with the License. You may obtain a copy of the\n+ * License at  http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software distributed\n+ * under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n+ * CONDITIONS OF ANY KIND, either express or implied.\n+ */\n+\n+package gobblin.config.common.impl;\n+\n+import gobblin.config.store.api.ConfigStore;\n+import gobblin.config.store.api.ConfigStoreWithResolution;\n+import gobblin.config.store.api.VersionDoesNotExistException;\n+\n+import java.net.URI;\n+import java.util.ArrayList;\n+import java.util.Collection;\n+import java.util.HashSet;\n+import java.util.List;\n+import java.util.Map.Entry;\n+import java.util.Set;\n+import java.util.UUID;\n+\n+import org.apache.log4j.Logger;\n+\n+import com.typesafe.config.Config;\n+import com.typesafe.config.ConfigValue;\n+\n+/**\n+ * Utility class to provide {@ConfigStoreWithResolution} functionality based on given {@ConfigStore}\n+ * @author mitu\n+ *\n+ */\n+public class SimpleConfigStoreResolver implements ConfigStoreWithResolution {\n+\n+  private static final Logger LOG = Logger.getLogger(SimpleConfigStoreResolver.class);\n+  private final ConfigStore store;\n+\n+  public SimpleConfigStoreResolver(ConfigStore base) {\n+    this.store = base;\n+  }\n+\n+  @Override\n+  public String getCurrentVersion() {\n+    return store.getCurrentVersion();\n+  }\n+\n+  @Override\n+  public URI getStoreURI() {\n+    return store.getStoreURI();\n+  }\n+\n+  @Override\n+  public Collection<URI> getChildren(URI uri, String version) throws VersionDoesNotExistException{\n+    return store.getChildren(uri, version);\n+  }\n+\n+  @Override\n+  public List<URI> getOwnImports(URI uri, String version) throws VersionDoesNotExistException{\n+    return store.getOwnImports(uri, version);\n+  }\n+\n+  @Override\n+  public Config getOwnConfig(URI uri, String version) throws VersionDoesNotExistException{\n+    return store.getOwnConfig(uri, version);\n+  }\n+\n+  @Override\n+  public Config getResolvedConfig(URI uri, String version) throws VersionDoesNotExistException{\n+    UUID traceID = UUID.randomUUID();\n+    LOG.info(String.format(\"Getting resolved config for uri: %s for version %s, with traceID: %s\", \n+        uri, version, traceID));\n+    return getResolvedConfigWithTrace(uri, version, traceID.toString());\n+  }\n+\n+  protected Config getResolvedConfigWithTrace(URI uri, String version, String traceID) throws VersionDoesNotExistException{\n+    CircularDependencyChecker.checkCircularDependency(store, version, uri);\n+    Config self = this.getOwnConfig(uri, version);\n+    for (Entry<String, ConfigValue> entry : self.entrySet()) {\n+      LOG.info(String.format(\"key %s, value %s from uri %s, with traceID %s\", \n+          entry.getKey(), entry.getValue(), uri, traceID)); \n+    }\n+\n+    // root can not include anything, otherwise will have circular dependency \n+    if (isRootURI(uri)) {\n+      return self;\n+    }\n+\n+    // The order is already decided in imported List : higher priority appear in the head\n+    List<URI> imported = this.getOwnImports(uri, version);\n+    for (URI u : imported) {\n+      Config singleImported = this.getResolvedConfigWithTrace(u, version, traceID);\n+      self = self.withFallback(singleImported);\n+    }\n+\n+    // all the imports have higher priority than ancestor\n+    Config ancestor = this.getAncestorConfig(uri, version, traceID);\n+    return self.withFallback(ancestor);\n+  }\n+\n+  protected Config getAncestorConfig(URI uri, String version, String traceID) throws VersionDoesNotExistException{\n+    URI parent = PathUtils.getParentURI(uri);\n+    Config res = getResolvedConfigWithTrace(parent, version, traceID);\n+    return res;\n+  }\n+\n+  protected static final boolean isRootURI(URI uri) {\n+    if (uri == null)\n+      return false;\n+\n+    return uri.toString().length() == 0;\n+  }\n+\n+  @Override\n+  public List<URI> getImportsRecursively(URI uri, String version) throws VersionDoesNotExistException{\n+    CircularDependencyChecker.checkCircularDependency(this, version, uri);\n+\n+    List<URI> result = getOwnImports(uri, version);\n+    // root can not include anything, otherwise will have circular dependency \n+    if (isRootURI(uri)) {\n+      return result;\n+    }\n+\n+    // The order is already decided in imported List : higher priority appear in the head\n+    List<URI> imported = this.getOwnImports(uri, version);","path":"gobblin-config-management/gobblin-config-core/src/main/java/gobblin/config/common/impl/SimpleConfigStoreResolver.java","position":129,"original_position":129,"commit_id":"5c84de7b8d33747d2132e33a403fa700efdc68ec","original_commit_id":"5c84de7b8d33747d2132e33a403fa700efdc68ec","user":{"login":"tuGithub","id":9965624,"avatar_url":"https://avatars.githubusercontent.com/u/9965624?v=3","gravatar_id":"","url":"https://api.github.com/users/tuGithub","html_url":"https://github.com/tuGithub","followers_url":"https://api.github.com/users/tuGithub/followers","following_url":"https://api.github.com/users/tuGithub/following{/other_user}","gists_url":"https://api.github.com/users/tuGithub/gists{/gist_id}","starred_url":"https://api.github.com/users/tuGithub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuGithub/subscriptions","organizations_url":"https://api.github.com/users/tuGithub/orgs","repos_url":"https://api.github.com/users/tuGithub/repos","events_url":"https://api.github.com/users/tuGithub/events{/privacy}","received_events_url":"https://api.github.com/users/tuGithub/received_events","type":"User","site_admin":false},"body":"fixed","created_at":"2015-12-18T00:23:07Z","updated_at":"2015-12-18T00:23:07Z","html_url":"https://github.com/linkedin/gobblin/pull/531#discussion_r47980939","pull_request_url":"https://api.github.com/repos/linkedin/gobblin/pulls/531","_links":{"self":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/comments/47980939"},"html":{"href":"https://github.com/linkedin/gobblin/pull/531#discussion_r47980939"},"pull_request":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/531"}}},"pull_request":{"url":"https://api.github.com/repos/linkedin/gobblin/pulls/531","id":53785759,"html_url":"https://github.com/linkedin/gobblin/pull/531","diff_url":"https://github.com/linkedin/gobblin/pull/531.diff","patch_url":"https://github.com/linkedin/gobblin/pull/531.patch","issue_url":"https://api.github.com/repos/linkedin/gobblin/issues/531","number":531,"state":"open","locked":false,"title":"config management common impl","user":{"login":"tuGithub","id":9965624,"avatar_url":"https://avatars.githubusercontent.com/u/9965624?v=3","gravatar_id":"","url":"https://api.github.com/users/tuGithub","html_url":"https://github.com/tuGithub","followers_url":"https://api.github.com/users/tuGithub/followers","following_url":"https://api.github.com/users/tuGithub/following{/other_user}","gists_url":"https://api.github.com/users/tuGithub/gists{/gist_id}","starred_url":"https://api.github.com/users/tuGithub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuGithub/subscriptions","organizations_url":"https://api.github.com/users/tuGithub/orgs","repos_url":"https://api.github.com/users/tuGithub/repos","events_url":"https://api.github.com/users/tuGithub/events{/privacy}","received_events_url":"https://api.github.com/users/tuGithub/received_events","type":"User","site_admin":false},"body":"@chavdar @ibuenros \r\n\r\nPlease review this PR","created_at":"2015-12-16T00:58:55Z","updated_at":"2015-12-18T00:23:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0231b66b7aa816bcbd015f3364b0c7812a3f5f6c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/linkedin/gobblin/pulls/531/commits","review_comments_url":"https://api.github.com/repos/linkedin/gobblin/pulls/531/comments","review_comment_url":"https://api.github.com/repos/linkedin/gobblin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/linkedin/gobblin/issues/531/comments","statuses_url":"https://api.github.com/repos/linkedin/gobblin/statuses/5c84de7b8d33747d2132e33a403fa700efdc68ec","head":{"label":"tuGithub:configManagement","ref":"configManagement","sha":"5c84de7b8d33747d2132e33a403fa700efdc68ec","user":{"login":"tuGithub","id":9965624,"avatar_url":"https://avatars.githubusercontent.com/u/9965624?v=3","gravatar_id":"","url":"https://api.github.com/users/tuGithub","html_url":"https://github.com/tuGithub","followers_url":"https://api.github.com/users/tuGithub/followers","following_url":"https://api.github.com/users/tuGithub/following{/other_user}","gists_url":"https://api.github.com/users/tuGithub/gists{/gist_id}","starred_url":"https://api.github.com/users/tuGithub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuGithub/subscriptions","organizations_url":"https://api.github.com/users/tuGithub/orgs","repos_url":"https://api.github.com/users/tuGithub/repos","events_url":"https://api.github.com/users/tuGithub/events{/privacy}","received_events_url":"https://api.github.com/users/tuGithub/received_events","type":"User","site_admin":false},"repo":{"id":34822460,"name":"gobblin-1","full_name":"tuGithub/gobblin-1","owner":{"login":"tuGithub","id":9965624,"avatar_url":"https://avatars.githubusercontent.com/u/9965624?v=3","gravatar_id":"","url":"https://api.github.com/users/tuGithub","html_url":"https://github.com/tuGithub","followers_url":"https://api.github.com/users/tuGithub/followers","following_url":"https://api.github.com/users/tuGithub/following{/other_user}","gists_url":"https://api.github.com/users/tuGithub/gists{/gist_id}","starred_url":"https://api.github.com/users/tuGithub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuGithub/subscriptions","organizations_url":"https://api.github.com/users/tuGithub/orgs","repos_url":"https://api.github.com/users/tuGithub/repos","events_url":"https://api.github.com/users/tuGithub/events{/privacy}","received_events_url":"https://api.github.com/users/tuGithub/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tuGithub/gobblin-1","description":"","fork":true,"url":"https://api.github.com/repos/tuGithub/gobblin-1","forks_url":"https://api.github.com/repos/tuGithub/gobblin-1/forks","keys_url":"https://api.github.com/repos/tuGithub/gobblin-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tuGithub/gobblin-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tuGithub/gobblin-1/teams","hooks_url":"https://api.github.com/repos/tuGithub/gobblin-1/hooks","issue_events_url":"https://api.github.com/repos/tuGithub/gobblin-1/issues/events{/number}","events_url":"https://api.github.com/repos/tuGithub/gobblin-1/events","assignees_url":"https://api.github.com/repos/tuGithub/gobblin-1/assignees{/user}","branches_url":"https://api.github.com/repos/tuGithub/gobblin-1/branches{/branch}","tags_url":"https://api.github.com/repos/tuGithub/gobblin-1/tags","blobs_url":"https://api.github.com/repos/tuGithub/gobblin-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tuGithub/gobblin-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tuGithub/gobblin-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/tuGithub/gobblin-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tuGithub/gobblin-1/statuses/{sha}","languages_url":"https://api.github.com/repos/tuGithub/gobblin-1/languages","stargazers_url":"https://api.github.com/repos/tuGithub/gobblin-1/stargazers","contributors_url":"https://api.github.com/repos/tuGithub/gobblin-1/contributors","subscribers_url":"https://api.github.com/repos/tuGithub/gobblin-1/subscribers","subscription_url":"https://api.github.com/repos/tuGithub/gobblin-1/subscription","commits_url":"https://api.github.com/repos/tuGithub/gobblin-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/tuGithub/gobblin-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/tuGithub/gobblin-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/tuGithub/gobblin-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/tuGithub/gobblin-1/contents/{+path}","compare_url":"https://api.github.com/repos/tuGithub/gobblin-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tuGithub/gobblin-1/merges","archive_url":"https://api.github.com/repos/tuGithub/gobblin-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tuGithub/gobblin-1/downloads","issues_url":"https://api.github.com/repos/tuGithub/gobblin-1/issues{/number}","pulls_url":"https://api.github.com/repos/tuGithub/gobblin-1/pulls{/number}","milestones_url":"https://api.github.com/repos/tuGithub/gobblin-1/milestones{/number}","notifications_url":"https://api.github.com/repos/tuGithub/gobblin-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tuGithub/gobblin-1/labels{/name}","releases_url":"https://api.github.com/repos/tuGithub/gobblin-1/releases{/id}","created_at":"2015-04-29T22:53:44Z","updated_at":"2015-04-29T22:53:45Z","pushed_at":"2015-12-17T18:34:15Z","git_url":"git://github.com/tuGithub/gobblin-1.git","ssh_url":"git@github.com:tuGithub/gobblin-1.git","clone_url":"https://github.com/tuGithub/gobblin-1.git","svn_url":"https://github.com/tuGithub/gobblin-1","homepage":null,"size":81443,"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":"linkedin:master","ref":"master","sha":"a5438e6e8e15dc618a6973434a8658423e0ed83b","user":{"login":"linkedin","id":357098,"avatar_url":"https://avatars.githubusercontent.com/u/357098?v=3","gravatar_id":"","url":"https://api.github.com/users/linkedin","html_url":"https://github.com/linkedin","followers_url":"https://api.github.com/users/linkedin/followers","following_url":"https://api.github.com/users/linkedin/following{/other_user}","gists_url":"https://api.github.com/users/linkedin/gists{/gist_id}","starred_url":"https://api.github.com/users/linkedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linkedin/subscriptions","organizations_url":"https://api.github.com/users/linkedin/orgs","repos_url":"https://api.github.com/users/linkedin/repos","events_url":"https://api.github.com/users/linkedin/events{/privacy}","received_events_url":"https://api.github.com/users/linkedin/received_events","type":"Organization","site_admin":false},"repo":{"id":27392543,"name":"gobblin","full_name":"linkedin/gobblin","owner":{"login":"linkedin","id":357098,"avatar_url":"https://avatars.githubusercontent.com/u/357098?v=3","gravatar_id":"","url":"https://api.github.com/users/linkedin","html_url":"https://github.com/linkedin","followers_url":"https://api.github.com/users/linkedin/followers","following_url":"https://api.github.com/users/linkedin/following{/other_user}","gists_url":"https://api.github.com/users/linkedin/gists{/gist_id}","starred_url":"https://api.github.com/users/linkedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linkedin/subscriptions","organizations_url":"https://api.github.com/users/linkedin/orgs","repos_url":"https://api.github.com/users/linkedin/repos","events_url":"https://api.github.com/users/linkedin/events{/privacy}","received_events_url":"https://api.github.com/users/linkedin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/linkedin/gobblin","description":"Universal data ingestion framework for Hadoop.","fork":false,"url":"https://api.github.com/repos/linkedin/gobblin","forks_url":"https://api.github.com/repos/linkedin/gobblin/forks","keys_url":"https://api.github.com/repos/linkedin/gobblin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/linkedin/gobblin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/linkedin/gobblin/teams","hooks_url":"https://api.github.com/repos/linkedin/gobblin/hooks","issue_events_url":"https://api.github.com/repos/linkedin/gobblin/issues/events{/number}","events_url":"https://api.github.com/repos/linkedin/gobblin/events","assignees_url":"https://api.github.com/repos/linkedin/gobblin/assignees{/user}","branches_url":"https://api.github.com/repos/linkedin/gobblin/branches{/branch}","tags_url":"https://api.github.com/repos/linkedin/gobblin/tags","blobs_url":"https://api.github.com/repos/linkedin/gobblin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/linkedin/gobblin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/linkedin/gobblin/git/refs{/sha}","trees_url":"https://api.github.com/repos/linkedin/gobblin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/linkedin/gobblin/statuses/{sha}","languages_url":"https://api.github.com/repos/linkedin/gobblin/languages","stargazers_url":"https://api.github.com/repos/linkedin/gobblin/stargazers","contributors_url":"https://api.github.com/repos/linkedin/gobblin/contributors","subscribers_url":"https://api.github.com/repos/linkedin/gobblin/subscribers","subscription_url":"https://api.github.com/repos/linkedin/gobblin/subscription","commits_url":"https://api.github.com/repos/linkedin/gobblin/commits{/sha}","git_commits_url":"https://api.github.com/repos/linkedin/gobblin/git/commits{/sha}","comments_url":"https://api.github.com/repos/linkedin/gobblin/comments{/number}","issue_comment_url":"https://api.github.com/repos/linkedin/gobblin/issues/comments{/number}","contents_url":"https://api.github.com/repos/linkedin/gobblin/contents/{+path}","compare_url":"https://api.github.com/repos/linkedin/gobblin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/linkedin/gobblin/merges","archive_url":"https://api.github.com/repos/linkedin/gobblin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/linkedin/gobblin/downloads","issues_url":"https://api.github.com/repos/linkedin/gobblin/issues{/number}","pulls_url":"https://api.github.com/repos/linkedin/gobblin/pulls{/number}","milestones_url":"https://api.github.com/repos/linkedin/gobblin/milestones{/number}","notifications_url":"https://api.github.com/repos/linkedin/gobblin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/linkedin/gobblin/labels{/name}","releases_url":"https://api.github.com/repos/linkedin/gobblin/releases{/id}","created_at":"2014-12-01T18:10:50Z","updated_at":"2015-12-16T22:50:54Z","pushed_at":"2015-12-17T23:07:48Z","git_url":"git://github.com/linkedin/gobblin.git","ssh_url":"git@github.com:linkedin/gobblin.git","clone_url":"https://github.com/linkedin/gobblin.git","svn_url":"https://github.com/linkedin/gobblin","homepage":"https://github.com/linkedin/gobblin/wiki","size":159053,"stargazers_count":332,"watchers_count":332,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":131,"mirror_url":null,"open_issues_count":22,"forks":131,"open_issues":22,"watchers":332,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/531"},"html":{"href":"https://github.com/linkedin/gobblin/pull/531"},"issue":{"href":"https://api.github.com/repos/linkedin/gobblin/issues/531"},"comments":{"href":"https://api.github.com/repos/linkedin/gobblin/issues/531/comments"},"review_comments":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/531/comments"},"review_comment":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/531/commits"},"statuses":{"href":"https://api.github.com/repos/linkedin/gobblin/statuses/5c84de7b8d33747d2132e33a403fa700efdc68ec"}}}}