Skip to content

Commit

Permalink
support configurationMetadataStoreUrl in function_worker-yml
Browse files Browse the repository at this point in the history
  • Loading branch information
gavingaozhangmin committed Jan 17, 2022
1 parent dd1a9e3 commit 728c9ac
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 9 deletions.
5 changes: 4 additions & 1 deletion conf/functions_worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ workerPort: 6750
workerPortTls: 6751

# Configuration Store connection string
configurationStoreServers: localhost:2181
configurationMetadataStoreUrl: localhost:2181
# ZooKeeper session timeout in milliseconds
zooKeeperSessionTimeoutMillis: 30000
# ZooKeeper operation timeout in seconds
Expand Down Expand Up @@ -328,3 +328,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 @@ -1573,7 +1573,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 @@ -147,6 +147,12 @@ public class WorkerConfig implements Serializable, PulsarConfiguration {
doc = "Configuration store connection string (as a comma-separated list)"
)
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 @@ -632,6 +638,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: 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 @@ -199,12 +199,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: <configuration-store-servers>
```
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: 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: <configuration-store-servers>

```
Expand Down

0 comments on commit 728c9ac

Please sign in to comment.