Search in sources :

Example 1 with Set

use of io.atomix.core.counter.impl.AtomicCounterOperations.Set in project atomix by atomix.

the class AtomicCounterServiceTest method testSnapshot.

@Test
public void testSnapshot() throws Exception {
    AtomicCounterService service = new AtomicCounterService();
    service.set(new DefaultCommit<>(2, SET, new Set(1L), mock(Session.class), System.currentTimeMillis()));
    Buffer buffer = HeapBuffer.allocate();
    service.backup(buffer);
    service = new AtomicCounterService();
    service.restore(buffer.flip());
    long value = service.get(new DefaultCommit<>(2, GET, null, mock(Session.class), System.currentTimeMillis()));
    assertEquals(1, value);
}
Also used : Buffer(io.atomix.storage.buffer.Buffer) HeapBuffer(io.atomix.storage.buffer.HeapBuffer) Set(io.atomix.core.counter.impl.AtomicCounterOperations.Set) AtomicCounterService(io.atomix.core.counter.impl.AtomicCounterService) Test(org.junit.Test)

Aggregations

Set (io.atomix.core.counter.impl.AtomicCounterOperations.Set)1 AtomicCounterService (io.atomix.core.counter.impl.AtomicCounterService)1 Buffer (io.atomix.storage.buffer.Buffer)1 HeapBuffer (io.atomix.storage.buffer.HeapBuffer)1 Test (org.junit.Test)1