Search in sources :

Example 1 with ESClusterUpdateSettingsPlan

use of io.crate.planner.node.ddl.ESClusterUpdateSettingsPlan in project crate by crate.

the class TransportExecutorDDLTest method testClusterUpdateSettingsTask.

@Test
public void testClusterUpdateSettingsTask() throws Exception {
    final String persistentSetting = "stats.enabled";
    final String transientSetting = "bulk.request_timeout";
    // Update persistent only
    Map<String, List<Expression>> persistentSettings = new HashMap<String, List<Expression>>() {

        {
            put(persistentSetting, ImmutableList.<Expression>of(Literal.fromObject(true)));
        }
    };
    ESClusterUpdateSettingsPlan node = new ESClusterUpdateSettingsPlan(UUID.randomUUID(), persistentSettings);
    Bucket objects = executePlan(node);
    assertThat(objects, contains(isRow(1L)));
    assertEquals("true", client().admin().cluster().prepareState().execute().actionGet().getState().metaData().persistentSettings().get(persistentSetting));
    // Update transient only
    Map<String, List<Expression>> transientSettings = new HashMap<String, List<Expression>>() {

        {
            put(transientSetting, ImmutableList.<Expression>of(Literal.fromObject("123s")));
        }
    };
    node = new ESClusterUpdateSettingsPlan(UUID.randomUUID(), ImmutableMap.<String, List<Expression>>of(), transientSettings);
    objects = executePlan(node);
    assertThat(objects, contains(isRow(1L)));
    assertEquals("123000ms", client().admin().cluster().prepareState().execute().actionGet().getState().metaData().transientSettings().get(transientSetting));
    // Update persistent & transient
    persistentSettings = new HashMap<String, List<Expression>>() {

        {
            put(persistentSetting, ImmutableList.<Expression>of(Literal.fromObject(false)));
        }
    };
    transientSettings = new HashMap<String, List<Expression>>() {

        {
            put(transientSetting, ImmutableList.<Expression>of(Literal.fromObject("243s")));
        }
    };
    node = new ESClusterUpdateSettingsPlan(UUID.randomUUID(), persistentSettings, transientSettings);
    objects = executePlan(node);
    MetaData md = client().admin().cluster().prepareState().execute().actionGet().getState().metaData();
    assertThat(objects, contains(isRow(1L)));
    assertEquals("false", md.persistentSettings().get(persistentSetting));
    assertEquals("243000ms", md.transientSettings().get(transientSetting));
}
Also used : ESClusterUpdateSettingsPlan(io.crate.planner.node.ddl.ESClusterUpdateSettingsPlan) Expression(io.crate.sql.tree.Expression) Bucket(io.crate.data.Bucket) MetaData(org.elasticsearch.cluster.metadata.MetaData) ImmutableList(com.google.common.collect.ImmutableList) SQLTransportIntegrationTest(io.crate.integrationtests.SQLTransportIntegrationTest) Test(org.junit.Test)

Example 2 with ESClusterUpdateSettingsPlan

use of io.crate.planner.node.ddl.ESClusterUpdateSettingsPlan in project crate by crate.

the class PlannerTest method testSetPlan.

@Test
public void testSetPlan() throws Exception {
    ESClusterUpdateSettingsPlan plan = e.plan("set GLOBAL PERSISTENT stats.jobs_log_size=1024");
    // set transient settings too when setting persistent ones
    assertThat(plan.transientSettings().get("stats.jobs_log_size").get(0), Is.<Expression>is(new LongLiteral("1024")));
    assertThat(plan.persistentSettings().get("stats.jobs_log_size").get(0), Is.<Expression>is(new LongLiteral("1024")));
    plan = e.plan("set GLOBAL TRANSIENT stats.enabled=false,stats.jobs_log_size=0");
    assertThat(plan.persistentSettings().size(), is(0));
    assertThat(plan.transientSettings().size(), is(2));
}
Also used : ESClusterUpdateSettingsPlan(io.crate.planner.node.ddl.ESClusterUpdateSettingsPlan) LongLiteral(io.crate.sql.tree.LongLiteral) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

ESClusterUpdateSettingsPlan (io.crate.planner.node.ddl.ESClusterUpdateSettingsPlan)2 Test (org.junit.Test)2 ImmutableList (com.google.common.collect.ImmutableList)1 Bucket (io.crate.data.Bucket)1 SQLTransportIntegrationTest (io.crate.integrationtests.SQLTransportIntegrationTest)1 Expression (io.crate.sql.tree.Expression)1 LongLiteral (io.crate.sql.tree.LongLiteral)1 CrateUnitTest (io.crate.test.integration.CrateUnitTest)1 MetaData (org.elasticsearch.cluster.metadata.MetaData)1