Search in sources :

Example 46 with Environment

use of org.elasticsearch.env.Environment in project elasticsearch-skywalker by jprante.

the class SkywalkerTests method test.

@Test
public void test() {
    Settings settings = ImmutableSettings.settingsBuilder().build();
    Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), new EnvironmentModule(new Environment(settings)), new IndicesAnalysisModule()).createInjector();
    ActionModule actionModule = new ActionModule(true);
    RestModule restModule = new RestModule(settings);
    SkywalkerPlugin plugin = new SkywalkerPlugin();
    plugin.onModule(actionModule);
    plugin.onModule(restModule);
}
Also used : IndicesAnalysisModule(org.elasticsearch.indices.analysis.IndicesAnalysisModule) RestModule(org.elasticsearch.rest.RestModule) EnvironmentModule(org.elasticsearch.env.EnvironmentModule) Injector(org.elasticsearch.common.inject.Injector) ActionModule(org.elasticsearch.action.ActionModule) SettingsModule(org.elasticsearch.common.settings.SettingsModule) Environment(org.elasticsearch.env.Environment) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) Settings(org.elasticsearch.common.settings.Settings) ImmutableSettings(org.elasticsearch.common.settings.ImmutableSettings) Test(org.testng.annotations.Test)

Example 47 with Environment

use of org.elasticsearch.env.Environment in project crate by crate.

the class PreExecutionBenchmark method setup.

@Setup
public void setup() throws Exception {
    Path tempDir = Files.createTempDirectory("");
    Settings settings = Settings.builder().put("path.home", tempDir.toAbsolutePath().toString()).build();
    Environment environment = new Environment(settings, tempDir);
    node = new Node(environment, List.of(Netty4Plugin.class), true);
    node.start();
    Injector injector = node.injector();
    sqlOperations = injector.getInstance(SQLOperations.class);
    analyzer = injector.getInstance(Analyzer.class);
    planner = injector.getInstance(Planner.class);
    clusterService = injector.getInstance(ClusterService.class);
    nodeCtx = injector.getInstance(NodeContext.class);
    String statement = "create table users (id int primary key, name string, date timestamp, text string index using fulltext)";
    var resultReceiver = new BaseResultReceiver();
    sqlOperations.newSystemSession().quickExec(statement, resultReceiver, Row.EMPTY);
    resultReceiver.completionFuture().get(5, TimeUnit.SECONDS);
}
Also used : Path(java.nio.file.Path) NodeContext(io.crate.metadata.NodeContext) Node(org.elasticsearch.node.Node) ClusterService(org.elasticsearch.cluster.service.ClusterService) Injector(org.elasticsearch.common.inject.Injector) Environment(org.elasticsearch.env.Environment) BaseResultReceiver(io.crate.action.sql.BaseResultReceiver) Planner(io.crate.planner.Planner) SQLOperations(io.crate.action.sql.SQLOperations) Settings(org.elasticsearch.common.settings.Settings) Setup(org.openjdk.jmh.annotations.Setup)

Example 48 with Environment

use of org.elasticsearch.env.Environment in project crate by crate.

the class NodeSettingsTest method doSetup.

@Before
public void doSetup() throws Exception {
    tmp.create();
    Path configPath = createConfigPath();
    Map<String, String> settings = new HashMap<>();
    settings.put("node.name", "node-test");
    settings.put("node.data", "true");
    settings.put(PATH_HOME_SETTING.getKey(), configPath.toString());
    // Avoid connecting to other test nodes
    settings.put("discovery.type", "single-node");
    Environment environment = InternalSettingsPreparer.prepareEnvironment(Settings.EMPTY, settings, configPath, () -> "node-test");
    node = new CrateNode(environment);
    node.start();
    sqlOperations = node.injector().getInstance(SQLOperations.class);
}
Also used : Path(java.nio.file.Path) HashMap(java.util.HashMap) Environment(org.elasticsearch.env.Environment) SQLOperations(io.crate.action.sql.SQLOperations) Before(org.junit.Before)

