the work location of an index should be under an additional "index" directory (so later, we can have other auxilary directories)
This commit is contained in:
parent
8a5a44c1c3
commit
778156787a
|
@ -20,6 +20,7 @@
|
|||
package org.elasticsearch.index.store.fs;
|
||||
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.util.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -31,11 +32,16 @@ public class FsStores {
|
|||
|
||||
public static final String DEFAULT_INDICES_LOCATION = "indices";
|
||||
|
||||
public static synchronized File createStoreFilePath(File basePath, String localNodeId, ShardId shardId) throws IOException {
|
||||
public static final String MAIN_INDEX_SUFFIX = "index";
|
||||
|
||||
public static synchronized File createStoreFilePath(File basePath, String localNodeId, ShardId shardId, @Nullable String suffix) throws IOException {
|
||||
// TODO we need to clean the nodeId from invalid folder characters
|
||||
File f = new File(new File(basePath, DEFAULT_INDICES_LOCATION), localNodeId);
|
||||
f = new File(f, shardId.index().name());
|
||||
f = new File(f, Integer.toString(shardId.id()));
|
||||
if (suffix != null) {
|
||||
f = new File(f, suffix);
|
||||
}
|
||||
|
||||
if (f.exists() && f.isDirectory()) {
|
||||
return f;
|
||||
|
|
|
@ -47,7 +47,7 @@ public class MmapFsStore extends AbstractFsStore<MMapDirectory> {
|
|||
super(shardId, indexSettings);
|
||||
// by default, we don't need to sync to disk, since we use the gateway
|
||||
this.syncToDisk = componentSettings.getAsBoolean("syncToDisk", false);
|
||||
this.directory = new CustomMMapDirectory(createStoreFilePath(environment.workWithClusterFile(), localNodeId, shardId), syncToDisk);
|
||||
this.directory = new CustomMMapDirectory(createStoreFilePath(environment.workWithClusterFile(), localNodeId, shardId, MAIN_INDEX_SUFFIX), syncToDisk);
|
||||
logger.debug("Using [MmapFs] Store with path [{}]", directory.getFile());
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public class NioFsStore extends AbstractFsStore<NIOFSDirectory> {
|
|||
super(shardId, indexSettings);
|
||||
// by default, we don't need to sync to disk, since we use the gateway
|
||||
this.syncToDisk = componentSettings.getAsBoolean("syncToDisk", false);
|
||||
this.directory = new CustomNioFSDirectory(createStoreFilePath(environment.workWithClusterFile(), localNodeId, shardId), syncToDisk);
|
||||
this.directory = new CustomNioFSDirectory(createStoreFilePath(environment.workWithClusterFile(), localNodeId, shardId, MAIN_INDEX_SUFFIX), syncToDisk);
|
||||
logger.debug("Using [NioFs] Store with path [{}], syncToDisk [{}]", directory.getFile(), syncToDisk);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public class SimpleFsStore extends AbstractFsStore<SimpleFSDirectory> {
|
|||
super(shardId, indexSettings);
|
||||
// by default, we don't need to sync to disk, since we use the gateway
|
||||
this.syncToDisk = componentSettings.getAsBoolean("syncToDisk", false);
|
||||
this.directory = new CustomSimpleFSDirectory(createStoreFilePath(environment.workWithClusterFile(), localNodeId, shardId), syncToDisk);
|
||||
this.directory = new CustomSimpleFSDirectory(createStoreFilePath(environment.workWithClusterFile(), localNodeId, shardId, MAIN_INDEX_SUFFIX), syncToDisk);
|
||||
logger.debug("Using [SimpleFs] Store with path [{}], syncToDisk [{}]", directory.getFile(), syncToDisk);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue