Search in sources :

Example 1 with NodeEnvironment

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

the class SigarExtendedNodeInfoTest method prepare.

@Before
public void prepare() throws Exception {
    NodeEnvironment nodeEnvironment = mock(NodeEnvironment.class);
    when(nodeEnvironment.hasNodeFile()).thenReturn(true);
    Path tempDir = createTempDir();
    NodeEnvironment.NodePath[] dataLocations = new NodeEnvironment.NodePath[] { new NodeEnvironment.NodePath(tempDir, mock(Environment.class)) };
    when(nodeEnvironment.nodePaths()).thenReturn(dataLocations);
    NodeEnvironmentModule nodeEnvironmentModule = new NodeEnvironmentModule(nodeEnvironment);
    MonitorModule monitorModule = new MonitorModule(NODE_SETTINGS);
    monitorModule.addExtendedNodeInfoType(SigarPlugin.NODE_INFO_EXTENDED_TYPE, SigarExtendedNodeInfo.class);
    Injector injector = new ModulesBuilder().add(new SettingsModule(NODE_SETTINGS), monitorModule, nodeEnvironmentModule, new SigarModule(new SigarService(NODE_SETTINGS))).createInjector();
    extendedNodeInfo = injector.getInstance(ExtendedNodeInfo.class);
}
Also used : Path(java.nio.file.Path) NodeEnvironment(org.elasticsearch.env.NodeEnvironment) Injector(org.elasticsearch.common.inject.Injector) SettingsModule(org.elasticsearch.common.settings.SettingsModule) SigarModule(io.crate.module.SigarModule) Environment(org.elasticsearch.env.Environment) NodeEnvironment(org.elasticsearch.env.NodeEnvironment) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) NodeEnvironmentModule(org.elasticsearch.env.NodeEnvironmentModule) Before(org.junit.Before)

Example 2 with NodeEnvironment

use of org.elasticsearch.env.NodeEnvironment in project elasticsearch by elastic.

the class OldIndexUtils method upgradeIndexFolder.

public static void upgradeIndexFolder(InternalTestCluster cluster, String nodeName) throws Exception {
    final NodeEnvironment nodeEnvironment = cluster.getInstance(NodeEnvironment.class, nodeName);
    IndexFolderUpgrader.upgradeIndicesIfNeeded(Settings.EMPTY, nodeEnvironment);
}
Also used : NodeEnvironment(org.elasticsearch.env.NodeEnvironment)

Example 3 with NodeEnvironment

use of org.elasticsearch.env.NodeEnvironment in project elasticsearch by elastic.

the class IndexFolderUpgraderTests method testUpgradeCustomDataPath.

/**
     * tests custom data paths are upgraded
     */
public void testUpgradeCustomDataPath() throws IOException {
    Path customPath = createTempDir();
    final Settings nodeSettings = Settings.builder().put(NodeEnvironment.ADD_NODE_LOCK_ID_TO_CUSTOM_PATH.getKey(), randomBoolean()).put(Environment.PATH_SHARED_DATA_SETTING.getKey(), customPath.toAbsolutePath().toString()).build();
    try (NodeEnvironment nodeEnv = newNodeEnvironment(nodeSettings)) {
        final Index index = new Index(randomAsciiOfLength(10), UUIDs.randomBase64UUID());
        Settings settings = Settings.builder().put(nodeSettings).put(IndexMetaData.SETTING_INDEX_UUID, index.getUUID()).put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_2_0_0).put(IndexMetaData.SETTING_DATA_PATH, customPath.toAbsolutePath().toString()).put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, randomIntBetween(1, 5)).put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0).build();
        IndexMetaData indexState = IndexMetaData.builder(index.getName()).settings(settings).build();
        int numIdxFiles = randomIntBetween(1, 5);
        int numTranslogFiles = randomIntBetween(1, 5);
        IndexSettings indexSettings = new IndexSettings(indexState, nodeSettings);
        writeIndex(nodeEnv, indexSettings, numIdxFiles, numTranslogFiles);
        IndexFolderUpgrader helper = new IndexFolderUpgrader(settings, nodeEnv);
        helper.upgrade(indexSettings.getIndex().getName());
        checkIndex(nodeEnv, indexSettings, numIdxFiles, numTranslogFiles);
    }
}
Also used : Path(java.nio.file.Path) ShardPath(org.elasticsearch.index.shard.ShardPath) NodeEnvironment(org.elasticsearch.env.NodeEnvironment) IndexSettings(org.elasticsearch.index.IndexSettings) Index(org.elasticsearch.index.Index) Settings(org.elasticsearch.common.settings.Settings) IndexSettings(org.elasticsearch.index.IndexSettings) IndexMetaData(org.elasticsearch.cluster.metadata.IndexMetaData)

Example 4 with NodeEnvironment

