Skip to content

Commit

Permalink
setup cluster for ServiceDiscoveryDemo (#2812)
Browse files Browse the repository at this point in the history
setup cluster for ServiceDiscoveryDemo
  • Loading branch information
JoeCqupt authored Jul 11, 2024
1 parent bf20e2a commit c0c64a4
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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 {
Expand All @@ -34,13 +35,19 @@ public static void main(String[] args) throws Exception {
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
demo(clusterName, zkAddress, serviceName, numServices, Mode.POLL);
// only registration + ondemand
demo(clusterName, zkAddress, serviceName, numServices, Mode.NONE);

admin.close();
}

private static void demo(String clusterName, String zkAddress, String serviceName,
Expand Down

0 comments on commit c0c64a4

Please sign in to comment.