mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-29 04:57:48 +01:00
a little cleanup with handleConnectionSuccess
let's not spam it right now
This commit is contained in:
@@ -44,16 +44,21 @@ public class RemoteHostManager {
|
||||
@Blocking
|
||||
public void tryConnectAll() {
|
||||
for (var host : persistentRemoteHostsService.getHosts()) {
|
||||
var shouldTry = _transientPeersState.runReadLocked(d -> {
|
||||
var s = d.getStates().get(host.getUuid());
|
||||
if (s == null) return true;
|
||||
return !s.getState().equals(TransientPeerState.ConnectionState.REACHABLE);
|
||||
});
|
||||
if (shouldTry) {
|
||||
Log.info("Trying to connect to " + host.getUuid());
|
||||
if (pingCheck(host.getUuid())) {
|
||||
handleConnectionSuccess(host.getUuid());
|
||||
try {
|
||||
var shouldTry = _transientPeersState.runReadLocked(d -> {
|
||||
var s = d.getStates().get(host.getUuid());
|
||||
if (s == null) return true;
|
||||
return !s.getState().equals(TransientPeerState.ConnectionState.REACHABLE) && s.getAddr() != null;
|
||||
});
|
||||
if (shouldTry) {
|
||||
Log.info("Trying to connect to " + host.getUuid());
|
||||
if (pingCheck(host.getUuid())) {
|
||||
handleConnectionSuccess(host.getUuid());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.error("Failed to connect to " + host.getUuid(), e);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,6 @@ import io.smallrye.mutiny.Uni;
|
||||
import jakarta.inject.Inject;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
// Note: RunOnVirtualThread hangs somehow
|
||||
@GrpcService
|
||||
public class RemoteObjectServiceServer implements DhfsObjectSyncGrpc {
|
||||
@@ -35,8 +33,6 @@ public class RemoteObjectServiceServer implements DhfsObjectSyncGrpc {
|
||||
public Uni<GetObjectReply> getObject(GetObjectRequest request) {
|
||||
if (request.getSelfUuid().isBlank()) throw new StatusRuntimeException(Status.INVALID_ARGUMENT);
|
||||
|
||||
remoteHostManager.handleConnectionSuccess(UUID.fromString(request.getSelfUuid()));
|
||||
|
||||
Log.info("<-- getObject: " + request.getName() + " from " + request.getSelfUuid());
|
||||
|
||||
var obj = jObjectManager.get(request.getName()).orElseThrow(() -> new StatusRuntimeException(Status.NOT_FOUND));
|
||||
@@ -58,7 +54,6 @@ public class RemoteObjectServiceServer implements DhfsObjectSyncGrpc {
|
||||
@Blocking
|
||||
public Uni<IndexUpdatePush> getIndex(GetIndexRequest request) {
|
||||
if (request.getSelfUuid().isBlank()) throw new StatusRuntimeException(Status.INVALID_ARGUMENT);
|
||||
remoteHostManager.handleConnectionSuccess(UUID.fromString(request.getSelfUuid()));
|
||||
|
||||
Log.info("<-- getIndex: from " + request.getSelfUuid());
|
||||
var builder = IndexUpdatePush.newBuilder().setSelfUuid(persistentRemoteHostsService.getSelfUuid().toString());
|
||||
@@ -78,7 +73,6 @@ public class RemoteObjectServiceServer implements DhfsObjectSyncGrpc {
|
||||
@Blocking
|
||||
public Uni<IndexUpdateReply> indexUpdate(IndexUpdatePush request) {
|
||||
if (request.getSelfUuid().isBlank()) throw new StatusRuntimeException(Status.INVALID_ARGUMENT);
|
||||
remoteHostManager.handleConnectionSuccess(UUID.fromString(request.getSelfUuid()));
|
||||
|
||||
// Log.info("<-- indexUpdate: " + request.getHeader().getName());
|
||||
return Uni.createFrom().item(syncHandler.handleRemoteUpdate(request));
|
||||
@@ -88,7 +82,6 @@ public class RemoteObjectServiceServer implements DhfsObjectSyncGrpc {
|
||||
@Blocking
|
||||
public Uni<PingReply> ping(PingRequest request) {
|
||||
if (request.getSelfUuid().isBlank()) throw new StatusRuntimeException(Status.INVALID_ARGUMENT);
|
||||
remoteHostManager.handleConnectionSuccess(UUID.fromString(request.getSelfUuid()));
|
||||
|
||||
return Uni.createFrom().item(PingReply.newBuilder().setSelfUuid(persistentRemoteHostsService.getSelfUuid().toString()).build());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user