Package org.apache.bookkeeper.bookie
Class SyncThread
- java.lang.Object
-
- org.apache.bookkeeper.bookie.SyncThread
-
- All Implemented Interfaces:
Checkpointer
class SyncThread extends java.lang.Object implements Checkpointer
SyncThread is a background thread which help checkpointing ledger storage when a checkpoint is requested. After a ledger storage is checkpointed, the journal files added before checkpoint will be garbage collected.After all data has been persisted to ledger index files and entry loggers, it is safe to complete a checkpoint by persisting the log marker to disk. If bookie failed after persist log mark, bookie is able to relay journal entries started from last log mark without losing any entries.
Those journal files whose id are less than the log id in last log mark, could be removed safely after persisting last log mark. We provide a setting to let user keeping number of old journal files which may be used for manual recovery in critical disaster.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) CheckpointSourcecheckpointSource(package private) LedgerDirsManager.LedgerDirsListenerdirsListener(package private) java.util.concurrent.ScheduledExecutorServiceexecutor(package private) LedgerStorageledgerStorage-
Fields inherited from interface org.apache.bookkeeper.bookie.Checkpointer
NULL
-
-
Constructor Summary
Constructors Constructor Description SyncThread(ServerConfiguration conf, LedgerDirsManager.LedgerDirsListener dirsListener, LedgerStorage ledgerStorage, CheckpointSource checkpointSource, StatsLogger statsLogger)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckpoint(CheckpointSource.Checkpoint checkpoint)voiddisableCheckpoint()protected voiddoCheckpoint(CheckpointSource.Checkpoint checkpoint)(package private) java.util.concurrent.ScheduledExecutorServicegetExecutor()(package private) static java.util.concurrent.ScheduledExecutorServicenewExecutor()java.util.concurrent.FuturerequestFlush()voidresumeSync()Resume sync thread.(package private) voidshutdown()voidstart()voidstartCheckpoint(CheckpointSource.Checkpoint checkpoint)Start checkpointing for a given checkpoint location.voidsuspendSync()Suspend sync thread.
-
-
-
Field Detail
-
executor
final java.util.concurrent.ScheduledExecutorService executor
-
ledgerStorage
final LedgerStorage ledgerStorage
-
dirsListener
final LedgerDirsManager.LedgerDirsListener dirsListener
-
checkpointSource
final CheckpointSource checkpointSource
-
-
Constructor Detail
-
SyncThread
public SyncThread(ServerConfiguration conf, LedgerDirsManager.LedgerDirsListener dirsListener, LedgerStorage ledgerStorage, CheckpointSource checkpointSource, StatsLogger statsLogger)
-
-
Method Detail
-
newExecutor
static java.util.concurrent.ScheduledExecutorService newExecutor()
-
startCheckpoint
public void startCheckpoint(CheckpointSource.Checkpoint checkpoint)
Description copied from interface:CheckpointerStart checkpointing for a given checkpoint location.- Specified by:
startCheckpointin interfaceCheckpointer- Parameters:
checkpoint- the checkpoint location to checkpoint.
-
doCheckpoint
protected void doCheckpoint(CheckpointSource.Checkpoint checkpoint)
-
requestFlush
public java.util.concurrent.Future requestFlush()
-
checkpoint
public void checkpoint(CheckpointSource.Checkpoint checkpoint)
-
start
public void start()
- Specified by:
startin interfaceCheckpointer
-
suspendSync
public void suspendSync()
Suspend sync thread. (for testing)
-
resumeSync
public void resumeSync()
Resume sync thread. (for testing)
-
disableCheckpoint
public void disableCheckpoint()
-
shutdown
void shutdown() throws java.lang.InterruptedException- Throws:
java.lang.InterruptedException
-
getExecutor
java.util.concurrent.ScheduledExecutorService getExecutor()
-
-