public class LogManagerImpl extends Object implements LogManager
LogManager.LastLogIndexListener, LogManager.NewLogCallback, LogManager.StableClosureDescriber.DefaultPrinter, Describer.Printer| Constructor and Description |
|---|
LogManagerImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
addLastLogIndexListener(LogManager.LastLogIndexListener listener)
Adds a last log index listener
|
void |
appendEntries(List<LogEntry> entries,
LogManager.StableClosure done)
Append log entry vector and wait until it's stable (NOT COMMITTED!)
|
ConfigurationEntry |
checkAndSetConfiguration(ConfigurationEntry current)
Check if |current| should be updated to the latest configuration
Returns the latest configuration, otherwise null.
|
Status |
checkConsistency()
Check log consistency, returns the status
|
void |
clearBufferedLogs()
We don't delete all the logs before last snapshot to avoid installing
snapshot on slow replica.
|
void |
describe(Describer.Printer out) |
ConfigurationEntry |
getConfiguration(long index)
Get the configuration at index.
|
LogEntry |
getEntry(long index)
Get the log entry at index.
|
protected LogEntry |
getEntryFromMemory(long index) |
long |
getFirstLogIndex()
Get the first log index of log
|
LogId |
getLastLogId(boolean isFlush)
Return the id the last log.
|
long |
getLastLogIndex()
Get the last log index of log
|
long |
getLastLogIndex(boolean isFlush)
Get the last log index of log
|
long |
getTerm(long index)
Get the log term at index.
|
boolean |
hasAvailableCapacityToAppendEntries(int requiredCapacity)
Given specified requiredCapacity determines if that amount of space
is available to append these entries.
|
boolean |
init(LogManagerOptions opts)
Initialize the service.
|
void |
join()
Wait the log manager to be shut down.
|
void |
removeLastLogIndexListener(LogManager.LastLogIndexListener listener)
Remove the last log index listener.
|
boolean |
removeWaiter(long id)
Remove a waiter.
|
void |
setAppliedId(LogId appliedId)
Set the applied id, indicating that the log before applied_id (included)
can be dropped from memory logs.
|
void |
setSnapshot(RaftOutter.SnapshotMeta meta)
Notify the log manager about the latest snapshot, which indicates the
logs which can be safely truncated.
|
void |
shutdown()
Dispose the resources for service.
|
long |
wait(long expectedLastLogIndex,
LogManager.NewLogCallback cb,
Object arg)
Wait until there are more logs since |last_log_index| and |on_new_log|
would be called after there are new logs or error occurs, return the waiter id.
|
public void addLastLogIndexListener(LogManager.LastLogIndexListener listener)
LogManageraddLastLogIndexListener in interface LogManagerpublic void removeLastLogIndexListener(LogManager.LastLogIndexListener listener)
LogManagerremoveLastLogIndexListener in interface LogManagerpublic boolean init(LogManagerOptions opts)
Lifecycleinit in interface Lifecycle<LogManagerOptions>public boolean hasAvailableCapacityToAppendEntries(int requiredCapacity)
LogManagerhasAvailableCapacityToAppendEntries in interface LogManagerpublic void join()
throws InterruptedException
LogManagerjoin in interface LogManagerInterruptedException - if the current thread is interrupted
while waitingpublic void shutdown()
Lifecycleshutdown in interface Lifecycle<LogManagerOptions>public void appendEntries(List<LogEntry> entries, LogManager.StableClosure done)
LogManagerappendEntries in interface LogManagerentries - log entriesdone - callbackpublic void setSnapshot(RaftOutter.SnapshotMeta meta)
LogManagersetSnapshot in interface LogManagermeta - snapshot metadatapublic void clearBufferedLogs()
LogManagerclearBufferedLogs in interface LogManagerprotected LogEntry getEntryFromMemory(long index)
public LogEntry getEntry(long index)
LogManagergetEntry in interface LogManagerindex - the index of log entryindexpublic long getTerm(long index)
LogManagergetTerm in interface LogManagerindex - the index of log entrypublic long getFirstLogIndex()
LogManagergetFirstLogIndex in interface LogManagerpublic long getLastLogIndex()
LogManagergetLastLogIndex in interface LogManagerpublic long getLastLogIndex(boolean isFlush)
LogManagergetLastLogIndex in interface LogManagerisFlush - whether to flush from disk.public LogId getLastLogId(boolean isFlush)
LogManagergetLastLogId in interface LogManagerisFlush - whether to flush all pending task.public ConfigurationEntry getConfiguration(long index)
LogManagergetConfiguration in interface LogManagerpublic ConfigurationEntry checkAndSetConfiguration(ConfigurationEntry current)
LogManagercheckAndSetConfiguration in interface LogManagerpublic long wait(long expectedLastLogIndex,
LogManager.NewLogCallback cb,
Object arg)
LogManagerwait in interface LogManagerexpectedLastLogIndex - expected last index of logcb - callbackarg - the waiter pass-in argumentpublic boolean removeWaiter(long id)
LogManagerremoveWaiter in interface LogManagerid - waiter idpublic void setAppliedId(LogId appliedId)
LogManagersetAppliedId in interface LogManagerpublic Status checkConsistency()
LogManagercheckConsistency in interface LogManagerpublic void describe(Describer.Printer out)
Copyright © 2024. All rights reserved.