public class DefaultContainerAllocator extends AbstractPollingAllocator implements ContainerAllocator
Constructor and Description |
---|
DefaultContainerAllocator() |
Modifier and Type | Method and Description |
---|---|
void |
addListener(ContainerAllocatorListener listener)
Adds the
ContainerAllocatorListener . |
void |
allocateContainers(ContainerAllocateData containerAllocateData)
Allocate new containers.
|
void |
allocateContainers(int count)
Allocate new containers.
|
protected org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse |
doContainerRequest()
Subclasses needs to implements this method to do container
requests against resource manager.
|
int |
getMemory()
Gets the memory for container request.
|
int |
getPriority()
Gets the priority for container request.
|
int |
getVirtualcores()
Gets the virtualcores for container request.
|
protected 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 void |
handleCompletedContainers(java.util.List<org.apache.hadoop.yarn.api.records.ContainerStatus> containerStatuses)
Subclasses needs to implement this method to handle newly
released containers.
|
boolean |
isLocality()
Checks if is locality relax flag is enabled.
|
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 |
releaseContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId)
Release container.
|
void |
releaseContainers(java.util.List<org.apache.hadoop.yarn.api.records.Container> containers)
Release containers.
|
void |
setAllocationValues(java.lang.String id,
java.lang.Integer priority,
java.lang.String labelExpression,
java.lang.Integer virtualcores,
java.lang.Integer memory,
java.lang.Boolean locality)
Sets the allocation values for given identifier.
|
void |
setLabelExpression(java.lang.String labelExpression)
Sets the label expression.
|
void |
setLocality(boolean locality)
Sets the flag telling if resource allocation
should not be relaxed.
|
void |
setMemory(int memory)
Sets the memory for container request defining
memory of the resource.
|
void |
setPriority(int priority)
Sets the priority for container request.
|
void |
setProgress(float progress)
Sets the current progress of application.
|
void |
setVirtualcores(int virtualcores)
Sets the virtualcores for container request defining
number of virtual cpu cores of the resource.
|
doStart, doStop, populateNmTokenCache, setTrigger
getApplicationAttemptId, getConfiguration, getEnvironment, getRmTemplate, setApplicationAttemptId, setConfiguration, setEnvironment, setRmTemplate
afterPropertiesSet, getBeanFactory, getPhase, getTaskExecutor, getTaskScheduler, getYarnEventPublisher, isAutoStartup, isRunning, setAutoStartup, setBeanFactory, setPhase, setTaskExecutor, setTaskScheduler, setYarnEventPublisher, start, stop, stop
protected void onInit() throws java.lang.Exception
LifecycleObjectSupport
InitializingBean
phase. Implementor should
always call super method not to break initialization chain.onInit
in class AbstractPollingAllocator
java.lang.Exception
- exceptionpublic void allocateContainers(int count)
ContainerAllocator
allocateContainers
in interface ContainerAllocator
count
- the new container count to allocatepublic void addListener(ContainerAllocatorListener listener)
ContainerAllocator
ContainerAllocatorListener
.addListener
in interface ContainerAllocator
listener
- the ContainerAllocatorListener
public void allocateContainers(ContainerAllocateData containerAllocateData)
ContainerAllocator
allocateContainers
in interface ContainerAllocator
containerAllocateData
- the ContainerAllocateData
public void releaseContainers(java.util.List<org.apache.hadoop.yarn.api.records.Container> containers)
ContainerAllocator
releaseContainers
in interface ContainerAllocator
containers
- the containerspublic void releaseContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId)
ContainerAllocator
releaseContainer
in interface ContainerAllocator
containerId
- the container idprotected org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse doContainerRequest()
AbstractPollingAllocator
AbstractPollingAllocator.handleAllocatedContainers(List)
and
AbstractPollingAllocator.handleCompletedContainers(List)
.doContainerRequest
in class AbstractPollingAllocator
AllocateResponse
from a resource managerprotected java.util.List<org.apache.hadoop.yarn.api.records.Container> preProcessAllocatedContainers(java.util.List<org.apache.hadoop.yarn.api.records.Container> containers)
AbstractPollingAllocator
preProcessAllocatedContainers
in class AbstractPollingAllocator
containers
- the containersprotected void handleAllocatedContainers(java.util.List<org.apache.hadoop.yarn.api.records.Container> containers)
AbstractPollingAllocator
handleAllocatedContainers
in class AbstractPollingAllocator
containers
- list of newly allocate containersprotected void handleCompletedContainers(java.util.List<org.apache.hadoop.yarn.api.records.ContainerStatus> containerStatuses)
AbstractPollingAllocator
handleCompletedContainers
in class AbstractPollingAllocator
containerStatuses
- list of newly released containerspublic void setProgress(float progress)
ContainerAllocator
setProgress
in interface ContainerAllocator
progress
- the current progress of applicationpublic void setAllocationValues(java.lang.String id, java.lang.Integer priority, java.lang.String labelExpression, java.lang.Integer virtualcores, java.lang.Integer memory, java.lang.Boolean locality)
id
- the allocation identifierpriority
- the base prioritylabelExpression
- the label expressionvirtualcores
- the cpu countmemory
- the memorylocality
- the locality flagpublic int getPriority()
public void setPriority(int priority)
priority
- the new prioritypublic void setLabelExpression(java.lang.String labelExpression)
labelExpression
- the new label expressionpublic int getVirtualcores()
public void setVirtualcores(int virtualcores)
virtualcores
- the new virtualcorespublic int getMemory()
public void setMemory(int memory)
memory
- the new memorypublic boolean isLocality()
public void setLocality(boolean locality)
locality
- the new locality relax flag