Constructor and Description |
---|
Reader(Log log)
Returns an instance of a reader that will access the given instance of
the Log.
|
Modifier and Type | Method and Description |
---|---|
Log.Position |
beginning()
Returns the beginning position of the log (might be out of date
with respect to another replica).
|
Log.Position |
catchup(long timeout,
java.util.concurrent.TimeUnit unit)
Attempts to catch-up positions from the log for reading.
|
Log.Position |
ending()
Returns the ending position of the log (might be out of date
with respect to another replica).
|
protected void |
finalize() |
protected void |
initialize(Log log) |
java.util.List<Log.Entry> |
read(Log.Position from,
Log.Position to,
long timeout,
java.util.concurrent.TimeUnit unit)
Attempts to read from the log between the specified positions
(inclusive).
|
public Reader(Log log)
log
- The log that this reader will access.public java.util.List<Log.Entry> read(Log.Position from, Log.Position to, long timeout, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.TimeoutException, Log.OperationFailedException
Log.OperationFailedException
will get thrown. Unfortunately, this
will also get thrown in other circumstances (e.g., disk
failure) and therefore it is currently impossible to tell these
two cases apart.from
- Where to start reading.to
- Where to finish reading.timeout
- Max number of time units to wait before a
TimeoutException
.unit
- Type of units used for the timeout, e.g. seconds,
minutes, etc.java.util.concurrent.TimeoutException
- If the read doesn't happen before the
timeout.Log.OperationFailedException
- If the read fails due that the read no
longer has the ability to perform its
operations.Log.Position
,
TimeUnit
public Log.Position beginning()
public Log.Position ending()
public Log.Position catchup(long timeout, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.TimeoutException, Log.OperationFailedException
timeout
- Max number of time units to wait before a
TimeoutException
.unit
- Type of time units used for the timeout, e.g. seconds,
minutes, etc.java.util.concurrent.TimeoutException
- If the catch-up doesn't happen before
the timeout.Log.OperationFailedException
- If the catch-up fails.protected void initialize(Log log)
protected void finalize()
finalize
in class java.lang.Object