Search in sources :

Example 16 with Setting

use of org.opensearch.common.settings.Setting in project OpenSearch by opensearch-project.

the class ProxyConnectionStrategyTests method testProxyStrategyWillNeedToBeRebuiltIfNumOfSocketsOrAddressesOrServerNameChange.

public void testProxyStrategyWillNeedToBeRebuiltIfNumOfSocketsOrAddressesOrServerNameChange() {
    try (MockTransportService remoteTransport = startTransport("node1", Version.CURRENT)) {
        TransportAddress remoteAddress = remoteTransport.boundAddress().publishAddress();
        try (MockTransportService localService = MockTransportService.createNewService(Settings.EMPTY, Version.CURRENT, threadPool)) {
            localService.start();
            localService.acceptIncomingRequests();
            ClusterConnectionManager connectionManager = new ClusterConnectionManager(profile, localService.transport);
            int numOfConnections = randomIntBetween(4, 8);
            try (RemoteConnectionManager remoteConnectionManager = new RemoteConnectionManager(clusterAlias, connectionManager);
                ProxyConnectionStrategy strategy = new ProxyConnectionStrategy(clusterAlias, localService, remoteConnectionManager, Settings.EMPTY, numOfConnections, remoteAddress.toString(), "server-name")) {
                PlainActionFuture<Void> connectFuture = PlainActionFuture.newFuture();
                strategy.connect(connectFuture);
                connectFuture.actionGet();
                assertTrue(connectionManager.getAllConnectedNodes().stream().anyMatch(n -> n.getAddress().equals(remoteAddress)));
                assertEquals(numOfConnections, connectionManager.size());
                assertTrue(strategy.assertNoRunningConnections());
                Setting<?> modeSetting = RemoteConnectionStrategy.REMOTE_CONNECTION_MODE.getConcreteSettingForNamespace("cluster-alias");
                Setting<?> addressesSetting = ProxyConnectionStrategy.PROXY_ADDRESS.getConcreteSettingForNamespace("cluster-alias");
                Setting<?> socketConnections = ProxyConnectionStrategy.REMOTE_SOCKET_CONNECTIONS.getConcreteSettingForNamespace("cluster-alias");
                Setting<?> serverName = ProxyConnectionStrategy.SERVER_NAME.getConcreteSettingForNamespace("cluster-alias");
                Settings noChange = Settings.builder().put(modeSetting.getKey(), "proxy").put(addressesSetting.getKey(), remoteAddress.toString()).put(socketConnections.getKey(), numOfConnections).put(serverName.getKey(), "server-name").build();
                assertFalse(strategy.shouldRebuildConnection(noChange));
                Settings addressesChanged = Settings.builder().put(modeSetting.getKey(), "proxy").put(addressesSetting.getKey(), remoteAddress.toString()).build();
                assertTrue(strategy.shouldRebuildConnection(addressesChanged));
                Settings socketsChanged = Settings.builder().put(modeSetting.getKey(), "proxy").put(addressesSetting.getKey(), remoteAddress.toString()).put(socketConnections.getKey(), numOfConnections + 1).build();
                assertTrue(strategy.shouldRebuildConnection(socketsChanged));
                Settings serverNameChange = Settings.builder().put(modeSetting.getKey(), "proxy").put(addressesSetting.getKey(), remoteAddress.toString()).put(socketConnections.getKey(), numOfConnections).put(serverName.getKey(), "server-name2").build();
                assertTrue(strategy.shouldRebuildConnection(serverNameChange));
            }
        }
    }
}
Also used : Arrays(java.util.Arrays) Setting(org.opensearch.common.settings.Setting) OpenSearchTestCase(org.opensearch.test.OpenSearchTestCase) ThreadPool(org.opensearch.threadpool.ThreadPool) TestThreadPool(org.opensearch.threadpool.TestThreadPool) Set(java.util.Set) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Version(org.opensearch.Version) AbstractScopedSettings(org.opensearch.common.settings.AbstractScopedSettings) Settings(org.opensearch.common.settings.Settings) MockTransportService(org.opensearch.test.transport.MockTransportService) Supplier(java.util.function.Supplier) Collectors(java.util.stream.Collectors) Tuple(org.opensearch.common.collect.Tuple) TransportAddress(org.opensearch.common.transport.TransportAddress) HashSet(java.util.HashSet) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) List(java.util.List) PlainActionFuture(org.opensearch.action.support.PlainActionFuture) ClusterName(org.opensearch.cluster.ClusterName) ClusterSettings(org.opensearch.common.settings.ClusterSettings) MockTransportService(org.opensearch.test.transport.MockTransportService) TransportAddress(org.opensearch.common.transport.TransportAddress) AbstractScopedSettings(org.opensearch.common.settings.AbstractScopedSettings) Settings(org.opensearch.common.settings.Settings) ClusterSettings(org.opensearch.common.settings.ClusterSettings)

