Search in sources :

Example 21 with Settings

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

the class RepositoryParamValidatorTest method testS3ConfigParams.

@Test
public void testS3ConfigParams() throws Exception {
    GenericProperties genericProperties = new GenericProperties();
    genericProperties.add(new GenericProperty("access_key", new StringLiteral("foobar")));
    genericProperties.add(new GenericProperty("base_path", new StringLiteral("/data")));
    genericProperties.add(new GenericProperty("bucket", new StringLiteral("myBucket")));
    genericProperties.add(new GenericProperty("buffer_size", new StringLiteral("10k")));
    genericProperties.add(new GenericProperty("canned_acl", new StringLiteral("cannedACL")));
    genericProperties.add(new GenericProperty("chunk_size", new StringLiteral("4g")));
    genericProperties.add(new GenericProperty("compress", new StringLiteral("true")));
    genericProperties.add(new GenericProperty("concurrent_streams", new StringLiteral("12")));
    genericProperties.add(new GenericProperty("endpoint", new StringLiteral("myEndpoint")));
    genericProperties.add(new GenericProperty("max_retries", new StringLiteral("8")));
    genericProperties.add(new GenericProperty("protocol", new StringLiteral("myProtocol")));
    genericProperties.add(new GenericProperty("region", new StringLiteral("Europe-1")));
    genericProperties.add(new GenericProperty("secret_key", new StringLiteral("thisIsASecretKey")));
    genericProperties.add(new GenericProperty("server_side_encryption", new StringLiteral("false")));
    Settings settings = validator.convertAndValidate("s3", Optional.of(genericProperties), ParameterContext.EMPTY);
    assertThat(settings.get("access_key"), is("foobar"));
    assertThat(settings.get("base_path"), is("/data"));
    assertThat(settings.get("bucket"), is("myBucket"));
    assertThat(settings.get("buffer_size"), is("10240b"));
    assertThat(settings.get("canned_acl"), is("cannedACL"));
    assertThat(settings.get("chunk_size"), is("4294967296b"));
    assertThat(settings.get("compress"), is("true"));
    assertThat(settings.get("concurrent_streams"), is("12"));
    assertThat(settings.get("endpoint"), is("myEndpoint"));
    assertThat(settings.get("max_retries"), is("8"));
    assertThat(settings.get("protocol"), is("myProtocol"));
    assertThat(settings.get("region"), is("Europe-1"));
    assertThat(settings.get("secret_key"), is("thisIsASecretKey"));
    assertThat(settings.get("server_side_encryption"), is("false"));
}
Also used : StringLiteral(io.crate.sql.tree.StringLiteral) GenericProperty(io.crate.sql.tree.GenericProperty) GenericProperties(io.crate.sql.tree.GenericProperties) Settings(org.elasticsearch.common.settings.Settings) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 22 with Settings

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

the class ApplySettingsTest method testOnRefreshSettings.

