This is an automated email from the ASF dual-hosted git repository.

jxue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git


The following commit(s) were added to refs/heads/master by this push:
     new c0c64a487 setup cluster for ServiceDiscoveryDemo (#2812)
c0c64a487 is described below

commit c0c64a487712e3b41e7e4b8a5a135991f126d69d
Author: jiangyuan <469391...@qq.com>
AuthorDate: Fri Jul 12 05:53:54 2024 +0800

    setup cluster for ServiceDiscoveryDemo (#2812)
    
    setup cluster for ServiceDiscoveryDemo
---
 .../org/apache/helix/servicediscovery/ServiceDiscoveryDemo.java    | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git 
a/recipes/service-discovery/src/main/java/org/apache/helix/servicediscovery/ServiceDiscoveryDemo.java
 
b/recipes/service-discovery/src/main/java/org/apache/helix/servicediscovery/ServiceDiscoveryDemo.java
index ddf393658..c34ead9da 100644
--- 
a/recipes/service-discovery/src/main/java/org/apache/helix/servicediscovery/ServiceDiscoveryDemo.java
+++ 
b/recipes/service-discovery/src/main/java/org/apache/helix/servicediscovery/ServiceDiscoveryDemo.java
@@ -24,6 +24,7 @@ import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.helix.manager.zk.ZKHelixAdmin;
 import org.apache.helix.servicediscovery.ServiceDiscovery.Mode;
 
 public class ServiceDiscoveryDemo {
@@ -34,6 +35,11 @@ public class ServiceDiscoveryDemo {
     String serviceName = "myServiceName";
     int numServices = 5;
 
+    ZKHelixAdmin admin = new ZKHelixAdmin(zkAddress);
+    // create cluster
+    System.out.println("Creating cluster: " + clusterName);
+    admin.addCluster(clusterName, true);
+
     // registration + zk watch
     demo(clusterName, zkAddress, serviceName, numServices, Mode.WATCH);
     // registration + periodic poll
@@ -41,6 +47,7 @@ public class ServiceDiscoveryDemo {
     // only registration + ondemand
     demo(clusterName, zkAddress, serviceName, numServices, Mode.NONE);
 
+    admin.close();
   }
 
   private static void demo(String clusterName, String zkAddress, String 
serviceName,

Reply via email to