Java Code Examples for org.apache.flink.core.fs.RecoverableWriter

The following examples show how to use org.apache.flink.core.fs.RecoverableWriter. These examples are extracted from open source projects. 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
@Override
public RecoverableWriter.ResumeRecoverable persist() throws IOException {
	lock();
	try {
		fileStream.flush();
		openNewPartIfNecessary(userDefinedMinPartSize);

		// We do not stop writing to the current file, we merely limit the upload to the
		// first n bytes of the current file

		return upload.snapshotAndGetRecoverable(fileStream);
	}
	finally {
		unlock();
	}
}
 
Example 2
@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
@Test(expected = FileNotFoundException.class)
public void testCleanupRecoverableState() throws Exception {
	final RecoverableWriter writer = getRecoverableWriter();
	final Path path = new Path(basePathForTest, "part-0");

	final RecoverableFsDataOutputStream stream = writer.open(path);
	stream.write(bytesOf(testData1));
	S3Recoverable recoverable = (S3Recoverable) stream.persist();

	stream.closeForCommit().commit();

	// still the data is there as we have not deleted them from the tmp object
	final String content = getContentsOfFile(new Path('/' + recoverable.incompleteObjectName()));
	Assert.assertEquals(testData1, content);

	boolean successfullyDeletedState = writer.cleanupRecoverableState(recoverable);
	Assert.assertTrue(successfullyDeletedState);

	// this should throw the exception as we deleted the file.
	getContentsOfFile(new Path('/' + recoverable.incompleteObjectName()));
}
 
Example 4
Source Project: flink   Source File: BucketTest.java    License: Apache License 2.0 6 votes vote down vote up
private static Bucket<String, String> createBucket(
		final RecoverableWriter writer,
		final Path bucketPath,
		final int subtaskIdx,
		final int initialPartCounter,
		final PartFileConfig partFileConfig) {

	return Bucket.getNew(
			writer,
			subtaskIdx,
			bucketId,
			bucketPath,
			initialPartCounter,
			partFileFactory,
			rollingPolicy,
			partFileConfig);
}
 
Example 5
@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();
}
 
Example 6
@Test(expected = IOException.class)
public void testResumeWithWrongOffset() throws Exception {
	// this is a rather unrealistic scenario, but it is to trigger
	// truncation of the file and try to resume with missing data.

	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 recoverable1 = stream.persist();
	stream.write(testData2.getBytes(StandardCharsets.UTF_8));

	final RecoverableWriter.ResumeRecoverable recoverable2 = stream.persist();
	stream.write(testData3.getBytes(StandardCharsets.UTF_8));

	final RecoverableFsDataOutputStream recoveredStream = writer.recover(recoverable1);
	recoveredStream.closeForCommit().commit();

	// this should throw an exception
	final RecoverableFsDataOutputStream newRecoveredStream = writer.recover(recoverable2);
	newRecoveredStream.closeForCommit().commit();
}
 
Example 7
Source Project: flink   Source File: HadoopS3RecoverableWriterITCase.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCallingDeleteObjectTwiceDoesNotThroughException() throws Exception {
	final RecoverableWriter writer = getRecoverableWriter();
	final Path path = new Path(basePathForTest, "part-0");

	final RecoverableFsDataOutputStream stream = writer.open(path);
	stream.write(bytesOf(testData1));
	S3Recoverable recoverable = (S3Recoverable) stream.persist();

	stream.closeForCommit().commit();

	// still the data is there as we have not deleted them from the tmp object
	final String content = getContentsOfFile(new Path('/' + recoverable.incompleteObjectName()));
	Assert.assertEquals(testData1, content);

	boolean successfullyDeletedState = writer.cleanupRecoverableState(recoverable);
	Assert.assertTrue(successfullyDeletedState);

	boolean unsuccessfulDeletion = writer.cleanupRecoverableState(recoverable);
	Assert.assertFalse(unsuccessfulDeletion);
}
 
