File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
common/src/main/java/org/dromara/dynamictp/common/properties
starter/starter-configcenter/starter-zookeeper/src/main/java/org/dromara/dynamictp/starter/zookeeper/util Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -188,6 +188,10 @@ public static class Zookeeper {
188188 private String node ;
189189
190190 private String configKey ;
191+
192+ private String scheme ;
193+
194+ private String auth ;
191195 }
192196
193197 /**
Original file line number Diff line number Diff line change 3737import java .util .List ;
3838import java .util .Map ;
3939import java .util .concurrent .CountDownLatch ;
40+ import cn .hutool .core .text .CharSequenceUtil ;
4041
4142import static org .dromara .dynamictp .common .em .ConfigFileTypeEnum .JSON ;
4243import static org .dromara .dynamictp .common .em .ConfigFileTypeEnum .PROPERTIES ;
@@ -59,8 +60,14 @@ private CuratorUtil() { }
5960 public static CuratorFramework getCuratorFramework (DtpProperties dtpProperties ) {
6061 if (curatorFramework == null ) {
6162 DtpProperties .Zookeeper zookeeper = dtpProperties .getZookeeper ();
62- curatorFramework = CuratorFrameworkFactory .newClient (zookeeper .getZkConnectStr (),
63- new ExponentialBackoffRetry (1000 , 3 ));
63+ CuratorFrameworkFactory .Builder builder = CuratorFrameworkFactory
64+ .builder ()
65+ .connectString (zookeeper .getZkConnectStr ())
66+ .retryPolicy (new ExponentialBackoffRetry (1000 , 3 ));
67+ if (CharSequenceUtil .isAllNotBlank (zookeeper .getScheme (), zookeeper .getAuth ())){
68+ builder .authorization (zookeeper .getScheme (), zookeeper .getAuth ().getBytes ());
69+ }
70+ curatorFramework = builder .build ();
6471 final ConnectionStateListener connectionStateListener = (client , newState ) -> {
6572 if (newState == ConnectionState .CONNECTED ) {
6673 COUNT_DOWN_LATCH .countDown ();
You can’t perform that action at this time.
0 commit comments