@Override public FileSystem create(URI fsUri) { return LocalFileSystem.getSharedInstance(); } }
/** * Returns a reference to the {@link FileSystem} instance for accessing the local file system. * * @return a reference to the {@link FileSystem} instance for accessing the local file system. */ public static FileSystem getLocalFileSystem() { return FileSystemSafetyNet.wrapWithSafetyNetWhenActivated(LocalFileSystem.getSharedInstance()); }
@Override public FileSystem getFileSystem() throws Exception { return LocalFileSystem.getSharedInstance(); }
@Test public void testCreateEntropyAwarePlainFs() throws Exception { File folder = TMP_FOLDER.newFolder(); Path path = new Path(Path.fromLocalFile(folder), "_entropy_/file"); OutputStreamAndPath out = EntropyInjector.createEntropyAware( LocalFileSystem.getSharedInstance(), path, WriteMode.NO_OVERWRITE); out.stream().close(); assertEquals(path, out.path()); assertTrue(new File (new File(folder, "_entropy_"), "file").exists()); }
@Test public void testLimitingMixedStreams() throws Exception { final int maxConcurrentOpen = 2; final int numThreads = 61; final LimitedConnectionsFileSystem limitedFs = new LimitedConnectionsFileSystem( LocalFileSystem.getSharedInstance(), maxConcurrentOpen); // limited total final Random rnd = new Random(); final CheckedThread[] threads = new CheckedThread[numThreads]; for (int i = 0; i < numThreads; i++) { File file = tempFolder.newFile(); Path path = new Path(file.toURI()); if (rnd.nextBoolean()) { // reader thread createRandomContents(file, rnd); threads[i] = new ReaderThread(limitedFs, path, Integer.MAX_VALUE, maxConcurrentOpen); } else { threads[i] = new WriterThread(limitedFs, path, Integer.MAX_VALUE, maxConcurrentOpen); } } for (CheckedThread t : threads) { t.start(); } for (CheckedThread t : threads) { t.sync(); } }
LocalFileSystem.getSharedInstance(), 1, 0L, 1000L);
public void testSlowOutputStreamNotClosed() throws Exception { final LimitedConnectionsFileSystem fs = new LimitedConnectionsFileSystem( LocalFileSystem.getSharedInstance(), 1, 0L, 1000L);
@Test public void testLimitingInputStreams() throws Exception { final int maxConcurrentOpen = 2; final int numThreads = 61; final LimitedConnectionsFileSystem limitedFs = new LimitedConnectionsFileSystem( LocalFileSystem.getSharedInstance(), Integer.MAX_VALUE, // unlimited total Integer.MAX_VALUE, // unlimited outgoing maxConcurrentOpen, // limited incoming 0, 0); final Random rnd = new Random(); final ReaderThread[] threads = new ReaderThread[numThreads]; for (int i = 0; i < numThreads; i++) { File file = tempFolder.newFile(); createRandomContents(file, rnd); Path path = new Path(file.toURI()); threads[i] = new ReaderThread(limitedFs, path, maxConcurrentOpen, Integer.MAX_VALUE); } for (ReaderThread t : threads) { t.start(); } for (ReaderThread t : threads) { t.sync(); } }
@Test public void testLimitingOutputStreams() throws Exception { final int maxConcurrentOpen = 2; final int numThreads = 61; final LimitedConnectionsFileSystem limitedFs = new LimitedConnectionsFileSystem( LocalFileSystem.getSharedInstance(), Integer.MAX_VALUE, // unlimited total maxConcurrentOpen, // limited outgoing Integer.MAX_VALUE, // unlimited incoming 0, 0); final WriterThread[] threads = new WriterThread[numThreads]; for (int i = 0; i < numThreads; i++) { Path path = new Path(tempFolder.newFile().toURI()); threads[i] = new WriterThread(limitedFs, path, maxConcurrentOpen, Integer.MAX_VALUE); } for (WriterThread t : threads) { t.start(); } for (WriterThread t : threads) { t.sync(); } }
LocalFileSystem.getSharedInstance(),
LocalFileSystem.getSharedInstance(),
LocalFileSystem.getSharedInstance(),
LocalFileSystem.getSharedInstance(),
LocalFileSystem.getSharedInstance(),
@Test public void testConstructionNumericOverflow() { final LimitedConnectionsFileSystem limitedFs = new LimitedConnectionsFileSystem( LocalFileSystem.getSharedInstance(), Integer.MAX_VALUE, // unlimited total Integer.MAX_VALUE, // limited outgoing Integer.MAX_VALUE, // unlimited incoming Long.MAX_VALUE - 1, // long timeout, close to overflow Long.MAX_VALUE - 1); // long timeout, close to overflow assertEquals(Integer.MAX_VALUE, limitedFs.getMaxNumOpenStreamsTotal()); assertEquals(Integer.MAX_VALUE, limitedFs.getMaxNumOpenOutputStreams()); assertEquals(Integer.MAX_VALUE, limitedFs.getMaxNumOpenInputStreams()); assertTrue(limitedFs.getStreamOpenTimeout() > 0); assertTrue(limitedFs.getStreamInactivityTimeout() > 0); }
@Override public FileSystem create(URI fsUri) { return LocalFileSystem.getSharedInstance(); } }
@Override public FileSystem create(URI fsUri) { return LocalFileSystem.getSharedInstance(); } }
/** * Returns a reference to the {@link FileSystem} instance for accessing the local file system. * * @return a reference to the {@link FileSystem} instance for accessing the local file system. */ public static FileSystem getLocalFileSystem() { return FileSystemSafetyNet.wrapWithSafetyNetWhenActivated(LocalFileSystem.getSharedInstance()); }
/** * Returns a reference to the {@link FileSystem} instance for accessing the local file system. * * @return a reference to the {@link FileSystem} instance for accessing the local file system. */ public static FileSystem getLocalFileSystem() { return FileSystemSafetyNet.wrapWithSafetyNetWhenActivated(LocalFileSystem.getSharedInstance()); }