mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-29 04:57:48 +01:00
Revert "Sync-base: get rid of JDataRemotePush"
This reverts commit 07133a71
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
package com.usatiuk.dhfs.invalidation;
|
package com.usatiuk.dhfs.invalidation;
|
||||||
|
|
||||||
import com.usatiuk.dhfs.peersync.PeerId;
|
import com.usatiuk.dhfs.peersync.PeerId;
|
||||||
|
import com.usatiuk.dhfs.remoteobj.JDataRemoteDto;
|
||||||
import com.usatiuk.objects.JObjectKey;
|
import com.usatiuk.objects.JObjectKey;
|
||||||
import org.pcollections.PMap;
|
import org.pcollections.PMap;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public record IndexUpdateOp(JObjectKey key, PMap<PeerId, Long> changelog) implements Op {
|
public record IndexUpdateOp(JObjectKey key, PMap<PeerId, Long> changelog, JDataRemoteDto data) implements Op {
|
||||||
@Override
|
@Override
|
||||||
public Collection<JObjectKey> getEscapedRefs() {
|
public Collection<JObjectKey> getEscapedRefs() {
|
||||||
return List.of(key);
|
return List.of(key);
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package com.usatiuk.dhfs.invalidation;
|
package com.usatiuk.dhfs.invalidation;
|
||||||
|
|
||||||
import com.usatiuk.dhfs.peersync.PeerId;
|
import com.usatiuk.dhfs.peersync.PeerId;
|
||||||
|
import com.usatiuk.dhfs.remoteobj.JDataRemoteDto;
|
||||||
|
import com.usatiuk.dhfs.remoteobj.JDataRemotePush;
|
||||||
import com.usatiuk.dhfs.remoteobj.RemoteObjectMeta;
|
import com.usatiuk.dhfs.remoteobj.RemoteObjectMeta;
|
||||||
import com.usatiuk.dhfs.remoteobj.RemoteTransaction;
|
import com.usatiuk.dhfs.remoteobj.RemoteTransaction;
|
||||||
|
import com.usatiuk.dhfs.syncmap.DtoMapperService;
|
||||||
import com.usatiuk.objects.transaction.Transaction;
|
import com.usatiuk.objects.transaction.Transaction;
|
||||||
import com.usatiuk.objects.transaction.TransactionManager;
|
import com.usatiuk.objects.transaction.TransactionManager;
|
||||||
|
import io.quarkus.logging.Log;
|
||||||
import jakarta.enterprise.context.ApplicationScoped;
|
import jakarta.enterprise.context.ApplicationScoped;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
@@ -19,11 +23,22 @@ public class RemoteObjectMetaOpExtractor implements OpExtractor<RemoteObjectMeta
|
|||||||
Transaction curTx;
|
Transaction curTx;
|
||||||
@Inject
|
@Inject
|
||||||
RemoteTransaction remoteTransaction;
|
RemoteTransaction remoteTransaction;
|
||||||
|
@Inject
|
||||||
|
DtoMapperService dtoMapperService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Pair<List<Op>, Runnable> extractOps(RemoteObjectMeta data, PeerId peerId) {
|
public Pair<List<Op>, Runnable> extractOps(RemoteObjectMeta data, PeerId peerId) {
|
||||||
return txm.run(() -> {
|
return txm.run(() -> {
|
||||||
return Pair.of(List.of(new IndexUpdateOp(data.key(), data.changelog())), () -> {
|
JDataRemoteDto dto =
|
||||||
|
data.knownType().isAnnotationPresent(JDataRemotePush.class)
|
||||||
|
? remoteTransaction.getData(data.knownType(), data.key())
|
||||||
|
.map(d -> dtoMapperService.toDto(d, d.dtoClass())).orElse(null)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
if (data.knownType().isAnnotationPresent(JDataRemotePush.class) && dto == null) {
|
||||||
|
Log.warnv("Failed to get data for push {0} of type {1}", data.key(), data.knownType());
|
||||||
|
}
|
||||||
|
return Pair.of(List.of(new IndexUpdateOp(data.key(), data.changelog(), dto)), () -> {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ import com.google.protobuf.ByteString;
|
|||||||
import com.usatiuk.dhfs.peertrust.CertificateTools;
|
import com.usatiuk.dhfs.peertrust.CertificateTools;
|
||||||
import com.usatiuk.dhfs.remoteobj.JDataRemote;
|
import com.usatiuk.dhfs.remoteobj.JDataRemote;
|
||||||
import com.usatiuk.dhfs.remoteobj.JDataRemoteDto;
|
import com.usatiuk.dhfs.remoteobj.JDataRemoteDto;
|
||||||
|
import com.usatiuk.dhfs.remoteobj.JDataRemotePush;
|
||||||
import com.usatiuk.objects.JObjectKey;
|
import com.usatiuk.objects.JObjectKey;
|
||||||
|
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
|
|
||||||
|
@JDataRemotePush
|
||||||
public record PeerInfo(JObjectKey key, PeerId id, ByteString cert) implements JDataRemote, JDataRemoteDto {
|
public record PeerInfo(JObjectKey key, PeerId id, ByteString cert) implements JDataRemote, JDataRemoteDto {
|
||||||
public PeerInfo(PeerId id, byte[] cert) {
|
public PeerInfo(PeerId id, byte[] cert) {
|
||||||
this(id.toJObjectKey(), id, ByteString.copyFrom(cert));
|
this(id.toJObjectKey(), id, ByteString.copyFrom(cert));
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.usatiuk.dhfs.remoteobj;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
public @interface JDataRemotePush {
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user