mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-28 20:47:49 +01:00
KleppmannTree: fix failed moves being recorded in op log
This commit is contained in:
@@ -167,8 +167,8 @@ public class KleppmannTree<TimestampT extends Comparable<TimestampT>, PeerIdT ex
|
||||
|
||||
public void move(NodeIdT newParent, MetaT newMeta, NodeIdT child, boolean failCreatingIfExists) {
|
||||
var createdMove = createMove(newParent, newMeta, child);
|
||||
_opRecorder.recordOp(createdMove);
|
||||
applyOp(_peers.getSelfId(), createdMove, failCreatingIfExists);
|
||||
_opRecorder.recordOp(createdMove);
|
||||
}
|
||||
|
||||
public void applyExternalOp(PeerIdT from, OpMove<TimestampT, PeerIdT, MetaT, NodeIdT> op) {
|
||||
|
||||
@@ -96,7 +96,7 @@ public class KleppmanTreeSimpleTest {
|
||||
void undoWithRenameTest(boolean opOrder) {
|
||||
var d1id = testNode1._storageInterface.getNewNodeId();
|
||||
var d2id = testNode2._storageInterface.getNewNodeId();
|
||||
var d3id = testNode2._storageInterface.getNewNodeId();
|
||||
var d3id = testNode3._storageInterface.getNewNodeId();
|
||||
testNode1._tree.move(testNode1._storageInterface.getRootId(), new TestNodeMetaDir("Test1"), d1id);
|
||||
testNode2._tree.move(testNode1._storageInterface.getRootId(), new TestNodeMetaDir("Test1"), d2id);
|
||||
testNode3._tree.move(testNode1._storageInterface.getRootId(), new TestNodeMetaDir("Test1"), d3id);
|
||||
@@ -137,4 +137,14 @@ public class KleppmanTreeSimpleTest {
|
||||
|
||||
Assertions.assertIterableEquals(List.of("Test1", "Test1.conflict." + d1id, "Test1.conflict." + d2id), testNode3._storageInterface.getById(testNode3._storageInterface.getRootId()).children().keySet());
|
||||
}
|
||||
|
||||
@Test
|
||||
void noFailedOpRecordTest() {
|
||||
var d1id = testNode1._storageInterface.getNewNodeId();
|
||||
var d2id = testNode1._storageInterface.getNewNodeId();
|
||||
testNode1._tree.move(testNode1._storageInterface.getRootId(), new TestNodeMetaDir("Test1"), d1id);
|
||||
Assertions.assertThrows(AlreadyExistsException.class, () -> testNode1._tree.move(testNode1._storageInterface.getRootId(), new TestNodeMetaDir("Test1"), d2id));
|
||||
var r1 = testNode1.getRecorded();
|
||||
Assertions.assertEquals(1, r1.size());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user