Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup cluster for ServiceDiscoveryDemo #2812

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading