Skip to content

Commit

Permalink
forget about non-connectable targets if they get LOST in the meantime
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Sep 7, 2023
1 parent 615702c commit 19a6d93
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/main/java/io/cryostat/discovery/DiscoveryStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class DiscoveryStorage extends AbstractPlatformClientVerticle {
private final WebClient http;
private final Logger logger;
private long pluginPruneTimerId = -1L;
private long targetRetryTimeId = -1L;
private long targetRetryTimerId = -1L;

private final Map<Pair<TargetNode, UUID>, ConnectionAttemptRecord> nonConnectableTargets =
new ConcurrentHashMap<>();
Expand Down Expand Up @@ -136,7 +136,7 @@ public void start(Promise<Void> future) throws Exception {
.onFailure(future::fail);

this.pluginPruneTimerId = getVertx().setPeriodic(pingPeriod.toMillis(), i -> pingPrune());
this.targetRetryTimeId =
this.targetRetryTimerId =
getVertx().setPeriodic(2_000, i -> checkNonConnectedTargetJvmIds());
this.credentialsManager
.get()
Expand Down Expand Up @@ -179,6 +179,16 @@ public void start(Promise<Void> future) throws Exception {
tde.getServiceRef(),
entry.getKey().getTarget()));
break;
case LOST:
var it = nonConnectableTargets.entrySet().iterator();
while (it.hasNext()) {
var entry = it.next();
if (Objects.equals(
tde.getServiceRef(), entry.getKey().getKey().getTarget())) {
it.remove();
}
}
break;
default:
break;
}
Expand Down Expand Up @@ -248,7 +258,7 @@ private void testNonConnectedTargets(Predicate<Entry<TargetNode, UUID>> predicat
@Override
public void stop() {
getVertx().cancelTimer(pluginPruneTimerId);
getVertx().cancelTimer(targetRetryTimeId);
getVertx().cancelTimer(targetRetryTimerId);
}

private CompositeFuture pingPrune() {
Expand Down

0 comments on commit 19a6d93

Please sign in to comment.