|
83 | 83 | import java.util.concurrent.ConcurrentHashMap;
|
84 | 84 | import java.util.concurrent.CountDownLatch;
|
85 | 85 | import java.util.concurrent.TimeUnit;
|
| 86 | +import java.util.concurrent.atomic.AtomicBoolean; |
86 | 87 | import java.util.concurrent.atomic.AtomicReference;
|
87 | 88 | import java.util.function.Function;
|
88 | 89 | import java.util.function.LongSupplier;
|
@@ -233,7 +234,7 @@ public static RemoteClusterStateValidationMode parseString(String mode) {
|
233 | 234 | private final String METADATA_UPDATE_LOG_STRING = "wrote metadata for [{}] indices and skipped [{}] unchanged "
|
234 | 235 | + "indices, coordination metadata updated : [{}], settings metadata updated : [{}], templates metadata "
|
235 | 236 | + "updated : [{}], custom metadata updated : [{}], indices routing updated : [{}]";
|
236 |
| - private boolean isPublicationEnabled; |
| 237 | + private AtomicBoolean isPublicationEnabled; |
237 | 238 | private final String remotePathPrefix;
|
238 | 239 |
|
239 | 240 | private final RemoteClusterStateCache remoteClusterStateCache;
|
@@ -274,9 +275,11 @@ public RemoteClusterStateService(
|
274 | 275 | this.remoteStateStats = new RemotePersistenceStats();
|
275 | 276 | this.namedWriteableRegistry = namedWriteableRegistry;
|
276 | 277 | this.indexMetadataUploadListeners = indexMetadataUploadListeners;
|
277 |
| - this.isPublicationEnabled = clusterSettings.get(REMOTE_PUBLICATION_SETTING) |
278 |
| - && RemoteStoreNodeAttribute.isRemoteStoreClusterStateEnabled(settings) |
279 |
| - && RemoteStoreNodeAttribute.isRemoteRoutingTableEnabled(settings); |
| 278 | + this.isPublicationEnabled = new AtomicBoolean( |
| 279 | + clusterSettings.get(REMOTE_PUBLICATION_SETTING) |
| 280 | + && RemoteStoreNodeAttribute.isRemoteStoreClusterStateEnabled(settings) |
| 281 | + && RemoteStoreNodeAttribute.isRemoteRoutingTableEnabled(settings) |
| 282 | + ); |
280 | 283 | clusterSettings.addSettingsUpdateConsumer(REMOTE_PUBLICATION_SETTING, this::setRemotePublicationSetting);
|
281 | 284 | this.remotePathPrefix = CLUSTER_REMOTE_STORE_STATE_PATH_PREFIX.get(settings);
|
282 | 285 | this.remoteRoutingTableService = RemoteRoutingTableServiceFactory.getService(
|
@@ -305,19 +308,20 @@ public RemoteClusterStateManifestInfo writeFullMetadata(ClusterState clusterStat
|
305 | 308 | return null;
|
306 | 309 | }
|
307 | 310 |
|
| 311 | + boolean publicationEnabled = isPublicationEnabled.get(); |
308 | 312 | UploadedMetadataResults uploadedMetadataResults = writeMetadataInParallel(
|
309 | 313 | clusterState,
|
310 | 314 | new ArrayList<>(clusterState.metadata().indices().values()),
|
311 | 315 | emptyMap(),
|
312 |
| - RemoteGlobalMetadataManager.filterCustoms(clusterState.metadata().customs(), isPublicationEnabled), |
| 316 | + RemoteGlobalMetadataManager.filterCustoms(clusterState.metadata().customs(), publicationEnabled), |
313 | 317 | true,
|
314 | 318 | true,
|
315 | 319 | true,
|
316 |
| - isPublicationEnabled, |
317 |
| - isPublicationEnabled, |
318 |
| - isPublicationEnabled, |
319 |
| - isPublicationEnabled ? clusterState.customs() : Collections.emptyMap(), |
320 |
| - isPublicationEnabled, |
| 320 | + publicationEnabled, |
| 321 | + publicationEnabled, |
| 322 | + publicationEnabled, |
| 323 | + publicationEnabled ? clusterState.customs() : Collections.emptyMap(), |
| 324 | + publicationEnabled, |
321 | 325 | remoteRoutingTableService.getIndicesRouting(clusterState.getRoutingTable()),
|
322 | 326 | null
|
323 | 327 | );
|
@@ -396,9 +400,9 @@ public RemoteClusterStateManifestInfo writeIncrementalMetadata(
|
396 | 400 | boolean firstUploadForSplitGlobalMetadata = !previousManifest.hasMetadataAttributesFiles();
|
397 | 401 |
|
398 | 402 | final DiffableUtils.MapDiff<String, Metadata.Custom, Map<String, Metadata.Custom>> customsDiff = remoteGlobalMetadataManager
|
399 |
| - .getCustomsDiff(clusterState, previousClusterState, firstUploadForSplitGlobalMetadata, isPublicationEnabled); |
| 403 | + .getCustomsDiff(clusterState, previousClusterState, firstUploadForSplitGlobalMetadata, isPublicationEnabled.get()); |
400 | 404 | final DiffableUtils.MapDiff<String, ClusterState.Custom, Map<String, ClusterState.Custom>> clusterStateCustomsDiff =
|
401 |
| - remoteClusterStateAttributesManager.getUpdatedCustoms(clusterState, previousClusterState, isPublicationEnabled, false); |
| 405 | + remoteClusterStateAttributesManager.getUpdatedCustoms(clusterState, previousClusterState, isPublicationEnabled.get(), false); |
402 | 406 | final Map<String, UploadedMetadataAttribute> allUploadedCustomMap = new HashMap<>(previousManifest.getCustomMetadataMap());
|
403 | 407 | final Map<String, UploadedMetadataAttribute> allUploadedClusterStateCustomsMap = new HashMap<>(
|
404 | 408 | previousManifest.getClusterStateCustomMap()
|
@@ -463,10 +467,10 @@ public RemoteClusterStateManifestInfo writeIncrementalMetadata(
|
463 | 467 | boolean updateTemplatesMetadata = firstUploadForSplitGlobalMetadata
|
464 | 468 | || Metadata.isTemplatesMetadataEqual(previousClusterState.metadata(), clusterState.metadata()) == false;
|
465 | 469 |
|
466 |
| - final boolean updateDiscoveryNodes = isPublicationEnabled |
| 470 | + final boolean updateDiscoveryNodes = isPublicationEnabled.get() |
467 | 471 | && clusterState.getNodes().delta(previousClusterState.getNodes()).hasChanges();
|
468 |
| - final boolean updateClusterBlocks = isPublicationEnabled && !clusterState.blocks().equals(previousClusterState.blocks()); |
469 |
| - final boolean updateHashesOfConsistentSettings = isPublicationEnabled |
| 472 | + final boolean updateClusterBlocks = isPublicationEnabled.get() && !clusterState.blocks().equals(previousClusterState.blocks()); |
| 473 | + final boolean updateHashesOfConsistentSettings = isPublicationEnabled.get() |
470 | 474 | && Metadata.isHashesOfConsistentSettingsEqual(previousClusterState.metadata(), clusterState.metadata()) == false;
|
471 | 475 |
|
472 | 476 | uploadedMetadataResults = writeMetadataInParallel(
|
@@ -1119,9 +1123,9 @@ private void setChecksumValidationMode(RemoteClusterStateValidationMode remoteCl
|
1119 | 1123 |
|
1120 | 1124 | private void setRemotePublicationSetting(boolean remotePublicationSetting) {
|
1121 | 1125 | if (remotePublicationSetting == false) {
|
1122 |
| - this.isPublicationEnabled = false; |
| 1126 | + this.isPublicationEnabled.set(false); |
1123 | 1127 | } else {
|
1124 |
| - this.isPublicationEnabled = isRemoteStoreClusterStateEnabled(settings) && isRemoteRoutingTableEnabled(settings); |
| 1128 | + this.isPublicationEnabled.set(isRemoteStoreClusterStateEnabled(settings) && isRemoteRoutingTableEnabled(settings)); |
1125 | 1129 | }
|
1126 | 1130 | }
|
1127 | 1131 |
|
@@ -1840,7 +1844,7 @@ public String getLastKnownUUIDFromRemote(String clusterName) {
|
1840 | 1844 | }
|
1841 | 1845 |
|
1842 | 1846 | public boolean isRemotePublicationEnabled() {
|
1843 |
| - return this.isPublicationEnabled; |
| 1847 | + return this.isPublicationEnabled.get(); |
1844 | 1848 | }
|
1845 | 1849 |
|
1846 | 1850 | public void setRemoteStateReadTimeout(TimeValue remoteStateReadTimeout) {
|
|
0 commit comments