Skip to content

Commit 9bb3a21

Browse files
authored
[improve] [broker] Introduce metadataStoreAllowReadOnlyOperations to deprecate zookeeperAllowReadOnlyOperations (#19246)
1 parent a2b707b commit 9bb3a21

File tree

7 files changed

+42
-6
lines changed

7 files changed

+42
-6
lines changed

pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java

+12
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,12 @@ The delayed message index bucket time step(in seconds) in per bucket snapshot se
434434
)
435435
private int metadataStoreCacheExpirySeconds = 300;
436436

437+
@FieldContext(
438+
category = CATEGORY_SERVER,
439+
doc = "Is metadata store read-only operations."
440+
)
441+
private boolean metadataStoreAllowReadOnlyOperations;
442+
437443
@Deprecated
438444
@FieldContext(
439445
category = CATEGORY_SERVER,
@@ -461,8 +467,10 @@ The delayed message index bucket time step(in seconds) in per bucket snapshot se
461467
)
462468
private int zooKeeperCacheExpirySeconds = -1;
463469

470+
@Deprecated
464471
@FieldContext(
465472
category = CATEGORY_SERVER,
473+
deprecated = true,
466474
doc = "Is zookeeper allow read-only operations."
467475
)
468476
private boolean zooKeeperAllowReadOnlyOperations;
@@ -3249,6 +3257,10 @@ public int getMetadataStoreCacheExpirySeconds() {
32493257
return zooKeeperCacheExpirySeconds > 0 ? zooKeeperCacheExpirySeconds : metadataStoreCacheExpirySeconds;
32503258
}
32513259

