From 8dbc1fbdbdaf06558d03305595aa1b98ad974b47 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Fri, 28 Aug 2015 03:59:02 -0400 Subject: [PATCH] use ShardPath.getRootStatePath; allow forbidden API --- core/src/main/java/org/elasticsearch/index/IndexService.java | 2 +- .../org/elasticsearch/index/shard/NewPathForShardTest.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/elasticsearch/index/IndexService.java b/core/src/main/java/org/elasticsearch/index/IndexService.java index 0c338ce1873..e6e71cf3874 100644 --- a/core/src/main/java/org/elasticsearch/index/IndexService.java +++ b/core/src/main/java/org/elasticsearch/index/IndexService.java @@ -325,7 +325,7 @@ public class IndexService extends AbstractIndexComponent implements IndexCompone // Count up how many shards are currently on each data path: Map dataPathToShardCount = new HashMap<>(); for(IndexShard shard : this) { - Path dataPath = NodeEnvironment.shardStatePathToDataPath(shard.shardPath().getShardStatePath()); + Path dataPath = shard.shardPath().getRootStatePath(); Integer curCount = dataPathToShardCount.get(dataPath); if (curCount == null) { curCount = 0; diff --git a/core/src/test/java/org/elasticsearch/index/shard/NewPathForShardTest.java b/core/src/test/java/org/elasticsearch/index/shard/NewPathForShardTest.java index 6e407a4ff11..5cb618ad084 100644 --- a/core/src/test/java/org/elasticsearch/index/shard/NewPathForShardTest.java +++ b/core/src/test/java/org/elasticsearch/index/shard/NewPathForShardTest.java @@ -39,6 +39,7 @@ import org.apache.lucene.mockfile.FilterFileSystem; import org.apache.lucene.mockfile.FilterFileSystemProvider; import org.apache.lucene.mockfile.FilterPath; import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.common.SuppressForbidden; import org.elasticsearch.common.io.PathUtils; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -54,6 +55,7 @@ import com.carrotsearch.randomizedtesting.annotations.Repeat; import static org.elasticsearch.common.settings.Settings.settingsBuilder; /** Separate test class from ShardPathTests because we need static (BeforeClass) setup to install mock filesystems... */ +@SuppressForbidden(reason = "ProviderMismatchException if I try to use PathUtils.getDefault instead") public class NewPathForShardTest extends ESTestCase { // Sneakiness to install mock file stores so we can pretend how much free space we have on each path.data: @@ -84,6 +86,7 @@ public class NewPathForShardTest extends ESTestCase { } /** Mock file system that fakes usable space for each FileStore */ + @SuppressForbidden(reason = "ProviderMismatchException if I try to use PathUtils.getDefault instead") static class MockUsableSpaceFileSystemProvider extends FilterFileSystemProvider { public MockUsableSpaceFileSystemProvider() {