From bd7e2a3c576242891092d4eee5752ff1fc3a1651 Mon Sep 17 00:00:00 2001 From: Zike Yang Date: Tue, 25 Jan 2022 17:05:46 +0800 Subject: [PATCH] [WebSocket] Add configuration metadata store url setting in websocket (#13786) Master Issue: #13760 ### Motivation As per #13077, `configurationStoreServers` need to be renamed to `configurationMetadataStoreUrl`. ### Modifications * Add `configurationMetadataStoreUrl` setting to websocket * Deprecate `configurationStoreServers` in websocket --- conf/websocket.conf | 5 ++++- .../pulsar/websocket/proxy/ProxyAuthenticationTest.java | 2 +- .../pulsar/websocket/proxy/ProxyAuthorizationTest.java | 3 +-- .../pulsar/websocket/proxy/ProxyConfigurationTest.java | 2 +- .../pulsar/websocket/proxy/ProxyPublishConsumeTest.java | 2 +- .../pulsar/websocket/proxy/ProxyPublishConsumeTlsTest.java | 3 +-- .../websocket/proxy/v1/V1_ProxyAuthenticationTest.java | 2 +- .../websocket/service/WebSocketProxyConfiguration.java | 4 ++++ 8 files changed, 14 insertions(+), 9 deletions(-) diff --git a/conf/websocket.conf b/conf/websocket.conf index e700484470ad2..f273402edbad8 100644 --- a/conf/websocket.conf +++ b/conf/websocket.conf @@ -20,7 +20,7 @@ ### --- Web Socket proxy settings --- ### # Configuration Store connection string -configurationStoreServers= +configurationMetadataStoreUrl= # Zookeeper session timeout in milliseconds zooKeeperSessionTimeoutMillis=30000 @@ -123,3 +123,6 @@ tlsCertRefreshCheckDurationSec=300 # Deprecated. Use configurationStoreServers globalZookeeperServers= + +# Deprecated. Use configurationMetadataStoreUrl +configurationStoreServers= diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyAuthenticationTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyAuthenticationTest.java index 764d4a5b7915a..a34ec879ba609 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyAuthenticationTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyAuthenticationTest.java @@ -70,7 +70,7 @@ public void setup() throws Exception { config.setClusterName("test"); config.setAuthenticationEnabled(true); // If this is not set, 500 error occurs. - config.setConfigurationStoreServers(GLOBAL_DUMMY_VALUE); + config.setConfigurationMetadataStoreUrl(GLOBAL_DUMMY_VALUE); config.setSuperUserRoles(Sets.newHashSet("pulsar.super_user")); if (methodName.equals("authenticatedSocketTest") || methodName.equals("statsTest")) { diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyAuthorizationTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyAuthorizationTest.java index 15c3e50e185b8..7e0ee1bd4669e 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyAuthorizationTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyAuthorizationTest.java @@ -59,11 +59,10 @@ protected void setup() throws Exception { WebSocketProxyConfiguration config = new WebSocketProxyConfiguration(); Set superUser = Sets.newHashSet(""); config.setAuthorizationEnabled(true); - config.setConfigurationStoreServers("dummy-zk-servers"); config.setSuperUserRoles(superUser); config.setClusterName("c1"); config.setWebServicePort(Optional.of(0)); - config.setConfigurationStoreServers(GLOBAL_DUMMY_VALUE); + config.setConfigurationMetadataStoreUrl(GLOBAL_DUMMY_VALUE); service = spyWithClassAndConstructorArgs(WebSocketService.class, config); doReturn(new ZKMetadataStore(mockZooKeeperGlobal)).when(service).createMetadataStore(anyString(), anyInt()); service.start(); diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyConfigurationTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyConfigurationTest.java index aeeab2afddcce..f60b1bc0add72 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyConfigurationTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyConfigurationTest.java @@ -46,7 +46,7 @@ public void setup() throws Exception { config = new WebSocketProxyConfiguration(); config.setWebServicePort(Optional.of(0)); config.setClusterName("test"); - config.setConfigurationStoreServers(GLOBAL_DUMMY_VALUE); + config.setConfigurationMetadataStoreUrl(GLOBAL_DUMMY_VALUE); } @AfterMethod(alwaysRun = true) diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyPublishConsumeTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyPublishConsumeTest.java index 177f6f8795a0f..918640642ecbd 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyPublishConsumeTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyPublishConsumeTest.java @@ -99,7 +99,7 @@ public void setup() throws Exception { WebSocketProxyConfiguration config = new WebSocketProxyConfiguration(); config.setWebServicePort(Optional.of(0)); config.setClusterName("test"); - config.setConfigurationStoreServers(GLOBAL_DUMMY_VALUE); + config.setConfigurationMetadataStoreUrl(GLOBAL_DUMMY_VALUE); service = spyWithClassAndConstructorArgs(WebSocketService.class, config); doReturn(new ZKMetadataStore(mockZooKeeperGlobal)).when(service).createMetadataStore(anyString(), anyInt()); proxyServer = new ProxyServer(config); diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyPublishConsumeTlsTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyPublishConsumeTlsTest.java index b8702522fce13..b96880b5627d3 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyPublishConsumeTlsTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/ProxyPublishConsumeTlsTest.java @@ -70,10 +70,9 @@ public void setup() throws Exception { config.setTlsTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH); config.setBrokerClientTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH); config.setClusterName("use"); - config.setConfigurationStoreServers("dummy-zk-servers"); config.setBrokerClientAuthenticationParameters("tlsCertFile:" + TLS_CLIENT_CERT_FILE_PATH + ",tlsKeyFile:" + TLS_CLIENT_KEY_FILE_PATH); config.setBrokerClientAuthenticationPlugin(AuthenticationTls.class.getName()); - config.setConfigurationStoreServers(GLOBAL_DUMMY_VALUE); + config.setConfigurationMetadataStoreUrl(GLOBAL_DUMMY_VALUE); service = spyWithClassAndConstructorArgs(WebSocketService.class, config); doReturn(new ZKMetadataStore(mockZooKeeperGlobal)).when(service).createMetadataStore(anyString(), anyInt()); proxyServer = new ProxyServer(config); diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/v1/V1_ProxyAuthenticationTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/v1/V1_ProxyAuthenticationTest.java index 842acede2492c..b80c3fb07be5e 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/v1/V1_ProxyAuthenticationTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/websocket/proxy/v1/V1_ProxyAuthenticationTest.java @@ -72,7 +72,7 @@ public void setup() throws Exception { config.setClusterName("use"); config.setAuthenticationEnabled(true); // If this is not set, 500 error occurs. - config.setConfigurationStoreServers(GLOBAL_DUMMY_VALUE); + config.setConfigurationMetadataStoreUrl(GLOBAL_DUMMY_VALUE); config.setSuperUserRoles(Sets.newHashSet("pulsar.super_user")); if (methodName.equals("authenticatedSocketTest") || methodName.equals("statsTest")) { diff --git a/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/service/WebSocketProxyConfiguration.java b/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/service/WebSocketProxyConfiguration.java index ca78c85a125b1..79fbc8edffe9b 100644 --- a/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/service/WebSocketProxyConfiguration.java +++ b/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/service/WebSocketProxyConfiguration.java @@ -65,9 +65,13 @@ public class WebSocketProxyConfiguration implements PulsarConfiguration { ) private String globalZookeeperServers; + @Deprecated @FieldContext(doc = "Connection string of configuration store servers") private String configurationStoreServers; + @FieldContext(doc = "Connection string of configuration metadata store servers") + private String configurationMetadataStoreUrl; + @FieldContext(doc = "ZooKeeper session timeout in milliseconds") private long zooKeeperSessionTimeoutMillis = 30000;