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;
}
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);
}
Aggregations