Skip to content

Commit

Permalink
Allow to configure metadata store URL in functions_worker.yml (apache…
Browse files Browse the repository at this point in the history
  • Loading branch information
gaozhangmin authored Jan 29, 2022
1 parent b7857d4 commit 604de4b
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 10 deletions.
11 changes: 9 additions & 2 deletions conf/functions_worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ workerHostname: localhost
workerPort: 6750
workerPortTls: 6751

# Configuration Store connection string
configurationStoreServers: localhost:2181
# The Configuration metadata store url
# Examples:
# * zk:my-zk-1:2181,my-zk-2:2181,my-zk-3:2181
# * my-zk-1:2181,my-zk-2:2181,my-zk-3:2181 (will default to ZooKeeper when the schema is not specified)
# * zk:my-zk-1:2181,my-zk-2:2181,my-zk-3:2181/my-chroot-path (to add a ZK chroot path)
configurationMetadataStoreUrl: zk:localhost:2181
# ZooKeeper session timeout in milliseconds
zooKeeperSessionTimeoutMillis: 30000
# ZooKeeper operation timeout in seconds
Expand Down Expand Up @@ -328,3 +332,6 @@ validateConnectorConfig: false
# Whether to initialize distributed log metadata by runtime.
# If it is set to true, you must ensure that it has been initialized by "bin/pulsar initialize-cluster-metadata" command.
initializedDlogMetadata: false

### --- Deprecated settings --- ###
configurationStoreServers: localhost:2181
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ public static WorkerConfig initializeWorkerConfigFromBrokerConfig(ServiceConfigu
workerConfig.setAuthenticationProviders(brokerConfig.getAuthenticationProviders());
workerConfig.setAuthorizationEnabled(brokerConfig.isAuthorizationEnabled());
workerConfig.setAuthorizationProvider(brokerConfig.getAuthorizationProvider());
workerConfig.setConfigurationStoreServers(brokerConfig.getConfigurationMetadataStoreUrl());
workerConfig.setConfigurationMetadataStoreUrl(brokerConfig.getConfigurationMetadataStoreUrl());
workerConfig.setZooKeeperSessionTimeoutMillis(brokerConfig.getZooKeeperSessionTimeoutMillis());
workerConfig.setZooKeeperOperationTimeoutSeconds(brokerConfig.getZooKeeperOperationTimeoutSeconds());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,17 @@ public class WorkerConfig implements Serializable, PulsarConfiguration {
@FieldContext(
category = CATEGORY_WORKER,
required = false,
deprecated = true,
doc = "Configuration store connection string (as a comma-separated list)"
)
@Deprecated
private String configurationStoreServers;
@FieldContext(
category = CATEGORY_WORKER,
required = false,
doc = "Configuration store connection string (as a comma-separated list)"
)
private String configurationMetadataStoreUrl;
@FieldContext(
category = CATEGORY_WORKER,
doc = "ZooKeeper session timeout in milliseconds"
Expand Down Expand Up @@ -633,6 +641,14 @@ public static String unsafeLocalhostResolve() {
}
}

public String getConfigurationMetadataStoreUrl() {
if (StringUtils.isNotBlank(configurationMetadataStoreUrl)) {
return configurationMetadataStoreUrl;
} else {
return configurationStoreServers;
}
}

@Override
public void setProperties(Properties properties) {
this.properties = properties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ private AuthorizationService getAuthorizationService() throws PulsarServerExcept

log.info("starting configuration cache service");
try {
configMetadataStore = PulsarResources.createMetadataStore(workerConfig.getConfigurationStoreServers(),
configMetadataStore = PulsarResources.createMetadataStore(
workerConfig.getConfigurationMetadataStoreUrl(),
(int) workerConfig.getZooKeeperSessionTimeoutMillis());
} catch (IOException e) {
throw new PulsarServerException(e);
Expand Down
2 changes: 1 addition & 1 deletion site2/docs/functions-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ For example, if you use token authentication, you need to configure the followin
```Yaml
clientAuthenticationPlugin: org.apache.pulsar.client.impl.auth.AuthenticationToken
clientAuthenticationParameters: file:///etc/pulsar/token/admin-token.txt
configurationStoreServers: zookeeper-cluster:2181 # auth requires a connection to zookeeper
configurationMetadataStoreUrl: zk:zookeeper-cluster:2181 # auth requires a connection to zookeeper
authenticationProviders:
- "org.apache.pulsar.broker.authentication.AuthenticationProviderToken"
authorizationEnabled: true
Expand Down
4 changes: 2 additions & 2 deletions site2/docs/functions-worker.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@ properties:

##### Enable Authorization Provider

To enable authorization on Functions Worker, you need to configure `authorizationEnabled`, `authorizationProvider` and `configurationStoreServers`. The authentication provider connects to `configurationStoreServers` to receive namespace policies.
To enable authorization on Functions Worker, you need to configure `authorizationEnabled`, `authorizationProvider` and `configurationMetadataStoreUrl`. The authentication provider connects to `configurationMetadataStoreUrl` to receive namespace policies.

```yaml
authorizationEnabled: true
authorizationProvider: org.apache.pulsar.broker.authorization.PulsarAuthorizationProvider
configurationStoreServers: <configuration-store-servers>
configurationMetadataStoreUrl: <meta-type>:<configuration-metadata-store-url>
```
You should also configure a list of superuser roles. The superuser roles are able to access any admin API. The following is a configuration example.
Expand Down
2 changes: 1 addition & 1 deletion site2/website-next/docs/functions-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ For example, if you use token authentication, you need to configure the followin
clientAuthenticationPlugin: org.apache.pulsar.client.impl.auth.AuthenticationToken
clientAuthenticationParameters: file:///etc/pulsar/token/admin-token.txt
configurationStoreServers: zookeeper-cluster:2181 # auth requires a connection to zookeeper
configurationMetadataStoreUrl: zk:zookeeper-cluster:2181 # auth requires a connection to zookeeper
authenticationProviders:
- "org.apache.pulsar.broker.authentication.AuthenticationProviderToken"
authorizationEnabled: true
Expand Down
4 changes: 2 additions & 2 deletions site2/website-next/docs/functions-worker.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,13 @@ properties:

##### Enable Authorization Provider

To enable authorization on Functions Worker, you need to configure `authorizationEnabled`, `authorizationProvider` and `configurationStoreServers`. The authentication provider connects to `configurationStoreServers` to receive namespace policies.
To enable authorization on Functions Worker, you need to configure `authorizationEnabled`, `authorizationProvider` and `configurationMetadataStoreUrl`. The authentication provider connects to `configurationMetadataStoreUrl` to receive namespace policies.

```yaml

authorizationEnabled: true
authorizationProvider: org.apache.pulsar.broker.authorization.PulsarAuthorizationProvider
configurationStoreServers: <configuration-store-servers>
configurationMetadataStoreUrl: <meta-type>:<configuration-metadata-store-url>

```
Expand Down

0 comments on commit 604de4b

Please sign in to comment.