You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2021/12/06 02:51:06 UTC

[GitHub] [bookkeeper] hangc0276 commented on a change in pull request #2778: Ledger replicate supports throttle

hangc0276 commented on a change in pull request #2778:
URL: https://github.com/apache/bookkeeper/pull/2778#discussion_r762669035



##########
File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/tools/cli/commands/bookies/RecoverCommand.java
##########
@@ -103,6 +103,9 @@ private RecoverCommand(RecoverFlags flags) {
 
         @Parameter(names = {"-sku", "--skipunrecoverableledgers"}, description = "Skip unrecoverable ledgers")
         private boolean skipUnrecoverableLedgers;
+
+        @Parameter(names = { "-trb", "--throttleRateByBytes" }, description = "Throttle replication rate in bytes")

Review comment:
       +1

##########
File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerFragmentReplicator.java
##########
@@ -112,10 +119,16 @@ public LedgerFragmentReplicator(BookKeeper bkc, StatsLogger statsLogger) {
         numBytesWritten = this.statsLogger.getOpStatsLogger(NUM_BYTES_WRITTEN);
         readDataLatency = this.statsLogger.getOpStatsLogger(READ_DATA_LATENCY);
         writeDataLatency = this.statsLogger.getOpStatsLogger(WRITE_DATA_LATENCY);
+        if (conf.getReplicationRateByBytes() > 0) {
+            this.replicationThrottle = new Throttler(conf.getReplicationRateByBytes());
+        }
+        totalReplicatedEntriesSize = 0;
+        replicatedEntriesNum = 0;
+        averageEntrySize = 1024;

Review comment:
       `1024` should be define as constant

##########
File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerFragmentReplicator.java
##########
@@ -379,10 +397,17 @@ public void readComplete(int rc, LedgerHandle lh,
                 final long dataLength = data.length;
                 numEntriesRead.inc();
                 numBytesRead.registerSuccessfulValue(dataLength);
+                ++replicatedEntriesNum;
+
                 ByteBufList toSend = lh.getDigestManager()
                         .computeDigestAndPackageForSending(entryId,
                                 lh.getLastAddConfirmed(), entry.getLength(),
                                 Unpooled.wrappedBuffer(data, 0, data.length));
+                int toSendSize = toSend.readableBytes();
+
+                totalReplicatedEntriesSize += toSendSize;
+                averageEntrySize = (int) ((totalReplicatedEntriesSize / replicatedEntriesNum));

Review comment:
       does the `avg = avg * ratio + (1 - ratio) * newSize` method to calculate averageEntrySize doesn't work well?




-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org