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, setTriggergetApplicationAttemptId, getConfiguration, getEnvironment, getRmTemplate, setApplicationAttemptId, setConfiguration, setEnvironment, setRmTemplateafterPropertiesSet, getBeanFactory, getPhase, getTaskExecutor, getTaskScheduler, getYarnEventPublisher, isAutoStartup, isRunning, setAutoStartup, setBeanFactory, setPhase, setTaskExecutor, setTaskScheduler, setYarnEventPublisher, start, stop, stopprotected void onInit()
throws java.lang.Exception
LifecycleObjectSupportInitializingBean phase. Implementor should
always call super method not to break initialization chain.onInit in class AbstractPollingAllocatorjava.lang.Exception - exceptionpublic void allocateContainers(int count)
ContainerAllocatorallocateContainers in interface ContainerAllocatorcount - the new container count to allocatepublic void addListener(ContainerAllocatorListener listener)
ContainerAllocatorContainerAllocatorListener.addListener in interface ContainerAllocatorlistener - the ContainerAllocatorListenerpublic void allocateContainers(ContainerAllocateData containerAllocateData)
ContainerAllocatorallocateContainers in interface ContainerAllocatorcontainerAllocateData - the ContainerAllocateDatapublic void releaseContainers(java.util.List<org.apache.hadoop.yarn.api.records.Container> containers)
ContainerAllocatorreleaseContainers in interface ContainerAllocatorcontainers - the containerspublic void releaseContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId)
ContainerAllocatorreleaseContainer in interface ContainerAllocatorcontainerId - the container idprotected org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse doContainerRequest()
AbstractPollingAllocatorAbstractPollingAllocator.handleAllocatedContainers(List) and
AbstractPollingAllocator.handleCompletedContainers(List).doContainerRequest in class AbstractPollingAllocatorAllocateResponse 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)
AbstractPollingAllocatorpreProcessAllocatedContainers in class AbstractPollingAllocatorcontainers - the containersprotected void handleAllocatedContainers(java.util.List<org.apache.hadoop.yarn.api.records.Container> containers)
AbstractPollingAllocatorhandleAllocatedContainers in class AbstractPollingAllocatorcontainers - list of newly allocate containersprotected void handleCompletedContainers(java.util.List<org.apache.hadoop.yarn.api.records.ContainerStatus> containerStatuses)
AbstractPollingAllocatorhandleCompletedContainers in class AbstractPollingAllocatorcontainerStatuses - list of newly released containerspublic void setProgress(float progress)
ContainerAllocatorsetProgress in interface ContainerAllocatorprogress - 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