Example 17 with Setting

use of org.opensearch.common.settings.Setting in project OpenSearch by opensearch-project.

the class IndexSettingsTests method testMergedSettingsArePassed.

public void testMergedSettingsArePassed() {
    Version version = VersionUtils.getPreviousVersion();
    Settings theSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).put(IndexMetadata.SETTING_INDEX_UUID, "0xdeadbeef").build();
    final AtomicInteger integer = new AtomicInteger(0);
    final StringBuilder builder = new StringBuilder();
    Setting<Integer> integerSetting = Setting.intSetting("index.test.setting.int", -1, Property.Dynamic, Property.IndexScope);
    Setting<String> notUpdated = new Setting<>("index.not.updated", "", Function.identity(), Property.Dynamic, Property.IndexScope);
    IndexSettings settings = newIndexSettings(newIndexMeta("index", theSettings), Settings.EMPTY, integerSetting, notUpdated);
    settings.getScopedSettings().addSettingsUpdateConsumer(integerSetting, integer::set);
    settings.getScopedSettings().addSettingsUpdateConsumer(notUpdated, builder::append);
    assertEquals(0, integer.get());
    assertEquals("", builder.toString());
    IndexMetadata newMetadata = newIndexMeta("index", Settings.builder().put(settings.getIndexMetadata().getSettings()).put("index.test.setting.int", 42).build());
    assertTrue(settings.updateIndexMetadata(newMetadata));
    assertSame(settings.getIndexMetadata(), newMetadata);
    assertEquals(42, integer.get());
    assertEquals("", builder.toString());
    integer.set(0);
    assertTrue(settings.updateIndexMetadata(newIndexMeta("index", Settings.builder().put(settings.getIndexMetadata().getSettings()).put("index.not.updated", "boom").build())));
    assertEquals("boom", builder.toString());
    assertEquals("not updated - we preserve the old settings", 0, integer.get());
}
Also used : Setting(org.opensearch.common.settings.Setting) HasToString.hasToString(org.hamcrest.object.HasToString.hasToString) StringContains.containsString(org.hamcrest.core.StringContains.containsString) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Version(org.opensearch.Version) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IndexMetadata(org.opensearch.cluster.metadata.IndexMetadata) IndexScopedSettings(org.opensearch.common.settings.IndexScopedSettings) AbstractScopedSettings(org.opensearch.common.settings.AbstractScopedSettings) Settings(org.opensearch.common.settings.Settings)

Example 18 with Setting

use of org.opensearch.common.settings.Setting in project OpenSearch by opensearch-project.

the class MetadataUpdateSettingsService method updateSettings.

