Package org.apache.bookkeeper.bookie
Class BookieStateManager
- java.lang.Object
-
- org.apache.bookkeeper.bookie.BookieStateManager
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,StateManager
@StatsDoc(name="bookie", category="server", help="Bookie state manager related stats") public class BookieStateManager extends java.lang.Object implements StateManager
An implementation of StateManager.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.bookkeeper.bookie.StateManager
StateManager.ShutdownHandler
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.concurrent.ScheduledExecutorService
stateService
-
Constructor Summary
Constructors Constructor Description BookieStateManager(ServerConfiguration conf, RegistrationManager registrationManager)
BookieStateManager(ServerConfiguration conf, StatsLogger statsLogger, RegistrationManager rm, java.util.List<java.io.File> statusDirs, java.util.function.Supplier<BookieId> bookieIdSupplier, java.util.function.Supplier<BookieServiceInfo> bookieServiceInfoProvider)
BookieStateManager(ServerConfiguration conf, StatsLogger statsLogger, RegistrationManager rm, LedgerDirsManager ledgerDirsManager, java.util.function.Supplier<BookieServiceInfo> bookieServiceInfoProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the manager, release its resources.(package private) void
doRegisterBookie()
void
doTransitionToReadOnlyMode()
void
doTransitionToWritableMode()
void
forceToReadOnly()
Turn state to the read only, just flag.void
forceToShuttingDown()
Turn state to the shutting down progress,just the flag.void
forceToUnregistered()
Turn state to not registered, just the flag.StateManager.ShutdownHandler
getShutdownHandler()
void
initState()
Init state of Bookie when launch bookie.boolean
isAvailableForHighPriorityWrites()
Check if the bookie is available for high priority writes or not.boolean
isForceReadOnly()
Check is forceReadOnly.boolean
isReadOnly()
Check is ReadOnly.boolean
isReadOnlyModeEnabled()
Check is readOnlyModeEnabled.(package private) boolean
isRegistered()
boolean
isRunning()
Check is Running.boolean
isShuttingDown()
Check is Shutting down.java.util.concurrent.Future<java.lang.Void>
registerBookie(boolean throwException)
Register the bookie to RegistrationManager.void
setHighPriorityWritesAvailability(boolean available)
Enable/Disable the availability for high priority writes.void
setShutdownHandler(StateManager.ShutdownHandler handler)
java.util.concurrent.Future<java.lang.Void>
transitionToReadOnlyMode()
Change the state of bookie to ReadOnly mode.java.util.concurrent.Future<java.lang.Void>
transitionToWritableMode()
Change the state of bookie to Writable mode.
-
-
-
Constructor Detail
-
BookieStateManager
public BookieStateManager(ServerConfiguration conf, StatsLogger statsLogger, RegistrationManager rm, LedgerDirsManager ledgerDirsManager, java.util.function.Supplier<BookieServiceInfo> bookieServiceInfoProvider) throws java.io.IOException
- Throws:
java.io.IOException
-
BookieStateManager
public BookieStateManager(ServerConfiguration conf, StatsLogger statsLogger, RegistrationManager rm, java.util.List<java.io.File> statusDirs, java.util.function.Supplier<BookieId> bookieIdSupplier, java.util.function.Supplier<BookieServiceInfo> bookieServiceInfoProvider) throws java.io.IOException
- Throws:
java.io.IOException
-
BookieStateManager
BookieStateManager(ServerConfiguration conf, RegistrationManager registrationManager) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
initState
public void initState()
Description copied from interface:StateManager
Init state of Bookie when launch bookie.- Specified by:
initState
in interfaceStateManager
-
forceToShuttingDown
public void forceToShuttingDown()
Description copied from interface:StateManager
Turn state to the shutting down progress,just the flag.- Specified by:
forceToShuttingDown
in interfaceStateManager
-
forceToReadOnly
public void forceToReadOnly()
Description copied from interface:StateManager
Turn state to the read only, just flag.- Specified by:
forceToReadOnly
in interfaceStateManager
-
forceToUnregistered
public void forceToUnregistered()
Description copied from interface:StateManager
Turn state to not registered, just the flag.- Specified by:
forceToUnregistered
in interfaceStateManager
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:StateManager
Check is ReadOnly.- Specified by:
isReadOnly
in interfaceStateManager
-
isForceReadOnly
public boolean isForceReadOnly()
Description copied from interface:StateManager
Check is forceReadOnly.- Specified by:
isForceReadOnly
in interfaceStateManager
-
isReadOnlyModeEnabled
public boolean isReadOnlyModeEnabled()
Description copied from interface:StateManager
Check is readOnlyModeEnabled.- Specified by:
isReadOnlyModeEnabled
in interfaceStateManager
-
isAvailableForHighPriorityWrites
public boolean isAvailableForHighPriorityWrites()
Description copied from interface:StateManager
Check if the bookie is available for high priority writes or not.- Specified by:
isAvailableForHighPriorityWrites
in interfaceStateManager
- Returns:
- true if the bookie is available for high priority writes; otherwise false.
-
setHighPriorityWritesAvailability
public void setHighPriorityWritesAvailability(boolean available)
Description copied from interface:StateManager
Enable/Disable the availability for high priority writes.- Specified by:
setHighPriorityWritesAvailability
in interfaceStateManager
- Parameters:
available
- the flag to enable/disable the availability for high priority writes.
-
isRunning
public boolean isRunning()
Description copied from interface:StateManager
Check is Running.- Specified by:
isRunning
in interfaceStateManager
-
isShuttingDown
public boolean isShuttingDown()
Description copied from interface:StateManager
Check is Shutting down.- Specified by:
isShuttingDown
in interfaceStateManager
-
close
public void close()
Description copied from interface:StateManager
Close the manager, release its resources.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceStateManager
-
registerBookie
public java.util.concurrent.Future<java.lang.Void> registerBookie(boolean throwException)
Description copied from interface:StateManager
Register the bookie to RegistrationManager.- Specified by:
registerBookie
in interfaceStateManager
-
transitionToWritableMode
public java.util.concurrent.Future<java.lang.Void> transitionToWritableMode()
Description copied from interface:StateManager
Change the state of bookie to Writable mode.- Specified by:
transitionToWritableMode
in interfaceStateManager
-
transitionToReadOnlyMode
public java.util.concurrent.Future<java.lang.Void> transitionToReadOnlyMode()
Description copied from interface:StateManager
Change the state of bookie to ReadOnly mode.- Specified by:
transitionToReadOnlyMode
in interfaceStateManager
-
doRegisterBookie
void doRegisterBookie() throws java.io.IOException
- Throws:
java.io.IOException
-
doTransitionToWritableMode
public void doTransitionToWritableMode()
-
doTransitionToReadOnlyMode
public void doTransitionToReadOnlyMode()
-
setShutdownHandler
public void setShutdownHandler(StateManager.ShutdownHandler handler)
- Specified by:
setShutdownHandler
in interfaceStateManager
-
getShutdownHandler
public StateManager.ShutdownHandler getShutdownHandler()
-
isRegistered
boolean isRegistered()
-
-