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];
}
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];
}
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");
}
}
}
}
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());
}
}
}
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);
}
}
Aggregations