|
@@ -20,18 +20,13 @@
|
|
|
package org.elasticsearch.common.io;
|
|
|
|
|
|
import org.apache.lucene.util.Constants;
|
|
|
-import org.apache.lucene.util.IOUtils;
|
|
|
import org.apache.lucene.util.ThreadInterruptedException;
|
|
|
import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.common.logging.ESLogger;
|
|
|
-import org.elasticsearch.common.logging.ESLoggerFactory;
|
|
|
-import org.elasticsearch.common.unit.TimeValue;
|
|
|
|
|
|
import java.io.*;
|
|
|
import java.nio.channels.FileChannel;
|
|
|
import java.nio.file.StandardOpenOption;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
|
|
|
/**
|
|
|
*
|
|
@@ -66,31 +61,6 @@ public class FileSystemUtils {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static int maxOpenFiles(File testDir) {
|
|
|
- boolean dirCreated = false;
|
|
|
- if (!testDir.exists()) {
|
|
|
- dirCreated = true;
|
|
|
- testDir.mkdirs();
|
|
|
- }
|
|
|
- List<RandomAccessFile> files = new ArrayList<>();
|
|
|
- try {
|
|
|
- while (true) {
|
|
|
- files.add(new RandomAccessFile(new File(testDir, "tmp" + files.size()), "rw"));
|
|
|
- }
|
|
|
- } catch (IOException ioe) {
|
|
|
- int i = 0;
|
|
|
- for (RandomAccessFile raf : files) {
|
|
|
- IOUtils.closeWhileHandlingException(raf);
|
|
|
- new File(testDir, "tmp" + i++).delete();
|
|
|
- }
|
|
|
- if (dirCreated) {
|
|
|
- deleteRecursively(testDir);
|
|
|
- }
|
|
|
- }
|
|
|
- return files.size();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
public static boolean hasExtensions(File root, String... extensions) {
|
|
|
if (root != null && root.exists()) {
|
|
|
if (root.isDirectory()) {
|