Skip to content

Commit

Permalink
[Java] Use deadline for cluster tool response.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpt777 committed Apr 11, 2022
1 parent 06649c6 commit bfe3234
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions aeron-cluster/src/main/java/io/aeron/cluster/ClusterTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -698,12 +698,12 @@ public void onClusterMembersExtendedResponse(
id.set(aeron.nextCorrelationId());
if (consensusModuleProxy.clusterMembersQuery(id.get()))
{
final long startTime = System.currentTimeMillis();
final long deadlineMs = System.currentTimeMillis() + timeoutMs;
do
{
if (clusterControlAdapter.poll() == 0)
{
if ((System.currentTimeMillis() - startTime) > timeoutMs)
if (System.currentTimeMillis() > deadlineMs)
{
break;
}
Expand Down Expand Up @@ -1053,13 +1053,13 @@ private static boolean toggleClusterState(
if (waitForToggleToComplete)
{
final long toggleTimeoutMs = Math.max(defaultTimeoutMs, TIMEOUT_MS);
final long startTime = System.currentTimeMillis();
final long deadlineMs = System.currentTimeMillis() + toggleTimeoutMs;
ClusterControl.ToggleState currentState = null;

do
{
Thread.yield();
if ((System.currentTimeMillis() - startTime) > toggleTimeoutMs)
if (System.currentTimeMillis() > deadlineMs)
{
break;
}
Expand Down

0 comments on commit bfe3234

Please sign in to comment.