Search in sources :

Example 1 with HeapBuffer

use of io.atomix.storage.buffer.HeapBuffer in project atomix by atomix.

the class SnapshotStore method createMemorySnapshot.

/**
 * Creates a memory snapshot.
 */
private Snapshot createMemorySnapshot(SnapshotDescriptor descriptor) {
    HeapBuffer buffer = HeapBuffer.allocate(SnapshotDescriptor.BYTES, Integer.MAX_VALUE);
    Snapshot snapshot = new MemorySnapshot(buffer, descriptor.copyTo(buffer), this);
    log.debug("Created memory snapshot: {}", snapshot);
    return snapshot;
}
Also used : HeapBuffer(io.atomix.storage.buffer.HeapBuffer)

Example 2 with HeapBuffer

use of io.atomix.storage.buffer.HeapBuffer in project atomix by atomix.

the class PrimaryRole method restore.

@Override
public CompletableFuture<RestoreResponse> restore(RestoreRequest request) {
    logRequest(request);
    if (request.term() != context.currentTerm()) {
        return CompletableFuture.completedFuture(logResponse(RestoreResponse.error()));
    }
    HeapBuffer buffer = HeapBuffer.allocate();
    context.service().backup(buffer);
    buffer.flip();
    byte[] bytes = buffer.readBytes(buffer.remaining());
    return CompletableFuture.completedFuture(RestoreResponse.ok(context.currentIndex(), context.currentTimestamp(), bytes)).thenApply(this::logResponse);
}
Also used : HeapBuffer(io.atomix.storage.buffer.HeapBuffer)

Aggregations

HeapBuffer (io.atomix.storage.buffer.HeapBuffer)2