111
111
import static org .opensearch .gateway .remote .model .RemoteTemplatesMetadata .TEMPLATES_METADATA ;
112
112
import static org .opensearch .gateway .remote .model .RemoteTransientSettingsMetadata .TRANSIENT_SETTING_METADATA ;
113
113
import static org .opensearch .gateway .remote .routingtable .RemoteIndexRoutingTable .INDEX_ROUTING_METADATA_PREFIX ;
114
+ import static org .opensearch .node .remotestore .RemoteStoreNodeAttribute .isRemoteRoutingTableEnabled ;
114
115
import static org .opensearch .node .remotestore .RemoteStoreNodeAttribute .isRemoteStoreClusterStateEnabled ;
115
116
116
117
/**
@@ -132,7 +133,7 @@ public class RemoteClusterStateService implements Closeable {
132
133
REMOTE_PUBLICATION_SETTING_KEY ,
133
134
false ,
134
135
Property .NodeScope ,
135
- Property .Final
136
+ Property .Dynamic
136
137
);
137
138
138
139
/**
@@ -232,7 +233,7 @@ public static RemoteClusterStateValidationMode parseString(String mode) {
232
233
private final String METADATA_UPDATE_LOG_STRING = "wrote metadata for [{}] indices and skipped [{}] unchanged "
233
234
+ "indices, coordination metadata updated : [{}], settings metadata updated : [{}], templates metadata "
234
235
+ "updated : [{}], custom metadata updated : [{}], indices routing updated : [{}]" ;
235
- private final boolean isPublicationEnabled ;
236
+ private boolean isPublicationEnabled ;
236
237
private final String remotePathPrefix ;
237
238
238
239
private final RemoteClusterStateCache remoteClusterStateCache ;
@@ -273,9 +274,10 @@ public RemoteClusterStateService(
273
274
this .remoteStateStats = new RemotePersistenceStats ();
274
275
this .namedWriteableRegistry = namedWriteableRegistry ;
275
276
this .indexMetadataUploadListeners = indexMetadataUploadListeners ;
276
- this .isPublicationEnabled = REMOTE_PUBLICATION_SETTING .get (settings )
277
+ this .isPublicationEnabled = clusterSettings .get (REMOTE_PUBLICATION_SETTING )
277
278
&& RemoteStoreNodeAttribute .isRemoteStoreClusterStateEnabled (settings )
278
279
&& RemoteStoreNodeAttribute .isRemoteRoutingTableEnabled (settings );
280
+ clusterSettings .addSettingsUpdateConsumer (REMOTE_PUBLICATION_SETTING , this ::setRemotePublicationSetting );
279
281
this .remotePathPrefix = CLUSTER_REMOTE_STORE_STATE_PATH_PREFIX .get (settings );
280
282
this .remoteRoutingTableService = RemoteRoutingTableServiceFactory .getService (
281
283
repositoriesService ,
@@ -1109,6 +1111,14 @@ private void setChecksumValidationMode(RemoteClusterStateValidationMode remoteCl
1109
1111
this .remoteClusterStateValidationMode = remoteClusterStateValidationMode ;
1110
1112
}
1111
1113
1114
+ private void setRemotePublicationSetting (boolean remotePublicationSetting ) {
1115
+ if (remotePublicationSetting == false ) {
1116
+ this .isPublicationEnabled = false ;
1117
+ } else {
1118
+ this .isPublicationEnabled = isRemoteStoreClusterStateEnabled (settings ) && isRemoteRoutingTableEnabled (settings );
1119
+ }
1120
+ }
1121
+
1112
1122
// Package private for unit test
1113
1123
RemoteRoutingTableService getRemoteRoutingTableService () {
1114
1124
return this .remoteRoutingTableService ;
0 commit comments