public interface IReplicationProtocol
A replication protocol exposes three public functions, which permit reading and writing to the log.
Created by mwei on 4/6/17.
Modifier and Type | Method and Description |
---|---|
ILogData |
peek(RuntimeLayout runtimeLayout,
long globalAddress)
Peek data from a given address.
|
ILogData |
read(RuntimeLayout runtimeLayout,
long globalAddress)
Read data from a given address.
|
Map<Long,ILogData> |
readAll(RuntimeLayout runtimeLayout,
List<Long> addresses,
boolean waitForWrite)
Read data from all the given addresses.
|
void |
write(RuntimeLayout runtimeLayout,
ILogData data)
Write data to the log at the given address.
|
void write(RuntimeLayout runtimeLayout, ILogData data) throws OverwriteException
This function blocks until -a- write at the global address is committed to the log.
If the write which is committed to the log was this write, the function returns normally.
If the write which was committed to the log was not the result of this call, an OverwriteException is thrown.
runtimeLayout
- the RuntimeLayout stamped with layout to use for the write.data
- the ILogData to write to the log.OverwriteException
- If a write was committed to the log and
it was not the result of this call.@Nonnull ILogData read(RuntimeLayout runtimeLayout, long globalAddress)
This function only returns committed data. If the address given has not committed, the implementation may either block until it is committed, or commit a hole filling entry to that address.
runtimeLayout
- the RuntimeLayout stamped with layout to use for the read.globalAddress
- the global address to read the data from.@Nonnull Map<Long,ILogData> readAll(RuntimeLayout runtimeLayout, List<Long> addresses, boolean waitForWrite)
This method functions exactly like a read, except that it returns the result for multiple addresses.
An implementation may optimize for this type of bulk request, but the default implementation just performs multiple reads (possible in parallel).
runtimeLayout
- the RuntimeLayout stamped with layout to use for the read.addresses
- a list of addresses to read from.waitForWrite
- flag whether wait for write is required or hole fill directly.ILogData peek(RuntimeLayout runtimeLayout, long globalAddress)
This function -may- return null if there was no entry committed at the given global address, otherwise it returns committed data at the given global address. It does not attempt to hole fill if there was no entry.
runtimeLayout
- the RuntimeLayout stamped with layout to use for the peek.globalAddress
- the global address to peek from.Copyright © 2019 CorfuDB. All rights reserved.