mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-29 04:57:48 +01:00
a little cleanup
This commit is contained in:
@@ -111,7 +111,7 @@ public class PersistentRemoteHostsService {
|
||||
}
|
||||
|
||||
private JObject<PersistentPeerInfo> getPeer(UUID uuid) {
|
||||
var got = jObjectManager.get(uuid.toString()).orElseThrow(() -> new IllegalStateException("Peer " + uuid + " not found"));
|
||||
var got = jObjectManager.get(PersistentPeerInfo.getNameFromUuid(uuid)).orElseThrow(() -> new IllegalStateException("Peer " + uuid + " not found"));
|
||||
got.runReadLocked(JObject.ResolutionStrategy.LOCAL_ONLY, (m, d) -> {
|
||||
if (d == null) throw new IllegalStateException("Could not resolve peer " + uuid);
|
||||
if (!(d instanceof PersistentPeerInfo))
|
||||
|
||||
@@ -37,7 +37,7 @@ public class PeerDirectory extends JObjectData {
|
||||
|
||||
@Override
|
||||
public Collection<String> extractRefs() {
|
||||
return _peers.stream().map(UUID::toString).toList();
|
||||
return _peers.stream().map(PersistentPeerInfo::getNameFromUuid).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -58,8 +58,8 @@ public class PeerDirectoryConflictResolver implements ConflictResolver {
|
||||
newChangelog.merge(persistentRemoteHostsService.getSelfUuid(), 1L, Long::sum);
|
||||
|
||||
for (var child : mergedChildren) {
|
||||
if (!(new HashSet<>(oursPD.getPeers()).contains(child))) {
|
||||
jObjectManager.getOrPut(child.toString(), PersistentPeerInfo.class, Optional.of(oursPD.getName()));
|
||||
if (!oursPD.getPeers().contains(child)) {
|
||||
jObjectManager.getOrPut(PersistentPeerInfo.getNameFromUuid(child), PersistentPeerInfo.class, Optional.of(oursPD.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package com.usatiuk.dhfs.storage.objects.repository.distributed.peersync;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.usatiuk.dhfs.objects.repository.distributed.peersync.PeerInfo;
|
||||
import com.usatiuk.dhfs.storage.files.conflicts.NotImplementedConflictResolver;
|
||||
import com.usatiuk.dhfs.storage.objects.jrepository.JObjectData;
|
||||
import com.usatiuk.dhfs.storage.objects.repository.distributed.ConflictResolver;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.security.cert.CertificateEncodingException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -20,18 +17,13 @@ public class PersistentPeerInfo extends JObjectData {
|
||||
private final UUID _uuid;
|
||||
private final X509Certificate _certificate;
|
||||
|
||||
public PeerInfo toPeerInfo() {
|
||||
try {
|
||||
return PeerInfo.newBuilder().setUuid(_uuid.toString())
|
||||
.setCert(ByteString.copyFrom(_certificate.getEncoded())).build();
|
||||
} catch (CertificateEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
public static String getNameFromUuid(UUID uuid) {
|
||||
return "peer_" + uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return _uuid.toString();
|
||||
return getNameFromUuid(_uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user