public interface LifecycleBean
LifecycleEventType
.
Use this bean whenever you need to plug some custom logic before or after
node startup and stopping routines.
There are four events you can react to:
LifecycleEventType.BEFORE_NODE_START
invoked before node startup
routine is initiated. Note that node is not available during this event,
therefore if you injected a ignite instance via IgniteInstanceResource
annotation, you cannot use it yet.
LifecycleEventType.AFTER_NODE_START
invoked right after node
has started. At this point, if you injected a node instance via
IgniteInstanceResource
annotation, you can start using it. Note that
you should not be using Ignition
to get node instance from
lifecycle bean.
LifecycleEventType.BEFORE_NODE_STOP
invoked right before node
stop routine is initiated. Node is still available at this stage, so
if you injected a ignite instance via IgniteInstanceResource
annotation,
you can use it.
LifecycleEventType.AFTER_NODE_STOP
invoked right after node
has stopped. Note that node is not available during this event.
IGNITE_HOME/libs
folder, and
simply start IGNITE_HOME/ignite.{sh|bat}
scripts.
IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setLifecycleBeans(new FooBarLifecycleBean1(), new FooBarLifecycleBean2()); // Start grid with given configuration. Ignition.start(cfg);or from Spring XML configuration file as follows:
<bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"> ... <property name="lifecycleBeans"> <list> <bean class="foo.bar.FooBarLifecycleBean1"/> <bean class="foo.bar.FooBarLifecycleBean2"/> </list> </property> ... </bean>
Modifier and Type | Method and Description |
---|---|
void |
onLifecycleEvent(LifecycleEventType evt)
This method is called when lifecycle event occurs.
|
void onLifecycleEvent(LifecycleEventType evt) throws IgniteException
evt
- Lifecycle event.IgniteException
- Thrown in case of any errors.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.7.2 Release Date : February 6 2019