{"action":"created","comment":{"url":"https://api.github.com/repos/linkedin/gobblin/pulls/comments/61162040","id":61162040,"diff_hunk":"@@ -0,0 +1,242 @@\n+/*\n+ * Copyright (C) 2014-2016 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.runtime.locks;\n+\n+import java.io.IOException;\n+import java.nio.file.Paths;\n+import java.util.Map;\n+import java.util.Properties;\n+import java.util.concurrent.ConcurrentMap;\n+import java.util.concurrent.TimeUnit;\n+\n+import com.google.common.annotations.VisibleForTesting;\n+import org.apache.curator.framework.CuratorFramework;\n+import org.apache.curator.framework.CuratorFrameworkFactory;\n+import org.apache.curator.framework.recipes.locks.InterProcessSemaphoreMutex;\n+import org.apache.curator.framework.state.ConnectionState;\n+import org.apache.curator.framework.state.ConnectionStateListener;\n+import org.apache.curator.retry.ExponentialBackoffRetry;\n+\n+import com.google.common.collect.Maps;\n+\n+import gobblin.configuration.ConfigurationKeys;\n+\n+import lombok.extern.slf4j.Slf4j;\n+\n+\n+/**\n+ * An implementation of {@link JobLock} that uses Zookeeper.\n+ *\n+ * @author Joel Baranick\n+ */\n+@Slf4j\n+public class ZookeeperBasedJobLock implements JobLock {\n+  private static final String LOCKS_ROOT_PATH = \"/locks\";\n+  private static final String CONNECTION_STRING_DEFAULT = \"localhost:2181\";\n+  private static final int LOCKS_ACQUIRE_TIMEOUT_MILLISECONDS_DEFAULT = 5000;\n+  private static final int CONNECTION_TIMEOUT_SECONDS_DEFAULT = 30;\n+  private static final int SESSION_TIMEOUT_SECONDS_DEFAULT = 180;\n+  private static final int RETRY_BACKOFF_SECONDS_DEFAULT = 1;\n+  private static final int MAX_RETRY_COUNT_DEFAULT = 10;\n+  private static CuratorFramework curatorFramework;\n+  private static ConcurrentMap<String, JobLockEventListener> lockEventListeners = Maps.newConcurrentMap();\n+  private static Thread curatorFrameworkShutdownHook;\n+\n+  public static final String LOCKS_ACQUIRE_TIMEOUT_MILLISECONDS = \"zookeeper.locks.acquire.timeout.milliseconds\";\n+  public static final String CONNECTION_STRING = \"zookeeper.connection.string\";\n+  public static final String CONNECTION_TIMEOUT_SECONDS = \"zookeeper.connection.timeout.seconds\";\n+  public static final String SESSION_TIMEOUT_SECONDS = \"zookeeper.session.timeout.seconds\";\n+  public static final String RETRY_BACKOFF_SECONDS = \"zookeeper.retry.backoff.seconds\";\n+  public static final String MAX_RETRY_COUNT = \"zookeeper.retry.count.max\";\n+\n+  private String lockPath;\n+  private long lockAcquireTimeoutMilliseconds;\n+  private InterProcessSemaphoreMutex lock;","path":"gobblin-runtime/src/main/java/gobblin/runtime/locks/ZookeeperBasedJobLock.java","position":64,"original_position":64,"commit_id":"e11a7575b42c403a01e61ca3d08765ebd363eaf3","original_commit_id":"e11a7575b42c403a01e61ca3d08765ebd363eaf3","user":{"login":"sahilTakiar","id":1282583,"avatar_url":"https://avatars.githubusercontent.com/u/1282583?v=3","gravatar_id":"","url":"https://api.github.com/users/sahilTakiar","html_url":"https://github.com/sahilTakiar","followers_url":"https://api.github.com/users/sahilTakiar/followers","following_url":"https://api.github.com/users/sahilTakiar/following{/other_user}","gists_url":"https://api.github.com/users/sahilTakiar/gists{/gist_id}","starred_url":"https://api.github.com/users/sahilTakiar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sahilTakiar/subscriptions","organizations_url":"https://api.github.com/users/sahilTakiar/orgs","repos_url":"https://api.github.com/users/sahilTakiar/repos","events_url":"https://api.github.com/users/sahilTakiar/events{/privacy}","received_events_url":"https://api.github.com/users/sahilTakiar/received_events","type":"User","site_admin":false},"body":"Change variable declaration to interface `InterProcessLock`","created_at":"2016-04-26T20:52:12Z","updated_at":"2016-04-26T20:52:13Z","html_url":"https://github.com/linkedin/gobblin/pull/828#discussion_r61162040","pull_request_url":"https://api.github.com/repos/linkedin/gobblin/pulls/828","_links":{"self":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/comments/61162040"},"html":{"href":"https://github.com/linkedin/gobblin/pull/828#discussion_r61162040"},"pull_request":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/828"}}},"pull_request":{"url":"https://api.github.com/repos/linkedin/gobblin/pulls/828","id":62460257,"html_url":"https://github.com/linkedin/gobblin/pull/828","diff_url":"https://github.com/linkedin/gobblin/pull/828.diff","patch_url":"https://github.com/linkedin/gobblin/pull/828.patch","issue_url":"https://api.github.com/repos/linkedin/gobblin/issues/828","number":828,"state":"open","locked":false,"title":"Add zookeeper based job lock for gobblin yarn","user":{"login":"kadaan","id":1904898,"avatar_url":"https://avatars.githubusercontent.com/u/1904898?v=3","gravatar_id":"","url":"https://api.github.com/users/kadaan","html_url":"https://github.com/kadaan","followers_url":"https://api.github.com/users/kadaan/followers","following_url":"https://api.github.com/users/kadaan/following{/other_user}","gists_url":"https://api.github.com/users/kadaan/gists{/gist_id}","starred_url":"https://api.github.com/users/kadaan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kadaan/subscriptions","organizations_url":"https://api.github.com/users/kadaan/orgs","repos_url":"https://api.github.com/users/kadaan/repos","events_url":"https://api.github.com/users/kadaan/events{/privacy}","received_events_url":"https://api.github.com/users/kadaan/received_events","type":"User","site_admin":false},"body":"@sahilTakiar Here is the `ZookeeperBasedJobLock` that we discussed in #754.  The only part I'm a little unsure about is the cancellation of a running job if the connection to ZK is lost.  I think it is needed to ensure that duplicate jobs are not running, but I'm not sure if the mean of cancellation is correct.","created_at":"2016-03-10T21:38:40Z","updated_at":"2016-04-26T20:52:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4761f187b44ef13e977a4dba36110d19f2f826e5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/linkedin/gobblin/pulls/828/commits","review_comments_url":"https://api.github.com/repos/linkedin/gobblin/pulls/828/comments","review_comment_url":"https://api.github.com/repos/linkedin/gobblin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/linkedin/gobblin/issues/828/comments","statuses_url":"https://api.github.com/repos/linkedin/gobblin/statuses/e11a7575b42c403a01e61ca3d08765ebd363eaf3","head":{"label":"kadaan:ZookeeperJobLock","ref":"ZookeeperJobLock","sha":"e11a7575b42c403a01e61ca3d08765ebd363eaf3","user":{"login":"kadaan","id":1904898,"avatar_url":"https://avatars.githubusercontent.com/u/1904898?v=3","gravatar_id":"","url":"https://api.github.com/users/kadaan","html_url":"https://github.com/kadaan","followers_url":"https://api.github.com/users/kadaan/followers","following_url":"https://api.github.com/users/kadaan/following{/other_user}","gists_url":"https://api.github.com/users/kadaan/gists{/gist_id}","starred_url":"https://api.github.com/users/kadaan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kadaan/subscriptions","organizations_url":"https://api.github.com/users/kadaan/orgs","repos_url":"https://api.github.com/users/kadaan/repos","events_url":"https://api.github.com/users/kadaan/events{/privacy}","received_events_url":"https://api.github.com/users/kadaan/received_events","type":"User","site_admin":false},"repo":{"id":47274294,"name":"gobblin","full_name":"kadaan/gobblin","owner":{"login":"kadaan","id":1904898,"avatar_url":"https://avatars.githubusercontent.com/u/1904898?v=3","gravatar_id":"","url":"https://api.github.com/users/kadaan","html_url":"https://github.com/kadaan","followers_url":"https://api.github.com/users/kadaan/followers","following_url":"https://api.github.com/users/kadaan/following{/other_user}","gists_url":"https://api.github.com/users/kadaan/gists{/gist_id}","starred_url":"https://api.github.com/users/kadaan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kadaan/subscriptions","organizations_url":"https://api.github.com/users/kadaan/orgs","repos_url":"https://api.github.com/users/kadaan/repos","events_url":"https://api.github.com/users/kadaan/events{/privacy}","received_events_url":"https://api.github.com/users/kadaan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kadaan/gobblin","description":"Universal data ingestion framework for Hadoop.","fork":true,"url":"https://api.github.com/repos/kadaan/gobblin","forks_url":"https://api.github.com/repos/kadaan/gobblin/forks","keys_url":"https://api.github.com/repos/kadaan/gobblin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kadaan/gobblin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kadaan/gobblin/teams","hooks_url":"https://api.github.com/repos/kadaan/gobblin/hooks","issue_events_url":"https://api.github.com/repos/kadaan/gobblin/issues/events{/number}","events_url":"https://api.github.com/repos/kadaan/gobblin/events","assignees_url":"https://api.github.com/repos/kadaan/gobblin/assignees{/user}","branches_url":"https://api.github.com/repos/kadaan/gobblin/branches{/branch}","tags_url":"https://api.github.com/repos/kadaan/gobblin/tags","blobs_url":"https://api.github.com/repos/kadaan/gobblin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kadaan/gobblin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kadaan/gobblin/git/refs{/sha}","trees_url":"https://api.github.com/repos/kadaan/gobblin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kadaan/gobblin/statuses/{sha}","languages_url":"https://api.github.com/repos/kadaan/gobblin/languages","stargazers_url":"https://api.github.com/repos/kadaan/gobblin/stargazers","contributors_url":"https://api.github.com/repos/kadaan/gobblin/contributors","subscribers_url":"https://api.github.com/repos/kadaan/gobblin/subscribers","subscription_url":"https://api.github.com/repos/kadaan/gobblin/subscription","commits_url":"https://api.github.com/repos/kadaan/gobblin/commits{/sha}","git_commits_url":"https://api.github.com/repos/kadaan/gobblin/git/commits{/sha}","comments_url":"https://api.github.com/repos/kadaan/gobblin/comments{/number}","issue_comment_url":"https://api.github.com/repos/kadaan/gobblin/issues/comments{/number}","contents_url":"https://api.github.com/repos/kadaan/gobblin/contents/{+path}","compare_url":"https://api.github.com/repos/kadaan/gobblin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kadaan/gobblin/merges","archive_url":"https://api.github.com/repos/kadaan/gobblin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kadaan/gobblin/downloads","issues_url":"https://api.github.com/repos/kadaan/gobblin/issues{/number}","pulls_url":"https://api.github.com/repos/kadaan/gobblin/pulls{/number}","milestones_url":"https://api.github.com/repos/kadaan/gobblin/milestones{/number}","notifications_url":"https://api.github.com/repos/kadaan/gobblin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kadaan/gobblin/labels{/name}","releases_url":"https://api.github.com/repos/kadaan/gobblin/releases{/id}","deployments_url":"https://api.github.com/repos/kadaan/gobblin/deployments","created_at":"2015-12-02T16:40:10Z","updated_at":"2016-01-11T23:41:37Z","pushed_at":"2016-04-20T17:15:51Z","git_url":"git://github.com/kadaan/gobblin.git","ssh_url":"git@github.com:kadaan/gobblin.git","clone_url":"https://github.com/kadaan/gobblin.git","svn_url":"https://github.com/kadaan/gobblin","homepage":"https://github.com/linkedin/gobblin/wiki","size":85880,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"linkedin:master","ref":"master","sha":"2f11078b523fd18b3af047ecd3c9538cb0e283ee","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}","deployments_url":"https://api.github.com/repos/linkedin/gobblin/deployments","created_at":"2014-12-01T18:10:50Z","updated_at":"2016-04-26T03:28:45Z","pushed_at":"2016-04-25T20:56:44Z","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":165568,"stargazers_count":539,"watchers_count":539,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":211,"mirror_url":null,"open_issues_count":83,"forks":211,"open_issues":83,"watchers":539,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/828"},"html":{"href":"https://github.com/linkedin/gobblin/pull/828"},"issue":{"href":"https://api.github.com/repos/linkedin/gobblin/issues/828"},"comments":{"href":"https://api.github.com/repos/linkedin/gobblin/issues/828/comments"},"review_comments":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/828/comments"},"review_comment":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/linkedin/gobblin/pulls/828/commits"},"statuses":{"href":"https://api.github.com/repos/linkedin/gobblin/statuses/e11a7575b42c403a01e61ca3d08765ebd363eaf3"}}}}