public void updateSettings(final UpdateSettingsClusterStateUpdateRequest request, final ActionListener<ClusterStateUpdateResponse> listener) {
    final Settings normalizedSettings = Settings.builder().put(request.settings()).normalizePrefix(IndexMetadata.INDEX_SETTING_PREFIX).build();
    Settings.Builder settingsForClosedIndices = Settings.builder();
    Settings.Builder settingsForOpenIndices = Settings.builder();
    final Set<String> skippedSettings = new HashSet<>();
    indexScopedSettings.validate(// don't validate wildcards
    normalizedSettings.filter(s -> Regex.isSimpleMatchPattern(s) == false), // don't validate dependencies here we check it below never allow to change the number of shards
    false, true);
    // validate internal or private index settings
    for (String key : normalizedSettings.keySet()) {
        Setting setting = indexScopedSettings.get(key);
        boolean isWildcard = setting == null && Regex.isSimpleMatchPattern(key);
        assert // we already validated the normalized settings
        setting != null || (isWildcard && normalizedSettings.hasValue(key) == false) : "unknown setting: " + key + " isWildcard: " + isWildcard + " hasValue: " + normalizedSettings.hasValue(key);
        settingsForClosedIndices.copy(key, normalizedSettings);
        if (isWildcard || setting.isDynamic()) {
            settingsForOpenIndices.copy(key, normalizedSettings);
        } else {
            skippedSettings.add(key);
        }
    }
    final Settings closedSettings = settingsForClosedIndices.build();
    final Settings openSettings = settingsForOpenIndices.build();
    final boolean preserveExisting = request.isPreserveExisting();
    clusterService.submitStateUpdateTask("update-settings " + Arrays.toString(request.indices()), new AckedClusterStateUpdateTask<ClusterStateUpdateResponse>(Priority.URGENT, request, wrapPreservingContext(listener, threadPool.getThreadContext())) {

        @Override
        protected ClusterStateUpdateResponse newResponse(boolean acknowledged) {
            return new ClusterStateUpdateResponse(acknowledged);
        }

        @Override
        public ClusterState execute(ClusterState currentState) {
            RoutingTable.Builder routingTableBuilder = RoutingTable.builder(currentState.routingTable());
            Metadata.Builder metadataBuilder = Metadata.builder(currentState.metadata());
            // allow to change any settings to a close index, and only allow dynamic settings to be changed
            // on an open index
            Set<Index> openIndices = new HashSet<>();
            Set<Index> closeIndices = new HashSet<>();
            final String[] actualIndices = new String[request.indices().length];
            for (int i = 0; i < request.indices().length; i++) {
                Index index = request.indices()[i];
                actualIndices[i] = index.getName();
                final IndexMetadata metadata = currentState.metadata().getIndexSafe(index);
                if (metadata.getState() == IndexMetadata.State.OPEN) {
                    openIndices.add(index);
                } else {
                    closeIndices.add(index);
                }
            }
            if (!skippedSettings.isEmpty() && !openIndices.isEmpty()) {
                throw new IllegalArgumentException(String.format(Locale.ROOT, "Can't update non dynamic settings [%s] for open indices %s", skippedSettings, openIndices));
            }
            if (IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.exists(openSettings)) {
                final int updatedNumberOfReplicas = IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.get(openSettings);
                if (preserveExisting == false) {
                    // Verify that this won't take us over the cluster shard limit.
                    int totalNewShards = Arrays.stream(request.indices()).mapToInt(i -> getTotalNewShards(i, currentState, updatedNumberOfReplicas)).sum();
                    Optional<String> error = shardLimitValidator.checkShardLimit(totalNewShards, currentState);
                    if (error.isPresent()) {
                        ValidationException ex = new ValidationException();
                        ex.addValidationError(error.get());
                        throw ex;
                    }
                    /*
                             * We do not update the in-sync allocation IDs as they will be removed upon the first index operation which makes
                             * these copies stale.
                             *
                             * TODO: should we update the in-sync allocation IDs once the data is deleted by the node?
                             */
                    routingTableBuilder.updateNumberOfReplicas(updatedNumberOfReplicas, actualIndices);
                    metadataBuilder.updateNumberOfReplicas(updatedNumberOfReplicas, actualIndices);
                    logger.info("updating number_of_replicas to [{}] for indices {}", updatedNumberOfReplicas, actualIndices);
                }
            }
            if (!openIndices.isEmpty()) {
                for (Index index : openIndices) {
                    IndexMetadata indexMetadata = metadataBuilder.getSafe(index);
                    Settings.Builder updates = Settings.builder();
                    Settings.Builder indexSettings = Settings.builder().put(indexMetadata.getSettings());
                    if (indexScopedSettings.updateDynamicSettings(openSettings, indexSettings, updates, index.getName())) {
                        if (preserveExisting) {
                            indexSettings.put(indexMetadata.getSettings());
                        }
                        /*
                                 * The setting index.number_of_replicas is special; we require that this setting has a value in the index. When
                                 * creating the index, we ensure this by explicitly providing a value for the setting to the default (one) if
                                 * there is a not value provided on the source of the index creation. A user can update this setting though,
                                 * including updating it to null, indicating that they want to use the default value. In this case, we again
                                 * have to provide an explicit value for the setting to the default (one).
                                 */
                        if (IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.exists(indexSettings) == false) {
                            indexSettings.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.get(Settings.EMPTY));
                        }
                        Settings finalSettings = indexSettings.build();
                        indexScopedSettings.validate(finalSettings.filter(k -> indexScopedSettings.isPrivateSetting(k) == false), true);
                        metadataBuilder.put(IndexMetadata.builder(indexMetadata).settings(finalSettings));
                    }
                }
            }
            if (!closeIndices.isEmpty()) {
                for (Index index : closeIndices) {
                    IndexMetadata indexMetadata = metadataBuilder.getSafe(index);
                    Settings.Builder updates = Settings.builder();
                    Settings.Builder indexSettings = Settings.builder().put(indexMetadata.getSettings());
                    if (indexScopedSettings.updateSettings(closedSettings, indexSettings, updates, index.getName())) {
                        if (preserveExisting) {
                            indexSettings.put(indexMetadata.getSettings());
                        }
                        /*
                                 * The setting index.number_of_replicas is special; we require that this setting has a value in the index. When
                                 * creating the index, we ensure this by explicitly providing a value for the setting to the default (one) if
                                 * there is a not value provided on the source of the index creation. A user can update this setting though,
                                 * including updating it to null, indicating that they want to use the default value. In this case, we again
                                 * have to provide an explicit value for the setting to the default (one).
                                 */
                        if (IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.exists(indexSettings) == false) {
                            indexSettings.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.get(Settings.EMPTY));
                        }
                        Settings finalSettings = indexSettings.build();
                        indexScopedSettings.validate(finalSettings.filter(k -> indexScopedSettings.isPrivateSetting(k) == false), true);
                        metadataBuilder.put(IndexMetadata.builder(indexMetadata).settings(finalSettings));
                    }
                }
            }
            if (IndexSettings.INDEX_TRANSLOG_RETENTION_AGE_SETTING.exists(normalizedSettings) || IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING.exists(normalizedSettings)) {
                Settings indexSettings;
                for (String index : actualIndices) {
                    indexSettings = metadataBuilder.get(index).getSettings();
                    MetadataCreateIndexService.validateTranslogRetentionSettings(indexSettings);
                    // validate storeType for deprecating index stores
                    MetadataCreateIndexService.validateStoreTypeSettings(indexSettings);
                }
            }
            boolean changed = false;
            // increment settings versions
            for (final String index : actualIndices) {
                if (same(currentState.metadata().index(index).getSettings(), metadataBuilder.get(index).getSettings()) == false) {
                    changed = true;
                    final IndexMetadata.Builder builder = IndexMetadata.builder(metadataBuilder.get(index));
                    builder.settingsVersion(1 + builder.settingsVersion());
                    metadataBuilder.put(builder);
                }
            }
            final ClusterBlocks.Builder blocks = ClusterBlocks.builder().blocks(currentState.blocks());
            for (IndexMetadata.APIBlock block : IndexMetadata.APIBlock.values()) {
                changed |= maybeUpdateClusterBlock(actualIndices, blocks, block.block, block.setting, openSettings);
            }
            if (changed == false) {
                return currentState;
            }
            ClusterState updatedState = ClusterState.builder(currentState).metadata(metadataBuilder).routingTable(routingTableBuilder.build()).blocks(blocks).build();
            // now, reroute in case things change that require it (like number of replicas)
            updatedState = allocationService.reroute(updatedState, "settings update");
            try {
                for (Index index : openIndices) {
                    final IndexMetadata currentMetadata = currentState.getMetadata().getIndexSafe(index);
                    final IndexMetadata updatedMetadata = updatedState.metadata().getIndexSafe(index);
                    indicesService.verifyIndexMetadata(currentMetadata, updatedMetadata);
                }
                for (Index index : closeIndices) {
                    final IndexMetadata currentMetadata = currentState.getMetadata().getIndexSafe(index);
                    final IndexMetadata updatedMetadata = updatedState.metadata().getIndexSafe(index);
                    // Verifies that the current index settings can be updated with the updated dynamic settings.
                    indicesService.verifyIndexMetadata(currentMetadata, updatedMetadata);
                    // Now check that we can create the index with the updated settings (dynamic and non-dynamic).
                    // This step is mandatory since we allow to update non-dynamic settings on closed indices.
                    indicesService.verifyIndexMetadata(updatedMetadata, updatedMetadata);
                }
            } catch (IOException ex) {
                throw ExceptionsHelper.convertToOpenSearchException(ex);
            }
            return updatedState;
        }
    });
}
Also used : Arrays(java.util.Arrays) IndexScopedSettings(org.opensearch.common.settings.IndexScopedSettings) ThreadPool(org.opensearch.threadpool.ThreadPool) AllocationService(org.opensearch.cluster.routing.allocation.AllocationService) Version(org.opensearch.Version) Priority(org.opensearch.common.Priority) Regex(org.opensearch.common.regex.Regex) HashSet(java.util.HashSet) ClusterState(org.opensearch.cluster.ClusterState) ClusterBlock(org.opensearch.cluster.block.ClusterBlock) Locale(java.util.Locale) Map(java.util.Map) AckedClusterStateUpdateTask(org.opensearch.cluster.AckedClusterStateUpdateTask) Inject(org.opensearch.common.inject.Inject) ActionListener(org.opensearch.action.ActionListener) ClusterBlocks(org.opensearch.cluster.block.ClusterBlocks) Setting(org.opensearch.common.settings.Setting) ShardLimitValidator(org.opensearch.indices.ShardLimitValidator) Index(org.opensearch.index.Index) IndicesService(org.opensearch.indices.IndicesService) ExceptionsHelper(org.opensearch.ExceptionsHelper) UpgradeSettingsClusterStateUpdateRequest(org.opensearch.action.admin.indices.upgrade.post.UpgradeSettingsClusterStateUpdateRequest) Set(java.util.Set) Settings(org.opensearch.common.settings.Settings) IOException(java.io.IOException) UpdateSettingsClusterStateUpdateRequest(org.opensearch.action.admin.indices.settings.put.UpdateSettingsClusterStateUpdateRequest) ValidationException(org.opensearch.common.ValidationException) Tuple(org.opensearch.common.collect.Tuple) Logger(org.apache.logging.log4j.Logger) ClusterService(org.opensearch.cluster.service.ClusterService) IndexSettings(org.opensearch.index.IndexSettings) RoutingTable(org.opensearch.cluster.routing.RoutingTable) Optional(java.util.Optional) IndexSettings.same(org.opensearch.index.IndexSettings.same) ClusterStateUpdateResponse(org.opensearch.cluster.ack.ClusterStateUpdateResponse) ContextPreservingActionListener.wrapPreservingContext(org.opensearch.action.support.ContextPreservingActionListener.wrapPreservingContext) LogManager(org.apache.logging.log4j.LogManager) ClusterState(org.opensearch.cluster.ClusterState) HashSet(java.util.HashSet) Set(java.util.Set) ValidationException(org.opensearch.common.ValidationException) Optional(java.util.Optional) Setting(org.opensearch.common.settings.Setting) Index(org.opensearch.index.Index) IOException(java.io.IOException) ClusterStateUpdateResponse(org.opensearch.cluster.ack.ClusterStateUpdateResponse) IndexScopedSettings(org.opensearch.common.settings.IndexScopedSettings) Settings(org.opensearch.common.settings.Settings) IndexSettings(org.opensearch.index.IndexSettings) HashSet(java.util.HashSet)

