Class AbstractLifecycleComponent<ConfT extends ComponentConfiguration>
- java.lang.Object
-
- org.apache.bookkeeper.common.component.AbstractComponent<ConfT>
-
- org.apache.bookkeeper.common.component.AbstractLifecycleComponent<ConfT>
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,LifecycleComponent
- Direct Known Subclasses:
DataIntegrityService
,RxSchedulerLifecycleComponent
,ServerLifecycleComponent
public abstract class AbstractLifecycleComponent<ConfT extends ComponentConfiguration> extends AbstractComponent<ConfT> implements LifecycleComponent
A mix ofAbstractComponent
andLifecycleComponent
.
-
-
Field Summary
Fields Modifier and Type Field Description protected Lifecycle
lifecycle
protected StatsLogger
statsLogger
protected java.lang.Thread.UncaughtExceptionHandler
uncaughtExceptionHandler
-
Fields inherited from class org.apache.bookkeeper.common.component.AbstractComponent
componentName, conf
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractLifecycleComponent(java.lang.String componentName, ConfT conf, StatsLogger statsLogger)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addLifecycleListener(LifecycleListener listener)
void
close()
protected abstract void
doClose()
protected abstract void
doStart()
protected abstract void
doStop()
protected StatsLogger
getStatsLogger()
Lifecycle.State
lifecycleState()
void
removeLifecycleListener(LifecycleListener listener)
void
setExceptionHandler(java.lang.Thread.UncaughtExceptionHandler handler)
Set the default handler invoked when a lifecycle component abruptly terminates due an uncaught exception.void
start()
void
stop()
-
Methods inherited from class org.apache.bookkeeper.common.component.AbstractComponent
getConf, getName
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.bookkeeper.common.component.LifecycleComponent
getName, publishInfo
-
-
-
-
Field Detail
-
lifecycle
protected final Lifecycle lifecycle
-
statsLogger
protected final StatsLogger statsLogger
-
uncaughtExceptionHandler
protected volatile java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler
-
-
Constructor Detail
-
AbstractLifecycleComponent
protected AbstractLifecycleComponent(java.lang.String componentName, ConfT conf, StatsLogger statsLogger)
-
-
Method Detail
-
setExceptionHandler
public void setExceptionHandler(java.lang.Thread.UncaughtExceptionHandler handler)
Description copied from interface:LifecycleComponent
Set the default handler invoked when a lifecycle component abruptly terminates due an uncaught exception.- Specified by:
setExceptionHandler
in interfaceLifecycleComponent
- Parameters:
handler
- handler invoked when an uncaught exception happens in the lifecycle component.
-
getStatsLogger
protected StatsLogger getStatsLogger()
-
lifecycleState
public Lifecycle.State lifecycleState()
- Specified by:
lifecycleState
in interfaceLifecycleComponent
-
addLifecycleListener
public void addLifecycleListener(LifecycleListener listener)
- Specified by:
addLifecycleListener
in interfaceLifecycleComponent
-
removeLifecycleListener
public void removeLifecycleListener(LifecycleListener listener)
- Specified by:
removeLifecycleListener
in interfaceLifecycleComponent
-
start
public void start()
- Specified by:
start
in interfaceLifecycleComponent
-
doStart
protected abstract void doStart()
-
stop
public void stop()
- Specified by:
stop
in interfaceLifecycleComponent
-
doStop
protected abstract void doStop()
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceLifecycleComponent
-
doClose
protected abstract void doClose() throws java.io.IOException
- Throws:
java.io.IOException
-
-