{"action":"created","comment":{"url":"https://api.github.com/repos/caskdata/cdap/pulls/comments/28209268","id":28209268,"diff_hunk":"@@ -61,20 +67,32 @@\n \n   /**\n    * Executes given {@link Program} with the given {@link ProgramOptions} and block until it completed.\n-   * On completion, return the {@link RuntimeContext} of the program.\n+   * On completion, return the {@link Map} of hadoop counters for the program run.\n    *\n    * @throws Exception if execution failed.\n    */\n   @Override\n-  public RuntimeContext runAndWait(Program program, ProgramOptions options) throws Exception {\n+  public Map<String, String> runAndWait(Program program, ProgramOptions options) throws Exception {\n     ProgramController controller = programRunnerFactory.create(ProgramRunnerFactory.Type.MAPREDUCE).run(program,\n                                                                                                         options);\n     if (controller instanceof MapReduceProgramController) {\n-      final RuntimeContext context = ((MapReduceProgramController) controller).getContext();\n-      return executeProgram(controller, context);\n+      MapReduceContext context = ((MapReduceProgramController) controller).getContext();\n+      executeProgram(controller, context);\n+      return getCounterMap(context);\n     } else {\n       throw new IllegalStateException(\"Failed to run program. The controller is not an instance of \" +\n                                         \"MapReduceProgramController\");\n     }\n   }\n+\n+  private Map<String, String> getCounterMap(MapReduceContext context) throws Exception {\n+    Map<String, String> mapCounters = Maps.newHashMap();\n+    Counters counters = ((Job) context.getHadoopJob()).getCounters();\n+    for (CounterGroup group : counters) {\n+      for (Counter counter : group) {\n+        mapCounters.put(group.getName() + \".\" + counter.getName(), Long.toString(counter.getValue()));","path":"cdap-app-fabric/src/main/java/co/cask/cdap/internal/app/runtime/workflow/MapReduceProgramWorkflowRunner.java","position":73,"original_position":73,"commit_id":"e01f0a41c65af21b8367bf55a7c5b60f31b85e61","original_commit_id":"e01f0a41c65af21b8367bf55a7c5b60f31b85e61","user":{"login":"sagarkapare","id":5713570,"avatar_url":"https://avatars.githubusercontent.com/u/5713570?v=3","gravatar_id":"","url":"https://api.github.com/users/sagarkapare","html_url":"https://github.com/sagarkapare","followers_url":"https://api.github.com/users/sagarkapare/followers","following_url":"https://api.github.com/users/sagarkapare/following{/other_user}","gists_url":"https://api.github.com/users/sagarkapare/gists{/gist_id}","starred_url":"https://api.github.com/users/sagarkapare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sagarkapare/subscriptions","organizations_url":"https://api.github.com/users/sagarkapare/orgs","repos_url":"https://api.github.com/users/sagarkapare/repos","events_url":"https://api.github.com/users/sagarkapare/events{/privacy}","received_events_url":"https://api.github.com/users/sagarkapare/received_events","type":"User","site_admin":false},"body":"We are just concatenating the counter group name and counter name to represent the key in the map. We are not recreating group name and counter name from the key, so it does not matter even if the counter name has `.` in it.\r\ne.g. assume the group name is `some.group.name` and counter name is `some.counter.name`. The key in the map will be `some.group.name.some.counter.name`.  We will document the same.","created_at":"2015-04-13T00:14:04Z","updated_at":"2015-04-13T00:14:04Z","html_url":"https://github.com/caskdata/cdap/pull/1997#discussion_r28209268","pull_request_url":"https://api.github.com/repos/caskdata/cdap/pulls/1997","_links":{"self":{"href":"https://api.github.com/repos/caskdata/cdap/pulls/comments/28209268"},"html":{"href":"https://github.com/caskdata/cdap/pull/1997#discussion_r28209268"},"pull_request":{"href":"https://api.github.com/repos/caskdata/cdap/pulls/1997"}}},"pull_request":{"url":"https://api.github.com/repos/caskdata/cdap/pulls/1997","id":33111931,"html_url":"https://github.com/caskdata/cdap/pull/1997","diff_url":"https://github.com/caskdata/cdap/pull/1997.diff","patch_url":"https://github.com/caskdata/cdap/pull/1997.patch","issue_url":"https://api.github.com/repos/caskdata/cdap/issues/1997","number":1997,"state":"open","locked":false,"title":"CDAP-1928,1611 Implementation of passing mapreduce counters to the Condi...","user":{"login":"sagarkapare","id":5713570,"avatar_url":"https://avatars.githubusercontent.com/u/5713570?v=3","gravatar_id":"","url":"https://api.github.com/users/sagarkapare","html_url":"https://github.com/sagarkapare","followers_url":"https://api.github.com/users/sagarkapare/followers","following_url":"https://api.github.com/users/sagarkapare/following{/other_user}","gists_url":"https://api.github.com/users/sagarkapare/gists{/gist_id}","starred_url":"https://api.github.com/users/sagarkapare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sagarkapare/subscriptions","organizations_url":"https://api.github.com/users/sagarkapare/orgs","repos_url":"https://api.github.com/users/sagarkapare/repos","events_url":"https://api.github.com/users/sagarkapare/events{/privacy}","received_events_url":"https://api.github.com/users/sagarkapare/received_events","type":"User","site_admin":false},"body":"...tion node and execution of the condition branches based on them.\r\n\r\nAssociated Jira:\r\n1. https://issues.cask.co/browse/CDAP-1928\r\n2. https://issues.cask.co/browse/CDAP-1611\r\n\r\nHadoop counters are passed as `Map<String, String>` to the `Predicate` in the Condition node. Key of the map represents the concatenation of the counter group name and counter name by `.`, while value represents the value of the counter. \r\n\r\nThis is currently work in progress - no unit tests yet and need more testing on the distributed cluster. \r\n\r\nOpening PR to get the early feedback on the approach.","created_at":"2015-04-11T23:35:53Z","updated_at":"2015-04-13T00:14:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1cb6ec6f5a5c731dc3b841c3cf4a566f97d78b08","assignee":null,"milestone":{"url":"https://api.github.com/repos/caskdata/cdap/milestones/4","html_url":"https://github.com/caskdata/cdap/milestones/3.0.0","labels_url":"https://api.github.com/repos/caskdata/cdap/milestones/4/labels","id":990469,"number":4,"title":"3.0.0","description":null,"creator":{"login":"jwang47","id":1084704,"avatar_url":"https://avatars.githubusercontent.com/u/1084704?v=3","gravatar_id":"","url":"https://api.github.com/users/jwang47","html_url":"https://github.com/jwang47","followers_url":"https://api.github.com/users/jwang47/followers","following_url":"https://api.github.com/users/jwang47/following{/other_user}","gists_url":"https://api.github.com/users/jwang47/gists{/gist_id}","starred_url":"https://api.github.com/users/jwang47/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwang47/subscriptions","organizations_url":"https://api.github.com/users/jwang47/orgs","repos_url":"https://api.github.com/users/jwang47/repos","events_url":"https://api.github.com/users/jwang47/events{/privacy}","received_events_url":"https://api.github.com/users/jwang47/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":119,"state":"open","created_at":"2015-02-23T00:07:53Z","updated_at":"2015-04-12T23:27:15Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/caskdata/cdap/pulls/1997/commits","review_comments_url":"https://api.github.com/repos/caskdata/cdap/pulls/1997/comments","review_comment_url":"https://api.github.com/repos/caskdata/cdap/pulls/comments{/number}","comments_url":"https://api.github.com/repos/caskdata/cdap/issues/1997/comments","statuses_url":"https://api.github.com/repos/caskdata/cdap/statuses/e01f0a41c65af21b8367bf55a7c5b60f31b85e61","head":{"label":"caskdata:feature/if-workflow-driver","ref":"feature/if-workflow-driver","sha":"e01f0a41c65af21b8367bf55a7c5b60f31b85e61","user":{"login":"caskdata","id":8123023,"avatar_url":"https://avatars.githubusercontent.com/u/8123023?v=3","gravatar_id":"","url":"https://api.github.com/users/caskdata","html_url":"https://github.com/caskdata","followers_url":"https://api.github.com/users/caskdata/followers","following_url":"https://api.github.com/users/caskdata/following{/other_user}","gists_url":"https://api.github.com/users/caskdata/gists{/gist_id}","starred_url":"https://api.github.com/users/caskdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caskdata/subscriptions","organizations_url":"https://api.github.com/users/caskdata/orgs","repos_url":"https://api.github.com/users/caskdata/repos","events_url":"https://api.github.com/users/caskdata/events{/privacy}","received_events_url":"https://api.github.com/users/caskdata/received_events","type":"Organization","site_admin":false},"repo":{"id":22542759,"name":"cdap","full_name":"caskdata/cdap","owner":{"login":"caskdata","id":8123023,"avatar_url":"https://avatars.githubusercontent.com/u/8123023?v=3","gravatar_id":"","url":"https://api.github.com/users/caskdata","html_url":"https://github.com/caskdata","followers_url":"https://api.github.com/users/caskdata/followers","following_url":"https://api.github.com/users/caskdata/following{/other_user}","gists_url":"https://api.github.com/users/caskdata/gists{/gist_id}","starred_url":"https://api.github.com/users/caskdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caskdata/subscriptions","organizations_url":"https://api.github.com/users/caskdata/orgs","repos_url":"https://api.github.com/users/caskdata/repos","events_url":"https://api.github.com/users/caskdata/events{/privacy}","received_events_url":"https://api.github.com/users/caskdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/caskdata/cdap","description":"Cask Data Application Platform (CDAP)","fork":false,"url":"https://api.github.com/repos/caskdata/cdap","forks_url":"https://api.github.com/repos/caskdata/cdap/forks","keys_url":"https://api.github.com/repos/caskdata/cdap/keys{/key_id}","collaborators_url":"https://api.github.com/repos/caskdata/cdap/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/caskdata/cdap/teams","hooks_url":"https://api.github.com/repos/caskdata/cdap/hooks","issue_events_url":"https://api.github.com/repos/caskdata/cdap/issues/events{/number}","events_url":"https://api.github.com/repos/caskdata/cdap/events","assignees_url":"https://api.github.com/repos/caskdata/cdap/assignees{/user}","branches_url":"https://api.github.com/repos/caskdata/cdap/branches{/branch}","tags_url":"https://api.github.com/repos/caskdata/cdap/tags","blobs_url":"https://api.github.com/repos/caskdata/cdap/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/caskdata/cdap/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/caskdata/cdap/git/refs{/sha}","trees_url":"https://api.github.com/repos/caskdata/cdap/git/trees{/sha}","statuses_url":"https://api.github.com/repos/caskdata/cdap/statuses/{sha}","languages_url":"https://api.github.com/repos/caskdata/cdap/languages","stargazers_url":"https://api.github.com/repos/caskdata/cdap/stargazers","contributors_url":"https://api.github.com/repos/caskdata/cdap/contributors","subscribers_url":"https://api.github.com/repos/caskdata/cdap/subscribers","subscription_url":"https://api.github.com/repos/caskdata/cdap/subscription","commits_url":"https://api.github.com/repos/caskdata/cdap/commits{/sha}","git_commits_url":"https://api.github.com/repos/caskdata/cdap/git/commits{/sha}","comments_url":"https://api.github.com/repos/caskdata/cdap/comments{/number}","issue_comment_url":"https://api.github.com/repos/caskdata/cdap/issues/comments{/number}","contents_url":"https://api.github.com/repos/caskdata/cdap/contents/{+path}","compare_url":"https://api.github.com/repos/caskdata/cdap/compare/{base}...{head}","merges_url":"https://api.github.com/repos/caskdata/cdap/merges","archive_url":"https://api.github.com/repos/caskdata/cdap/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/caskdata/cdap/downloads","issues_url":"https://api.github.com/repos/caskdata/cdap/issues{/number}","pulls_url":"https://api.github.com/repos/caskdata/cdap/pulls{/number}","milestones_url":"https://api.github.com/repos/caskdata/cdap/milestones{/number}","notifications_url":"https://api.github.com/repos/caskdata/cdap/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/caskdata/cdap/labels{/name}","releases_url":"https://api.github.com/repos/caskdata/cdap/releases{/id}","created_at":"2014-08-02T09:00:10Z","updated_at":"2015-04-12T23:27:16Z","pushed_at":"2015-04-13T00:01:16Z","git_url":"git://github.com/caskdata/cdap.git","ssh_url":"git@github.com:caskdata/cdap.git","clone_url":"https://github.com/caskdata/cdap.git","svn_url":"https://github.com/caskdata/cdap","homepage":"http://cdap.io","size":839459,"stargazers_count":41,"watchers_count":41,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":12,"mirror_url":null,"open_issues_count":20,"forks":12,"open_issues":20,"watchers":41,"default_branch":"develop"}},"base":{"label":"caskdata:develop","ref":"develop","sha":"5d6e96da04117eb466971e4b19e31ecda841d54b","user":{"login":"caskdata","id":8123023,"avatar_url":"https://avatars.githubusercontent.com/u/8123023?v=3","gravatar_id":"","url":"https://api.github.com/users/caskdata","html_url":"https://github.com/caskdata","followers_url":"https://api.github.com/users/caskdata/followers","following_url":"https://api.github.com/users/caskdata/following{/other_user}","gists_url":"https://api.github.com/users/caskdata/gists{/gist_id}","starred_url":"https://api.github.com/users/caskdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caskdata/subscriptions","organizations_url":"https://api.github.com/users/caskdata/orgs","repos_url":"https://api.github.com/users/caskdata/repos","events_url":"https://api.github.com/users/caskdata/events{/privacy}","received_events_url":"https://api.github.com/users/caskdata/received_events","type":"Organization","site_admin":false},"repo":{"id":22542759,"name":"cdap","full_name":"caskdata/cdap","owner":{"login":"caskdata","id":8123023,"avatar_url":"https://avatars.githubusercontent.com/u/8123023?v=3","gravatar_id":"","url":"https://api.github.com/users/caskdata","html_url":"https://github.com/caskdata","followers_url":"https://api.github.com/users/caskdata/followers","following_url":"https://api.github.com/users/caskdata/following{/other_user}","gists_url":"https://api.github.com/users/caskdata/gists{/gist_id}","starred_url":"https://api.github.com/users/caskdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caskdata/subscriptions","organizations_url":"https://api.github.com/users/caskdata/orgs","repos_url":"https://api.github.com/users/caskdata/repos","events_url":"https://api.github.com/users/caskdata/events{/privacy}","received_events_url":"https://api.github.com/users/caskdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/caskdata/cdap","description":"Cask Data Application Platform (CDAP)","fork":false,"url":"https://api.github.com/repos/caskdata/cdap","forks_url":"https://api.github.com/repos/caskdata/cdap/forks","keys_url":"https://api.github.com/repos/caskdata/cdap/keys{/key_id}","collaborators_url":"https://api.github.com/repos/caskdata/cdap/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/caskdata/cdap/teams","hooks_url":"https://api.github.com/repos/caskdata/cdap/hooks","issue_events_url":"https://api.github.com/repos/caskdata/cdap/issues/events{/number}","events_url":"https://api.github.com/repos/caskdata/cdap/events","assignees_url":"https://api.github.com/repos/caskdata/cdap/assignees{/user}","branches_url":"https://api.github.com/repos/caskdata/cdap/branches{/branch}","tags_url":"https://api.github.com/repos/caskdata/cdap/tags","blobs_url":"https://api.github.com/repos/caskdata/cdap/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/caskdata/cdap/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/caskdata/cdap/git/refs{/sha}","trees_url":"https://api.github.com/repos/caskdata/cdap/git/trees{/sha}","statuses_url":"https://api.github.com/repos/caskdata/cdap/statuses/{sha}","languages_url":"https://api.github.com/repos/caskdata/cdap/languages","stargazers_url":"https://api.github.com/repos/caskdata/cdap/stargazers","contributors_url":"https://api.github.com/repos/caskdata/cdap/contributors","subscribers_url":"https://api.github.com/repos/caskdata/cdap/subscribers","subscription_url":"https://api.github.com/repos/caskdata/cdap/subscription","commits_url":"https://api.github.com/repos/caskdata/cdap/commits{/sha}","git_commits_url":"https://api.github.com/repos/caskdata/cdap/git/commits{/sha}","comments_url":"https://api.github.com/repos/caskdata/cdap/comments{/number}","issue_comment_url":"https://api.github.com/repos/caskdata/cdap/issues/comments{/number}","contents_url":"https://api.github.com/repos/caskdata/cdap/contents/{+path}","compare_url":"https://api.github.com/repos/caskdata/cdap/compare/{base}...{head}","merges_url":"https://api.github.com/repos/caskdata/cdap/merges","archive_url":"https://api.github.com/repos/caskdata/cdap/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/caskdata/cdap/downloads","issues_url":"https://api.github.com/repos/caskdata/cdap/issues{/number}","pulls_url":"https://api.github.com/repos/caskdata/cdap/pulls{/number}","milestones_url":"https://api.github.com/repos/caskdata/cdap/milestones{/number}","notifications_url":"https://api.github.com/repos/caskdata/cdap/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/caskdata/cdap/labels{/name}","releases_url":"https://api.github.com/repos/caskdata/cdap/releases{/id}","created_at":"2014-08-02T09:00:10Z","updated_at":"2015-04-12T23:27:16Z","pushed_at":"2015-04-13T00:01:16Z","git_url":"git://github.com/caskdata/cdap.git","ssh_url":"git@github.com:caskdata/cdap.git","clone_url":"https://github.com/caskdata/cdap.git","svn_url":"https://github.com/caskdata/cdap","homepage":"http://cdap.io","size":839459,"stargazers_count":41,"watchers_count":41,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":12,"mirror_url":null,"open_issues_count":20,"forks":12,"open_issues":20,"watchers":41,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/caskdata/cdap/pulls/1997"},"html":{"href":"https://github.com/caskdata/cdap/pull/1997"},"issue":{"href":"https://api.github.com/repos/caskdata/cdap/issues/1997"},"comments":{"href":"https://api.github.com/repos/caskdata/cdap/issues/1997/comments"},"review_comments":{"href":"https://api.github.com/repos/caskdata/cdap/pulls/1997/comments"},"review_comment":{"href":"https://api.github.com/repos/caskdata/cdap/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/caskdata/cdap/pulls/1997/commits"},"statuses":{"href":"https://api.github.com/repos/caskdata/cdap/statuses/e01f0a41c65af21b8367bf55a7c5b60f31b85e61"}}}}