Skip to content

Commit

Permalink
Reset lastFailedJoinAttempt
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Ershov committed Mar 12, 2019
1 parent 83f1bb5 commit 283fdea
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.LongSupplier;
Expand All @@ -84,7 +85,7 @@ public class JoinHelper {

final Set<Tuple<DiscoveryNode, JoinRequest>> pendingOutgoingJoins = ConcurrentCollections.newConcurrentSet();

private volatile FailedJoinAttempt lastFailedJoinAttempt;
private AtomicReference<FailedJoinAttempt> lastFailedJoinAttempt = new AtomicReference<>();

JoinHelper(Settings settings, AllocationService allocationService, MasterService masterService,
TransportService transportService, LongSupplier currentTermSupplier, Supplier<ClusterState> currentStateSupplier,
Expand Down Expand Up @@ -217,9 +218,10 @@ void logWarnWithTimestamp() {


void logLastFailedJoinAttempt() {
FailedJoinAttempt attempt = lastFailedJoinAttempt;
FailedJoinAttempt attempt = lastFailedJoinAttempt.get();
if (attempt != null) {
attempt.logWarnWithTimestamp();
lastFailedJoinAttempt.compareAndSet(attempt, null);
}
}

Expand All @@ -241,15 +243,15 @@ public Empty read(StreamInput in) {
public void handleResponse(Empty response) {
pendingOutgoingJoins.remove(dedupKey);
logger.debug("successfully joined {} with {}", destination, joinRequest);
lastFailedJoinAttempt = null;
lastFailedJoinAttempt.set(null);
}

@Override
public void handleException(TransportException exp) {
pendingOutgoingJoins.remove(dedupKey);
FailedJoinAttempt attempt = new FailedJoinAttempt(destination, joinRequest, exp);
attempt.logNow();
lastFailedJoinAttempt = attempt;
lastFailedJoinAttempt.set(attempt);
}

@Override
Expand Down

0 comments on commit 283fdea

Please sign in to comment.