Search in sources :

Example 6 with RefCountedBufferingFileStream

use of org.apache.flink.fs.s3.common.utils.RefCountedBufferingFileStream in project flink by apache.

the class RecoverableMultiPartUploadImplTest method uploadingNonClosedFileAsCompleteShouldThroughException.

@Test(expected = IllegalStateException.class)
public void uploadingNonClosedFileAsCompleteShouldThroughException() throws IOException {
    final byte[] incompletePart = bytesOf("!!!");
    final RefCountedBufferingFileStream incompletePartFile = writeContent(incompletePart);
    multiPartUploadUnderTest.uploadPart(incompletePartFile);
}
Also used : RefCountedBufferingFileStream(org.apache.flink.fs.s3.common.utils.RefCountedBufferingFileStream) Test(org.junit.Test)

Example 7 with RefCountedBufferingFileStream

use of org.apache.flink.fs.s3.common.utils.RefCountedBufferingFileStream in project flink by apache.

the class RecoverableMultiPartUploadImplTest method writeContent.

private RefCountedBufferingFileStream writeContent(byte[] content) throws IOException {
    final File newFile = new File(temporaryFolder.getRoot(), ".tmp_" + UUID.randomUUID());
    final OutputStream out = Files.newOutputStream(newFile.toPath(), StandardOpenOption.CREATE_NEW);
    final RefCountedBufferingFileStream testStream = new RefCountedBufferingFileStream(RefCountedFileWithStream.newFile(newFile, out), BUFFER_SIZE);
    testStream.write(content, 0, content.length);
    return testStream;
}
Also used : RefCountedBufferingFileStream(org.apache.flink.fs.s3.common.utils.RefCountedBufferingFileStream) OutputStream(java.io.OutputStream) File(java.io.File)

Example 8 with RefCountedBufferingFileStream

use of org.apache.flink.fs.s3.common.utils.RefCountedBufferingFileStream in project flink by apache.

the class RecoverableMultiPartUploadImplTest method uploadObject.

private S3Recoverable uploadObject(byte[] content) throws IOException {
    final RefCountedBufferingFileStream incompletePartFile = writeContent(content);
    incompletePartFile.flush();
    return multiPartUploadUnderTest.snapshotAndGetRecoverable(incompletePartFile);
}
Also used : RefCountedBufferingFileStream(org.apache.flink.fs.s3.common.utils.RefCountedBufferingFileStream)

Aggregations

RefCountedBufferingFileStream (org.apache.flink.fs.s3.common.utils.RefCountedBufferingFileStream)8 File (java.io.File)2 OutputStream (java.io.OutputStream)1 Before (org.junit.Before)1 Test (org.junit.Test)1