ensure we only pull system filestores once time

This commit is contained in:
Robert Muir 2015-04-23 15:32:00 -04:00
parent ffd8db6828
commit e2861bd7be
1 changed files with 14 additions and 8 deletions

View File

@ -58,7 +58,20 @@ public class Environment {
private final Path logsFile; private final Path logsFile;
/** List of filestores on the system */ /** List of filestores on the system */
private final FileStore[] fileStores; private static final FileStore[] fileStores;
/**
* We have to do this in clinit instead of init, because ES code is pretty messy,
* and makes these environments, throws them away, makes them again, etc.
*/
static {
// gather information about filesystems
ArrayList<FileStore> allStores = new ArrayList<>();
for (FileStore store : PathUtils.getDefaultFileSystem().getFileStores()) {
allStores.add(new ESFileStore(store));
}
fileStores = allStores.toArray(new ESFileStore[allStores.size()]);
}
public Environment() { public Environment() {
this(EMPTY_SETTINGS); this(EMPTY_SETTINGS);
@ -109,13 +122,6 @@ public class Environment {
} else { } else {
logsFile = homeFile.resolve("logs"); logsFile = homeFile.resolve("logs");
} }
// gather information about filesystems
ArrayList<FileStore> allStores = new ArrayList<>();
for (FileStore store : PathUtils.getDefaultFileSystem().getFileStores()) {
allStores.add(new ESFileStore(store));
}
fileStores = allStores.toArray(new ESFileStore[allStores.size()]);
} }
/** /**