@Test
public void testOnRefreshSettings() throws Exception {
    ConcurrentHashMap<String, Object> values = new ConcurrentHashMap<>();
    ClusterSettingsExpression.ApplySettings applySettings = new ClusterSettingsExpression.ApplySettings(Settings.EMPTY, values);
    Settings.Builder builder = Settings.builder().put(CrateSettings.STATS_JOBS_LOG_SIZE.settingName(), 1).put(CrateSettings.STATS_ENABLED.settingName(), false).put(CrateSettings.GRACEFUL_STOP_MIN_AVAILABILITY.settingName(), "full").put(CrateSettings.GRACEFUL_STOP_TIMEOUT.settingName(), "1m").put(CrateSettings.DISCOVERY_ZEN_MIN_MASTER_NODES.settingName(), 2);
    Settings settings = builder.build();
    applySettings.onRefreshSettings(settings);
    String name = CrateSettings.STATS_JOBS_LOG_SIZE.settingName();
    assertEquals(values.get(name), settings.getAsInt(name, 0));
    name = CrateSettings.STATS_ENABLED.settingName();
    assertEquals(values.get(name), settings.getAsBoolean(name, true));
    name = CrateSettings.GRACEFUL_STOP_MIN_AVAILABILITY.settingName();
    assertEquals(values.get(name), settings.get(name, "none"));
    name = CrateSettings.GRACEFUL_STOP_TIMEOUT.settingName();
    assertEquals(values.get(name), settings.get(name, "1h"));
    name = CrateSettings.DISCOVERY_ZEN_MIN_MASTER_NODES.settingName();
    assertEquals(values.get(name), settings.getAsInt(name, 2));
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CrateSettings(io.crate.metadata.settings.CrateSettings) Settings(org.elasticsearch.common.settings.Settings) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 23 with Settings

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

the class JobsLogsTest method testEnableStats.

@Test
public void testEnableStats() throws Exception {
    Settings settings = Settings.builder().put(CrateSettings.STATS_ENABLED.settingName(), false).put(CrateSettings.STATS_JOBS_LOG_SIZE.settingName(), 100).put(CrateSettings.STATS_OPERATIONS_LOG_SIZE.settingName(), 100).build();
    JobsLogService stats = new JobsLogService(settings, nodeSettingsService, scheduler, breakerService);
    stats.listener.onRefreshSettings(Settings.builder().put(CrateSettings.STATS_ENABLED.settingName(), true).build());
    assertThat(stats.isEnabled(), is(true));
    assertThat(stats.lastJobsLogSize, is(100));
    assertThat(stats.jobsLogSink, Matchers.instanceOf(QueueSink.class));
    assertThat(stats.lastOperationsLogSize, is(100));
    assertThat(stats.operationsLogSink, Matchers.instanceOf(QueueSink.class));
}
Also used : CrateSettings(io.crate.metadata.settings.CrateSettings) Settings(org.elasticsearch.common.settings.Settings) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 24 with Settings

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

the class DocLevelExpressionsTest method prepare.

@Before
public void prepare() throws Exception {
    Settings settings = Settings.builder().put("index.fielddata.cache", "none").build();
    IndexService indexService = createIndex("test", settings);
    ifd = indexService.fieldData();
    writer = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(new StandardAnalyzer()).setMergePolicy(new LogByteSizeMergePolicy()));
    insertValues(writer);
    DirectoryReader directoryReader = DirectoryReader.open(writer, true);
    readerContext = directoryReader.leaves().get(0);
    ctx = new CollectorContext(ifd, null);
}
Also used : IndexService(org.elasticsearch.index.IndexService) StandardAnalyzer(org.apache.lucene.analysis.standard.StandardAnalyzer) CollectorContext(io.crate.operation.reference.doc.lucene.CollectorContext) Settings(org.elasticsearch.common.settings.Settings) RAMDirectory(org.apache.lucene.store.RAMDirectory) Before(org.junit.Before)

Example 25 with Settings

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

the class ESClusterUpdateSettingsTaskTest method testUpdateMultipleSettingsWithParameters.

@Test
public void testUpdateMultipleSettingsWithParameters() throws Exception {
    Map<String, List<Expression>> settings = new HashMap<String, List<Expression>>() {

        {
            put("stats.operations_log_size", ImmutableList.<Expression>of(new ParameterExpression(1)));
            put("stats.jobs_log_size", ImmutableList.<Expression>of(new ParameterExpression(2)));
        }
    };
    Settings expected = Settings.builder().put("stats.operations_log_size", 10).put("stats.jobs_log_size", 25).build();
    assertThat(ESClusterUpdateSettingsTask.buildSettingsFrom(settings, new RowN(new Object[] { 10, 25 })), is(expected));
}
Also used : RowN(io.crate.data.RowN) HashMap(java.util.HashMap) ParameterExpression(io.crate.sql.tree.ParameterExpression) Expression(io.crate.sql.tree.Expression) ParameterExpression(io.crate.sql.tree.ParameterExpression) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Settings(org.elasticsearch.common.settings.Settings) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

Settings (org.elasticsearch.common.settings.Settings)866 IndexSettings (org.elasticsearch.index.IndexSettings)112 Path (java.nio.file.Path)91 IOException (java.io.IOException)83 ClusterState (org.elasticsearch.cluster.ClusterState)76 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)72 ClusterSettings (org.elasticsearch.common.settings.ClusterSettings)68 HashMap (java.util.HashMap)66 ArrayList (java.util.ArrayList)64 Version (org.elasticsearch.Version)63 Environment (org.elasticsearch.env.Environment)63 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)61 Test (org.junit.Test)60 Map (java.util.Map)55 Index (org.elasticsearch.index.Index)55 Matchers.containsString (org.hamcrest.Matchers.containsString)54 List (java.util.List)45 ThreadPool (org.elasticsearch.threadpool.ThreadPool)40 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)37 MetaData (org.elasticsearch.cluster.metadata.MetaData)36