mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-29 04:57:48 +01:00
Server: mutator interface fixes
This commit is contained in:
@@ -395,7 +395,8 @@ public class DhfsFileServiceImpl implements DhfsFileService {
|
||||
}
|
||||
|
||||
|
||||
file.rwLockNoCopy();
|
||||
// FIXME:
|
||||
file.rwLock();
|
||||
try {
|
||||
file.tryResolve(JObjectManager.ResolutionStrategy.REMOTE);
|
||||
// FIXME:
|
||||
|
||||
@@ -373,15 +373,20 @@ public class JKleppmannTreeManager {
|
||||
_persistentData.get().assertRwLock();
|
||||
_persistentData.get().tryResolve(JObjectManager.ResolutionStrategy.LOCAL_ONLY);
|
||||
_persistentData.get().mutate(new JMutator<>() {
|
||||
Long old;
|
||||
|
||||
@Override
|
||||
public boolean mutate(JKleppmannTreePersistentData object) {
|
||||
var old = object.getPeerTimestampLog().put(peerId, timestamp);
|
||||
return Objects.equals(old, timestamp);
|
||||
old = object.getPeerTimestampLog().put(peerId, timestamp);
|
||||
return !Objects.equals(old, timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void revert(JKleppmannTreePersistentData object) {
|
||||
object.getPeerTimestampLog().remove(peerId, timestamp);
|
||||
if (old != null)
|
||||
object.getPeerTimestampLog().put(peerId, old);
|
||||
else
|
||||
object.getPeerTimestampLog().remove(peerId, timestamp);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -112,14 +112,14 @@ public class JObjectTxManager {
|
||||
var rev = dataProtoSerializer.serialize(obj.getKey().getData());
|
||||
|
||||
if (obj.getValue().snapshot.data() != null && !Objects.equals(rev, obj.getValue().snapshot.data()))
|
||||
throw new IllegalStateException("Mutator could not be reverted for object " + obj.getKey().getMeta().getName());
|
||||
throw new IllegalStateException("Mutator could not be reverted for object " + obj.getKey().getMeta().getName() + "\n old = " + obj.getValue().snapshot.data() + "\n reverted = " + rev + "\n");
|
||||
|
||||
for (var mut : obj.getValue()._mutators)
|
||||
applyMutator(obj.getKey(), mut);
|
||||
|
||||
var cur2 = dataProtoSerializer.serialize(obj.getKey().getData());
|
||||
if (!Objects.equals(cur, cur2))
|
||||
throw new IllegalStateException("Mutator could not be reapplied for object " + obj.getKey().getMeta().getName());
|
||||
throw new IllegalStateException("Mutator could not be reapplied for object " + obj.getKey().getMeta().getName() + "\n old = " + cur + "\n reapplied = " + cur2 + "\n");
|
||||
}
|
||||
|
||||
notifyWrite(obj.getKey(),
|
||||
@@ -370,8 +370,7 @@ public class JObjectTxManager {
|
||||
(obj.getData() == null) ? null : dataProtoSerializer.serialize(obj.getData()),
|
||||
obj.getMeta().changelogHash())
|
||||
: new JObjectSnapshot(
|
||||
metaProtoSerializer.serialize(obj.getMeta()), refVerification ? null :
|
||||
(obj.getData() == null) ? null : dataProtoSerializer.serialize(obj.getData()),
|
||||
metaProtoSerializer.serialize(obj.getMeta()), (!refVerification || (obj.getData() == null)) ? null : dataProtoSerializer.serialize(obj.getData()),
|
||||
obj.getMeta().changelogHash());
|
||||
|
||||
state._writeObjects.put(obj, new TxState.TxObjectState(snapshot, copy));
|
||||
|
||||
Reference in New Issue
Block a user