From 79aa971d9c47e21f69acb63da72f1ae9fb3086e8 Mon Sep 17 00:00:00 2001 From: wforget <643348094@qq.com> Date: Tue, 6 Feb 2024 10:46:05 +0800 Subject: [PATCH] Assign serviceNode and add volatile to the variables --- .../ha/client/etcd/EtcdDiscoveryClient.scala | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/etcd/EtcdDiscoveryClient.scala b/kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/etcd/EtcdDiscoveryClient.scala index 2f27f7b8096..a322ca8d88c 100644 --- a/kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/etcd/EtcdDiscoveryClient.scala +++ b/kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/etcd/EtcdDiscoveryClient.scala @@ -59,13 +59,13 @@ class EtcdDiscoveryClient(conf: KyuubiConf) extends DiscoveryClient { case class ServiceNode(path: String, lease: Long) - var client: Client = _ - var kvClient: KV = _ - var lockClient: Lock = _ - var leaseClient: Lease = _ - var serviceNode: ServiceNode = _ + @volatile var client: Client = _ + @volatile var kvClient: KV = _ + @volatile var lockClient: Lock = _ + @volatile var leaseClient: Lease = _ + @volatile var serviceNode: ServiceNode = _ - var leaseTTL: Long = _ + @volatile var leaseTTL: Long = _ private def buildClient(): Client = { val endpoints = conf.get(HA_ADDRESSES).split(",") @@ -251,7 +251,7 @@ class EtcdDiscoveryClient(conf: KyuubiConf) extends DiscoveryClient { val instance = serviceDiscovery.fe.connectionUrl val watcher = new DeRegisterWatcher(instance, serviceDiscovery) - val serviceNode = createPersistentNode( + serviceNode = createPersistentNode( conf, namespace, instance,