Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

fix: use origin expireNanoTime to init new clientRequestRound #105

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,28 @@ public ClientRequestRound(
Table.ClientOPCallback cb,
boolean enableCounter,
long timeoutInMilliseconds) {
operator = op;
callback = cb;
timeoutMs = timeoutInMilliseconds;
this(
op,
cb,
enableCounter,
System.nanoTime() + timeoutInMilliseconds * 1000000L,
timeoutInMilliseconds);
}

public ClientRequestRound(
client_operator op,
Table.ClientOPCallback cb,
boolean enableCounter,
long expireNanoTime,
long timeoutInMilliseconds) {
this.operator = op;
this.callback = cb;
this.timeoutMs = timeoutInMilliseconds;

this.enableCounter = enableCounter;
createNanoTime = System.nanoTime();
expireNanoTime = createNanoTime + timeoutMs * 1000000L;
isCompleted = false;
backupRequestTask = null;
this.expireNanoTime = expireNanoTime;
this.isCompleted = false;
this.backupRequestTask = null;
}

public com.xiaomi.infra.pegasus.operator.client_operator getOperator() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,16 @@ void onRpcReply(
}

// must use new round here, because round.isSuccess is true now
tryDelayCall(
// must use round.expireNanoTime to init, otherwise "round.expireNanoTime - System.nanoTime() >
// nanoDelay" in "tryDelayCall()" will be always true
ClientRequestRound delayRequestRound =
new ClientRequestRound(
round.operator, round.callback, round.enableCounter, round.timeoutMs),
tryId + 1);
round.operator,
round.callback,
round.enableCounter,
round.expireNanoTime,
round.timeoutMs);
tryDelayCall(delayRequestRound, tryId + 1);
}

void tryDelayCall(final ClientRequestRound round, final int tryId) {
Expand Down