/** * Fill a hole at a given address. * * @param address The address to fill a hole at. */ public CompletableFuture<Boolean> fillHole(Token address) { Timer.Context context = getTimerContext("fillHole"); CompletableFuture<Boolean> cf = sendMessageWithFuture( CorfuMsgType.FILL_HOLE.payloadMsg(new FillHoleRequest(address))); return cf.thenApply(x -> { context.stop(); return x; }); }
/** * Read data from the log unit server for a list of addresses. * * @param list list of global addresses. * @return CompletableFuture which returns a ReadResponse on completion. */ public CompletableFuture<ReadResponse> read(List<Long> list) { Timer.Context context = getTimerContext("readList"); CompletableFuture<ReadResponse> cf = sendMessageWithFuture( CorfuMsgType.MULTIPLE_READ_REQUEST.payloadMsg(new MultipleReadRequest(list))); return cf.thenApply(x -> { context.stop(); return x; }); }
/** * Read data from the log unit server for a range of addresses. * * @param range Range of global offsets. * @return CompletableFuture which returns a ReadResponse on completion. */ public CompletableFuture<ReadResponse> read(Range<Long> range) { Timer.Context context = getTimerContext("readRange"); CompletableFuture<ReadResponse> cf = sendMessageWithFuture( CorfuMsgType.READ_REQUEST.payloadMsg(new ReadRequest(range))); return cf.thenApply(x -> { context.stop(); return x; }); }
/** * Asynchronously read from the logging unit. * * @param address The address to read from. * @return A CompletableFuture which will complete with a ReadResult once the read * completes. */ public CompletableFuture<ReadResponse> read(long address) { Timer.Context context = getTimerContext("read"); CompletableFuture<ReadResponse> cf = sendMessageWithFuture( CorfuMsgType.READ_REQUEST.payloadMsg(new ReadRequest(address))); return cf.thenApply(x -> { context.stop(); return x; }); }
/** * Asynchronously write an empty payload to the logging unit with ranked address space. * Used from the quorum replication when filling holes or during the first phase of the * recovery write. * * @param address The address to write to. * @param type The data type * @param streams The streams, if any, that this write belongs to. * @param rank The rank of this write] */ public CompletableFuture<Boolean> writeEmptyData(long address, DataType type, Set<UUID> streams, IMetadata.DataRank rank) { Timer.Context context = getTimerContext("writeObject"); LogEntry entry = new LogEntry(LogEntry.LogEntryType.NOP); ByteBuf payload = Unpooled.buffer(); Serializers.CORFU.serialize(entry, payload); WriteRequest wr = new WriteRequest(WriteMode.NORMAL, type, null, payload); wr.setRank(rank); wr.setGlobalAddress(address); checkWriteSize(wr.getData()); CompletableFuture<Boolean> cf = sendMessageWithFuture(CorfuMsgType.WRITE.payloadMsg(wr)); return cf.thenApply(x -> { context.stop(); return x; }); }
/** * Asynchronously write to the logging unit. * * @param address The address to write to. * @param streams The streams, if any, that this write belongs to. * @param rank The rank of this write (used for quorum * replication). * @param writeObject The object, pre-serialization, to write. * @param backpointerMap The map of backpointers to write. * @return A CompletableFuture which will complete with the WriteResult once the * write completes. */ public CompletableFuture<Boolean> write(long address, Set<UUID> streams, IMetadata.DataRank rank, Object writeObject, Map<UUID, Long> backpointerMap) { Timer.Context context = getTimerContext("writeObject"); ByteBuf payload = Unpooled.buffer(); Serializers.CORFU.serialize(writeObject, payload); WriteRequest wr = new WriteRequest(WriteMode.NORMAL, null, payload); wr.setRank(rank); wr.setBackpointerMap(backpointerMap); wr.setGlobalAddress(address); checkWriteSize(wr.getData()); CompletableFuture<Boolean> cf = sendMessageWithFuture(CorfuMsgType.WRITE.payloadMsg(wr)); return cf.thenApply(x -> { context.stop(); return x; }); }