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