From 2e9452363fd53ece33bddde43c5655bd63d09d8a Mon Sep 17 00:00:00 2001 From: Yong Zhang Date: Wed, 19 Jun 2019 10:44:48 +0800 Subject: [PATCH] Introduce multi host in pulsar doc (#4546) Pulsar already have been supported multi host. Introduce them in Pulsar document. --- site2/docs/admin-api-overview.md | 20 ++++++++++++++++++++ site2/docs/client-libraries-java.md | 12 ++++++++++++ site2/docs/deploy-bare-metal.md | 2 ++ 3 files changed, 34 insertions(+) diff --git a/site2/docs/admin-api-overview.md b/site2/docs/admin-api-overview.md index 7b48c864ed848..df12d3ece2e67 100644 --- a/site2/docs/admin-api-overview.md +++ b/site2/docs/admin-api-overview.md @@ -70,3 +70,23 @@ config.setTlsTrustCertsFilePath(tlsTrustCertsFilePath); PulsarAdmin admin = new PulsarAdmin(url, config); ``` + +If you have multiple brokers to use, you can use multi-host like Pulsar service. For example, +```java +URL url = new URL("http://localhost:8080,localhost:8081,localhost:8082"); +// Pass auth-plugin class fully-qualified name if Pulsar-security is enabled. +String authPluginClassName = "com.org.MyAuthPluginClass"; +// Pass auth-param if auth-plugin class requires it +String authParams = "param1=value1"; +boolean useTls = false; +boolean tlsAllowInsecureConnection = false; +String tlsTrustCertsFilePath = null; + +ClientConfiguration config = new ClientConfiguration(); +config.setAuthentication(authPluginClassName, authParams); +config.setUseTls(useTls); +config.setTlsAllowInsecureConnection(tlsAllowInsecureConnection); +config.setTlsTrustCertsFilePath(tlsTrustCertsFilePath); + +PulsarAdmin admin = new PulsarAdmin(url, config); +``` diff --git a/site2/docs/client-libraries-java.md b/site2/docs/client-libraries-java.md index 4c4261f9e2c62..2a07981f69a51 100644 --- a/site2/docs/client-libraries-java.md +++ b/site2/docs/client-libraries-java.md @@ -57,6 +57,11 @@ Pulsar protocol URLs are assigned to specific clusters, use the `pulsar` scheme pulsar://localhost:6650 ``` +If you have more than one broker, the URL may look like this: +```http +pulsar://localhost:6550,localhost:6651,localhost:6652 +``` + A URL for a production Pulsar cluster may look something like this: ```http @@ -79,6 +84,13 @@ PulsarClient client = PulsarClient.builder() .build(); ``` +If you have multiple brokers, you can initiate a PulsarClient like this: +```java +PulsarClient client = PulsarClient.builder() + .serviceUrl("pulsar://localhost:6650,localhost:6651,localhost:6652") + .build(); +``` + > #### Default broker URLs for standalone clusters > If you're running a cluster in [standalone mode](getting-started-standalone.md), the broker will be available at the `pulsar://localhost:6650` URL by default. diff --git a/site2/docs/deploy-bare-metal.md b/site2/docs/deploy-bare-metal.md index 7a69227a4b4b2..6ed6a774cae5e 100644 --- a/site2/docs/deploy-bare-metal.md +++ b/site2/docs/deploy-bare-metal.md @@ -43,6 +43,8 @@ To run Pulsar on bare metal, you are recommended to have: > However if you don't have enough machines, or are trying out Pulsar in cluster mode (and expand the cluster later), > you can even deploy Pulsar in one node, where it will run zookeeper, bookie and broker in same machine. +> If you don't have a DNS server, you can use multi-host in service URL instead. + Each machine in your cluster will need to have [Java 8](http://www.oracle.com/technetwork/java/javase/downloads/index.html) or higher installed. Here's a diagram showing the basic setup: