Search in sources :

Example 1 with Update

use of io.atomix.core.tree.impl.DocumentTreeOperations.Update in project atomix by atomix.

the class DocumentTreeServiceTest method testSnapshot.

private void testSnapshot(Ordering ordering) throws Exception {
    DocumentTreeService service = new DocumentTreeService(ordering);
    service.update(new DefaultCommit<>(2, UPDATE, new Update(DocumentPath.from("root|foo"), Optional.of("Hello world!".getBytes()), Match.any(), Match.ifNull()), mock(Session.class), System.currentTimeMillis()));
    Buffer buffer = HeapBuffer.allocate();
    service.backup(buffer);
    service = new DocumentTreeService(ordering);
    service.restore(buffer.flip());
    Versioned<byte[]> value = service.get(new DefaultCommit<>(2, GET, new Get(DocumentPath.from("root|foo")), mock(Session.class), System.currentTimeMillis()));
    assertNotNull(value);
    assertArrayEquals("Hello world!".getBytes(), value.value());
}
Also used : Buffer(io.atomix.storage.buffer.Buffer) HeapBuffer(io.atomix.storage.buffer.HeapBuffer) DocumentTreeService(io.atomix.core.tree.impl.DocumentTreeService) Get(io.atomix.core.tree.impl.DocumentTreeOperations.Get) Update(io.atomix.core.tree.impl.DocumentTreeOperations.Update)

Aggregations

Get (io.atomix.core.tree.impl.DocumentTreeOperations.Get)1 Update (io.atomix.core.tree.impl.DocumentTreeOperations.Update)1 DocumentTreeService (io.atomix.core.tree.impl.DocumentTreeService)1 Buffer (io.atomix.storage.buffer.Buffer)1 HeapBuffer (io.atomix.storage.buffer.HeapBuffer)1