Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,16 @@ private LedgerReader(ReadHandle readHandle,

@Override
public void run() {
if (readHandle.getLength() == 0 || !readHandle.isClosed() || readHandle.getLastAddConfirmed() < 0) {
if (!readHandle.isClosed() || readHandle.getLastAddConfirmed() < 0) {
promise.completeExceptionally(
new IllegalArgumentException("An empty or open ledger should never be offloaded"));
return;
}
if (readHandle.getLength() <= 0) {
log.warn("Ledger [{}] has zero length, but it contains {} entries. "
+ " Attempting to offload ledger since it contains entries.", readHandle.getId(),
readHandle.getLastAddConfirmed() + 1);
}
long ledgerId = readHandle.getId();
final String managedLedgerName = extraMetadata.get(MANAGED_LEDGER_NAME);
String storagePath = getStoragePath(storageBasePath, managedLedgerName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,16 @@ public CompletableFuture<Void> offload(ReadHandle readHandle,
final BlobStore writeBlobStore = getBlobStore(config.getBlobStoreLocation());
log.info("offload {} uuid {} extraMetadata {} to {} {}", readHandle.getId(), uuid, extraMetadata,
config.getBlobStoreLocation(), writeBlobStore);
if (readHandle.getLength() == 0 || !readHandle.isClosed() || readHandle.getLastAddConfirmed() < 0) {
if (!readHandle.isClosed() || readHandle.getLastAddConfirmed() < 0) {
promise.completeExceptionally(
new IllegalArgumentException("An empty or open ledger should never be offloaded"));
return;
}
if (readHandle.getLength() <= 0) {
log.warn("[{}] Ledger [{}] has zero length, but it contains {} entries."
+ " Attempting to offload ledger since it contains entries.", topicName, readHandle.getId(),
readHandle.getLastAddConfirmed() + 1);
}
OffloadIndexBlockBuilder indexBuilder = OffloadIndexBlockBuilder.create()
.withLedgerMetadata(readHandle.getLedgerMetadata())
.withDataBlockHeaderLength(BlockAwareSegmentInputStreamImpl.getHeaderSize());
Expand Down
Loading