use of org.elasticsearch.env.NodeEnvironment in project elasticsearch by elastic.
the class IndexFolderUpgraderTests method testNeedsUpgrade.
public void testNeedsUpgrade() throws IOException {
final Index index = new Index("foo", UUIDs.randomBase64UUID());
IndexMetaData indexState = IndexMetaData.builder(index.getName()).settings(Settings.builder().put(IndexMetaData.SETTING_INDEX_UUID, index.getUUID()).put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)).numberOfShards(1).numberOfReplicas(0).build();
try (NodeEnvironment nodeEnvironment = newNodeEnvironment()) {
IndexMetaData.FORMAT.write(indexState, nodeEnvironment.indexPaths(index));
assertFalse(IndexFolderUpgrader.needsUpgrade(index, index.getUUID()));
}
}
use of org.elasticsearch.env.NodeEnvironment in project elasticsearch by elastic.
the class IndexFolderUpgraderTests method testPartialUpgradeCustomDataPath.
/**
* tests upgrade on partially upgraded index, when we crash while upgrading
*/
public void testPartialUpgradeCustomDataPath() 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) {
@Override
void upgrade(Index index, Path source, Path target) throws IOException {
if (randomBoolean()) {
throw new FileNotFoundException("simulated");
}
}
};
// only upgrade some paths
try {
helper.upgrade(index.getName());
} catch (IOException e) {
assertTrue(e instanceof FileNotFoundException);
}
helper = new IndexFolderUpgrader(settings, nodeEnv);
// try to upgrade again
helper.upgrade(indexSettings.getIndex().getName());
checkIndex(nodeEnv, indexSettings, numIdxFiles, numTranslogFiles);
}
}
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];
}
Aggregations