Example 8
@Test(expected = IOException.class)
public void testResumeWithWrongOffset() throws Exception {
	// this is a rather unrealistic scenario, but it is to trigger
	// truncation of the file and try to resume with missing data.

	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 recoverable1 = stream.persist();
	stream.write(testData2.getBytes(StandardCharsets.UTF_8));

	final RecoverableWriter.ResumeRecoverable recoverable2 = stream.persist();
	stream.write(testData3.getBytes(StandardCharsets.UTF_8));

	final RecoverableFsDataOutputStream recoveredStream = writer.recover(recoverable1);
	recoveredStream.closeForCommit().commit();

	// this should throw an exception
	final RecoverableFsDataOutputStream newRecoveredStream = writer.recover(recoverable2);
	newRecoveredStream.closeForCommit().commit();
}
 
Example 9
Source Project: Flink-CEPplus   Source File: Bucket.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructor to restore a bucket from checkpointed state.
 */
private Bucket(
		final RecoverableWriter fsWriter,
		final int subtaskIndex,
		final long initialPartCounter,
		final PartFileWriter.PartFileFactory<IN, BucketID> partFileFactory,
		final RollingPolicy<IN, BucketID> rollingPolicy,
		final BucketState<BucketID> bucketState) throws IOException {

	this(
			fsWriter,
			subtaskIndex,
			bucketState.getBucketId(),
			bucketState.getBucketPath(),
			initialPartCounter,
			partFileFactory,
			rollingPolicy);

	restoreInProgressFile(bucketState);
	commitRecoveredPendingFiles(bucketState);
}
 
Example 10
@Test
public void testRecoveryAfterClosingForCommitWorks() throws IOException {
	final Path testPath = new Path(basePath, "test-1");
	final String expectedContent = "test_line";

	final RecoverableWriter writerUnderTest = fileSystem.createRecoverableWriter();
	final RecoverableFsDataOutputStream streamUnderTest =
			getOpenStreamToFileWithContent(writerUnderTest, testPath, expectedContent);

	final RecoverableWriter.CommitRecoverable committable =
			streamUnderTest.closeForCommit().getRecoverable();

	writerUnderTest.recoverForCommit(committable).commitAfterRecovery();

	verifyFileContent(testPath, expectedContent);
}
 
Example 11
Source Project: Flink-CEPplus   Source File: BucketStateSerializerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testSerializationEmpty() throws IOException {
	final File testFolder = tempFolder.newFolder();
	final FileSystem fs = FileSystem.get(testFolder.toURI());
	final RecoverableWriter writer = fs.createRecoverableWriter();

	final Path testBucket = new Path(testFolder.getPath(), "test");

	final BucketState<String> bucketState = new BucketState<>(
			"test", testBucket, Long.MAX_VALUE, null, new HashMap<>());

	final SimpleVersionedSerializer<BucketState<String>> serializer =
			new BucketStateSerializer<>(
					writer.getResumeRecoverableSerializer(),
					writer.getCommitRecoverableSerializer(),
					SimpleVersionedStringSerializer.INSTANCE
			);

	byte[] bytes = SimpleVersionedSerialization.writeVersionAndSerialize(serializer, bucketState);
	final BucketState<String> recoveredState =  SimpleVersionedSerialization.readVersionAndDeSerialize(serializer, bytes);

	Assert.assertEquals(testBucket, recoveredState.getBucketPath());
	Assert.assertNull(recoveredState.getInProgressResumableFile());
	Assert.assertTrue(recoveredState.getCommittableFilesPerCheckpoint().isEmpty());
}
 
Example 12
Source Project: flink   Source File: S3RecoverableFsDataOutputStream.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public RecoverableWriter.ResumeRecoverable persist() throws IOException {
	lock();
	try {
		fileStream.flush();
		openNewPartIfNecessary(userDefinedMinPartSize);

		// We do not stop writing to the current file, we merely limit the upload to the
		// first n bytes of the current file

		return upload.snapshotAndGetRecoverable(fileStream);
	}
	finally {
		unlock();
	}
}
 
