Search in sources :

Example 11 with Settings

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));
}
Also used : BlobAdminClient(io.crate.blob.v2.BlobAdminClient) Settings(org.elasticsearch.common.settings.Settings) Test(org.junit.Test)

Example 12 with Settings

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();
}
Also used : BlobAdminClient(io.crate.blob.v2.BlobAdminClient) Settings(org.elasticsearch.common.settings.Settings) Before(org.junit.Before)

Example 13 with Settings

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();
}
Also used : File(java.io.File) URL(java.net.URL) Settings(org.elasticsearch.common.settings.Settings)

Example 14 with Settings

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"));
}
Also used : PluginsService(org.elasticsearch.plugins.PluginsService) Settings(org.elasticsearch.common.settings.Settings) Test(org.junit.Test)

Example 15 with Settings

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());
}
Also used : Path(java.nio.file.Path) Strings.cleanPath(org.elasticsearch.common.Strings.cleanPath) Environment(org.elasticsearch.env.Environment) CrateSettings(io.crate.metadata.settings.CrateSettings) Settings(org.elasticsearch.common.settings.Settings)

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