use of org.apache.flink.streaming.api.functions.sink.filesystem.OutputStreamBasedPartFileWriter.OutputStreamBasedInProgressFileRecoverable in project flink by apache.
the class OutputStreamBasedPartFileRecoverableMigrationTest method testSerializationInProgress.
@Test
public void testSerializationInProgress() throws IOException {
String scenario = "in-progress";
java.nio.file.Path path = resolveVersionPath(previousVersion, scenario);
RecoverableWriter writer = FileSystem.getLocalFileSystem().createRecoverableWriter();
OutputStreamBasedInProgressFileRecoverableSerializer serializer = new OutputStreamBasedInProgressFileRecoverableSerializer(writer.getResumeRecoverableSerializer());
InProgressFileRecoverable recoverable = serializer.deserialize(previousVersion, Files.readAllBytes(path.resolve("recoverable")));
Assert.assertTrue(recoverable instanceof OutputStreamBasedInProgressFileRecoverable);
// make sure the ResumeRecoverable is valid
writer.recover(((OutputStreamBasedInProgressFileRecoverable) recoverable).getResumeRecoverable());
}
use of org.apache.flink.streaming.api.functions.sink.filesystem.OutputStreamBasedPartFileWriter.OutputStreamBasedInProgressFileRecoverable 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);
}
use of org.apache.flink.streaming.api.functions.sink.filesystem.OutputStreamBasedPartFileWriter.OutputStreamBasedInProgressFileRecoverable 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);
}
Aggregations