Java Code Examples for org.apache.flink.core.fs.RecoverableFsDataOutputStream#Committer

The following examples show how to use org.apache.flink.core.fs.RecoverableFsDataOutputStream#Committer . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: S3RecoverableFsDataOutputStreamTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public RecoverableFsDataOutputStream.Committer snapshotAndGetCommitter() throws IOException {
	lastPersistedIndex = uploadedContent.size();

	return new RecoverableFsDataOutputStream.Committer() {
		@Override
		public void commit() throws IOException {
			published = getPublishedContents();
			uploadedContent.clear();
			lastPersistedIndex = 0;
		}

		@Override
		public void commitAfterRecovery() throws IOException {
			if (published.length == 0) {
				commit();
			}
		}

		@Override
		public RecoverableWriter.CommitRecoverable getRecoverable() {
			return null;
		}
	};
}
 
Example 2
Source File: S3RecoverableFsDataOutputStreamTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public RecoverableFsDataOutputStream.Committer snapshotAndGetCommitter() throws IOException {
	lastPersistedIndex = uploadedContent.size();

	return new RecoverableFsDataOutputStream.Committer() {
		@Override
		public void commit() throws IOException {
			published = getPublishedContents();
			uploadedContent.clear();
			lastPersistedIndex = 0;
		}

		@Override
		public void commitAfterRecovery() throws IOException {
			if (published.length == 0) {
				commit();
			}
		}

		@Override
		public RecoverableWriter.CommitRecoverable getRecoverable() {
			return null;
		}
	};
}
 
Example 3
Source File: S3RecoverableFsDataOutputStreamTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public RecoverableFsDataOutputStream.Committer snapshotAndGetCommitter() throws IOException {
	lastPersistedIndex = uploadedContent.size();

	return new RecoverableFsDataOutputStream.Committer() {
		@Override
		public void commit() throws IOException {
			published = getPublishedContents();
			uploadedContent.clear();
			lastPersistedIndex = 0;
		}

		@Override
		public void commitAfterRecovery() throws IOException {
			if (published.length == 0) {
				commit();
			}
		}

		@Override
		public RecoverableWriter.CommitRecoverable getRecoverable() {
			return null;
		}
	};
}
 
Example 4
Source File: S3RecoverableFsDataOutputStreamTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void noWritesShouldResolveInAnEmptyFile() throws IOException {
	RecoverableFsDataOutputStream.Committer committer = streamUnderTest.closeForCommit();
	committer.commit();

	assertThat(multipartUploadUnderTest, hasContent(new byte[0]));
}
 
Example 5
Source File: S3RecoverableFsDataOutputStreamTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void noWritesShouldResolveInAnEmptyFile() throws IOException {
	RecoverableFsDataOutputStream.Committer committer = streamUnderTest.closeForCommit();
	committer.commit();

	assertThat(multipartUploadUnderTest, hasContent(new byte[0]));
}
 
Example 6
Source File: S3RecoverableFsDataOutputStreamTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void simpleUsage() throws IOException {
	streamUnderTest.write(bytesOf("hello world"));

	RecoverableFsDataOutputStream.Committer committer = streamUnderTest.closeForCommit();
	committer.commit();

	assertThat(multipartUploadUnderTest, hasContent(bytesOf("hello world")));
}
 
Example 7
Source File: S3RecoverableFsDataOutputStreamTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void noWritesShouldResolveInAnEmptyFile() throws IOException {
	RecoverableFsDataOutputStream.Committer committer = streamUnderTest.closeForCommit();
	committer.commit();

	assertThat(multipartUploadUnderTest, hasContent(new byte[0]));
}
 
Example 8
Source File: OutputStreamBasedPartFileWriter.java    From flink with Apache License 2.0 4 votes vote down vote up
OutputStreamBasedPendingFile(final RecoverableFsDataOutputStream.Committer committer) {
	this.committer = committer;
}
 
Example 9
Source File: BucketTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public RecoverableFsDataOutputStream.Committer recoverForCommit(CommitRecoverable resumable) throws IOException {
	checkArgument(resumable instanceof NoOpRecoverable);
	recoverForCommitCallCounter++;
	return new NoOpCommitter();
}
 
Example 10
Source File: NoOpRecoverableWriter.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public RecoverableFsDataOutputStream.Committer recoverForCommit(RecoverableWriter.CommitRecoverable resumable) throws IOException {
	return null;
}
 
Example 11
Source File: BucketTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public RecoverableFsDataOutputStream.Committer recoverForCommit(CommitRecoverable resumable) throws IOException {
	checkArgument(resumable instanceof NoOpRecoverable);
	recoverForCommitCallCounter++;
	return new NoOpCommitter();
}
 
Example 12
Source File: NoOpRecoverableWriter.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public RecoverableFsDataOutputStream.Committer recoverForCommit(RecoverableWriter.CommitRecoverable resumable) throws IOException {
	return null;
}
 
Example 13
Source File: BucketTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public RecoverableFsDataOutputStream.Committer recoverForCommit(CommitRecoverable resumable) throws IOException {
	checkArgument(resumable instanceof NoOpRecoverable);
	recoverForCommitCallCounter++;
	return new NoOpCommitter();
}
 
Example 14
Source File: NoOpRecoverableWriter.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public RecoverableFsDataOutputStream.Committer recoverForCommit(RecoverableWriter.CommitRecoverable resumable) throws IOException {
	return null;
}
 
