use of com.palantir.atlasdb.protos.generated.StreamPersistence.StreamMetadata in project atlasdb by palantir.
the class AbstractGenericStreamStore method loadStreamAsFile.
@Override
public final File loadStreamAsFile(Transaction transaction, T id) {
StreamMetadata metadata = getMetadata(transaction, id);
checkStreamStored(id, metadata);
return loadToNewTempFile(transaction, id, metadata);
}
use of com.palantir.atlasdb.protos.generated.StreamPersistence.StreamMetadata in project atlasdb by palantir.
the class AbstractPersistentStreamStore method storeBlocksAndGetHashlessMetadata.
protected final StreamMetadata storeBlocksAndGetHashlessMetadata(@Nullable Transaction tx, long id, InputStream stream) {
CountingInputStream countingStream = new CountingInputStream(stream);
// Try to store the bytes in the stream and get length
try {
storeBlocksFromStream(tx, id, countingStream);
} catch (IOException e) {
long length = countingStream.getCount();
StreamMetadata metadata = StreamMetadata.newBuilder().setStatus(Status.FAILED).setLength(length).setHash(com.google.protobuf.ByteString.EMPTY).build();
storeMetadataAndIndex(id, metadata);
log.error("Could not store stream {}. Failed after {} bytes.", id, length, e);
throw Throwables.rewrapAndThrowUncheckedException("Failed to store stream.", e);
}
long length = countingStream.getCount();
return StreamMetadata.newBuilder().setStatus(Status.STORED).setLength(length).setHash(com.google.protobuf.ByteString.EMPTY).build();
}
Aggregations