Search in sources :

Example 1 with ResumeRecoverable

use of org.apache.flink.core.fs.RecoverableWriter.ResumeRecoverable in project flink by apache.

the class OutputStreamBasedPartFileRecoverableMigrationTest method prepareDeserializationInProgress.

@Test
@Ignore
public void prepareDeserializationInProgress() throws IOException {
    String scenario = "in-progress";
    java.nio.file.Path path = resolveVersionPath(CURRENT_VERSION, scenario);
    RecoverableWriter writer = FileSystem.getLocalFileSystem().createRecoverableWriter();
    OutputStreamBasedInProgressFileRecoverableSerializer serializer = new OutputStreamBasedInProgressFileRecoverableSerializer(writer.getResumeRecoverableSerializer());
    RecoverableFsDataOutputStream outputStream = writer.open(new Path(path.resolve("content").toString()));
    outputStream.write(IN_PROGRESS_CONTENT.getBytes(StandardCharsets.UTF_8));
    ResumeRecoverable resumeRecoverable = outputStream.persist();
    OutputStreamBasedInProgressFileRecoverable recoverable = new OutputStreamBasedInProgressFileRecoverable(resumeRecoverable);
    byte[] bytes = serializer.serialize(recoverable);
    Files.write(path.resolve("recoverable"), bytes);
}
Also used : Path(org.apache.flink.core.fs.Path) OutputStreamBasedInProgressFileRecoverable(org.apache.flink.streaming.api.functions.sink.filesystem.OutputStreamBasedPartFileWriter.OutputStreamBasedInProgressFileRecoverable) RecoverableWriter(org.apache.flink.core.fs.RecoverableWriter) RecoverableFsDataOutputStream(org.apache.flink.core.fs.RecoverableFsDataOutputStream) ResumeRecoverable(org.apache.flink.core.fs.RecoverableWriter.ResumeRecoverable) OutputStreamBasedInProgressFileRecoverableSerializer(org.apache.flink.streaming.api.functions.sink.filesystem.OutputStreamBasedPartFileWriter.OutputStreamBasedInProgressFileRecoverableSerializer) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with ResumeRecoverable

use of org.apache.flink.core.fs.RecoverableWriter.ResumeRecoverable in project flink by apache.

the class HadoopViewFileSystemTruncateTest method testViewFileSystemRecoverWorks.

@Test
public void testViewFileSystemRecoverWorks() throws IOException {
    final org.apache.flink.core.fs.Path testPath = new org.apache.flink.core.fs.Path(fSystem.getUri() + "mountOnNn1/test-1");
    final String expectedContent = "test_line";
    final RecoverableWriter writer = fSystem.createRecoverableWriter();
    final RecoverableFsDataOutputStream streamUnderTest = getOpenStreamToFileWithContent(writer, testPath, expectedContent);
    final ResumeRecoverable resumeRecover = streamUnderTest.persist();
    final RecoverableFsDataOutputStream recover = writer.recover(resumeRecover);
    final RecoverableWriter.CommitRecoverable committable = recover.closeForCommit().getRecoverable();
    final RecoverableWriter recoveredWriter = fSystem.createRecoverableWriter();
    recoveredWriter.recoverForCommit(committable).commitAfterRecovery();
    verifyFileContent(testPath, expectedContent);
}
Also used : Path(org.apache.hadoop.fs.Path) RecoverableWriter(org.apache.flink.core.fs.RecoverableWriter) RecoverableFsDataOutputStream(org.apache.flink.core.fs.RecoverableFsDataOutputStream) ResumeRecoverable(org.apache.flink.core.fs.RecoverableWriter.ResumeRecoverable) Test(org.junit.Test)

Example 3 with ResumeRecoverable

use of org.apache.flink.core.fs.RecoverableWriter.ResumeRecoverable in project flink by apache.

the class FileSinkCommittableSerializerMigrationTest method prepareDeserializationInProgressToCleanup.

@Test
@Ignore
public void prepareDeserializationInProgressToCleanup() throws IOException {
    String scenario = "in-progress";
    java.nio.file.Path path = resolveVersionPath(CURRENT_VERSION, scenario);
    BucketWriter<String, String> bucketWriter = createBucketWriter();
    RecoverableWriter writer = FileSystem.getLocalFileSystem().createRecoverableWriter();
    FileSinkCommittableSerializer serializer = new FileSinkCommittableSerializer(bucketWriter.getProperties().getPendingFileRecoverableSerializer(), bucketWriter.getProperties().getInProgressFileRecoverableSerializer());
    RecoverableFsDataOutputStream outputStream = writer.open(new Path(path.resolve("content").toString()));
    outputStream.write(IN_PROGRESS_CONTENT.getBytes(StandardCharsets.UTF_8));
    ResumeRecoverable resumeRecoverable = outputStream.persist();
    OutputStreamBasedInProgressFileRecoverable recoverable = new OutputStreamBasedInProgressFileRecoverable(resumeRecoverable);
    FileSinkCommittable committable = new FileSinkCommittable("0", recoverable);
    byte[] bytes = serializer.serialize(committable);
    Files.write(path.resolve("committable"), bytes);
}
Also used : Path(org.apache.flink.core.fs.Path) RecoverableWriter(org.apache.flink.core.fs.RecoverableWriter) RecoverableFsDataOutputStream(org.apache.flink.core.fs.RecoverableFsDataOutputStream) OutputStreamBasedInProgressFileRecoverable(org.apache.flink.streaming.api.functions.sink.filesystem.OutputStreamBasedPartFileWriter.OutputStreamBasedInProgressFileRecoverable) ResumeRecoverable(org.apache.flink.core.fs.RecoverableWriter.ResumeRecoverable) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

RecoverableFsDataOutputStream (org.apache.flink.core.fs.RecoverableFsDataOutputStream)3 RecoverableWriter (org.apache.flink.core.fs.RecoverableWriter)3 ResumeRecoverable (org.apache.flink.core.fs.RecoverableWriter.ResumeRecoverable)3 Test (org.junit.Test)3 Path (org.apache.flink.core.fs.Path)2 OutputStreamBasedInProgressFileRecoverable (org.apache.flink.streaming.api.functions.sink.filesystem.OutputStreamBasedPartFileWriter.OutputStreamBasedInProgressFileRecoverable)2 Ignore (org.junit.Ignore)2 OutputStreamBasedInProgressFileRecoverableSerializer (org.apache.flink.streaming.api.functions.sink.filesystem.OutputStreamBasedPartFileWriter.OutputStreamBasedInProgressFileRecoverableSerializer)1 Path (org.apache.hadoop.fs.Path)1