Search in sources :

Example 6 with MockCommitRequest

use of org.apache.flink.api.connector.sink2.mocks.MockCommitRequest in project flink by apache.

the class FileCommitterTest method testCommitPendingFile.

@Test
public void testCommitPendingFile() throws Exception {
    StubBucketWriter stubBucketWriter = new StubBucketWriter();
    FileCommitter fileCommitter = new FileCommitter(stubBucketWriter);
    MockCommitRequest<FileSinkCommittable> fileSinkCommittable = new MockCommitRequest<>(new FileSinkCommittable("0", new FileSinkTestUtils.TestPendingFileRecoverable()));
    fileCommitter.commit(Collections.singletonList(fileSinkCommittable));
    assertEquals(1, stubBucketWriter.getRecoveredPendingFiles().size());
    assertEquals(0, stubBucketWriter.getNumCleanUp());
    assertTrue(stubBucketWriter.getRecoveredPendingFiles().get(0).isCommitted());
    assertEquals(0, fileSinkCommittable.getNumberOfRetries());
}
Also used : MockCommitRequest(org.apache.flink.api.connector.sink2.mocks.MockCommitRequest) FileSinkCommittable(org.apache.flink.connector.file.sink.FileSinkCommittable) Test(org.junit.Test)

Aggregations

MockCommitRequest (org.apache.flink.api.connector.sink2.mocks.MockCommitRequest)6 FileSinkCommittable (org.apache.flink.connector.file.sink.FileSinkCommittable)4 Test (org.junit.Test)4 IOException (java.io.IOException)2 Collection (java.util.Collection)2 List (java.util.List)2 Properties (java.util.Properties)2 Collectors (java.util.stream.Collectors)2 CommitRequest (org.apache.flink.api.connector.sink2.Committer.CommitRequest)2 InProgressFileWriter (org.apache.flink.streaming.api.functions.sink.filesystem.InProgressFileWriter)2 Test (org.junit.jupiter.api.Test)2 Files (java.nio.file.Files)1 Paths (java.nio.file.Paths)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Map (java.util.Map)1 Set (java.util.Set)1 Stream (java.util.stream.Stream)1 SimpleStringEncoder (org.apache.flink.api.common.serialization.SimpleStringEncoder)1