Search in sources :

Example 31 with NodeEnvironment

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

the class IndicesStoreIntegrationIT method shardDirectory.

private Path shardDirectory(String server, Index index, int shard) {
    NodeEnvironment env = internalCluster().getInstance(NodeEnvironment.class, server);
    final Path[] paths = env.availableShardPaths(new ShardId(index, shard));
    assert paths.length == 1;
    return paths[0];
}
Also used : ShardId(org.elasticsearch.index.shard.ShardId) Path(java.nio.file.Path) NodeEnvironment(org.elasticsearch.env.NodeEnvironment)

Example 32 with NodeEnvironment

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

the class IndicesStoreIntegrationIT method indexDirectory.

private Path indexDirectory(String server, Index index) {
    NodeEnvironment env = internalCluster().getInstance(NodeEnvironment.class, server);
    final Path[] paths = env.indexPaths(index);
    assert paths.length == 1;
    return paths[0];
}
Also used : Path(java.nio.file.Path) NodeEnvironment(org.elasticsearch.env.NodeEnvironment)

Example 33 with NodeEnvironment

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

the class InternalTestCluster method assertAfterTest.

@Override
public void assertAfterTest() throws IOException {
    super.assertAfterTest();
    assertRequestsFinished();
    for (NodeAndClient nodeAndClient : nodes.values()) {
        NodeEnvironment env = nodeAndClient.node().getNodeEnvironment();
        Set<ShardId> shardIds = env.lockedShards();
        for (ShardId id : shardIds) {
            try {
                env.shardLock(id, TimeUnit.SECONDS.toMillis(5)).close();
            } catch (ShardLockObtainFailedException ex) {
                fail("Shard " + id + " is still locked after 5 sec waiting");
            }
        }
    }
}
Also used : ShardId(org.elasticsearch.index.shard.ShardId) NodeEnvironment(org.elasticsearch.env.NodeEnvironment) ShardLockObtainFailedException(org.elasticsearch.env.ShardLockObtainFailedException)

Example 34 with NodeEnvironment

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

the class IndexFolderUpgraderTests method testUpgradeIndices.

public void testUpgradeIndices() throws IOException {
    final Settings nodeSettings = Settings.builder().put(NodeEnvironment.ADD_NODE_LOCK_ID_TO_CUSTOM_PATH.getKey(), randomBoolean()).build();
    try (NodeEnvironment nodeEnv = newNodeEnvironment(nodeSettings)) {
        Map<IndexSettings, Tuple<Integer, Integer>> indexSettingsMap = new HashMap<>();
        for (int i = 0; i < randomIntBetween(2, 5); i++) {
            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_NUMBER_OF_SHARDS, randomIntBetween(1, 5)).put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0).build();
            IndexMetaData indexState = IndexMetaData.builder(index.getName()).settings(settings).build();
            Tuple<Integer, Integer> fileCounts = new Tuple<>(randomIntBetween(1, 5), randomIntBetween(1, 5));
            IndexSettings indexSettings = new IndexSettings(indexState, nodeSettings);
            indexSettingsMap.put(indexSettings, fileCounts);
            writeIndex(nodeEnv, indexSettings, fileCounts.v1(), fileCounts.v2());
        }
        IndexFolderUpgrader.upgradeIndicesIfNeeded(nodeSettings, nodeEnv);
        for (Map.Entry<IndexSettings, Tuple<Integer, Integer>> entry : indexSettingsMap.entrySet()) {
            checkIndex(nodeEnv, entry.getKey(), entry.getValue().v1(), entry.getValue().v2());
        }
    }
}
Also used : NodeEnvironment(org.elasticsearch.env.NodeEnvironment) HashMap(java.util.HashMap) IndexSettings(org.elasticsearch.index.IndexSettings) Index(org.elasticsearch.index.Index) IndexMetaData(org.elasticsearch.cluster.metadata.IndexMetaData) HashMap(java.util.HashMap) Map(java.util.Map) Settings(org.elasticsearch.common.settings.Settings) IndexSettings(org.elasticsearch.index.IndexSettings) Tuple(org.elasticsearch.common.collect.Tuple)

Example 35 with NodeEnvironment

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

the class IndexFolderUpgraderTests method testUpgrade.

public void testUpgrade() throws IOException {
    final Settings nodeSettings = Settings.builder().put(NodeEnvironment.ADD_NODE_LOCK_ID_TO_CUSTOM_PATH.getKey(), randomBoolean()).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_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 : 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)

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