Example 19 with Setting

use of org.opensearch.common.settings.Setting in project OpenSearch by opensearch-project.

the class ProxyConnectionStrategyTests method testModeSettingsCannotBeUsedWhenInDifferentMode.

public void testModeSettingsCannotBeUsedWhenInDifferentMode() {
    List<Tuple<Setting.AffixSetting<?>, String>> restrictedSettings = Arrays.asList(new Tuple<>(ProxyConnectionStrategy.PROXY_ADDRESS, "192.168.0.1:8080"), new Tuple<>(ProxyConnectionStrategy.REMOTE_SOCKET_CONNECTIONS, "3"));
    RemoteConnectionStrategy.ConnectionStrategy sniff = RemoteConnectionStrategy.ConnectionStrategy.SNIFF;
    String clusterName = "cluster_name";
    Settings settings = Settings.builder().put(RemoteConnectionStrategy.REMOTE_CONNECTION_MODE.getConcreteSettingForNamespace(clusterName).getKey(), sniff.name()).build();
    Set<Setting<?>> clusterSettings = new HashSet<>();
    clusterSettings.add(RemoteConnectionStrategy.REMOTE_CONNECTION_MODE);
    clusterSettings.addAll(restrictedSettings.stream().map(Tuple::v1).collect(Collectors.toList()));
    AbstractScopedSettings service = new ClusterSettings(Settings.EMPTY, clusterSettings);
    // Should validate successfully
    service.validate(settings, true);
    for (Tuple<Setting.AffixSetting<?>, String> restrictedSetting : restrictedSettings) {
        Setting<?> concreteSetting = restrictedSetting.v1().getConcreteSettingForNamespace(clusterName);
        Settings invalid = Settings.builder().put(settings).put(concreteSetting.getKey(), restrictedSetting.v2()).build();
        IllegalArgumentException iae = expectThrows(IllegalArgumentException.class, () -> service.validate(invalid, true));
        String expected = "Setting \"" + concreteSetting.getKey() + "\" cannot be used with the configured " + "\"cluster.remote.cluster_name.mode\" [required=PROXY, configured=SNIFF]";
        assertEquals(expected, iae.getMessage());
    }
}
Also used : ClusterSettings(org.opensearch.common.settings.ClusterSettings) Setting(org.opensearch.common.settings.Setting) AbstractScopedSettings(org.opensearch.common.settings.AbstractScopedSettings) Tuple(org.opensearch.common.collect.Tuple) AbstractScopedSettings(org.opensearch.common.settings.AbstractScopedSettings) Settings(org.opensearch.common.settings.Settings) ClusterSettings(org.opensearch.common.settings.ClusterSettings) HashSet(java.util.HashSet)

