Skip to content

Commit 28b0906

Browse files
committed
[HUDI-3638] Make ZookeeperBasedLockProvider serializable
1 parent ff13665 commit 28b0906

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/transaction/lock/ZookeeperBasedLockProvider.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,25 @@
1818

1919
package org.apache.hudi.client.transaction.lock;
2020

21-
import org.apache.curator.framework.CuratorFramework;
22-
import org.apache.curator.framework.CuratorFrameworkFactory;
23-
import org.apache.curator.framework.imps.CuratorFrameworkState;
24-
import org.apache.curator.framework.recipes.locks.InterProcessMutex;
25-
import org.apache.curator.retry.BoundedExponentialBackoffRetry;
26-
import org.apache.hadoop.conf.Configuration;
2721
import org.apache.hudi.common.config.LockConfiguration;
2822
import org.apache.hudi.common.lock.LockProvider;
2923
import org.apache.hudi.common.lock.LockState;
3024
import org.apache.hudi.common.util.StringUtils;
3125
import org.apache.hudi.common.util.ValidationUtils;
3226
import org.apache.hudi.exception.HoodieLockException;
27+
28+
import org.apache.curator.framework.CuratorFramework;
29+
import org.apache.curator.framework.CuratorFrameworkFactory;
30+
import org.apache.curator.framework.imps.CuratorFrameworkState;
31+
import org.apache.curator.framework.recipes.locks.InterProcessMutex;
32+
import org.apache.curator.retry.BoundedExponentialBackoffRetry;
33+
import org.apache.hadoop.conf.Configuration;
3334
import org.apache.log4j.LogManager;
3435
import org.apache.log4j.Logger;
3536

3637
import javax.annotation.concurrent.NotThreadSafe;
38+
39+
import java.io.Serializable;
3740
import java.util.concurrent.TimeUnit;
3841

3942
import static org.apache.hudi.common.config.LockConfiguration.DEFAULT_ZK_CONNECTION_TIMEOUT_MS;
@@ -52,11 +55,11 @@
5255
* using zookeeper. Users need to have a Zookeeper cluster deployed to be able to use this lock.
5356
*/
5457
@NotThreadSafe
55-
public class ZookeeperBasedLockProvider implements LockProvider<InterProcessMutex> {
58+
public class ZookeeperBasedLockProvider implements LockProvider<InterProcessMutex>, Serializable {
5659

5760
private static final Logger LOG = LogManager.getLogger(ZookeeperBasedLockProvider.class);
5861

59-
private final CuratorFramework curatorFrameworkClient;
62+
private final transient CuratorFramework curatorFrameworkClient;
6063
private volatile InterProcessMutex lock = null;
6164
protected LockConfiguration lockConfiguration;
6265

0 commit comments

Comments
 (0)