Example 13
Source Project: flink   Source File: S3RecoverableFsDataOutputStreamTest.java    License: 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 14
@Test(expected = IOException.class)
public void testResumeWithWrongOffset() throws Exception {
	// this is a rather unrealistic scenario, but it is to trigger
	// truncation of the file and try to resume with missing data.

	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 recoverable1 = stream.persist();
	stream.write(testData2.getBytes(StandardCharsets.UTF_8));

	final RecoverableWriter.ResumeRecoverable recoverable2 = stream.persist();
	stream.write(testData3.getBytes(StandardCharsets.UTF_8));

	final RecoverableFsDataOutputStream recoveredStream = writer.recover(recoverable1);
	recoveredStream.closeForCommit().commit();

	// this should throw an exception
	final RecoverableFsDataOutputStream newRecoveredStream = writer.recover(recoverable2);
	newRecoveredStream.closeForCommit().commit();
}
 
Example 15
Source Project: flink   Source File: DefaultBucketFactoryImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Bucket<IN, BucketID> restoreBucket(
		final RecoverableWriter fsWriter,
		final int subtaskIndex,
		final long initialPartCounter,
		final PartFileWriter.PartFileFactory<IN, BucketID> partFileWriterFactory,
		final RollingPolicy<IN, BucketID> rollingPolicy,
		final BucketState<BucketID> bucketState,
		final PartFileConfig partFileConfig) throws IOException {

	return Bucket.restore(
			fsWriter,
			subtaskIndex,
			initialPartCounter,
			partFileWriterFactory,
			rollingPolicy,
			bucketState,
			partFileConfig);
}
 
Example 16
Source Project: flink   Source File: Bucket.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructor to create a new empty bucket.
 */
private Bucket(
		final RecoverableWriter fsWriter,
		final int subtaskIndex,
		final BucketID bucketId,
		final Path bucketPath,
		final long initialPartCounter,
		final PartFileWriter.PartFileFactory<IN, BucketID> partFileFactory,
		final RollingPolicy<IN, BucketID> rollingPolicy,
		final PartFileConfig partFileConfig) {
	this.fsWriter = checkNotNull(fsWriter);
	this.subtaskIndex = subtaskIndex;
	this.bucketId = checkNotNull(bucketId);
	this.bucketPath = checkNotNull(bucketPath);
	this.partCounter = initialPartCounter;
	this.partFileFactory = checkNotNull(partFileFactory);
	this.rollingPolicy = checkNotNull(rollingPolicy);

	this.pendingPartsForCurrentCheckpoint = new ArrayList<>();
	this.pendingPartsPerCheckpoint = new TreeMap<>();
	this.resumablesPerCheckpoint = new TreeMap<>();

	this.partFileConfig = checkNotNull(partFileConfig);
}
 
Example 17
Source Project: flink   Source File: BucketStateSerializerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testSerializationEmpty() throws IOException {
	final File testFolder = tempFolder.newFolder();
	final FileSystem fs = FileSystem.get(testFolder.toURI());
	final RecoverableWriter writer = fs.createRecoverableWriter();

	final Path testBucket = new Path(testFolder.getPath(), "test");

	final BucketState<String> bucketState = new BucketState<>(
			"test", testBucket, Long.MAX_VALUE, null, new HashMap<>());

	final SimpleVersionedSerializer<BucketState<String>> serializer =
			new BucketStateSerializer<>(
					writer.getResumeRecoverableSerializer(),
					writer.getCommitRecoverableSerializer(),
					SimpleVersionedStringSerializer.INSTANCE
			);

	byte[] bytes = SimpleVersionedSerialization.writeVersionAndSerialize(serializer, bucketState);
	final BucketState<String> recoveredState =  SimpleVersionedSerialization.readVersionAndDeSerialize(serializer, bytes);

	Assert.assertEquals(testBucket, recoveredState.getBucketPath());
	Assert.assertNull(recoveredState.getInProgressResumableFile());
	Assert.assertTrue(recoveredState.getCommittableFilesPerCheckpoint().isEmpty());
}
 
