public interface LifecycleBean
LifecycleEventType
.
Use this bean whenever you need to plug some custom logic before or after
grid startup and stopping routines.
There are four events you can react to:
LifecycleEventType.BEFORE_GRID_START
invoked before grid startup
routine is initiated. Note that grid is not available during this event,
therefore if you injected a ignite instance via IgniteInstanceResource
annotation, you cannot use it yet.
LifecycleEventType.AFTER_GRID_START
invoked right after grid
has started. At this point, if you injected a grid instance via
IgniteInstanceResource
annotation, you can start using it. Note that
you should not be using Ignition
to get grid instance from
lifecycle bean.
LifecycleEventType.BEFORE_GRID_STOP
invoked right before grid
stop routine is initiated. Grid is still available at this stage, so
if you injected a ignite instance via IgniteInstanceResource
annotation,
you can use it.
LifecycleEventType.AFTER_GRID_STOP
invoked right after grid
has stopped. Note that grid is not available during this event.
IGNITE_HOME/libs
folder, and
simply start IGNITE_HOME/ignite.{sh|bat}
scripts.
Collection<GridLifecycleBean> lifecycleBeans = new ArrayList<GridLifecycleBean>(); Collections.addAll(lifecycleBeans, new FooBarLifecycleBean1(), new FooBarLifecycleBean2()); GridConfiguration cfg = new GridConfiguration(); cfg.setLifecycleBeans(lifecycleBeans); // Start grid with given configuration. G.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
Apache Ignite Fabric : ver. 1.0.0-RC1 Release Date : February 16 2015