Example 49 with Environment

use of org.elasticsearch.env.Environment in project crate by crate.

the class UnsafeBootstrapAndDetachCommandIT method testBootstrapNotBootstrappedCluster.

public void testBootstrapNotBootstrappedCluster() throws Exception {
    String node = internalCluster().startNode(Settings.builder().put(Node.INITIAL_STATE_TIMEOUT_SETTING.getKey(), // to ensure quick node startup
    "0s").build());
    assertBusy(() -> {
        ClusterState state = client().admin().cluster().prepareState().setLocal(true).execute().actionGet().getState();
        assertTrue(state.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID));
    });
    Settings dataPathSettings = internalCluster().dataPathSettings(node);
    internalCluster().stopRandomDataNode();
    Environment environment = TestEnvironment.newEnvironment(Settings.builder().put(internalCluster().getDefaultSettings()).put(dataPathSettings).build());
    expectThrows(() -> unsafeBootstrap(environment), UnsafeBootstrapMasterCommand.EMPTY_LAST_COMMITTED_VOTING_CONFIG_MSG);
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) Environment(org.elasticsearch.env.Environment) NodeEnvironment(org.elasticsearch.env.NodeEnvironment) TestEnvironment(org.elasticsearch.env.TestEnvironment) Matchers.containsString(org.hamcrest.Matchers.containsString) Settings(org.elasticsearch.common.settings.Settings)

Example 50 with Environment

use of org.elasticsearch.env.Environment in project crate by crate.

the class UnsafeBootstrapAndDetachCommandIT method testBootstrapAbortedByUser.

public void testBootstrapAbortedByUser() throws IOException {
    internalCluster().setBootstrapMasterNodeIndex(0);
    String node = internalCluster().startNode();
    Settings dataPathSettings = internalCluster().dataPathSettings(node);
    ensureStableCluster(1);
    internalCluster().stopRandomDataNode();
    Environment environment = TestEnvironment.newEnvironment(Settings.builder().put(internalCluster().getDefaultSettings()).put(dataPathSettings).build());
    expectThrows(() -> unsafeBootstrap(environment, true), ElasticsearchNodeCommand.ABORTED_BY_USER_MSG);
}
Also used : Environment(org.elasticsearch.env.Environment) NodeEnvironment(org.elasticsearch.env.NodeEnvironment) TestEnvironment(org.elasticsearch.env.TestEnvironment) Matchers.containsString(org.hamcrest.Matchers.containsString) Settings(org.elasticsearch.common.settings.Settings)

Aggregations

Environment (org.elasticsearch.env.Environment)130 Settings (org.elasticsearch.common.settings.Settings)84 Path (java.nio.file.Path)66 Matchers.containsString (org.hamcrest.Matchers.containsString)42 NodeEnvironment (org.elasticsearch.env.NodeEnvironment)26 TestEnvironment (org.elasticsearch.env.TestEnvironment)22 IndexSettings (org.elasticsearch.index.IndexSettings)21 UserException (org.elasticsearch.cli.UserException)17 IOException (java.io.IOException)15 AnalysisModule (org.elasticsearch.indices.analysis.AnalysisModule)9 MockTerminal (org.elasticsearch.cli.MockTerminal)8 ClusterState (org.elasticsearch.cluster.ClusterState)8 ScriptService (org.elasticsearch.script.ScriptService)8 HashMap (java.util.HashMap)7 ScriptContextRegistry (org.elasticsearch.script.ScriptContextRegistry)7 ScriptEngineRegistry (org.elasticsearch.script.ScriptEngineRegistry)7 ScriptSettings (org.elasticsearch.script.ScriptSettings)7 ArrayList (java.util.ArrayList)6 ElasticsearchException (org.elasticsearch.ElasticsearchException)6 Before (org.junit.Before)6