use of org.elasticsearch.env.NodeEnvironment in project elasticsearch by elastic.

the class IndexModuleTests method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build();
    indicesQueryCache = new IndicesQueryCache(settings);
    indexSettings = IndexSettingsModule.newIndexSettings("foo", settings);
    index = indexSettings.getIndex();
    environment = new Environment(settings);
    threadPool = new TestThreadPool("test");
    circuitBreakerService = new NoneCircuitBreakerService();
    bigArrays = new BigArrays(settings, circuitBreakerService);
    ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry(emptyList());
    ScriptContextRegistry scriptContextRegistry = new ScriptContextRegistry(Collections.emptyList());
    ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, scriptContextRegistry);
    scriptService = new ScriptService(settings, environment, new ResourceWatcherService(settings, threadPool), scriptEngineRegistry, scriptContextRegistry, scriptSettings);
    clusterService = ClusterServiceUtils.createClusterService(threadPool);
    nodeEnvironment = new NodeEnvironment(settings, environment);
    mapperRegistry = new IndicesModule(Collections.emptyList()).getMapperRegistry();
}
Also used : IndicesQueryCache(org.elasticsearch.indices.IndicesQueryCache) ScriptService(org.elasticsearch.script.ScriptService) BigArrays(org.elasticsearch.common.util.BigArrays) IndicesModule(org.elasticsearch.indices.IndicesModule) ScriptSettings(org.elasticsearch.script.ScriptSettings) NodeEnvironment(org.elasticsearch.env.NodeEnvironment) ScriptEngineRegistry(org.elasticsearch.script.ScriptEngineRegistry) Environment(org.elasticsearch.env.Environment) NodeEnvironment(org.elasticsearch.env.NodeEnvironment) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) ResourceWatcherService(org.elasticsearch.watcher.ResourceWatcherService) ScriptContextRegistry(org.elasticsearch.script.ScriptContextRegistry) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService)

Example 5 with NodeEnvironment

use of org.elasticsearch.env.NodeEnvironment in project elasticsearch by elastic.

the class DanglingIndicesStateTests method testInvalidIndexFolder.

public void testInvalidIndexFolder() throws Exception {
    try (NodeEnvironment env = newNodeEnvironment()) {
        MetaStateService metaStateService = new MetaStateService(Settings.EMPTY, env, xContentRegistry());
        DanglingIndicesState danglingState = createDanglingIndicesState(env, metaStateService);
        MetaData metaData = MetaData.builder().build();
        final String uuid = "test1UUID";
        final Settings.Builder settings = Settings.builder().put(indexSettings).put(IndexMetaData.SETTING_INDEX_UUID, uuid);
        IndexMetaData dangledIndex = IndexMetaData.builder("test1").settings(settings).build();
        metaStateService.writeIndex("test_write", dangledIndex);
        for (Path path : env.resolveIndexFolder(uuid)) {
            if (Files.exists(path)) {
                Files.move(path, path.resolveSibling("invalidUUID"), StandardCopyOption.ATOMIC_MOVE);
            }
        }
        try {
            danglingState.findNewDanglingIndices(metaData);
            fail("no exception thrown for invalid folder name");
        } catch (IllegalStateException e) {
            assertThat(e.getMessage(), equalTo("[invalidUUID] invalid index folder name, rename to [test1UUID]"));
        }
    }
}
Also used : Path(java.nio.file.Path) NodeEnvironment(org.elasticsearch.env.NodeEnvironment) MetaData(org.elasticsearch.cluster.metadata.MetaData) IndexMetaData(org.elasticsearch.cluster.metadata.IndexMetaData) Settings(org.elasticsearch.common.settings.Settings) IndexMetaData(org.elasticsearch.cluster.metadata.IndexMetaData)

Aggregations

NodeEnvironment (org.elasticsearch.env.NodeEnvironment)39 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)19 Path (java.nio.file.Path)17 Settings (org.elasticsearch.common.settings.Settings)15 Index (org.elasticsearch.index.Index)11 MetaData (org.elasticsearch.cluster.metadata.MetaData)10 IndexSettings (org.elasticsearch.index.IndexSettings)7 IOException (java.io.IOException)5 ClusterState (org.elasticsearch.cluster.ClusterState)5 ShardId (org.elasticsearch.index.shard.ShardId)4 ElasticsearchException (org.elasticsearch.ElasticsearchException)3 ClusterService (org.elasticsearch.cluster.service.ClusterService)3 Environment (org.elasticsearch.env.Environment)3 ShardPath (org.elasticsearch.index.shard.ShardPath)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 SigarModule (io.crate.module.SigarModule)1 DummyExtendedNodeInfo (io.crate.monitor.DummyExtendedNodeInfo)1 ExtendedNodeInfo (io.crate.monitor.ExtendedNodeInfo)1