Skip to content

Commit

Permalink
sleep to delay send data
Browse files Browse the repository at this point in the history
  • Loading branch information
qifanwang committed Dec 19, 2024
1 parent a195c95 commit 1133538
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ client-output-buffer-limit slave 0 0 0
repl-diskless-sync yes
repl-diskless-sync-delay 3
#protected-mode no
maxmemory-policy volatile-lru
maxmemory-policy allkeys-lru
protected-mode no

hz 1
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public ReferenceFileRegion doRead(long milliSeconds) throws IOException {
if (null != replDelayConfig
&& (delayBytes = replDelayConfig.getDelayBytes()) > 0 && (delayMilli = replDelayConfig.getDelayMilli()) > 0) {
logger.debug("[readDelay]{}:{}", delayBytes, delayMilli);
offsetNotifier.await(curPosition + delayBytes, delayMilli);
// offsetNotifier.await(curPosition, delayMilli);
Thread.sleep(delayMilli);
} else if (milliSeconds >= 0) {
offsetNotifier.await(curPosition, milliSeconds);
} else {
Expand All @@ -66,7 +67,7 @@ public ReferenceFileRegion doRead(long milliSeconds) throws IOException {
}

if (!referenceFileChannel.hasAnythingToRead()) return null;
ReferenceFileRegion referenceFileRegion = referenceFileChannel.readTilEnd();
ReferenceFileRegion referenceFileRegion = referenceFileChannel.readTilEndWithDelay(replDelayConfig.getDelayBytes());

curPosition += referenceFileRegion.count();

Expand Down

0 comments on commit 1133538

Please sign in to comment.