Search in sources :

Example 16 with Settings

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.

the class EvilLoggerTests method setupLogging.

private void setupLogging(final String config, final Settings settings) throws IOException, UserException {
    assert !Environment.PATH_CONF_SETTING.exists(settings);
    assert !Environment.PATH_HOME_SETTING.exists(settings);
    final Path configDir = getDataPath(config);
    // need to set custom path.conf so we can use a custom log4j2.properties file for the test
    final Settings mergedSettings = Settings.builder().put(settings).put(Environment.PATH_CONF_SETTING.getKey(), configDir.toAbsolutePath()).put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build();
    final Environment environment = new Environment(mergedSettings);
    LogConfigurator.configure(environment);
}
Also used : Path(java.nio.file.Path) Environment(org.elasticsearch.env.Environment) Settings(org.elasticsearch.common.settings.Settings)

Example 17 with Settings

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.

the class S3ProxiedSnapshotRestoreOverHttpsTests method nodeSettings.

@Override
public Settings nodeSettings(int nodeOrdinal) {
    Settings settings = super.nodeSettings(nodeOrdinal);
    String proxyHost = settings.get("cloud.aws.s3.proxy_host");
    proxySet = proxyHost != null;
    return settings;
}
Also used : Settings(org.elasticsearch.common.settings.Settings)

Example 18 with Settings

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.

the class S3RepositoryTests method testBasePathSetting.

public void testBasePathSetting() throws IOException {
    RepositoryMetaData metadata = new RepositoryMetaData("dummy-repo", "mock", Settings.builder().put(Repository.BASE_PATH_SETTING.getKey(), "/foo/bar").build());
    S3Repository s3repo = new S3Repository(metadata, Settings.EMPTY, NamedXContentRegistry.EMPTY, new DummyS3Service());
    // make sure leading `/` is removed and trailing is added
    assertEquals("foo/bar/", s3repo.basePath().buildAsString());
    assertWarnings("S3 repository base_path" + " trimming the leading `/`, and leading `/` will not be supported for the S3 repository in future releases");
    metadata = new RepositoryMetaData("dummy-repo", "mock", Settings.EMPTY);
    Settings settings = Settings.builder().put(Repositories.BASE_PATH_SETTING.getKey(), "/foo/bar").build();
    s3repo = new S3Repository(metadata, settings, NamedXContentRegistry.EMPTY, new DummyS3Service());
    // make sure leading `/` is removed and trailing is added
    assertEquals("foo/bar/", s3repo.basePath().buildAsString());
    assertWarnings("S3 repository base_path" + " trimming the leading `/`, and leading `/` will not be supported for the S3 repository in future releases");
}
Also used : RepositoryMetaData(org.elasticsearch.cluster.metadata.RepositoryMetaData) Settings(org.elasticsearch.common.settings.Settings)

Example 19 with Settings

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.

the class S3RepositoryTests method testSettingsResolution.

public void testSettingsResolution() throws Exception {
    Settings localSettings = Settings.builder().put(Repository.KEY_SETTING.getKey(), "key1").build();
    Settings globalSettings = Settings.builder().put(Repositories.KEY_SETTING.getKey(), "key2").build();
    assertEquals(new SecureString("key1".toCharArray()), getValue(localSettings, globalSettings, Repository.KEY_SETTING, Repositories.KEY_SETTING));
    assertEquals(new SecureString("key1".toCharArray()), getValue(localSettings, Settings.EMPTY, Repository.KEY_SETTING, Repositories.KEY_SETTING));
    assertEquals(new SecureString("key2".toCharArray()), getValue(Settings.EMPTY, globalSettings, Repository.KEY_SETTING, Repositories.KEY_SETTING));
    assertEquals(new SecureString("".toCharArray()), getValue(Settings.EMPTY, Settings.EMPTY, Repository.KEY_SETTING, Repositories.KEY_SETTING));
    assertSettingDeprecationsAndWarnings(new Setting<?>[] { Repository.KEY_SETTING, Repositories.KEY_SETTING });
}
Also used : Settings(org.elasticsearch.common.settings.Settings) SecureString(org.elasticsearch.common.settings.SecureString)

Example 20 with Settings

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.common.settings.Settings in project crate by crate.

the class RepositoryParamValidator method convertAndValidate.

public Settings convertAndValidate(String type, Optional<GenericProperties> genericProperties, ParameterContext parameterContext) {
    TypeSettings typeSettings = this.typeSettings.get(type);
    if (typeSettings == null) {
        throw new IllegalArgumentException(String.format(Locale.ENGLISH, "Invalid repository type \"%s\"", type));
    }
    Map<String, SettingsApplier> allSettings = typeSettings.all();
    // create string settings applier for all dynamic settings
    Optional<GenericProperties> dynamicProperties = typeSettings.dynamicProperties(genericProperties);
    if (dynamicProperties.isPresent()) {
        // allSettings are immutable by default, copy map
        allSettings = Maps.newHashMap(allSettings);
        for (String key : dynamicProperties.get().properties().keySet()) {
            allSettings.put(key, new SettingsAppliers.StringSettingsApplier(new StringSetting(key, true)));
        }
    }
    // convert and validate all settings
    Settings settings = GenericPropertiesConverter.settingsFromProperties(genericProperties, parameterContext, allSettings).build();
    Set<String> names = settings.getAsMap().keySet();
    Sets.SetView<String> missingRequiredSettings = Sets.difference(typeSettings.required().keySet(), names);
    if (!missingRequiredSettings.isEmpty()) {
        throw new IllegalArgumentException(String.format(Locale.ENGLISH, "The following required parameters are missing to create a repository of type \"%s\": [%s]", type, Joiner.on(", ").join(missingRequiredSettings)));
    }
    return settings;
}
Also used : SettingsAppliers(io.crate.metadata.settings.SettingsAppliers) SettingsApplier(io.crate.metadata.settings.SettingsApplier) StringSetting(io.crate.metadata.settings.StringSetting) Sets(com.google.common.collect.Sets) GenericProperties(io.crate.sql.tree.GenericProperties) Settings(org.elasticsearch.common.settings.Settings)

Aggregations

Settings (org.elasticsearch.common.settings.Settings)1248 Test (org.junit.Test)197 IndexSettings (org.elasticsearch.index.IndexSettings)167 IOException (java.io.IOException)133 Path (java.nio.file.Path)121 ClusterState (org.elasticsearch.cluster.ClusterState)120 ArrayList (java.util.ArrayList)108 ClusterSettings (org.elasticsearch.common.settings.ClusterSettings)106 HashMap (java.util.HashMap)105 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)98 Version (org.elasticsearch.Version)91 Matchers.containsString (org.hamcrest.Matchers.containsString)91 Environment (org.elasticsearch.env.Environment)87 Map (java.util.Map)85 List (java.util.List)79 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)72 Index (org.elasticsearch.index.Index)70 HashSet (java.util.HashSet)58 IndexMetadata (org.elasticsearch.cluster.metadata.IndexMetadata)54 ThreadPool (org.elasticsearch.threadpool.ThreadPool)54