use of org.apache.flink.runtime.state.filesystem.FsCheckpointStreamFactory.FsCheckpointStateOutputStream in project flink by apache.
the class FsCheckpointStorageAccessTest method testDirectoriesForExclusiveAndSharedState.
@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();
}
Aggregations