Skip to content

Commit

Permalink
[pulsar-cli] fix update-cluster cli updates proxy-url (apache#7422)
Browse files Browse the repository at this point in the history
### Motivation
Pulsar-admin CLI doesn't update cluster-metadata with proxy-url and proxy-protocol.

### Modification
Fix CLI to update proxy metadata.
  • Loading branch information
rdhabalia authored Jul 2, 2020
1 parent 70ccbf2 commit 1e152bd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import org.apache.pulsar.client.api.Message;
import org.apache.pulsar.client.api.MessageRoutingMode;
import org.apache.pulsar.client.api.Producer;
import org.apache.pulsar.client.api.ProxyProtocol;
import org.apache.pulsar.client.api.PulsarClient;
import org.apache.pulsar.client.api.PulsarClientException;
import org.apache.pulsar.client.api.SubscriptionInitialPosition;
Expand Down Expand Up @@ -1269,4 +1270,17 @@ public void testMaxNumPartitionsPerPartitionedTopicFailure() {
}
}

@Test
public void testUpdateClusterWithProxyUrl() throws Exception {
ClusterData cluster = new ClusterData(pulsar.getWebServiceAddress());
String clusterName = "test2";
admin.clusters().createCluster(clusterName, cluster);
Assert.assertEquals(admin.clusters().getCluster(clusterName), cluster);

// update
cluster.setProxyServiceUrl("proxy");
cluster.setProxyProtocol(ProxyProtocol.SNI);
admin.clusters().updateCluster(clusterName, cluster);
Assert.assertEquals(admin.clusters().getCluster(clusterName), cluster);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,16 @@ private class Update extends CliCommand {
@Parameter(names = "--broker-url-secure", description = "broker-service-url for secure connection", required = false)
private String brokerServiceUrlTls;

@Parameter(names = "--proxy-url", description = "Proxy-service url when client would like to connect to broker via proxy.", required = false)
private String proxyServiceUrl;

@Parameter(names = "--proxy-protocol", description = "protocol to decide type of proxy routing eg: SNI", required = false)
private ProxyProtocol proxyProtocol;

void run() throws PulsarAdminException {
String cluster = getOneArgument(params);
admin.clusters().updateCluster(cluster,
new ClusterData(serviceUrl, serviceUrlTls, brokerServiceUrl, brokerServiceUrlTls));
admin.clusters().updateCluster(cluster, new ClusterData(serviceUrl, serviceUrlTls, brokerServiceUrl,
brokerServiceUrlTls, proxyServiceUrl, proxyProtocol));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ public void update(ClusterData other) {
this.serviceUrlTls = other.serviceUrlTls;
this.brokerServiceUrl = other.brokerServiceUrl;
this.brokerServiceUrlTls = other.brokerServiceUrlTls;
this.proxyServiceUrl = other.proxyServiceUrl;
this.proxyProtocol = other.proxyProtocol;
}

public String getServiceUrl() {
Expand Down

0 comments on commit 1e152bd

Please sign in to comment.