Example 18
@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();
}
 
Example 19
Source Project: flink   Source File: S3RecoverableFsDataOutputStreamTest.java    License: 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 20
Source Project: Flink-CEPplus   Source File: FlinkS3FileSystem.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RecoverableWriter createRecoverableWriter() throws IOException {
	if (s3AccessHelper == null) {
		// this is the case for Presto
		throw new UnsupportedOperationException("This s3 file system implementation does not support recoverable writers.");
	}

	return S3RecoverableWriter.writer(
			getHadoopFileSystem(),
			tmpFileCreator,
			s3AccessHelper,
			uploadThreadPool,
			s3uploadPartSize,
			maxConcurrentUploadsPerStream);
}
 
Example 21
@Override
public RecoverableWriter.ResumeRecoverable snapshotAndGetRecoverable(RefCountedFSOutputStream incompletePartFile) throws IOException {
	lastPersistedIndex = uploadedContent.size();

	if (incompletePartFile.getPos() >= 0L) {
		byte[] bytes = readFileContents(incompletePartFile);
		uncompleted = Optional.of(bytes);
	}

	return null;
}
 
Example 22
@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();
}
 
Example 23
@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));
}
 
Example 24
private void testResumeAfterMultiplePersist(
		final String persistName,
		final String expectedFinalContents,
		final String firstItemToWrite,
		final String secondItemToWrite,
		final String thirdItemToWrite) throws Exception {

	final Path path = new Path(basePathForTest, "part-0");
	final RecoverableWriter initWriter = getRecoverableWriter();

	final Map<String, RecoverableWriter.ResumeRecoverable> recoverables = new HashMap<>(4);
	try (final RecoverableFsDataOutputStream stream = initWriter.open(path)) {
		recoverables.put(INIT_EMPTY_PERSIST, stream.persist());

		stream.write(bytesOf(firstItemToWrite));

		recoverables.put(INTERM_WITH_STATE_PERSIST, stream.persist());
		recoverables.put(INTERM_WITH_NO_ADDITIONAL_STATE_PERSIST, stream.persist());

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

		recoverables.put(FINAL_WITH_EXTRA_STATE, stream.persist());
	}

	final SimpleVersionedSerializer<RecoverableWriter.ResumeRecoverable> serializer = initWriter.getResumeRecoverableSerializer();
	final byte[] serializedRecoverable = serializer.serialize(recoverables.get(persistName));

	// 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.ResumeRecoverable> deserializer = newWriter.getResumeRecoverableSerializer();
	final RecoverableWriter.ResumeRecoverable recoveredRecoverable =
			deserializer.deserialize(serializer.getVersion(), serializedRecoverable);

	final RecoverableFsDataOutputStream recoveredStream = newWriter.recover(recoveredRecoverable);
	recoveredStream.write(bytesOf(thirdItemToWrite));
	recoveredStream.closeForCommit().commit();

	Assert.assertEquals(expectedFinalContents, getContentsOfFile(path));
}
 
Example 25
Source Project: flink   Source File: HadoopS3RecoverableWriterITCase.java    License: Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example 26
Source Project: Flink-CEPplus   Source File: RowWisePartWriter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public PartFileWriter<IN, BucketID> resumeFrom(
		final BucketID bucketId,
		final RecoverableFsDataOutputStream stream,
		final RecoverableWriter.ResumeRecoverable resumable,
		final long creationTime) throws IOException {

	Preconditions.checkNotNull(stream);
	Preconditions.checkNotNull(resumable);

	return new RowWisePartWriter<>(bucketId, stream, encoder, creationTime);
}
 
