Spring for Apache Hadoop

org.springframework.yarn.support
Class LifecycleObjectSupport

java.lang.Object
  extended by org.springframework.yarn.support.LifecycleObjectSupport
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle
Direct Known Subclasses:
AbstractAllocator, AbstractAppmaster, AbstractLauncher, AbstractMonitor, BootApplicationEventTransformer, IntegrationObjectSupport

public abstract class LifecycleObjectSupport
extends java.lang.Object
implements org.springframework.beans.factory.InitializingBean, org.springframework.context.SmartLifecycle, org.springframework.beans.factory.BeanFactoryAware

Convenient base class for object which needs spring task scheduler, task executor and life cycle handling.

Author:
Janne Valkealahti

Constructor Summary
LifecycleObjectSupport()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  void doStart()
          Subclasses may implement this method with the start behavior.
protected  void doStop()
          Subclasses may implement this method with the stop behavior.
protected  org.springframework.beans.factory.BeanFactory getBeanFactory()
          Gets the BeanFactory for this instance.
 int getPhase()
           
protected  org.springframework.core.task.TaskExecutor getTaskExecutor()
          Gets the defined TaskExecutor.
protected  org.springframework.scheduling.TaskScheduler getTaskScheduler()
          Gets the defined TaskScheduler.
 YarnEventPublisher getYarnEventPublisher()
          Gets the yarn event publisher.
 boolean isAutoStartup()
           
 boolean isRunning()
           
protected  void onInit()
          Subclasses may implement this for initialization logic.
 void setAutoStartup(boolean autoStartup)
          Sets the auto startup.
 void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
           
 void setPhase(int phase)
          Sets the phase.
 void setTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor)
          Sets the used TaskExecutor.
 void setTaskScheduler(org.springframework.scheduling.TaskScheduler taskScheduler)
          Sets the used TaskScheduler.
 void setYarnEventPublisher(YarnEventPublisher yarnEventPublisher)
          Sets the yarn event publisher.
 void start()
           
 void stop()
           
 void stop(java.lang.Runnable callback)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LifecycleObjectSupport

public LifecycleObjectSupport()
Method Detail

afterPropertiesSet

public final void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean

setBeanFactory

public final void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
                          throws org.springframework.beans.BeansException
Specified by:
setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
Throws:
org.springframework.beans.BeansException

isAutoStartup

public final boolean isAutoStartup()
Specified by:
isAutoStartup in interface org.springframework.context.SmartLifecycle

getPhase

public final int getPhase()
Specified by:
getPhase in interface org.springframework.context.Phased

isRunning

public final boolean isRunning()
Specified by:
isRunning in interface org.springframework.context.Lifecycle

start

public final void start()
Specified by:
start in interface org.springframework.context.Lifecycle

stop

public final void stop()
Specified by:
stop in interface org.springframework.context.Lifecycle

stop

public final void stop(java.lang.Runnable callback)
Specified by:
stop in interface org.springframework.context.SmartLifecycle

setAutoStartup

public void setAutoStartup(boolean autoStartup)
Sets the auto startup.

Parameters:
autoStartup - the new auto startup
See Also:
SmartLifecycle

setPhase

public void setPhase(int phase)
Sets the phase.

Parameters:
phase - the new phase
See Also:
SmartLifecycle

getBeanFactory

protected final org.springframework.beans.factory.BeanFactory getBeanFactory()
Gets the BeanFactory for this instance.

Returns:
the bean factory.

setTaskScheduler

public void setTaskScheduler(org.springframework.scheduling.TaskScheduler taskScheduler)
Sets the used TaskScheduler.

Parameters:
taskScheduler - the task scheduler

getTaskScheduler

protected org.springframework.scheduling.TaskScheduler getTaskScheduler()
Gets the defined TaskScheduler.

Returns:
the defined task scheduler

setTaskExecutor

public void setTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor)
Sets the used TaskExecutor.

Parameters:
taskExecutor - the task executor

getYarnEventPublisher

public YarnEventPublisher getYarnEventPublisher()
Gets the yarn event publisher.

Returns:
the yarn event publisher

setYarnEventPublisher

public void setYarnEventPublisher(YarnEventPublisher yarnEventPublisher)
Sets the yarn event publisher.

Parameters:
yarnEventPublisher - the new yarn event publisher

getTaskExecutor

protected org.springframework.core.task.TaskExecutor getTaskExecutor()
Gets the defined TaskExecutor.

Returns:
the defined task executor

onInit

protected void onInit()
               throws java.lang.Exception
Subclasses may implement this for initialization logic. Called during the InitializingBean phase. Implementor should always call super method not to break initialization chain.

Throws:
java.lang.Exception

doStart

protected void doStart()
Subclasses may implement this method with the start behavior. This method will be invoked while holding the lifecycleLock.


doStop

protected void doStop()
Subclasses may implement this method with the stop behavior. This method will be invoked while holding the lifecycleLock.


Spring for Apache Hadoop