Renkai commented on a change in pull request #9202:
URL: https://github.com/apache/pulsar/pull/9202#discussion_r569203005
##########
File path:
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
##########
@@ -780,12 +1088,99 @@ private boolean beforeAddEntry(OpAddEntry addOperation) {
}
}
+ /**
+ * This method should not block the thread, if the buffer is full then use
another runnable to fill data
+ * when buffer available.
+ *
+ * @param addOperation
+ */
+ protected synchronized void addToOffload(OpAddEntry addOperation) {
+ if (currentOffloadHandle == null) {
+ return;
+ }
+ final PositionImpl positionNextToOffered = getNextValidPosition(
+ PositionImpl.get(currentOffloadHandle.lastOffered()));
+
+ final PositionImpl offeringPosition = addOperation.getPosition();
+ if (positionNextToOffered
+ .equals(offeringPosition)) {
+ final EntryImpl entry = EntryImpl
+ .create(PositionImpl.get(addOperation.ledger.getId(),
addOperation.getEntryId()),
+ addOperation.getData());
+
+ OfferEntryResult offerEntryResult =
currentOffloadHandle.offerEntry(entry);
+ entry.release();
+ switch (offerEntryResult) {
+ case SUCCESS:
+ //happy case
+ return;
+ case FAIL_SEGMENT_CLOSED:
+ log.debug("segment closed");
Review comment:
Details are easier to get at offloader, I will remove the debug code
here.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]