Search in sources :

Example 6 with RecoverableWriter

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

the class HadoopRecoverableWriterOldHadoopWithNoTruncateSupportTest method testExceptionThrownWhenRecoveringWithInProgressFile.

@Test
public void testExceptionThrownWhenRecoveringWithInProgressFile() throws IOException {
    final RecoverableWriter writerUnderTest = fileSystem.createRecoverableWriter();
    final RecoverableFsDataOutputStream stream = writerUnderTest.open(new Path(basePath, "test-2"));
    final RecoverableWriter.ResumeRecoverable recoverable = stream.persist();
    assertNotNull(recoverable);
    try {
        writerUnderTest.recover(recoverable);
    } catch (IOException e) {
        // this is the expected exception and we check also if the root cause is the hadoop <
        // 2.7 version
        assertTrue(e.getCause() instanceof IllegalStateException);
    }
}
Also used : Path(org.apache.flink.core.fs.Path) RecoverableWriter(org.apache.flink.core.fs.RecoverableWriter) RecoverableFsDataOutputStream(org.apache.flink.core.fs.RecoverableFsDataOutputStream) IOException(java.io.IOException) Test(org.junit.Test)

Example 7 with RecoverableWriter

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

the class HadoopRecoverableWriterOldHadoopWithNoTruncateSupportTest method testRecoverableWriterWithViewfsScheme.

@Test
public void testRecoverableWriterWithViewfsScheme() {
    final org.apache.hadoop.fs.FileSystem mockViewfs = Mockito.mock(org.apache.hadoop.fs.FileSystem.class);
    when(mockViewfs.getScheme()).thenReturn("viewfs");
    // Creating the writer should not throw UnsupportedOperationException.
    RecoverableWriter recoverableWriter = new HadoopRecoverableWriter(mockViewfs);
}
Also used : RecoverableWriter(org.apache.flink.core.fs.RecoverableWriter) Test(org.junit.Test)

Example 8 with RecoverableWriter

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

the class HadoopS3RecoverableWriterExceptionITCase method testResumeAfterCommit.

// IMPORTANT FOR THE FOLLOWING TWO TESTS:
// These tests illustrate a difference in the user-perceived behavior of the different writers.
// In HDFS this will fail when trying to recover the stream while here is will fail at "commit",
// i.e.
// when we try to "publish" the multipart upload and we realize that the MPU is no longer
// active.
@Test(expected = IOException.class)
public void testResumeAfterCommit() throws Exception {
    final RecoverableWriter writer = getFileSystem().createRecoverableWriter();
    final Path path = new Path(basePathForTest, "part-0");
    final RecoverableFsDataOutputStream stream = writer.open(path);
    stream.write(testData1.getBytes(StandardCharsets.UTF_8));
    final RecoverableWriter.ResumeRecoverable recoverable = stream.persist();
    stream.write(testData2.getBytes(StandardCharsets.UTF_8));
    stream.closeForCommit().commit();
    final RecoverableFsDataOutputStream recoveredStream = writer.recover(recoverable);
    recoveredStream.closeForCommit().commit();
}
Also used : Path(org.apache.flink.core.fs.Path) RecoverableWriter(org.apache.flink.core.fs.RecoverableWriter) RecoverableFsDataOutputStream(org.apache.flink.core.fs.RecoverableFsDataOutputStream) Test(org.junit.Test)

Example 9 with RecoverableWriter

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

the class HadoopS3RecoverableWriterITCase method testCommitAfterPersist.

@Test
public void testCommitAfterPersist() throws Exception {
    final RecoverableWriter writer = getRecoverableWriter();
    final Path path = new Path(basePathForTest, "part-0");
    final RecoverableFsDataOutputStream stream = writer.open(path);
    stream.write(bytesOf(testData1));
    stream.persist();
    stream.write(bytesOf(testData2));
    stream.closeForCommit().commit();
    Assert.assertEquals(testData1 + testData2, getContentsOfFile(path));
}
Also used : Path(org.apache.flink.core.fs.Path) RecoverableWriter(org.apache.flink.core.fs.RecoverableWriter) RecoverableFsDataOutputStream(org.apache.flink.core.fs.RecoverableFsDataOutputStream) Test(org.junit.Test)

Example 10 with RecoverableWriter

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

the class HadoopS3RecoverableWriterITCase method testCloseWithNoData.

// ----------------------- Test Normal Execution -----------------------
@Test
public void testCloseWithNoData() throws Exception {
    final RecoverableWriter writer = getRecoverableWriter();
    final Path path = new Path(basePathForTest, "part-0");
    final RecoverableFsDataOutputStream stream = writer.open(path);
    stream.closeForCommit().commit();
}
Also used : Path(org.apache.flink.core.fs.Path) RecoverableWriter(org.apache.flink.core.fs.RecoverableWriter) RecoverableFsDataOutputStream(org.apache.flink.core.fs.RecoverableFsDataOutputStream) Test(org.junit.Test)

Aggregations

RecoverableWriter (org.apache.flink.core.fs.RecoverableWriter)24 Test (org.junit.Test)22 RecoverableFsDataOutputStream (org.apache.flink.core.fs.RecoverableFsDataOutputStream)21 Path (org.apache.flink.core.fs.Path)16 Ignore (org.junit.Ignore)4 ResumeRecoverable (org.apache.flink.core.fs.RecoverableWriter.ResumeRecoverable)3 MockBlobStorage (org.apache.flink.fs.gs.storage.MockBlobStorage)3 GSRecoverableWriter (org.apache.flink.fs.gs.writer.GSRecoverableWriter)3 OutputStreamBasedInProgressFileRecoverable (org.apache.flink.streaming.api.functions.sink.filesystem.OutputStreamBasedPartFileWriter.OutputStreamBasedInProgressFileRecoverable)3 OutputStreamBasedPendingFileRecoverable (org.apache.flink.streaming.api.functions.sink.filesystem.OutputStreamBasedPartFileWriter.OutputStreamBasedPendingFileRecoverable)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 CommitRecoverable (org.apache.flink.core.fs.RecoverableWriter.CommitRecoverable)2 S3Recoverable (org.apache.flink.fs.s3.common.writer.S3Recoverable)2 OutputStreamBasedInProgressFileRecoverableSerializer (org.apache.flink.streaming.api.functions.sink.filesystem.OutputStreamBasedPartFileWriter.OutputStreamBasedInProgressFileRecoverableSerializer)2 OutputStreamBasedPendingFileRecoverableSerializer (org.apache.flink.streaming.api.functions.sink.filesystem.OutputStreamBasedPartFileWriter.OutputStreamBasedPendingFileRecoverableSerializer)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 FSDataInputStream (org.apache.flink.core.fs.FSDataInputStream)1 GSBlobIdentifier (org.apache.flink.fs.gs.storage.GSBlobIdentifier)1 InProgressFileRecoverable (org.apache.flink.streaming.api.functions.sink.filesystem.InProgressFileWriter.InProgressFileRecoverable)1