Remove unused index store in directory service
With this commit we remove the unused field `indexStore` from all implementations of `FsDirectoryService`. Relates #37097
This commit is contained in:
parent
07dc8c7eee
commit
abe35fb99b
|
@ -25,7 +25,6 @@ import org.apache.lucene.store.MMapDirectory;
|
|||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.shard.ShardPath;
|
||||
import org.elasticsearch.index.store.FsDirectoryService;
|
||||
import org.elasticsearch.index.store.IndexStore;
|
||||
import org.elasticsearch.index.store.SmbDirectoryWrapper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -33,8 +32,8 @@ import java.nio.file.Path;
|
|||
|
||||
public class SmbMmapFsDirectoryService extends FsDirectoryService {
|
||||
|
||||
public SmbMmapFsDirectoryService(IndexSettings indexSettings, IndexStore indexStore, ShardPath path) {
|
||||
super(indexSettings, indexStore, path);
|
||||
public SmbMmapFsDirectoryService(IndexSettings indexSettings, ShardPath path) {
|
||||
super(indexSettings, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,6 +32,6 @@ public class SmbMmapFsIndexStore extends IndexStore {
|
|||
|
||||
@Override
|
||||
public DirectoryService newDirectoryService(ShardPath path) {
|
||||
return new SmbMmapFsDirectoryService(indexSettings, this, path);
|
||||
return new SmbMmapFsDirectoryService(indexSettings, path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.apache.lucene.store.SimpleFSDirectory;
|
|||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.shard.ShardPath;
|
||||
import org.elasticsearch.index.store.FsDirectoryService;
|
||||
import org.elasticsearch.index.store.IndexStore;
|
||||
import org.elasticsearch.index.store.SmbDirectoryWrapper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -33,8 +32,8 @@ import java.nio.file.Path;
|
|||
|
||||
public class SmbSimpleFsDirectoryService extends FsDirectoryService {
|
||||
|
||||
public SmbSimpleFsDirectoryService(IndexSettings indexSettings, IndexStore indexStore, ShardPath path) {
|
||||
super(indexSettings, indexStore, path);
|
||||
public SmbSimpleFsDirectoryService(IndexSettings indexSettings, ShardPath path) {
|
||||
super(indexSettings, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,7 +32,7 @@ public class SmbSimpleFsIndexStore extends IndexStore {
|
|||
|
||||
@Override
|
||||
public DirectoryService newDirectoryService(ShardPath path) {
|
||||
return new SmbSimpleFsDirectoryService(indexSettings, this, path);
|
||||
return new SmbSimpleFsDirectoryService(indexSettings, path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
|
||||
public class FsDirectoryService extends DirectoryService {
|
||||
protected final IndexStore indexStore;
|
||||
public static final Setting<LockFactory> INDEX_LOCK_FACTOR_SETTING = new Setting<>("index.store.fs.fs_lock", "native", (s) -> {
|
||||
switch (s) {
|
||||
case "native":
|
||||
|
@ -60,10 +59,9 @@ public class FsDirectoryService extends DirectoryService {
|
|||
private final ShardPath path;
|
||||
|
||||
@Inject
|
||||
public FsDirectoryService(IndexSettings indexSettings, IndexStore indexStore, ShardPath path) {
|
||||
public FsDirectoryService(IndexSettings indexSettings, ShardPath path) {
|
||||
super(path.getShardId(), indexSettings);
|
||||
this.path = path;
|
||||
this.indexStore = indexStore;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,7 +33,7 @@ public class IndexStore extends AbstractIndexComponent {
|
|||
* The shard store class that should be used for each shard.
|
||||
*/
|
||||
public DirectoryService newDirectoryService(ShardPath path) {
|
||||
return new FsDirectoryService(indexSettings, this, path);
|
||||
return new FsDirectoryService(indexSettings, path);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,11 +49,10 @@ public class FsDirectoryServiceTests extends ESTestCase {
|
|||
.putList(IndexModule.INDEX_STORE_PRE_LOAD_SETTING.getKey(), preload)
|
||||
.build();
|
||||
IndexSettings settings = IndexSettingsModule.newIndexSettings("foo", build);
|
||||
IndexStore store = new IndexStore(settings);
|
||||
Path tempDir = createTempDir().resolve(settings.getUUID()).resolve("0");
|
||||
Files.createDirectories(tempDir);
|
||||
ShardPath path = new ShardPath(false, tempDir, tempDir, new ShardId(settings.getIndex(), 0));
|
||||
FsDirectoryService fsDirectoryService = new FsDirectoryService(settings, store, path);
|
||||
FsDirectoryService fsDirectoryService = new FsDirectoryService(settings, path);
|
||||
Directory directory = fsDirectoryService.newDirectory();
|
||||
assertFalse(directory instanceof SleepingLockWrapper);
|
||||
if (preload.length == 0) {
|
||||
|
|
|
@ -60,8 +60,7 @@ public class IndexStoreTests extends ESTestCase {
|
|||
}
|
||||
Settings settings = settingsBuilder.build();
|
||||
IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("foo", settings);
|
||||
FsDirectoryService service = new FsDirectoryService(indexSettings, null,
|
||||
new ShardPath(false, tempDir, tempDir, new ShardId(index, 0)));
|
||||
FsDirectoryService service = new FsDirectoryService(indexSettings, new ShardPath(false, tempDir, tempDir, new ShardId(index, 0)));
|
||||
try (Directory directory = service.newFSDirectory(tempDir, NoLockFactory.INSTANCE)) {
|
||||
switch (type) {
|
||||
case HYBRIDFS:
|
||||
|
|
|
@ -43,7 +43,6 @@ import org.elasticsearch.index.IndexSettings;
|
|||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.index.shard.ShardPath;
|
||||
import org.elasticsearch.index.store.FsDirectoryService;
|
||||
import org.elasticsearch.index.store.IndexStore;
|
||||
import org.elasticsearch.index.store.Store;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
@ -74,8 +73,8 @@ public class MockFSDirectoryService extends FsDirectoryService {
|
|||
private final boolean crashIndex;
|
||||
|
||||
@Inject
|
||||
public MockFSDirectoryService(IndexSettings idxSettings, IndexStore indexStore, final ShardPath path) {
|
||||
super(idxSettings, indexStore, path);
|
||||
public MockFSDirectoryService(IndexSettings idxSettings, final ShardPath path) {
|
||||
super(idxSettings, path);
|
||||
Settings indexSettings = idxSettings.getSettings();
|
||||
final long seed = idxSettings.getValue(ESIntegTestCase.INDEX_TEST_SEED_SETTING);
|
||||
this.random = new Random(seed);
|
||||
|
@ -90,7 +89,7 @@ public class MockFSDirectoryService extends FsDirectoryService {
|
|||
logger.debug("Using MockDirWrapper with seed [{}] throttle: [{}] crashIndex: [{}]", SeedUtils.formatSeed(seed),
|
||||
throttle, crashIndex);
|
||||
}
|
||||
delegateService = randomDirectoryService(indexStore, path);
|
||||
delegateService = randomDirectoryService(idxSettings, path);
|
||||
}
|
||||
|
||||
|
||||
|
@ -152,8 +151,7 @@ public class MockFSDirectoryService extends FsDirectoryService {
|
|||
return w;
|
||||
}
|
||||
|
||||
private FsDirectoryService randomDirectoryService(IndexStore indexStore, ShardPath path) {
|
||||
final IndexSettings indexSettings = indexStore.getIndexSettings();
|
||||
private FsDirectoryService randomDirectoryService(IndexSettings indexSettings, ShardPath path) {
|
||||
final IndexMetaData build = IndexMetaData.builder(indexSettings.getIndexMetaData())
|
||||
.settings(Settings.builder()
|
||||
// don't use the settings from indexSettings#getSettings() they are merged with node settings and might contain
|
||||
|
@ -163,7 +161,7 @@ public class MockFSDirectoryService extends FsDirectoryService {
|
|||
RandomPicks.randomFrom(random, IndexModule.Type.values()).getSettingsKey()))
|
||||
.build();
|
||||
final IndexSettings newIndexSettings = new IndexSettings(build, indexSettings.getNodeSettings());
|
||||
return new FsDirectoryService(newIndexSettings, indexStore, path);
|
||||
return new FsDirectoryService(newIndexSettings, path);
|
||||
}
|
||||
|
||||
public static final class ElasticsearchMockDirectoryWrapper extends MockDirectoryWrapper {
|
||||
|
|
|
@ -86,7 +86,7 @@ public class MockFSIndexStore extends IndexStore {
|
|||
|
||||
@Override
|
||||
public DirectoryService newDirectoryService(ShardPath path) {
|
||||
return new MockFSDirectoryService(indexSettings, this, path);
|
||||
return new MockFSDirectoryService(indexSettings, path);
|
||||
}
|
||||
|
||||
private static final EnumSet<IndexShardState> validCheckIndexStates = EnumSet.of(
|
||||
|
|
Loading…
Reference in New Issue