Example 20 with Setting

use of org.opensearch.common.settings.Setting in project OpenSearch by opensearch-project.

the class SniffConnectionStrategyTests method testModeSettingsCannotBeUsedWhenInDifferentMode.

public void testModeSettingsCannotBeUsedWhenInDifferentMode() {
    List<Tuple<Setting.AffixSetting<?>, String>> restrictedSettings = Arrays.asList(new Tuple<>(SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS, "192.168.0.1:8080"), new Tuple<>(SniffConnectionStrategy.REMOTE_NODE_CONNECTIONS, "2"));
    RemoteConnectionStrategy.ConnectionStrategy proxy = RemoteConnectionStrategy.ConnectionStrategy.PROXY;
    String clusterName = "cluster_name";
    Settings settings = Settings.builder().put(RemoteConnectionStrategy.REMOTE_CONNECTION_MODE.getConcreteSettingForNamespace(clusterName).getKey(), proxy.name()).build();
    Set<Setting<?>> clusterSettings = new HashSet<>();
    clusterSettings.add(RemoteConnectionStrategy.REMOTE_CONNECTION_MODE);
    clusterSettings.addAll(restrictedSettings.stream().map(Tuple::v1).collect(Collectors.toList()));
    AbstractScopedSettings service = new ClusterSettings(Settings.EMPTY, clusterSettings);
    // Should validate successfully
    service.validate(settings, true);
    for (Tuple<Setting.AffixSetting<?>, String> restrictedSetting : restrictedSettings) {
        Setting<?> concreteSetting = restrictedSetting.v1().getConcreteSettingForNamespace(clusterName);
        Settings invalid = Settings.builder().put(settings).put(concreteSetting.getKey(), restrictedSetting.v2()).build();
        IllegalArgumentException iae = expectThrows(IllegalArgumentException.class, () -> service.validate(invalid, true));
        String expected = "Setting \"" + concreteSetting.getKey() + "\" cannot be used with the configured " + "\"cluster.remote.cluster_name.mode\" [required=SNIFF, configured=PROXY]";
        assertEquals(expected, iae.getMessage());
    }
}
Also used : ClusterSettings(org.opensearch.common.settings.ClusterSettings) Setting(org.opensearch.common.settings.Setting) AbstractScopedSettings(org.opensearch.common.settings.AbstractScopedSettings) Tuple(org.opensearch.common.collect.Tuple) AbstractScopedSettings(org.opensearch.common.settings.AbstractScopedSettings) ClusterSettings(org.opensearch.common.settings.ClusterSettings) Settings(org.opensearch.common.settings.Settings) HashSet(java.util.HashSet)

Aggregations

Setting (org.opensearch.common.settings.Setting)32 ClusterSettings (org.opensearch.common.settings.ClusterSettings)22 Settings (org.opensearch.common.settings.Settings)21 ArrayList (java.util.ArrayList)11 HashSet (java.util.HashSet)11 Before (org.junit.Before)10 ClusterState (org.opensearch.cluster.ClusterState)9 ClusterService (org.opensearch.cluster.service.ClusterService)7 Client (org.opensearch.client.Client)6 Metadata (org.opensearch.cluster.metadata.Metadata)6 DiscoveryNode (org.opensearch.cluster.node.DiscoveryNode)6 Version (org.opensearch.Version)5 ClusterName (org.opensearch.cluster.ClusterName)5 AbstractScopedSettings (org.opensearch.common.settings.AbstractScopedSettings)5 IndexScopedSettings (org.opensearch.common.settings.IndexScopedSettings)5 ExecutorBuilder (org.opensearch.threadpool.ExecutorBuilder)5 ScalingExecutorBuilder (org.opensearch.threadpool.ScalingExecutorBuilder)5 ThreadPool (org.opensearch.threadpool.ThreadPool)5 Arrays (java.util.Arrays)4 Set (java.util.Set)4