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