Server: connected event only if really connecting

This commit is contained in:
2024-10-13 11:00:57 +02:00
parent 4ef2fd5775
commit e97ea78623
2 changed files with 14 additions and 5 deletions

View File

@@ -118,13 +118,13 @@ public class PeerManager {
return null;
});
for (var l : _connectedListeners) {
l.apply(host);
}
if (wasReachable) return;
Log.info("Connected to " + host);
for (var l : _connectedListeners) {
l.apply(host);
}
}
public void handleConnectionError(UUID host) {

View File

@@ -5,6 +5,8 @@ import com.usatiuk.dhfs.objects.repository.PeerManager;
import io.quarkus.logging.Log;
import io.quarkus.runtime.ShutdownEvent;
import io.quarkus.runtime.StartupEvent;
import io.quarkus.scheduler.Scheduled;
import io.smallrye.common.annotation.Blocking;
import jakarta.annotation.Priority;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Observes;
@@ -41,7 +43,6 @@ public class DeferredInvalidationQueueService {
Log.warn("Reading invalidation queue from backup");
_persistentData = SerializationHelper.deserialize(Files.readAllBytes(Paths.get(dataRoot).resolve(dataFileName)));
}
remoteHostManager.registerConnectEventListener(this::returnForHost);
}
@@ -63,6 +64,14 @@ public class DeferredInvalidationQueueService {
}
}
// FIXME:
@Scheduled(every = "15s", concurrentExecution = Scheduled.ConcurrentExecution.SKIP)
@Blocking
void periodicReturn() {
for (var reachable : remoteHostManager.getAvailableHosts())
returnForHost(reachable);
}
void returnForHost(UUID host) {
synchronized (this) {
var col = _persistentData.getDeferredInvalidations().get(host);