sijie commented on a change in pull request #889: BP-14 Implementation of
WriteFlag.DEFERRED_SYNC on Journal
URL: https://github.com/apache/bookkeeper/pull/889#discussion_r157884636
##########
File path:
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
##########
@@ -283,30 +283,43 @@ public boolean accept(long journalId) {
WriteCallback cb;
Object ctx;
long enqueueTime;
+ boolean ackBeforeForce;
+ boolean persisted;
OpStatsLogger journalAddEntryStats;
- static QueueEntry create(ByteBuf entry, long ledgerId, long entryId,
WriteCallback cb, Object ctx,
- long enqueueTime, OpStatsLogger journalAddEntryStats) {
+ static QueueEntry create(ByteBuf entry, boolean ackBeforeForce, long
ledgerId, long entryId,
+ WriteCallback cb, Object ctx, long enqueueTime, OpStatsLogger
journalAddEntryStats) {
QueueEntry qe = RECYCLER.get();
qe.entry = entry;
+ qe.ackBeforeForce = ackBeforeForce;
qe.cb = cb;
qe.ctx = ctx;
qe.ledgerId = ledgerId;
qe.entryId = entryId;
qe.enqueueTime = enqueueTime;
qe.journalAddEntryStats = journalAddEntryStats;
+ qe.persisted = false;
return qe;
}
@Override
public void run() {
if (LOG.isDebugEnabled()) {
- LOG.debug("Acknowledge Ledger: {}, Entry: {}", ledgerId,
entryId);
+ LOG.debug("Acknowledge Ledger: {}, Entry: {} ackBeforeForce {}
persisted {}", ledgerId, entryId,
+ ackBeforeForce, persisted);
+ }
+
+ if ((!ackBeforeForce) || (ackBeforeForce && !persisted)) {
+ // for entries with ackBeforeForce=true this callback will be
executed twice
+ // we will update the LastAddSynced cursor on the second call
+
journalAddEntryStats.registerSuccessfulEvent(MathUtils.elapsedNanos(enqueueTime),
TimeUnit.NANOSECONDS);
+ cb.writeComplete(0, ledgerId, entryId, null, ctx);
+ }
+ if (persisted){
Review comment:
why does it only recycle on `persisted=true`? how do you recycle objects for
`persisted=false? I can't find any references in this pull request.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services