Skip to content

Commit

Permalink
Convert staleJoinPreventionDuration to not static field (#19623)
Browse files Browse the repository at this point in the history
Co-authored-by: Vassilis Bekiaris <vbekiaris@gmail.com>
  • Loading branch information
ufukyilmaz and vbekiaris committed Sep 24, 2021
1 parent 47206ba commit 8866289
Showing 1 changed file with 5 additions and 5 deletions.
Expand Up @@ -88,9 +88,8 @@
public class ClusterJoinManager {

public static final String STALE_JOIN_PREVENTION_DURATION_PROP = "hazelcast.stale.join.prevention.duration.seconds";
private static final int DEFAULT_STALE_JOIN_PREVENTION_DURATION_IN_SECS = 30;
private static final int CLUSTER_OPERATION_RETRY_COUNT = 100;
private static final int STALE_JOIN_PREVENTION_DURATION_SECONDS
= Integer.getInteger(STALE_JOIN_PREVENTION_DURATION_PROP, 30);

private final ILogger logger;
private final Node node;
Expand All @@ -115,7 +114,7 @@ public class ClusterJoinManager {
private final ConcurrentMap<UUID, Long> leftMembersUuids = new ConcurrentHashMap<>();
private final long maxWaitMillisBeforeJoin;
private final long waitMillisBeforeJoin;
private final long staleJoinPreventionDuration;
private final long staleJoinPreventionDurationInMillis;

private long firstJoinRequest;
private long timeToStartJoin;
Expand All @@ -133,7 +132,8 @@ public class ClusterJoinManager {

maxWaitMillisBeforeJoin = node.getProperties().getMillis(ClusterProperty.MAX_WAIT_SECONDS_BEFORE_JOIN);
waitMillisBeforeJoin = node.getProperties().getMillis(ClusterProperty.WAIT_SECONDS_BEFORE_JOIN);
staleJoinPreventionDuration = TimeUnit.SECONDS.toMillis(STALE_JOIN_PREVENTION_DURATION_SECONDS);
staleJoinPreventionDurationInMillis = TimeUnit.SECONDS.toMillis(
Integer.getInteger(STALE_JOIN_PREVENTION_DURATION_PROP, DEFAULT_STALE_JOIN_PREVENTION_DURATION_IN_SECS));
}

boolean isJoinInProgress() {
Expand Down Expand Up @@ -364,7 +364,7 @@ private boolean checkRecentlyJoinedMemberUuidBeforeJoin(Address target, UUID uui

private void cleanupRecentlyJoinedMemberUuids() {
long currentTime = Clock.currentTimeMillis();
recentlyJoinedMemberUuids.values().removeIf(joinTime -> (currentTime - joinTime) >= staleJoinPreventionDuration);
recentlyJoinedMemberUuids.values().removeIf(joinTime -> (currentTime - joinTime) >= staleJoinPreventionDurationInMillis);
}

private boolean authenticate(JoinRequest joinRequest, Connection connection) {
Expand Down

0 comments on commit 8866289

Please sign in to comment.