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_STARTinvoked before node startup routine is initiated. Note that node is not available during this event, therefore if you injected a ignite instance via
IgniteInstanceResourceannotation, you cannot use it yet.
LifecycleEventType.AFTER_NODE_STARTinvoked right after node has started. At this point, if you injected a node instance via
IgniteInstanceResourceannotation, you can start using it. Note that you should not be using
Ignitionto get node instance from lifecycle bean.
LifecycleEventType.BEFORE_NODE_STOPinvoked right before node stop routine is initiated. Node is still available at this stage, so if you injected a ignite instance via
IgniteInstanceResourceannotation, you can use it.
LifecycleEventType.AFTER_NODE_STOPinvoked right after node has stopped. Note that node is not available during this event.
IGNITE_HOME/libsfolder, and simply start
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>