{"action":"created","comment":{"url":"https://api.github.com/repos/linkedin/gobblin/pulls/comments/40603895","id":40603895,"diff_hunk":"@@ -0,0 +1,89 @@\n+package gobblin.compaction.event;\n+\n+import java.io.IOException;\n+\n+import org.apache.hadoop.fs.FileStatus;\n+import org.apache.hadoop.fs.FileSystem;\n+import org.apache.hadoop.fs.Path;\n+import org.apache.hadoop.mapreduce.Counter;\n+import org.apache.hadoop.mapreduce.Counters;\n+import org.apache.hadoop.mapreduce.Job;\n+\n+import gobblin.compaction.mapreduce.avro.AvroKeyDedupReducer;\n+import gobblin.configuration.ConfigurationKeys;\n+import gobblin.configuration.State;\n+import gobblin.metrics.event.sla.SlaEventKeys;\n+\n+/**\n+ * Helper class to populate sla event metadata in state.\n+ */\n+public class CompactionSlaEventHelper {\n+\n+  public static void populateState(State state , Job job, FileSystem fs) {\n+    setDatasetUrn(state);\n+    setPartition(state);\n+    setDedupeStatus(state);\n+    setPreviousPublishTime(state, fs);\n+    setRecordCount(state, job);\n+    setUpstreamTimeStamp(state, fs);\n+  }\n+\n+  private static void setDatasetUrn(State state) {\n+    state.setProp(SlaEventKeys.DATASET_URN_KEY, new Path(state.getProp(ConfigurationKeys.COMPACTION_DEST_DIR),\n+        state.getProp(ConfigurationKeys.COMPACTION_TOPIC)).toString());\n+  }\n+\n+  private static void setPartition(State state) {\n+    state.setProp(SlaEventKeys.PARTITION_KEY, state.getProp(ConfigurationKeys.COMPACTION_JOB_DEST_PARTITION));\n+  }\n+\n+  private static void setUpstreamTimeStamp(State state, FileSystem fs) {\n+\n+    String inputDirectory = state.getProp(ConfigurationKeys.COMPACTION_JOB_INPUT_DIR);\n+    try {\n+      FileStatus fileStatus = fs.getFileStatus(new Path(inputDirectory));\n+      state.setProp(SlaEventKeys.UPSTREAM_TS_KEY, Long.toString(fileStatus.getModificationTime()));\n+    } catch (IOException e) {\n+    }\n+  }\n+\n+  private static void setPreviousPublishTime(State state, FileSystem fs) {\n+\n+    Path compactionCompletePath =\n+        new Path(state.getProp(ConfigurationKeys.COMPACTION_JOB_DEST_DIR),\n+            ConfigurationKeys.COMPACTION_COMPLETE_FILE_NAME);\n+\n+    try {\n+      FileStatus fileStatus = fs.getFileStatus(compactionCompletePath);\n+      state.setProp(SlaEventKeys.PREVIOUS_PUBLISH_TS_KEY, Long.toString(fileStatus.getModificationTime()));\n+    } catch (IOException e) {\n+    }\n+  }\n+\n+  private static void setDedupeStatus(State state) {\n+    if (state.getPropAsBoolean(ConfigurationKeys.COMPACTION_DEDUPLICATE,\n+        ConfigurationKeys.DEFAULT_COMPACTION_DEDUPLICATE)) {\n+      state.setProp(SlaEventKeys.DEDUPE_STATUS_KEY, DedupeStatus.DEDUPED);\n+","path":"gobblin-compaction/src/main/java/gobblin/compaction/event/CompactionSlaEventHelper.java","position":67,"original_position":67,"commit_id":"92627cd1e12fd1f194979fd993bc98758708c0ef","original_commit_id":"92627cd1e12fd1f194979fd993bc98758708c0ef","user":{"login":"ibuenros","id":1364112,"avatar_url":"https://avatars.githubusercontent.com/u/1364112?v=3","gravatar_id":"","url":"https://api.github.com/users/ibuenros","html_url":"https://github.com/ibuenros","followers_url":"https://api.github.com/users/ibuenros/followers","following_url":"https://api.github.com/users/ibuenros/following{/other_user}","gists_url":"https://api.github.com/users/ibuenros/gists{/gist_id}","starred_url":"https://api.github.com/users/ibuenros/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ibuenros/subscriptions","organizations_url":"https://api.github.com/users/ibuenros/orgs","repos_url":"https://api.github.com/users/ibuenros/repos","events_url":"https://api.github.com/users/ibuenros/events{/privacy}","received_events_url":"https://api.github.com/users/ibuenros/received_events","type":"User","site_admin":false},"body":"are you supposed to return here?","created_at":"2015-09-28T20:51:42Z","updated_at":"2015-09-28T20:51:42Z","html_url":"https://github.com/linkedin/gobblin/pull/341#discussion_r40603895","pull_request_url":"https://api.github.com/repos/linkedin/gobblin/pulls/341","_links":{"self":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/comments/40603895"},"html":{"href":"https://github.com/linkedin/gobblin/pull/341#discussion_r40603895"},"pull_request":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/341"}}},"pull_request":{"url":"https://api.github.com/repos/linkedin/gobblin/pulls/341","id":45846603,"html_url":"https://github.com/linkedin/gobblin/pull/341","diff_url":"https://github.com/linkedin/gobblin/pull/341.diff","patch_url":"https://github.com/linkedin/gobblin/pull/341.patch","issue_url":"https://api.github.com/repos/linkedin/gobblin/issues/341","number":341,"state":"open","locked":false,"title":"Defining Sla Event metadata","user":{"login":"pcadabam","id":1166372,"avatar_url":"https://avatars.githubusercontent.com/u/1166372?v=3","gravatar_id":"","url":"https://api.github.com/users/pcadabam","html_url":"https://github.com/pcadabam","followers_url":"https://api.github.com/users/pcadabam/followers","following_url":"https://api.github.com/users/pcadabam/following{/other_user}","gists_url":"https://api.github.com/users/pcadabam/gists{/gist_id}","starred_url":"https://api.github.com/users/pcadabam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pcadabam/subscriptions","organizations_url":"https://api.github.com/users/pcadabam/orgs","repos_url":"https://api.github.com/users/pcadabam/repos","events_url":"https://api.github.com/users/pcadabam/events{/privacy}","received_events_url":"https://api.github.com/users/pcadabam/received_events","type":"User","site_admin":false},"body":"@ibuenros @chavdar  can you take a look at this?\r\n\r\nOverview\r\n- The change defines metadata required in an SLA event. An SLA event must have datasetUrn, partition, originTs and upstreamTs\r\n- An SLA event can also have additional optional metadata like completenessPercentage, recordCount etc. See SlaEventKeys.java. Optional metadata is not applicable to all ETL flows.\r\n- Any ETL flow can extend the abstract class SlaEvent and implement the getters for datasetUrn, partition, originTs, upstreamTs. The SlaEvent class does not expose the key names for any metadata. This promises a fixed schema for an SlaEvent.\r\n- Next, we want to define and Arvo schema for the sla event. This change will still emit a GobblinTrackingEvent.\r\n\r\nCompaction changes\r\n- Enabled metrics/events for MRCompactor job\r\n- emit an SLA event when daily compaction is completed. See CompactionSlaEvent.java","created_at":"2015-09-24T00:07:58Z","updated_at":"2015-09-28T20:51:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"33e6b655bb5c0706a0360a547fe252ffede719cb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/linkedin/gobblin/pulls/341/commits","review_comments_url":"https://api.github.com/repos/linkedin/gobblin/pulls/341/comments","review_comment_url":"https://api.github.com/repos/linkedin/gobblin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/linkedin/gobblin/issues/341/comments","statuses_url":"https://api.github.com/repos/linkedin/gobblin/statuses/92627cd1e12fd1f194979fd993bc98758708c0ef","head":{"label":"pcadabam:master","ref":"master","sha":"92627cd1e12fd1f194979fd993bc98758708c0ef","user":{"login":"pcadabam","id":1166372,"avatar_url":"https://avatars.githubusercontent.com/u/1166372?v=3","gravatar_id":"","url":"https://api.github.com/users/pcadabam","html_url":"https://github.com/pcadabam","followers_url":"https://api.github.com/users/pcadabam/followers","following_url":"https://api.github.com/users/pcadabam/following{/other_user}","gists_url":"https://api.github.com/users/pcadabam/gists{/gist_id}","starred_url":"https://api.github.com/users/pcadabam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pcadabam/subscriptions","organizations_url":"https://api.github.com/users/pcadabam/orgs","repos_url":"https://api.github.com/users/pcadabam/repos","events_url":"https://api.github.com/users/pcadabam/events{/privacy}","received_events_url":"https://api.github.com/users/pcadabam/received_events","type":"User","site_admin":false},"repo":{"id":36956709,"name":"gobblin","full_name":"pcadabam/gobblin","owner":{"login":"pcadabam","id":1166372,"avatar_url":"https://avatars.githubusercontent.com/u/1166372?v=3","gravatar_id":"","url":"https://api.github.com/users/pcadabam","html_url":"https://github.com/pcadabam","followers_url":"https://api.github.com/users/pcadabam/followers","following_url":"https://api.github.com/users/pcadabam/following{/other_user}","gists_url":"https://api.github.com/users/pcadabam/gists{/gist_id}","starred_url":"https://api.github.com/users/pcadabam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pcadabam/subscriptions","organizations_url":"https://api.github.com/users/pcadabam/orgs","repos_url":"https://api.github.com/users/pcadabam/repos","events_url":"https://api.github.com/users/pcadabam/events{/privacy}","received_events_url":"https://api.github.com/users/pcadabam/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pcadabam/gobblin","description":"","fork":true,"url":"https://api.github.com/repos/pcadabam/gobblin","forks_url":"https://api.github.com/repos/pcadabam/gobblin/forks","keys_url":"https://api.github.com/repos/pcadabam/gobblin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pcadabam/gobblin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pcadabam/gobblin/teams","hooks_url":"https://api.github.com/repos/pcadabam/gobblin/hooks","issue_events_url":"https://api.github.com/repos/pcadabam/gobblin/issues/events{/number}","events_url":"https://api.github.com/repos/pcadabam/gobblin/events","assignees_url":"https://api.github.com/repos/pcadabam/gobblin/assignees{/user}","branches_url":"https://api.github.com/repos/pcadabam/gobblin/branches{/branch}","tags_url":"https://api.github.com/repos/pcadabam/gobblin/tags","blobs_url":"https://api.github.com/repos/pcadabam/gobblin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pcadabam/gobblin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pcadabam/gobblin/git/refs{/sha}","trees_url":"https://api.github.com/repos/pcadabam/gobblin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pcadabam/gobblin/statuses/{sha}","languages_url":"https://api.github.com/repos/pcadabam/gobblin/languages","stargazers_url":"https://api.github.com/repos/pcadabam/gobblin/stargazers","contributors_url":"https://api.github.com/repos/pcadabam/gobblin/contributors","subscribers_url":"https://api.github.com/repos/pcadabam/gobblin/subscribers","subscription_url":"https://api.github.com/repos/pcadabam/gobblin/subscription","commits_url":"https://api.github.com/repos/pcadabam/gobblin/commits{/sha}","git_commits_url":"https://api.github.com/repos/pcadabam/gobblin/git/commits{/sha}","comments_url":"https://api.github.com/repos/pcadabam/gobblin/comments{/number}","issue_comment_url":"https://api.github.com/repos/pcadabam/gobblin/issues/comments{/number}","contents_url":"https://api.github.com/repos/pcadabam/gobblin/contents/{+path}","compare_url":"https://api.github.com/repos/pcadabam/gobblin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pcadabam/gobblin/merges","archive_url":"https://api.github.com/repos/pcadabam/gobblin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pcadabam/gobblin/downloads","issues_url":"https://api.github.com/repos/pcadabam/gobblin/issues{/number}","pulls_url":"https://api.github.com/repos/pcadabam/gobblin/pulls{/number}","milestones_url":"https://api.github.com/repos/pcadabam/gobblin/milestones{/number}","notifications_url":"https://api.github.com/repos/pcadabam/gobblin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pcadabam/gobblin/labels{/name}","releases_url":"https://api.github.com/repos/pcadabam/gobblin/releases{/id}","created_at":"2015-06-05T21:39:40Z","updated_at":"2015-06-05T21:39:42Z","pushed_at":"2015-09-25T22:18:44Z","git_url":"git://github.com/pcadabam/gobblin.git","ssh_url":"git@github.com:pcadabam/gobblin.git","clone_url":"https://github.com/pcadabam/gobblin.git","svn_url":"https://github.com/pcadabam/gobblin","homepage":null,"size":78838,"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":"474831ec5aac0efd7eefdf2ff656008624b6f5b2","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-09-28T18:51:54Z","pushed_at":"2015-09-28T20:40:56Z","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":161379,"stargazers_count":195,"watchers_count":195,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":68,"mirror_url":null,"open_issues_count":14,"forks":68,"open_issues":14,"watchers":195,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/341"},"html":{"href":"https://github.com/linkedin/gobblin/pull/341"},"issue":{"href":"https://api.github.com/repos/linkedin/gobblin/issues/341"},"comments":{"href":"https://api.github.com/repos/linkedin/gobblin/issues/341/comments"},"review_comments":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/341/comments"},"review_comment":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/341/commits"},"statuses":{"href":"https://api.github.com/repos/linkedin/gobblin/statuses/92627cd1e12fd1f194979fd993bc98758708c0ef"}}}}