From 0226f9f97ee2fd9c1d89b687dee7a71b7299b459 Mon Sep 17 00:00:00 2001 From: CalvinKirs Date: Thu, 14 May 2020 19:06:46 +0800 Subject: [PATCH] Deprecated method changes (#2706) Co-authored-by: dailidong --- .../dolphinscheduler/service/zk/ZookeeperOperator.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/zk/ZookeeperOperator.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/zk/ZookeeperOperator.java index a2cabce805..cd479d44cc 100644 --- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/zk/ZookeeperOperator.java +++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/zk/ZookeeperOperator.java @@ -20,6 +20,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.framework.api.ACLProvider; +import org.apache.curator.framework.api.transaction.CuratorOp; import org.apache.curator.framework.state.ConnectionState; import org.apache.curator.retry.ExponentialBackoffRetry; import org.apache.curator.utils.CloseableUtils; @@ -171,7 +172,11 @@ public class ZookeeperOperator implements InitializingBean { public void update(final String key, final String value) { try { - zkClient.inTransaction().check().forPath(key).and().setData().forPath(key, value.getBytes(StandardCharsets.UTF_8)).and().commit(); + + CuratorOp check = zkClient.transactionOp().check().forPath(key); + CuratorOp setData = zkClient.transactionOp().setData().forPath(key, value.getBytes(StandardCharsets.UTF_8)); + zkClient.transaction().forOperations(check, setData); + } catch (Exception ex) { logger.error("update key : {} , value : {}", key, value, ex); }