@InterfaceAudience.Private @InterfaceStability.Unstable public class AllocationTagsManager extends Object
Modifier and Type | Class and Description |
---|---|
static class |
AllocationTagsManager.TypeToCountedTags<T>
Generic store mapping type T to counted tags.
|
Constructor and Description |
---|
AllocationTagsManager(RMContext context) |
Modifier and Type | Method and Description |
---|---|
void |
addContainer(org.apache.hadoop.yarn.api.records.NodeId nodeId,
org.apache.hadoop.yarn.api.records.ContainerId containerId,
Set<String> allocationTags)
Notify container allocated on a node.
|
void |
addTags(org.apache.hadoop.yarn.api.records.NodeId nodeId,
org.apache.hadoop.yarn.api.records.ApplicationId applicationId,
Set<String> allocationTags) |
boolean |
allocationTagExistsOnNode(org.apache.hadoop.yarn.api.records.NodeId nodeId,
org.apache.hadoop.yarn.api.records.ApplicationId applicationId,
String tag)
Check if given tag exists on node.
|
Map<String,Long> |
getAllocationTagsWithCount(org.apache.hadoop.yarn.api.records.NodeId nodeId)
Returns a map whose key is the allocation tag and value is the
count of allocations with this tag.
|
long |
getNodeCardinality(org.apache.hadoop.yarn.api.records.NodeId nodeId,
org.apache.hadoop.yarn.api.records.ApplicationId applicationId,
String tag)
Get Node cardinality for a specific tag.
|
long |
getNodeCardinalityByOp(org.apache.hadoop.yarn.api.records.NodeId nodeId,
AllocationTags tags,
LongBinaryOperator op)
Get cardinality for following conditions.
|
Map<org.apache.hadoop.yarn.api.records.ApplicationId,AllocationTagsManager.TypeToCountedTags> |
getPerAppNodeMappings() |
long |
getRackCardinality(String rack,
org.apache.hadoop.yarn.api.records.ApplicationId applicationId,
String tag)
Get Rack cardinality for a specific tag.
|
long |
getRackCardinalityByOp(String rack,
AllocationTags tags,
LongBinaryOperator op)
Get cardinality for following conditions.
|
void |
removeContainer(org.apache.hadoop.yarn.api.records.NodeId nodeId,
org.apache.hadoop.yarn.api.records.ContainerId containerId,
Set<String> allocationTags)
Notify container removed.
|
void |
removeTags(org.apache.hadoop.yarn.api.records.NodeId nodeId,
org.apache.hadoop.yarn.api.records.ApplicationId applicationId,
Set<String> allocationTags)
Helper method to just remove the tags associated with a container.
|
public AllocationTagsManager(RMContext context)
public Map<org.apache.hadoop.yarn.api.records.ApplicationId,AllocationTagsManager.TypeToCountedTags> getPerAppNodeMappings()
public void addContainer(org.apache.hadoop.yarn.api.records.NodeId nodeId, org.apache.hadoop.yarn.api.records.ContainerId containerId, Set<String> allocationTags)
nodeId
- allocated node.containerId
- container id.allocationTags
- allocation tags, see
SchedulingRequest.getAllocationTags()
application_id will be added to allocationTags.public void addTags(org.apache.hadoop.yarn.api.records.NodeId nodeId, org.apache.hadoop.yarn.api.records.ApplicationId applicationId, Set<String> allocationTags)
public void removeContainer(org.apache.hadoop.yarn.api.records.NodeId nodeId, org.apache.hadoop.yarn.api.records.ContainerId containerId, Set<String> allocationTags)
nodeId
- nodeIdcontainerId
- containerId.allocationTags
- allocation tags for given containerpublic void removeTags(org.apache.hadoop.yarn.api.records.NodeId nodeId, org.apache.hadoop.yarn.api.records.ApplicationId applicationId, Set<String> allocationTags)
nodeId
- applicationId
- allocationTags
- public long getNodeCardinality(org.apache.hadoop.yarn.api.records.NodeId nodeId, org.apache.hadoop.yarn.api.records.ApplicationId applicationId, String tag) throws InvalidAllocationTagsQueryException
nodeId
- nodeId, required.applicationId
- applicationId. When null is specified, return
aggregated cardinality among all nodes.tag
- allocation tag, see
SchedulingRequest.getAllocationTags()
,
If a specified tag doesn't exist,
method returns 0.InvalidAllocationTagsQueryException
- when illegal query
parameter specifiedpublic long getRackCardinality(String rack, org.apache.hadoop.yarn.api.records.ApplicationId applicationId, String tag) throws InvalidAllocationTagsQueryException
rack
- rack, required.applicationId
- applicationId. When null is specified, return
aggregated cardinality among all nodes.tag
- allocation tag, see
SchedulingRequest.getAllocationTags()
,
If a specified tag doesn't exist,
method returns 0.InvalidAllocationTagsQueryException
- when illegal query
parameter specifiedpublic boolean allocationTagExistsOnNode(org.apache.hadoop.yarn.api.records.NodeId nodeId, org.apache.hadoop.yarn.api.records.ApplicationId applicationId, String tag) throws InvalidAllocationTagsQueryException
nodeId
- nodeId, required.applicationId
- applicationId. When null is specified, return
aggregation among all applications.tag
- allocation tag, see
SchedulingRequest.getAllocationTags()
,
When multiple tags specified. Returns cardinality
depends on op. If a specified tag doesn't exist,
0 will be its cardinality.
When null/empty tags specified, all tags
(of the node/app) will be considered.InvalidAllocationTagsQueryException
- when illegal query
parameter specifiedpublic long getNodeCardinalityByOp(org.apache.hadoop.yarn.api.records.NodeId nodeId, AllocationTags tags, LongBinaryOperator op) throws InvalidAllocationTagsQueryException
nodeId
- nodeId, required.tags
- AllocationTags
, allocation tags under a
specific namespace. See
SchedulingRequest.getAllocationTags()
,
When multiple tags specified. Returns cardinality
depends on op. If a specified tag doesn't exist, 0
will be its cardinality. When null/empty tags
specified, all tags (of the node/app) will be
considered.op
- operator. Such as Long::max, Long::sum, etc. Required.
This parameter only take effect when #values greater
than 2.InvalidAllocationTagsQueryException
- when illegal query
parameter specifiedpublic long getRackCardinalityByOp(String rack, AllocationTags tags, LongBinaryOperator op) throws InvalidAllocationTagsQueryException
rack
- rack, required.tags
- AllocationTags
, allocation tags under a
specific namespace. See
SchedulingRequest.getAllocationTags()
,
When multiple tags specified. Returns cardinality
depends on op. If a specified tag doesn't exist, 0
will be its cardinality. When null/empty tags
specified, all tags (of the rack/app) will be
considered.op
- operator. Such as Long::max, Long::sum, etc. Required.
This parameter only take effect when #values
greater than 2.InvalidAllocationTagsQueryException
- when illegal query
parameter specifiedCopyright © 2008–2021 Apache Software Foundation. All rights reserved.