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:
kimchy 2010-02-18 00:08:39 +02:00
parent 8a5a44c1c3
commit 778156787a
4 changed files with 10 additions and 4 deletions

View File

@ -20,6 +20,7 @@
package org.elasticsearch.index.store.fs; package org.elasticsearch.index.store.fs;
import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.util.Nullable;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -31,11 +32,16 @@ public class FsStores {
public static final String DEFAULT_INDICES_LOCATION = "indices"; 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 // TODO we need to clean the nodeId from invalid folder characters
File f = new File(new File(basePath, DEFAULT_INDICES_LOCATION), localNodeId); File f = new File(new File(basePath, DEFAULT_INDICES_LOCATION), localNodeId);
f = new File(f, shardId.index().name()); f = new File(f, shardId.index().name());
f = new File(f, Integer.toString(shardId.id())); f = new File(f, Integer.toString(shardId.id()));
if (suffix != null) {
f = new File(f, suffix);
}
if (f.exists() && f.isDirectory()) { if (f.exists() && f.isDirectory()) {
return f; return f;

View File

@ -47,7 +47,7 @@ public class MmapFsStore extends AbstractFsStore<MMapDirectory> {
super(shardId, indexSettings); super(shardId, indexSettings);
// by default, we don't need to sync to disk, since we use the gateway // by default, we don't need to sync to disk, since we use the gateway
this.syncToDisk = componentSettings.getAsBoolean("syncToDisk", false); 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()); logger.debug("Using [MmapFs] Store with path [{}]", directory.getFile());
} }

View File

@ -45,7 +45,7 @@ public class NioFsStore extends AbstractFsStore<NIOFSDirectory> {
super(shardId, indexSettings); super(shardId, indexSettings);
// by default, we don't need to sync to disk, since we use the gateway // by default, we don't need to sync to disk, since we use the gateway
this.syncToDisk = componentSettings.getAsBoolean("syncToDisk", false); 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); logger.debug("Using [NioFs] Store with path [{}], syncToDisk [{}]", directory.getFile(), syncToDisk);
} }

View File

@ -45,7 +45,7 @@ public class SimpleFsStore extends AbstractFsStore<SimpleFSDirectory> {
super(shardId, indexSettings); super(shardId, indexSettings);
// by default, we don't need to sync to disk, since we use the gateway // by default, we don't need to sync to disk, since we use the gateway
this.syncToDisk = componentSettings.getAsBoolean("syncToDisk", false); 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); logger.debug("Using [SimpleFs] Store with path [{}], syncToDisk [{}]", directory.getFile(), syncToDisk);
} }