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);
}
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;
}
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");
}
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 });
}
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;
}
Aggregations