@Override public String toString() { return String.format("LedgerId = %s, Length = %s, Attempts = %s, InProgress = %s, Done = %s, Failed %s", this.writeLedger.get().metadata.getLedgerId(), this.data.getLength(), this.attemptCount, isInProgress(), isDone(), this.failureCause.get() != null); }
/** * Removes all the completed writes (whether successful or failed) from the beginning of the queue, until the first * non-completed item is encountered or the queue is empty. * * @return A CleanupStatus representing the state of the Operation. If there were failed writes, this will be WriteFailed, * otherwise it will be one of QueueEmpty or QueueNotEmpty, depending on the final state of the queue when this method * finishes. */ synchronized CleanupStatus removeFinishedWrites() { Exceptions.checkNotClosed(this.closed, this); long currentTime = this.timeSupplier.get(); long totalElapsed = 0; int removedCount = 0; boolean failedWrite = false; while (!this.writes.isEmpty() && this.writes.peekFirst().isDone()) { Write w = this.writes.removeFirst(); this.totalLength = Math.max(0, this.totalLength - w.data.getLength()); removedCount++; totalElapsed += currentTime - w.getQueueAddedTimestamp(); failedWrite |= w.getFailureCause() != null; } if (removedCount > 0) { this.lastDurationMillis = (int) (totalElapsed / removedCount / AbstractTimer.NANOS_TO_MILLIS); } return failedWrite ? CleanupStatus.WriteFailed : this.writes.isEmpty() ? CleanupStatus.QueueEmpty : CleanupStatus.QueueNotEmpty; }
} else if (!write.isDone()) { canSkip = false; result.add(write);
boolean anythingChanged = false; for (Write w : writes) { if (w.isDone() || !w.getWriteLedger().ledger.isClosed()) { continue;
if (!write.isDone()) { val result1 = q.removeFinishedWrites(); Assert.assertEquals("Unexpected value from removeFinishedWrites when there were writes left in the queue.", while (!writes.isEmpty() && writes.peekFirst().isDone()) { expectedElapsed += writes.pollFirst().getQueueAddedTimestamp(); removed++;