Skip to content

Commit d278601

Browse files
rdhabaliamerlimat
authored andcommitted
Add binary-protocol lookup url in documentation (#129)
* Add binary-protocol lookup url in documentation * add webServiceUrl and brokerServiceUrl to clientTools * Fallback to old version serviceUrl property for clientTools
1 parent 9833b19 commit d278601

File tree

11 files changed

+59
-21
lines changed

11 files changed

+59
-21
lines changed

conf/client.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
#
1616

1717
# Pulsar Client configuration
18-
serviceUrl=http://localhost:8080/
18+
webServiceUrl=http://localhost:8080/
19+
brokerServiceUrl=pulsar://localhost:6650/
1920
#authPlugin=
2021
#authParams=
2122
#useTls=

docs/Architecture.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Pulsar enables messages to be produced and consumed in different geo-locations.
197197

198198
### Authentication and Authorization
199199

200-
TODO
200+
Pulsar supports a pluggable [authentication](https://github.com/yahoo/pulsar/blob/master/docs/Authentication.md) mechanism which can be configured at broker and it also supports [authorization](https://github.com/yahoo/pulsar/blob/master/docs/Authorization.md) to identify client and its access rights on topics and properties.
201201

202202

203203
# Client Library
@@ -219,7 +219,7 @@ A PulsarClient (TODO: javadocs) instance is needed before producing/consuming me
219219

220220
```java
221221
ClientConfiguration config = new ClientConfiguration();
222-
PulsarClient pulsarClient = PulsarClient.create("http://broker.example.com:8080", config);
222+
PulsarClient pulsarClient = PulsarClient.create("pulsar://broker.example.com:6650", config);
223223
...
224224
pulsarClient.close();
225225
```

docs/Authentication.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ authParams.put("tlsKeyFile", "/path/to/client-cert.pem");
136136
conf.setAuthentication(AuthenticationTls.class.getName(), authParams);
137137

138138
PulsarClient client = PulsarClient.create(
139-
"https://my-broker.com:4443", conf);
139+
"pulsar+ssl://my-broker.com:6651", conf);
140140
```
141141

142142
#### Configure CLI tools

docs/ClusterSetup.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,10 @@ as well as the Pulsar metadata.
136136
$ bin/pulsar initialize-cluster-metadata --cluster us-west \
137137
--zookeeper zk1.us-west.example.com:2181 \
138138
--global-zookeeper zk1.us-west.example.com:2184 \
139-
--service-url http://pulsar.us-west.example.com:8080/ \
140-
--service-url-tls https://pulsar.us-west.example.com:8443/
139+
--web-service-url http://pulsar.us-west.example.com:8080/ \
140+
--web-service-url-tls https://pulsar.us-west.example.com:8443/ \
141+
--broker-service-url pulsar://pulsar.us-west.example.com:6650/ \
142+
--broker-service-url-tls pulsar+ssl://pulsar.us-west.example.com:6651/
141143
```
142144

143145
#### BookKeeper
@@ -241,8 +243,7 @@ only requirement is that when the client does a HTTP request on
241243
`http://pulsar.us-west.example.com:8080/` it must be redirected (through DNS, IP
242244
or HTTP redirect) to an active broker, without preference.
243245

244-
The included discovery service works with HTTP redirect and it maintains the
245-
list of active brokers from ZooKeeper.
246+
The included discovery service maintains the list of active brokers from ZooKeeper and it supports lookup redirection with HTTP and also with [binary protocol](https://github.com/yahoo/pulsar/blob/master/docs/BinaryProtocol.md#service-discovery).
246247

247248
Add the ZK servers in `conf/discovery.conf`:
248249
```shell

docs/GettingStarted.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ $ bin/pulsar standalone
8888
```
8989

9090
The Pulsar service is now ready to use and we can point
91-
clients to use service URL `http://localhost:8080/`
91+
clients to use service URL as either `http://localhost:8080/` or `pulsar://localhost:6650`
9292

9393
A sample namespace, `sample/standalone/ns1`, is already available.
9494

@@ -109,7 +109,7 @@ Latest version is [![Maven Central](https://maven-badges.herokuapp.com/maven-cen
109109
### Consumer
110110

111111
```java
112-
PulsarClient client = PulsarClient.create("http://localhost:8080");
112+
PulsarClient client = PulsarClient.create("pulsar://localhost:6650");
113113

114114
Consumer consumer = client.subscribe(
115115
"persistent://sample/standalone/ns1/my-topic",
@@ -132,7 +132,7 @@ client.close();
132132
### Producer
133133

134134
```java
135-
PulsarClient client = PulsarClient.create("http://localhost:8080");
135+
PulsarClient client = PulsarClient.create("pulsar://localhost:6650");
136136

137137
Producer producer = client.createProducer(
138138
"persistent://sample/standalone/ns1/my-topic");

docs/PulsarStorm.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ MessageToValuesMapper messageToValuesMapper = new MessageToValuesMapper() {
5555

5656
// Configure a Pulsar Spout
5757
PulsarSpoutConfiguration spoutConf = new PulsarSpoutConfiguration();
58-
spoutConf.setServiceUrl("http://broker.messaging.usw.example.com:8080");
58+
spoutConf.setServiceUrl("pulsar://broker.messaging.usw.example.com:6650");
5959
spoutConf.setTopic("persistent://my-property/usw/my-ns/my-topic1");
6060
spoutConf.setSubscriptionName("my-subscriber-name1");
6161
spoutConf.setMessageToValuesMapper(messageToValuesMapper);
@@ -95,7 +95,7 @@ TupleToMessageMapper tupleToMessageMapper = new TupleToMessageMapper() {
9595

9696
// Configure a Pulsar Bolt
9797
PulsarBoltConfiguration boltConf = new PulsarBoltConfiguration();
98-
boltConf.setServiceUrl("http://broker.messaging.usw.example.com:8080");
98+
boltConf.setServiceUrl("pulsar://broker.messaging.usw.example.com:6650");
9999
boltConf.setTopic("persistent://my-property/usw/my-ns/my-topic2");
100100
boltConf.setTupleToMessageMapper(tupleToMessageMapper);
101101

pulsar-broker/src/main/java/com/yahoo/pulsar/PulsarClusterMetadataSetup.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,19 @@ private static class Arguments {
4444
@Parameter(names = { "-c", "--cluster" }, description = "Cluster name", required = true)
4545
private String cluster;
4646

47-
@Parameter(names = { "-u", "--service-url" }, description = "Service URL for new cluster", required = true)
48-
private String clusterServiceUrl;
47+
@Parameter(names = { "-uw", "--web-service-url" }, description = "Web-service URL for new cluster", required = true)
48+
private String clusterWebServiceUrl;
4949

50-
@Parameter(names = { "-t",
51-
"--service-url-tls" }, description = "Service URL for new cluster with TLS encryption", required = false)
52-
private String clusterServiceUrlTls;
50+
@Parameter(names = { "-tw",
51+
"--web-service-url-tls" }, description = "Web-service URL for new cluster with TLS encryption", required = false)
52+
private String clusterWebServiceUrlTls;
53+
54+
@Parameter(names = { "-ub", "--broker-service-url" }, description = "Broker-service URL for new cluster", required = false)
55+
private String clusterBrokerServiceUrl;
56+
57+
@Parameter(names = { "-tb",
58+
"--broker-service-url-tls" }, description = "Broker-service URL for new cluster with TLS encryption", required = false)
59+
private String clusterBrokerServiceUrlTls;
5360

5461
@Parameter(names = { "-zk",
5562
"--zookeeper" }, description = "Local ZooKeeper quorum connection string", required = true)
@@ -101,7 +108,8 @@ public static void main(String[] args) throws Exception {
101108
ZkUtils.createFullPathOptimistic(globalZk, "/admin/clusters", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE,
102109
CreateMode.PERSISTENT);
103110

104-
ClusterData clusterData = new ClusterData(arguments.clusterServiceUrl, arguments.clusterServiceUrlTls);
111+
ClusterData clusterData = new ClusterData(arguments.clusterWebServiceUrl, arguments.clusterWebServiceUrlTls,
112+
arguments.clusterBrokerServiceUrl, arguments.clusterBrokerServiceUrlTls);
105113
byte[] clusterDataJson = ObjectMapperFactory.getThreadLocal().writeValueAsBytes(clusterData);
106114

107115
globalZk.create("/admin/clusters/" + arguments.cluster, clusterDataJson, ZooDefs.Ids.OPEN_ACL_UNSAFE,

pulsar-client-tools/src/main/java/com/yahoo/pulsar/admin/cli/PulsarAdminTool.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import java.util.Arrays;
2222
import java.util.Properties;
2323

24+
import org.apache.commons.lang3.StringUtils;
25+
2426
import com.beust.jcommander.JCommander;
2527
import com.beust.jcommander.Parameter;
2628
import com.yahoo.pulsar.client.admin.PulsarAdmin;
@@ -34,7 +36,9 @@ public class PulsarAdminTool {
3436
private boolean help;
3537

3638
PulsarAdminTool(Properties properties) throws Exception {
37-
String serviceUrl = properties.getProperty("serviceUrl");
39+
// fallback to previous-version serviceUrl property to maintain backward-compatibility
40+
String serviceUrl = StringUtils.isNotBlank(properties.getProperty("webServiceUrl"))
41+
? properties.getProperty("webServiceUrl") : properties.getProperty("serviceUrl");
3842
String authPluginClassName = properties.getProperty("authPlugin");
3943
String authParams = properties.getProperty("authParams");
4044
boolean useTls = Boolean.parseBoolean(properties.getProperty("useTls"));

pulsar-client-tools/src/main/java/com/yahoo/pulsar/client/cli/PulsarClientTool.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.Arrays;
2424
import java.util.Properties;
2525

26+
import org.apache.commons.lang3.StringUtils;
2627
import org.slf4j.Logger;
2728
import org.slf4j.LoggerFactory;
2829

@@ -59,7 +60,12 @@ public class PulsarClientTool {
5960
CmdConsume consumeCommand;
6061

6162
public PulsarClientTool(Properties properties) throws MalformedURLException {
62-
this.serviceURL = properties.getProperty("serviceUrl");
63+
this.serviceURL = StringUtils.isNotBlank(properties.getProperty("brokerServiceUrl"))
64+
? properties.getProperty("brokerServiceUrl") : properties.getProperty("webServiceUrl");
65+
// fallback to previous-version serviceUrl property to maintain backward-compatibility
66+
if (StringUtils.isBlank(this.serviceURL)) {
67+
this.serviceURL = properties.getProperty("serviceUrl");
68+
}
6369
this.authPluginClassName = properties.getProperty("authPlugin");
6470
this.authParams = properties.getProperty("authParams");
6571
this.useTls = Boolean.parseBoolean(properties.getProperty("useTls"));

pulsar-testclient/src/main/java/com/yahoo/pulsar/testclient/PerformanceConsumer.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ public static void main(String[] args) throws Exception {
129129
Properties prop = new Properties(System.getProperties());
130130
prop.load(new FileInputStream(arguments.confFile));
131131

132+
if (arguments.serviceURL == null) {
133+
arguments.serviceURL = prop.getProperty("brokerServiceUrl");
134+
}
135+
136+
if (arguments.serviceURL == null) {
137+
arguments.serviceURL = prop.getProperty("webServiceUrl");
138+
}
139+
140+
// fallback to previous-version serviceUrl property to maintain backward-compatibility
132141
if (arguments.serviceURL == null) {
133142
arguments.serviceURL = prop.getProperty("serviceUrl", "http://localhost:8080/");
134143
}

pulsar-testclient/src/main/java/com/yahoo/pulsar/testclient/PerformanceProducer.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,15 @@ public static void main(String[] args) throws Exception {
163163
Properties prop = new Properties(System.getProperties());
164164
prop.load(new FileInputStream(arguments.confFile));
165165

166+
if (arguments.serviceURL == null) {
167+
arguments.serviceURL = prop.getProperty("brokerServiceUrl");
168+
}
169+
170+
if (arguments.serviceURL == null) {
171+
arguments.serviceURL = prop.getProperty("webServiceUrl");
172+
}
173+
174+
// fallback to previous-version serviceUrl property to maintain backward-compatibility
166175
if (arguments.serviceURL == null) {
167176
arguments.serviceURL = prop.getProperty("serviceUrl", "http://localhost:8080/");
168177
}

0 commit comments

Comments
 (0)