Java Code Examples for org.apache.flink.core.fs.local.LocalFileSystem#getSharedInstance()
The following examples show how to use
org.apache.flink.core.fs.local.LocalFileSystem#getSharedInstance() .
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: 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 2
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 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: 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 5
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 6
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 7
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 8
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 9
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 10
Source File: FsCheckpointStorageTest.java From Flink-CEPplus 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); 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 11
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 12
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 FsCheckpointStateOutputStream exclusiveStream = storageLocation.createCheckpointStateOutputStream(CheckpointedStateScope.EXCLUSIVE); exclusiveStream.write(42); exclusiveStream.flushToFile(); StreamStateHandle exclusiveHandle = exclusiveStream.closeAndGetHandle(); assertEquals(1, fs.listStatus(storageLocation.getCheckpointDirectory()).length); assertEquals(0, fs.listStatus(storageLocation.getSharedStateDirectory()).length); // create shared state FsCheckpointStateOutputStream sharedStream = storageLocation.createCheckpointStateOutputStream(CheckpointedStateScope.SHARED); sharedStream.write(42); sharedStream.flushToFile(); StreamStateHandle sharedHandle = sharedStream.closeAndGetHandle(); assertEquals(1, fs.listStatus(storageLocation.getCheckpointDirectory()).length); assertEquals(1, fs.listStatus(storageLocation.getSharedStateDirectory()).length); // drop state exclusiveHandle.discardState(); sharedHandle.discardState(); }