Example 15
Source File: HadoopS3RecoverableWriterITCase.java    From flink with Apache License 2.0 3 votes vote down vote up
@Test
public void testCommitAfterRecovery() throws Exception {
	final Path path = new Path(basePathForTest, "part-0");

	final RecoverableWriter initWriter = getRecoverableWriter();

	final RecoverableFsDataOutputStream stream = initWriter.open(path);
	stream.write(bytesOf(testData1));

	stream.persist();
	stream.persist();

	// and write some more data
	stream.write(bytesOf(testData2));

	final RecoverableWriter.CommitRecoverable recoverable = stream.closeForCommit().getRecoverable();

	final byte[] serializedRecoverable = initWriter.getCommitRecoverableSerializer().serialize(recoverable);

	// get a new serializer from a new writer to make sure that no pre-initialized state leaks in.
	final RecoverableWriter newWriter = getRecoverableWriter();

	final SimpleVersionedSerializer<RecoverableWriter.CommitRecoverable> deserializer = newWriter.getCommitRecoverableSerializer();
	final RecoverableWriter.CommitRecoverable recoveredRecoverable = deserializer.deserialize(deserializer.getVersion(), serializedRecoverable);

	final RecoverableFsDataOutputStream.Committer committer = newWriter.recoverForCommit(recoveredRecoverable);
	committer.commitAfterRecovery();

	Assert.assertEquals(testData1 + testData2, getContentsOfFile(path));
}
 
Example 16
Source File: HadoopS3RecoverableWriterITCase.java    From Flink-CEPplus with Apache License 2.0 3 votes vote down vote up
@Test
public void testCommitAfterRecovery() throws Exception {
	final Path path = new Path(basePathForTest, "part-0");

	final RecoverableWriter initWriter = getRecoverableWriter();

	final RecoverableFsDataOutputStream stream = initWriter.open(path);
	stream.write(bytesOf(testData1));

	stream.persist();
	stream.persist();

	// and write some more data
	stream.write(bytesOf(testData2));

	final RecoverableWriter.CommitRecoverable recoverable = stream.closeForCommit().getRecoverable();

	final byte[] serializedRecoverable = initWriter.getCommitRecoverableSerializer().serialize(recoverable);

	// get a new serializer from a new writer to make sure that no pre-initialized state leaks in.
	final RecoverableWriter newWriter = getRecoverableWriter();

	final SimpleVersionedSerializer<RecoverableWriter.CommitRecoverable> deserializer = newWriter.getCommitRecoverableSerializer();
	final RecoverableWriter.CommitRecoverable recoveredRecoverable = deserializer.deserialize(deserializer.getVersion(), serializedRecoverable);

	final RecoverableFsDataOutputStream.Committer committer = newWriter.recoverForCommit(recoveredRecoverable);
	committer.commitAfterRecovery();

	Assert.assertEquals(testData1 + testData2, getContentsOfFile(path));
}
 
Example 17
Source File: HadoopS3RecoverableWriterITCase.java    From flink with Apache License 2.0 3 votes vote down vote up
@Test
public void testCommitAfterRecovery() throws Exception {
	final Path path = new Path(basePathForTest, "part-0");

	final RecoverableWriter initWriter = getRecoverableWriter();

	final RecoverableFsDataOutputStream stream = initWriter.open(path);
	stream.write(bytesOf(testData1));

	stream.persist();
	stream.persist();

	// and write some more data
	stream.write(bytesOf(testData2));

	final RecoverableWriter.CommitRecoverable recoverable = stream.closeForCommit().getRecoverable();

	final byte[] serializedRecoverable = initWriter.getCommitRecoverableSerializer().serialize(recoverable);

	// get a new serializer from a new writer to make sure that no pre-initialized state leaks in.
	final RecoverableWriter newWriter = getRecoverableWriter();

	final SimpleVersionedSerializer<RecoverableWriter.CommitRecoverable> deserializer = newWriter.getCommitRecoverableSerializer();
	final RecoverableWriter.CommitRecoverable recoveredRecoverable = deserializer.deserialize(deserializer.getVersion(), serializedRecoverable);

	final RecoverableFsDataOutputStream.Committer committer = newWriter.recoverForCommit(recoveredRecoverable);
	committer.commitAfterRecovery();

	Assert.assertEquals(testData1 + testData2, getContentsOfFile(path));
}
 
Example 18
Source File: RecoverableMultiPartUpload.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a snapshot of this MultiPartUpload (MPU) and returns a
 * {@link RecoverableFsDataOutputStream.Committer Committer} which can be used to finalize the MPU.
 *
 * @return The {@link RecoverableFsDataOutputStream.Committer Committer} that can be used to complete the MPU.
 */
RecoverableFsDataOutputStream.Committer snapshotAndGetCommitter() throws IOException;
 
Example 19
Source File: RecoverableMultiPartUpload.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a snapshot of this MultiPartUpload (MPU) and returns a
 * {@link RecoverableFsDataOutputStream.Committer Committer} which can be used to finalize the MPU.
 *
 * @return The {@link RecoverableFsDataOutputStream.Committer Committer} that can be used to complete the MPU.
 */
RecoverableFsDataOutputStream.Committer snapshotAndGetCommitter() throws IOException;
 
Example 20
Source File: RecoverableMultiPartUpload.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a snapshot of this MultiPartUpload (MPU) and returns a
 * {@link RecoverableFsDataOutputStream.Committer Committer} which can be used to finalize the MPU.
 *
 * @return The {@link RecoverableFsDataOutputStream.Committer Committer} that can be used to complete the MPU.
 */
RecoverableFsDataOutputStream.Committer snapshotAndGetCommitter() throws IOException;