public class LogManagerImpl extends Object implements LogManager
LogManager.LastLogIndexListener, LogManager.NewLogCallback, LogManager.StableClosureDescriber.DefaultPrinter, Describer.Printer| 构造器和说明 |
|---|
LogManagerImpl() |
| 限定符和类型 | 方法和说明 |
|---|---|
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 |
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 在接口中 LogManagerpublic void removeLastLogIndexListener(LogManager.LastLogIndexListener listener)
LogManagerremoveLastLogIndexListener 在接口中 LogManagerpublic boolean init(LogManagerOptions opts)
Lifecycleinit 在接口中 Lifecycle<LogManagerOptions>public void join()
throws InterruptedException
LogManagerjoin 在接口中 LogManagerInterruptedException - if the current thread is interrupted
while waitingpublic void shutdown()
Lifecycleshutdown 在接口中 Lifecycle<LogManagerOptions>public void appendEntries(List<LogEntry> entries, LogManager.StableClosure done)
LogManagerappendEntries 在接口中 LogManagerentries - log entriesdone - callbackpublic void setSnapshot(RaftOutter.SnapshotMeta meta)
LogManagersetSnapshot 在接口中 LogManagermeta - snapshot metadatapublic void clearBufferedLogs()
LogManagerclearBufferedLogs 在接口中 LogManagerprotected LogEntry getEntryFromMemory(long index)
public LogEntry getEntry(long index)
LogManagergetEntry 在接口中 LogManagerindex - the index of log entryindexpublic long getTerm(long index)
LogManagergetTerm 在接口中 LogManagerindex - the index of log entrypublic long getFirstLogIndex()
LogManagergetFirstLogIndex 在接口中 LogManagerpublic long getLastLogIndex()
LogManagergetLastLogIndex 在接口中 LogManagerpublic long getLastLogIndex(boolean isFlush)
LogManagergetLastLogIndex 在接口中 LogManagerisFlush - whether to flush from disk.public LogId getLastLogId(boolean isFlush)
LogManagergetLastLogId 在接口中 LogManagerisFlush - whether to flush all pending task.public ConfigurationEntry getConfiguration(long index)
LogManagergetConfiguration 在接口中 LogManagerpublic ConfigurationEntry checkAndSetConfiguration(ConfigurationEntry current)
LogManagercheckAndSetConfiguration 在接口中 LogManagerpublic long wait(long expectedLastLogIndex,
LogManager.NewLogCallback cb,
Object arg)
LogManagerwait 在接口中 LogManagerexpectedLastLogIndex - expected last index of logcb - callbackarg - the waiter pass-in argumentpublic boolean removeWaiter(long id)
LogManagerremoveWaiter 在接口中 LogManagerid - waiter idpublic void setAppliedId(LogId appliedId)
LogManagersetAppliedId 在接口中 LogManagerpublic Status checkConsistency()
LogManagercheckConsistency 在接口中 LogManagerpublic void describe(Describer.Printer out)
Copyright © 2021. All rights reserved.