use ShardPath.getRootStatePath; allow forbidden API

This commit is contained in:
Michael McCandless 2015-08-28 03:59:02 -04:00 committed by mikemccand
parent e2e1b7f76a
commit 8dbc1fbdbd
2 changed files with 4 additions and 1 deletions

View File

@ -325,7 +325,7 @@ public class IndexService extends AbstractIndexComponent implements IndexCompone
// Count up how many shards are currently on each data path: // Count up how many shards are currently on each data path:
Map<Path,Integer> dataPathToShardCount = new HashMap<>(); Map<Path,Integer> dataPathToShardCount = new HashMap<>();
for(IndexShard shard : this) { for(IndexShard shard : this) {
Path dataPath = NodeEnvironment.shardStatePathToDataPath(shard.shardPath().getShardStatePath()); Path dataPath = shard.shardPath().getRootStatePath();
Integer curCount = dataPathToShardCount.get(dataPath); Integer curCount = dataPathToShardCount.get(dataPath);
if (curCount == null) { if (curCount == null) {
curCount = 0; curCount = 0;

View File

@ -39,6 +39,7 @@ import org.apache.lucene.mockfile.FilterFileSystem;
import org.apache.lucene.mockfile.FilterFileSystemProvider; import org.apache.lucene.mockfile.FilterFileSystemProvider;
import org.apache.lucene.mockfile.FilterPath; import org.apache.lucene.mockfile.FilterPath;
import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.io.PathUtils; import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment; import org.elasticsearch.env.Environment;
@ -54,6 +55,7 @@ import com.carrotsearch.randomizedtesting.annotations.Repeat;
import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.settingsBuilder;
/** Separate test class from ShardPathTests because we need static (BeforeClass) setup to install mock filesystems... */ /** 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 { 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: // 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 */ /** 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 { static class MockUsableSpaceFileSystemProvider extends FilterFileSystemProvider {
public MockUsableSpaceFileSystemProvider() { public MockUsableSpaceFileSystemProvider() {