Spring for Apache Hadoop

org.springframework.yarn.am.allocate
Class AbstractPollingAllocator

java.lang.Object
  extended by org.springframework.yarn.support.LifecycleObjectSupport
      extended by org.springframework.yarn.am.allocate.AbstractAllocator
          extended by org.springframework.yarn.am.allocate.AbstractPollingAllocator
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:
DefaultContainerAllocator

public abstract class AbstractPollingAllocator
extends AbstractAllocator

Base implementation of allocator which is meant to handle allocation by doing a simple periodic polling against resource manager.

Author:
Janne Valkealahti

Constructor Summary
AbstractPollingAllocator()
           
 
Method Summary
protected abstract  org.apache.hadoop.yarn.api.records.AMResponse doContainerRequest()
          Subclasses needs to implements this method to do container requests against resource manager.
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 abstract  void handleAllocatedContainers(java.util.List<org.apache.hadoop.yarn.api.records.Container> containers)
          Subclasses needs to implement this method to handle newly allocated containers.
protected abstract  void handleCompletedContainers(java.util.List<org.apache.hadoop.yarn.api.records.ContainerStatus> containerStatuses)
          Subclasses needs to implement this method to handle newly released containers.
protected  void onInit()
          Subclasses may implement this for initialization logic.
protected  java.util.List<org.apache.hadoop.yarn.api.records.Container> preProcessAllocatedContainers(java.util.List<org.apache.hadoop.yarn.api.records.Container> containers)
          Pre process allocated containers.
 void setTrigger(org.springframework.scheduling.Trigger trigger)
          Sets Trigger used to trigger polling tasks.
 
Methods inherited from class org.springframework.yarn.am.allocate.AbstractAllocator
getApplicationAttemptId, getConfiguration, getEnvironment, getRmTemplate, setApplicationAttemptId, setConfiguration, setEnvironment, setRmTemplate
 
Methods inherited from class org.springframework.yarn.support.LifecycleObjectSupport
afterPropertiesSet, getBeanFactory, getPhase, getTaskExecutor, getTaskScheduler, getYarnEventPublisher, isAutoStartup, isRunning, setAutoStartup, setBeanFactory, setPhase, setTaskExecutor, setTaskScheduler, setYarnEventPublisher, start, stop, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPollingAllocator

public AbstractPollingAllocator()
Method Detail

setTrigger

public void setTrigger(org.springframework.scheduling.Trigger trigger)
Sets Trigger used to trigger polling tasks.

Parameters:
trigger - trigger to set

onInit

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

Overrides:
onInit in class AbstractAllocator
Throws:
java.lang.Exception

doStart

protected void doStart()
Description copied from class: LifecycleObjectSupport
Subclasses may implement this method with the start behavior. This method will be invoked while holding the LifecycleObjectSupport.lifecycleLock.

Overrides:
doStart in class LifecycleObjectSupport

doStop

protected void doStop()
Description copied from class: LifecycleObjectSupport
Subclasses may implement this method with the stop behavior. This method will be invoked while holding the LifecycleObjectSupport.lifecycleLock.

Overrides:
doStop in class LifecycleObjectSupport

doContainerRequest

protected abstract org.apache.hadoop.yarn.api.records.AMResponse doContainerRequest()
Subclasses needs to implements this method to do container requests against resource manager. This method is called during the polling cycle handled by this class. New containers and newly released containers are passed to methods handleAllocatedContainers(List) and handleCompletedContainers(List).

Returns:
AMResponse from a resource manager

preProcessAllocatedContainers

protected java.util.List<org.apache.hadoop.yarn.api.records.Container> preProcessAllocatedContainers(java.util.List<org.apache.hadoop.yarn.api.records.Container> containers)
Pre process allocated containers. Allows implementors to intercept containers before further processing is done. Default implementation returns list as it is.

Parameters:
containers - the containers
Returns:
the list of containers

handleAllocatedContainers

protected abstract void handleAllocatedContainers(java.util.List<org.apache.hadoop.yarn.api.records.Container> containers)
Subclasses needs to implement this method to handle newly allocated containers.

Parameters:
containers - list of newly allocate containers

handleCompletedContainers

protected abstract void handleCompletedContainers(java.util.List<org.apache.hadoop.yarn.api.records.ContainerStatus> containerStatuses)
Subclasses needs to implement this method to handle newly released containers.

Parameters:
containerStatuses - list of newly released containers

Spring for Apache Hadoop