3260+
public boolean isMetadataStoreAllowReadOnlyOperations() {
3261+
return zooKeeperAllowReadOnlyOperations || metadataStoreAllowReadOnlyOperations;
3262+
}
3263+
32523264
public long getManagedLedgerCacheEvictionIntervalMs() {
32533265
return managedLedgerCacheEvictionFrequency > 0
32543266
? (long) (1000 / Math.max(

pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ public MetadataStore createConfigurationMetadataStore(PulsarMetadataEventSynchro
356356
return MetadataStoreFactory.create(config.getConfigurationMetadataStoreUrl(),
357357
MetadataStoreConfig.builder()
358358
.sessionTimeoutMillis((int) config.getMetadataStoreSessionTimeoutMillis())
359-
.allowReadOnlyOperations(config.isZooKeeperAllowReadOnlyOperations())
359+
.allowReadOnlyOperations(config.isMetadataStoreAllowReadOnlyOperations())
360360
.configFilePath(config.getMetadataStoreConfigPath())
361361
.batchingEnabled(config.isMetadataStoreBatchingEnabled())
362362
.batchingMaxDelayMillis(config.getMetadataStoreBatchingMaxDelayMillis())
@@ -1063,7 +1063,7 @@ public MetadataStoreExtended createLocalMetadataStore(PulsarMetadataEventSynchro
10631063
return MetadataStoreExtended.create(config.getMetadataStoreUrl(),
10641064
MetadataStoreConfig.builder()
10651065
.sessionTimeoutMillis((int) config.getMetadataStoreSessionTimeoutMillis())
1066-
.allowReadOnlyOperations(config.isZooKeeperAllowReadOnlyOperations())
1066+
.allowReadOnlyOperations(config.isMetadataStoreAllowReadOnlyOperations())
10671067
.configFilePath(config.getMetadataStoreConfigPath())
10681068
.batchingEnabled(config.isMetadataStoreBatchingEnabled())
10691069
.batchingMaxDelayMillis(config.getMetadataStoreBatchingMaxDelayMillis())

pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/worker/WorkerConfig.java

+12
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ public class WorkerConfig implements Serializable, PulsarConfiguration {
197197
)
198198
private int metadataStoreCacheExpirySeconds = 300;
199199

200+
@FieldContext(
201+
category = CATEGORY_WORKER,
202+
doc = "Is metadata store read-only operations."
203+
)
204+
private boolean metadataStoreAllowReadOnlyOperations;
205+
200206
@Deprecated
201207
@FieldContext(
202208
category = CATEGORY_WORKER,
@@ -224,8 +230,10 @@ public class WorkerConfig implements Serializable, PulsarConfiguration {
224230
)
225231
private int zooKeeperCacheExpirySeconds = -1;
226232

233+
@Deprecated
227234
@FieldContext(
228235
category = CATEGORY_WORKER,
236+
deprecated = true,
229237
doc = "Is zooKeeper allow read-only operations."
230238
)
231239
private boolean zooKeeperAllowReadOnlyOperations;
@@ -911,4 +919,8 @@ public int getMetadataStoreOperationTimeoutSeconds() {
911919
public int getMetadataStoreCacheExpirySeconds() {
912920
return zooKeeperCacheExpirySeconds > 0 ? zooKeeperCacheExpirySeconds : metadataStoreCacheExpirySeconds;
913921
}
922+
923+
public boolean isMetadataStoreAllowReadOnlyOperations() {
924+
return zooKeeperAllowReadOnlyOperations || metadataStoreAllowReadOnlyOperations;
925+
}
914926
}

pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/Worker.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private AuthorizationService getAuthorizationService() throws PulsarServerExcept
7777
configMetadataStore = PulsarResources.createConfigMetadataStore(
7878
workerConfig.getConfigurationMetadataStoreUrl(),
7979
(int) workerConfig.getMetadataStoreSessionTimeoutMillis(),
80-
workerConfig.isZooKeeperAllowReadOnlyOperations());
80+
workerConfig.isMetadataStoreAllowReadOnlyOperations());
8181
} catch (IOException e) {
8282
throw new PulsarServerException(e);
8383
}

pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyConfiguration.java

+12
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ public class ProxyConfiguration implements PulsarConfiguration {
133133
)
134134
private int metadataStoreCacheExpirySeconds = 300;
135135

136+
@FieldContext(
137+
category = CATEGORY_SERVER,
138+
doc = "Is metadata store read-only operations."
139+
)
140+
private boolean metadataStoreAllowReadOnlyOperations;
141+
136142
@FieldContext(
137143
category = CATEGORY_SERVER,
138144
doc = "Max size of messages.",
@@ -157,8 +163,10 @@ public class ProxyConfiguration implements PulsarConfiguration {
157163
)
158164
private int zooKeeperCacheExpirySeconds = -1;
159165

166+
@Deprecated
160167
@FieldContext(
161168
category = CATEGORY_SERVER,
169+
deprecated = true,
162170
doc = "Is zooKeeper allow read-only operations."
163171
)
164172
private boolean zooKeeperAllowReadOnlyOperations;
@@ -916,4 +924,8 @@ public int getMetadataStoreSessionTimeoutMillis() {
916924
public int getMetadataStoreCacheExpirySeconds() {
917925
return zooKeeperCacheExpirySeconds > 0 ? zooKeeperCacheExpirySeconds : metadataStoreCacheExpirySeconds;
918926
}
927+
928+
public boolean isMetadataStoreAllowReadOnlyOperations() {
929+
return zooKeeperAllowReadOnlyOperations || metadataStoreAllowReadOnlyOperations;
930+
}
919931
}

pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyService.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -449,13 +449,13 @@ public Optional<Integer> getListenPortTls() {
449449
public MetadataStoreExtended createLocalMetadataStore() throws MetadataStoreException {
450450
return PulsarResources.createLocalMetadataStore(proxyConfig.getMetadataStoreUrl(),
451451
proxyConfig.getMetadataStoreSessionTimeoutMillis(),
452-
proxyConfig.isZooKeeperAllowReadOnlyOperations());
452+
proxyConfig.isMetadataStoreAllowReadOnlyOperations());
453453
}
454454

455455
public MetadataStoreExtended createConfigurationMetadataStore() throws MetadataStoreException {
456456
return PulsarResources.createConfigMetadataStore(proxyConfig.getConfigurationMetadataStoreUrl(),
457457
proxyConfig.getMetadataStoreSessionTimeoutMillis(),
458-
proxyConfig.isZooKeeperAllowReadOnlyOperations());
458+
proxyConfig.isMetadataStoreAllowReadOnlyOperations());
459459
}
460460

461461
public Authentication getProxyClientAuthenticationPlugin() {

pulsar-websocket/src/main/java/org/apache/pulsar/websocket/WebSocketService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public void start() throws PulsarServerException, PulsarClientException, Malform
113113
try {
114114
configMetadataStore = createConfigMetadataStore(config.getConfigurationMetadataStoreUrl(),
115115
(int) config.getMetadataStoreSessionTimeoutMillis(),
116-
config.isZooKeeperAllowReadOnlyOperations());
116+
config.isMetadataStoreAllowReadOnlyOperations());
117117
} catch (MetadataStoreException e) {
118118
throw new PulsarServerException(e);
119119
}

0 commit comments

Comments
 (0)