use of org.elasticsearch.common.settings.Settings in project crate by crate.
the class ShardStatsTest method testTableNameBlobTable.
@Test
public void testTableNameBlobTable() throws Exception {
BlobAdminClient blobAdminClient = internalCluster().getInstance(BlobAdminClient.class);
Settings indexSettings = Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1).put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1).build();
blobAdminClient.createBlobTable("blobs", indexSettings).get();
ensureGreen();
execute("select schema_name, table_name from sys.shards where table_name = 'blobs'");
assertThat(response.rowCount(), is(2L));
for (int i = 0; i < response.rowCount(); i++) {
assertThat((String) response.rows()[i][0], is("blob"));
assertThat((String) response.rows()[i][1], is("blobs"));
}
execute("create blob table sbolb clustered into 4 shards with (number_of_replicas=3)");
ensureYellow();
execute("select schema_name, table_name from sys.shards where table_name = 'sbolb'");
assertThat(response.rowCount(), is(16L));
for (int i = 0; i < response.rowCount(); i++) {
assertThat((String) response.rows()[i][0], is("blob"));
assertThat((String) response.rows()[i][1], is("sbolb"));
}
execute("select count(*) from sys.shards " + "where schema_name='blob' and table_name != 'blobs' " + "and table_name != 'sbolb'");
assertThat(response.rowCount(), is(1L));
assertThat((Long) response.rows()[0][0], is(0L));
}
use of org.elasticsearch.common.settings.Settings in project crate by crate.
the class SysShardsTest method initTestData.
@Before
public void initTestData() throws Exception {
Setup setup = new Setup(sqlExecutor);
setup.groupBySetup();
sqlExecutor.exec("create table quotes (id integer primary key, quote string) with(number_of_replicas=1)");
BlobAdminClient blobAdminClient = internalCluster().getInstance(BlobAdminClient.class);
Settings indexSettings = Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1).put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 5).build();
blobAdminClient.createBlobTable("blobs", indexSettings);
sqlExecutor.ensureGreen();
}
use of org.elasticsearch.common.settings.Settings in project crate by crate.
the class PluginLoaderTest method startNodeWithPlugins.
private static String startNodeWithPlugins(String pluginDir) throws URISyntaxException {
URL resource = PluginLoaderTest.class.getResource(pluginDir);
Settings.Builder settings = settingsBuilder();
if (resource != null) {
settings.put("path.crate_plugins", new File(resource.toURI()).getAbsolutePath());
}
String nodeName = internalCluster().startNode(settings);
// We wait for a Green status
client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
return internalCluster().getInstance(ClusterService.class, nodeName).state().nodes().localNode().name();
}
use of org.elasticsearch.common.settings.Settings in project crate by crate.
the class PluginLoaderTest method testPluginWithCrateSettings.
@Test
public void testPluginWithCrateSettings() throws Exception {
String node = startNodeWithPlugins("/io/crate/plugin/plugin_with_crate_settings");
PluginsService pluginsService = internalCluster().getInstance(PluginsService.class, node);
PluginLoaderPlugin corePlugin = getCratePlugin(pluginsService.plugins());
Settings settings = corePlugin.settings;
assertThat(settings.get("setting.for.crate"), is("foo"));
}
use of org.elasticsearch.common.settings.Settings in project crate by crate.
the class CrateSettingsPreparer method prepareEnvironment.
/**
* ES_COPY_OF: core/src/main/java/org/elasticsearch/node/internal/InternalSettingsPreparer.java
* This is a copy of {@link InternalSettingsPreparer#prepareEnvironment(Settings, Terminal)}
* <p>
* with the addition of the "applyCrateDefaults" call.
*/
public static Environment prepareEnvironment(Settings input, Terminal terminal) {
// just create enough settings to build the environment, to get the config dir
Settings.Builder output = settingsBuilder();
InternalSettingsPreparer.initializeSettings(output, input, true);
Environment environment = new Environment(output.build());
Path path = environment.configFile().resolve("crate.yml");
if (Files.exists(path)) {
output.loadFromPath(path);
}
// re-initialize settings now that the config file has been loaded
// TODO: only re-initialize if a config file was actually loaded
InternalSettingsPreparer.initializeSettings(output, input, false);
InternalSettingsPreparer.finalizeSettings(output, terminal, environment.configFile());
validateKnownSettings(output);
applyCrateDefaults(output);
environment = new Environment(output.build());
// we put back the path.logs so we can use it in the logging configuration file
output.put("path.logs", cleanPath(environment.logsFile().toAbsolutePath().toString()));
return new Environment(output.build());
}
Aggregations