org.apache.flink.core.fs.local.LocalFileSystem Java Examples
The following examples show how to use
org.apache.flink.core.fs.local.LocalFileSystem.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FileSystemTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testGet() throws URISyntaxException, IOException { String scheme = "file"; assertTrue(getFileSystemWithoutSafetyNet(scheme + ":///test/test") instanceof LocalFileSystem); try { getFileSystemWithoutSafetyNet(scheme + "://test/test"); } catch (IOException ioe) { assertTrue(ioe.getMessage().startsWith("Found local file path with authority '")); } assertTrue(getFileSystemWithoutSafetyNet(scheme + ":/test/test") instanceof LocalFileSystem); assertTrue(getFileSystemWithoutSafetyNet(scheme + ":test/test") instanceof LocalFileSystem); assertTrue(getFileSystemWithoutSafetyNet("/test/test") instanceof LocalFileSystem); assertTrue(getFileSystemWithoutSafetyNet("test/test") instanceof LocalFileSystem); }
Example #2
Source File: FsCheckpointStorageTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testResolveCheckpointStorageLocation() throws Exception { final FileSystem checkpointFileSystem = mock(FileSystem.class); final FsCheckpointStorage storage = new FsCheckpointStorage( new TestingPath("hdfs:///checkpoint/", checkpointFileSystem), null, new JobID(), FILE_SIZE_THRESHOLD, WRITE_BUFFER_SIZE); final FsCheckpointStorageLocation checkpointStreamFactory = (FsCheckpointStorageLocation) storage.resolveCheckpointStorageLocation(1L, CheckpointStorageLocationReference.getDefault()); assertEquals(checkpointFileSystem, checkpointStreamFactory.getFileSystem()); final CheckpointStorageLocationReference savepointLocationReference = AbstractFsCheckpointStorage.encodePathAsReference(new Path("file:///savepoint/")); final FsCheckpointStorageLocation savepointStreamFactory = (FsCheckpointStorageLocation) storage.resolveCheckpointStorageLocation(2L, savepointLocationReference); final FileSystem fileSystem = savepointStreamFactory.getFileSystem(); assertTrue(fileSystem instanceof LocalFileSystem); }
Example #3
Source File: LimitedConnectionsFileSystemTest.java From flink with Apache License 2.0 | 6 votes |
@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); }
Example #4
Source File: FileSystemTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testGet() throws URISyntaxException, IOException { String scheme = "file"; assertTrue(getFileSystemWithoutSafetyNet(scheme + ":///test/test") instanceof LocalFileSystem); try { getFileSystemWithoutSafetyNet(scheme + "://test/test"); } catch (IOException ioe) { assertTrue(ioe.getMessage().startsWith("Found local file path with authority '")); } assertTrue(getFileSystemWithoutSafetyNet(scheme + ":/test/test") instanceof LocalFileSystem); assertTrue(getFileSystemWithoutSafetyNet(scheme + ":test/test") instanceof LocalFileSystem); assertTrue(getFileSystemWithoutSafetyNet("/test/test") instanceof LocalFileSystem); assertTrue(getFileSystemWithoutSafetyNet("test/test") instanceof LocalFileSystem); }
Example #5
Source File: LimitedConnectionsFileSystemTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@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); }
Example #6
Source File: LimitedConnectionsFileSystemTest.java From flink with Apache License 2.0 | 6 votes |
@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); }
Example #7
Source File: FileSystemTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testGet() throws URISyntaxException, IOException { String scheme = "file"; assertTrue(getFileSystemWithoutSafetyNet(scheme + ":///test/test") instanceof LocalFileSystem); try { getFileSystemWithoutSafetyNet(scheme + "://test/test"); } catch (IOException ioe) { assertTrue(ioe.getMessage().startsWith("Found local file path with authority '")); } assertTrue(getFileSystemWithoutSafetyNet(scheme + ":/test/test") instanceof LocalFileSystem); assertTrue(getFileSystemWithoutSafetyNet(scheme + ":test/test") instanceof LocalFileSystem); assertTrue(getFileSystemWithoutSafetyNet("/test/test") instanceof LocalFileSystem); assertTrue(getFileSystemWithoutSafetyNet("test/test") instanceof LocalFileSystem); }
Example #8
Source File: PendingCheckpointTest.java From flink with Apache License 2.0 | 6 votes |
private PendingCheckpoint createPendingCheckpoint(CheckpointProperties props, Executor executor) throws IOException { final Path checkpointDir = new Path(tmpFolder.newFolder().toURI()); final FsCheckpointStorageLocation location = new FsCheckpointStorageLocation( LocalFileSystem.getSharedInstance(), checkpointDir, checkpointDir, checkpointDir, CheckpointStorageLocationReference.getDefault(), 1024, 4096); final Map<ExecutionAttemptID, ExecutionVertex> ackTasks = new HashMap<>(ACK_TASKS); return new PendingCheckpoint( new JobID(), 0, 1, ackTasks, props, location, executor); }
Example #9
Source File: PendingCheckpointTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private PendingCheckpoint createPendingCheckpoint(CheckpointProperties props, Executor executor) throws IOException { final Path checkpointDir = new Path(tmpFolder.newFolder().toURI()); final FsCheckpointStorageLocation location = new FsCheckpointStorageLocation( LocalFileSystem.getSharedInstance(), checkpointDir, checkpointDir, checkpointDir, CheckpointStorageLocationReference.getDefault(), 1024); final Map<ExecutionAttemptID, ExecutionVertex> ackTasks = new HashMap<>(ACK_TASKS); return new PendingCheckpoint( new JobID(), 0, 1, ackTasks, props, location, executor); }
Example #10
Source File: FsCheckpointStorageTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testResolveCheckpointStorageLocation() throws Exception { final FileSystem checkpointFileSystem = mock(FileSystem.class); final FsCheckpointStorage storage = new FsCheckpointStorage( new TestingPath("hdfs:///checkpoint/", checkpointFileSystem), null, new JobID(), FILE_SIZE_THRESHOLD, WRITE_BUFFER_SIZE); final FsCheckpointStorageLocation checkpointStreamFactory = (FsCheckpointStorageLocation) storage.resolveCheckpointStorageLocation(1L, CheckpointStorageLocationReference.getDefault()); assertEquals(checkpointFileSystem, checkpointStreamFactory.getFileSystem()); final CheckpointStorageLocationReference savepointLocationReference = AbstractFsCheckpointStorage.encodePathAsReference(new Path("file:///savepoint/")); final FsCheckpointStorageLocation savepointStreamFactory = (FsCheckpointStorageLocation) storage.resolveCheckpointStorageLocation(2L, savepointLocationReference); final FileSystem fileSystem = savepointStreamFactory.getFileSystem(); assertTrue(fileSystem instanceof LocalFileSystem); }
Example #11
Source File: FsCheckpointStorageTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testResolveCheckpointStorageLocation() throws Exception { final FileSystem checkpointFileSystem = mock(FileSystem.class); final FsCheckpointStorage storage = new FsCheckpointStorage( new TestingPath("hdfs:///checkpoint/", checkpointFileSystem), null, new JobID(), FILE_SIZE_THRESHOLD); final FsCheckpointStorageLocation checkpointStreamFactory = (FsCheckpointStorageLocation) storage.resolveCheckpointStorageLocation(1L, CheckpointStorageLocationReference.getDefault()); assertEquals(checkpointFileSystem, checkpointStreamFactory.getFileSystem()); final CheckpointStorageLocationReference savepointLocationReference = AbstractFsCheckpointStorage.encodePathAsReference(new Path("file:///savepoint/")); final FsCheckpointStorageLocation savepointStreamFactory = (FsCheckpointStorageLocation) storage.resolveCheckpointStorageLocation(2L, savepointLocationReference); final FileSystem fileSystem = savepointStreamFactory.getFileSystem(); assertTrue(fileSystem instanceof LocalFileSystem); }
Example #12
Source File: FilesystemSchemeConfigTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testExplicitlySetToLocal() throws Exception { final Configuration conf = new Configuration(); conf.setString(CoreOptions.DEFAULT_FILESYSTEM_SCHEME, LocalFileSystem.getLocalFsURI().toString()); FileSystem.initialize(conf); URI justPath = new URI(tempFolder.newFile().toURI().getPath()); assertNull(justPath.getScheme()); FileSystem fs = FileSystem.get(justPath); assertEquals("file", fs.getUri().getScheme()); }
Example #13
Source File: CollectionExecutor.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public CompletedFuture(Path entry) { try{ LocalFileSystem fs = (LocalFileSystem) FileSystem.getUnguardedFileSystem(entry.toUri()); result = entry.isAbsolute() ? new Path(entry.toUri().getPath()): new Path(fs.getWorkingDirectory(),entry); } catch (Exception e){ throw new RuntimeException("DistributedCache supports only local files for Collection Environments"); } }
Example #14
Source File: EntropyInjectorTest.java From flink with Apache License 2.0 | 5 votes |
@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()); }
Example #15
Source File: BucketTest.java From flink with Apache License 2.0 | 5 votes |
private static TestRecoverableWriter getRecoverableWriter(Path path) { try { final FileSystem fs = FileSystem.get(path.toUri()); if (!(fs instanceof LocalFileSystem)) { fail("Expected Local FS but got a " + fs.getClass().getName() + " for path: " + path); } return new TestRecoverableWriter((LocalFileSystem) fs); } catch (IOException e) { fail(); } return null; }
Example #16
Source File: CollectionExecutor.java From flink with Apache License 2.0 | 5 votes |
public CompletedFuture(Path entry) { try{ LocalFileSystem fs = (LocalFileSystem) FileSystem.getUnguardedFileSystem(entry.toUri()); result = entry.isAbsolute() ? new Path(entry.toUri().getPath()): new Path(fs.getWorkingDirectory(),entry); } catch (Exception e){ throw new RuntimeException("DistributedCache supports only local files for Collection Environments"); } }
Example #17
Source File: LimitedConnectionsFileSystemTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testOpenTimeoutOutputStreams() throws Exception { final long openTimeout = 50L; final int maxConcurrentOpen = 2; final LimitedConnectionsFileSystem limitedFs = new LimitedConnectionsFileSystem( LocalFileSystem.getSharedInstance(), maxConcurrentOpen, // limited total openTimeout, // small opening timeout 0L); // infinite inactivity timeout // create the threads that block all streams final BlockingWriterThread[] threads = new BlockingWriterThread[maxConcurrentOpen]; for (int i = 0; i < maxConcurrentOpen; i++) { Path path = new Path(tempFolder.newFile().toURI()); threads[i] = new BlockingWriterThread(limitedFs, path, Integer.MAX_VALUE, maxConcurrentOpen); threads[i].start(); } // wait until all are open while (limitedFs.getTotalNumberOfOpenStreams() < maxConcurrentOpen) { Thread.sleep(1); } // try to open another thread try { limitedFs.create(new Path(tempFolder.newFile().toURI()), WriteMode.OVERWRITE); fail("this should have timed out"); } catch (IOException e) { // expected } // clean shutdown for (BlockingWriterThread t : threads) { t.wakeup(); t.sync(); } }
Example #18
Source File: LimitedConnectionsFileSystemTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testOpenTimeoutOutputStreams() throws Exception { final long openTimeout = 50L; final int maxConcurrentOpen = 2; final LimitedConnectionsFileSystem limitedFs = new LimitedConnectionsFileSystem( LocalFileSystem.getSharedInstance(), maxConcurrentOpen, // limited total openTimeout, // small opening timeout 0L); // infinite inactivity timeout // create the threads that block all streams final BlockingWriterThread[] threads = new BlockingWriterThread[maxConcurrentOpen]; for (int i = 0; i < maxConcurrentOpen; i++) { Path path = new Path(tempFolder.newFile().toURI()); threads[i] = new BlockingWriterThread(limitedFs, path, Integer.MAX_VALUE, maxConcurrentOpen); threads[i].start(); } // wait until all are open while (limitedFs.getTotalNumberOfOpenStreams() < maxConcurrentOpen) { Thread.sleep(1); } // try to open another thread try { limitedFs.create(new Path(tempFolder.newFile().toURI()), WriteMode.OVERWRITE); fail("this should have timed out"); } catch (IOException e) { // expected } // clean shutdown for (BlockingWriterThread t : threads) { t.wakeup(); t.sync(); } }
Example #19
Source File: EntropyInjectorTest.java From flink with Apache License 2.0 | 5 votes |
@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()); }
Example #20
Source File: PendingCheckpointTest.java From flink with Apache License 2.0 | 5 votes |
private PendingCheckpoint createPendingCheckpoint( CheckpointProperties props, Collection<OperatorID> operatorCoordinators, Collection<String> masterStateIdentifiers, Executor executor) throws IOException { final Path checkpointDir = new Path(tmpFolder.newFolder().toURI()); final FsCheckpointStorageLocation location = new FsCheckpointStorageLocation( LocalFileSystem.getSharedInstance(), checkpointDir, checkpointDir, checkpointDir, CheckpointStorageLocationReference.getDefault(), 1024, 4096); final Map<ExecutionAttemptID, ExecutionVertex> ackTasks = new HashMap<>(ACK_TASKS); return new PendingCheckpoint( new JobID(), 0, 1, ackTasks, operatorCoordinators, masterStateIdentifiers, props, location, executor, new CompletableFuture<>()); }
Example #21
Source File: BucketTest.java From flink with Apache License 2.0 | 5 votes |
private static TestRecoverableWriter getRecoverableWriter(Path path) { try { final FileSystem fs = FileSystem.get(path.toUri()); if (!(fs instanceof LocalFileSystem)) { fail("Expected Local FS but got a " + fs.getClass().getName() + " for path: " + path); } return new TestRecoverableWriter((LocalFileSystem) fs); } catch (IOException e) { fail(); } return null; }
Example #22
Source File: FilesystemSchemeConfigTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testExplicitlySetToLocal() throws Exception { final Configuration conf = new Configuration(); conf.setString(CoreOptions.DEFAULT_FILESYSTEM_SCHEME, LocalFileSystem.getLocalFsURI().toString()); FileSystem.initialize(conf); URI justPath = new URI(tempFolder.newFile().toURI().getPath()); assertNull(justPath.getScheme()); FileSystem fs = FileSystem.get(justPath); assertEquals("file", fs.getUri().getScheme()); }
Example #23
Source File: FilesystemSchemeConfigTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testExplicitlySetToLocal() throws Exception { final Configuration conf = new Configuration(); conf.setString(CoreOptions.DEFAULT_FILESYSTEM_SCHEME, LocalFileSystem.getLocalFsURI().toString()); FileSystem.initialize(conf); URI justPath = new URI(tempFolder.newFile().toURI().getPath()); assertNull(justPath.getScheme()); FileSystem fs = FileSystem.get(justPath); assertEquals("file", fs.getUri().getScheme()); }
Example #24
Source File: LimitedConnectionsFileSystemTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testOpenTimeoutOutputStreams() throws Exception { final long openTimeout = 50L; final int maxConcurrentOpen = 2; final LimitedConnectionsFileSystem limitedFs = new LimitedConnectionsFileSystem( LocalFileSystem.getSharedInstance(), maxConcurrentOpen, // limited total openTimeout, // small opening timeout 0L); // infinite inactivity timeout // create the threads that block all streams final BlockingWriterThread[] threads = new BlockingWriterThread[maxConcurrentOpen]; for (int i = 0; i < maxConcurrentOpen; i++) { Path path = new Path(tempFolder.newFile().toURI()); threads[i] = new BlockingWriterThread(limitedFs, path, Integer.MAX_VALUE, maxConcurrentOpen); threads[i].start(); } // wait until all are open while (limitedFs.getTotalNumberOfOpenStreams() < maxConcurrentOpen) { Thread.sleep(1); } // try to open another thread try { limitedFs.create(new Path(tempFolder.newFile().toURI()), WriteMode.OVERWRITE); fail("this should have timed out"); } catch (IOException e) { // expected } // clean shutdown for (BlockingWriterThread t : threads) { t.wakeup(); t.sync(); } }
Example #25
Source File: EntropyInjectorTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@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()); }
Example #26
Source File: BucketTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private static TestRecoverableWriter getRecoverableWriter(Path path) { try { final FileSystem fs = FileSystem.get(path.toUri()); if (!(fs instanceof LocalFileSystem)) { fail("Expected Local FS but got a " + fs.getClass().getName() + " for path: " + path); } return new TestRecoverableWriter((LocalFileSystem) fs); } catch (IOException e) { fail(); } return null; }
Example #27
Source File: CollectionExecutor.java From flink with Apache License 2.0 | 5 votes |
public CompletedFuture(Path entry) { try{ LocalFileSystem fs = (LocalFileSystem) FileSystem.getUnguardedFileSystem(entry.toUri()); result = entry.isAbsolute() ? new Path(entry.toUri().getPath()): new Path(fs.getWorkingDirectory(),entry); } catch (Exception e){ throw new RuntimeException("DistributedCache supports only local files for Collection Environments"); } }
Example #28
Source File: FsCheckpointStorageTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testDirectoriesForExclusiveAndSharedState() throws Exception { final FileSystem fs = LocalFileSystem.getSharedInstance(); final Path checkpointDir = randomTempPath(); final Path sharedStateDir = randomTempPath(); FsCheckpointStorageLocation storageLocation = new FsCheckpointStorageLocation( fs, checkpointDir, sharedStateDir, randomTempPath(), CheckpointStorageLocationReference.getDefault(), FILE_SIZE_THRESHOLD, WRITE_BUFFER_SIZE); assertNotEquals(storageLocation.getCheckpointDirectory(), storageLocation.getSharedStateDirectory()); assertEquals(0, fs.listStatus(storageLocation.getCheckpointDirectory()).length); assertEquals(0, fs.listStatus(storageLocation.getSharedStateDirectory()).length); // create exclusive state CheckpointStateOutputStream exclusiveStream = storageLocation.createCheckpointStateOutputStream(CheckpointedStateScope.EXCLUSIVE); exclusiveStream.write(42); exclusiveStream.flush(); StreamStateHandle exclusiveHandle = exclusiveStream.closeAndGetHandle(); assertEquals(1, fs.listStatus(storageLocation.getCheckpointDirectory()).length); assertEquals(0, fs.listStatus(storageLocation.getSharedStateDirectory()).length); // create shared state CheckpointStateOutputStream sharedStream = storageLocation.createCheckpointStateOutputStream(CheckpointedStateScope.SHARED); sharedStream.write(42); sharedStream.flush(); StreamStateHandle sharedHandle = sharedStream.closeAndGetHandle(); assertEquals(1, fs.listStatus(storageLocation.getCheckpointDirectory()).length); assertEquals(1, fs.listStatus(storageLocation.getSharedStateDirectory()).length); // drop state exclusiveHandle.discardState(); sharedHandle.discardState(); }
Example #29
Source File: HadoopLocalFileSystemBehaviorTest.java From flink with Apache License 2.0 | 4 votes |
@Override public FileSystem getFileSystem() throws Exception { org.apache.hadoop.fs.FileSystem fs = new RawLocalFileSystem(); fs.initialize(LocalFileSystem.getLocalFsURI(), new Configuration()); return new HadoopFileSystem(fs); }
Example #30
Source File: BucketTest.java From flink with Apache License 2.0 | 4 votes |
TestRecoverableWriter(LocalFileSystem fs) { super(fs); }