Example 27
Source Project: flink   Source File: BucketTest.java    License: Apache License 2.0 5 votes vote down vote up
private Map<Long, List<RecoverableWriter.CommitRecoverable>> createPendingPartsPerCheckpoint(int noOfCheckpoints) {
	final Map<Long, List<RecoverableWriter.CommitRecoverable>> pendingCommittablesPerCheckpoint = new HashMap<>();
	for (int checkpointId = 0; checkpointId < noOfCheckpoints; checkpointId++) {
		final List<RecoverableWriter.CommitRecoverable> pending = new ArrayList<>();
		pending.add(new NoOpRecoverable());
		pendingCommittablesPerCheckpoint.put((long) checkpointId, pending);
	}
	return pendingCommittablesPerCheckpoint;
}
 
Example 28
Source Project: Flink-CEPplus   Source File: BucketStateSerializer.java    License: Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
BucketState<BucketID> deserializeV1(DataInputView in) throws IOException {
	final BucketID bucketId = SimpleVersionedSerialization.readVersionAndDeSerialize(bucketIdSerializer, in);
	final String bucketPathStr = in.readUTF();
	final long creationTime = in.readLong();

	// then get the current resumable stream
	RecoverableWriter.ResumeRecoverable current = null;
	if (in.readBoolean()) {
		current = SimpleVersionedSerialization.readVersionAndDeSerialize(resumableSerializer, in);
	}

	final int committableVersion = in.readInt();
	final int numCheckpoints = in.readInt();
	final HashMap<Long, List<RecoverableWriter.CommitRecoverable>> resumablesPerCheckpoint = new HashMap<>(numCheckpoints);

	for (int i = 0; i < numCheckpoints; i++) {
		final long checkpointId = in.readLong();
		final int noOfResumables = in.readInt();

		final List<RecoverableWriter.CommitRecoverable> resumables = new ArrayList<>(noOfResumables);
		for (int j = 0; j < noOfResumables; j++) {
			final byte[] bytes = new byte[in.readInt()];
			in.readFully(bytes);
			resumables.add(commitableSerializer.deserialize(committableVersion, bytes));
		}
		resumablesPerCheckpoint.put(checkpointId, resumables);
	}

	return new BucketState<>(
			bucketId,
			new Path(bucketPathStr),
			creationTime,
			current,
			resumablesPerCheckpoint);
}
 
Example 29
Source Project: Flink-CEPplus   Source File: BucketState.java    License: Apache License 2.0 5 votes vote down vote up
BucketState(
		final BucketID bucketId,
		final Path bucketPath,
		final long inProgressFileCreationTime,
		@Nullable final RecoverableWriter.ResumeRecoverable inProgressResumableFile,
		final Map<Long, List<RecoverableWriter.CommitRecoverable>> pendingCommittablesPerCheckpoint
) {
	this.bucketId = Preconditions.checkNotNull(bucketId);
	this.bucketPath = Preconditions.checkNotNull(bucketPath);
	this.inProgressFileCreationTime = inProgressFileCreationTime;
	this.inProgressResumableFile = inProgressResumableFile;
	this.committableFilesPerCheckpoint = Preconditions.checkNotNull(pendingCommittablesPerCheckpoint);
}
 
Example 30
Source Project: flink   Source File: OutputStreamBasedPartFileWriter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public PendingFile recoverPendingFile(final PendingFileRecoverable pendingFileRecoverable) throws IOException {
	final RecoverableWriter.CommitRecoverable commitRecoverable;

	if (pendingFileRecoverable instanceof OutputStreamBasedPendingFileRecoverable) {
		commitRecoverable = ((OutputStreamBasedPendingFileRecoverable) pendingFileRecoverable).getCommitRecoverable();
	} else if (pendingFileRecoverable instanceof OutputStreamBasedInProgressFileRecoverable) {
		commitRecoverable = ((OutputStreamBasedInProgressFileRecoverable) pendingFileRecoverable).getResumeRecoverable();
	} else {
		throw new IllegalArgumentException("can not recover from the pendingFileRecoverable");
	}
	return new OutputStreamBasedPendingFile(recoverableWriter.recoverForCommit(commitRecoverable));
}