public class ResourceUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
EXTERNAL_VOLUME_RESOURCE_TAG |
static String |
MAXIMUM_ALLOCATION |
static String |
MINIMUM_ALLOCATION |
static Pattern |
RESOURCE_REQUEST_VALUE_PATTERN |
static String |
TAGS |
static String |
TYPE |
static String |
UNITS |
static String |
YARN_IO_OPTIONAL |
| Modifier and Type | Method and Description |
|---|---|
static void |
areMandatoryResourcesAvailable(Resource res)
Are mandatory resources like memory-mb, vcores available?
If not, throw exceptions.
|
static Resource |
createResourceFromString(String resourceStr,
List<ResourceTypeInfo> resourceTypeInfos) |
static ResourceInformation[] |
createResourceTypesArray(Map<String,Long> res)
Create an array of
ResourceInformation objects corresponding to
the passed in map of names to values. |
static Resource |
createResourceWithSameValue(long value)
Return a new
Resource instance with all resource values
initialized to value. |
static Resource |
fetchMaximumAllocationFromConfig(org.apache.hadoop.conf.Configuration conf)
Get maximum allocation from config, *THIS WILL NOT UPDATE INTERNAL DATA.
|
static StringBuilder |
getCustomResourcesStrings(Resource resource) |
static String |
getDefaultUnit(String resourceType)
Get default unit by given resource type.
|
static Map<String,ResourceInformation> |
getNodeResourceInformation(org.apache.hadoop.conf.Configuration conf)
Function to get the resources for a node.
|
static int |
getNumberOfCountableResourceTypes() |
static int |
getNumberOfKnownResourceTypes() |
static List<ResourceInformation> |
getRequestedResourcesFromConfig(org.apache.hadoop.conf.Configuration configuration,
String prefix)
From a given configuration get all entries representing requested
resources: entries that match the {prefix}{resourceName}={value}[{units}]
pattern.
|
static List<ResourceTypeInfo> |
getResourcesTypeInfo()
Get all resource types information from known resource types.
|
static Map<String,Integer> |
getResourceTypeIndex()
Get associate index of resource types such memory, cpu etc.
|
static Map<String,ResourceInformation> |
getResourceTypes()
Get the resource types to be supported by the system.
|
static ResourceInformation[] |
getResourceTypesArray() |
static Resource |
getResourceTypesMaximumAllocation()
Get a Resource object with for the maximum allocation possible.
|
static Resource |
getResourceTypesMinimumAllocation() |
static String |
getUnits(String resourceValue) |
static long |
getValue(String resourceValue) |
static void |
initializeResourcesFromResourceInformationMap(Map<String,ResourceInformation> resourceInformationMap)
This method is visible for testing, unit test can construct a
resourceInformationMap and pass it to this method to initialize multiple resources.
|
static Resource |
multiplyFloor(Resource resource,
double multiplier) |
static Resource |
multiplyRound(Resource resource,
double multiplier) |
static String[] |
parseResourceValue(String resourceValue)
Extract unit and actual value from resource value.
|
static void |
reinitializeResources(List<ResourceTypeInfo> resourceTypeInfo)
Reinitialize all resource types from external source (in case of client,
server will send the updated list and local resourceutils cache will be
updated as per server's list of resources).
|
static void |
resetNodeResources() |
static void |
resetResourceTypes() |
static Map<String,ResourceInformation> |
resetResourceTypes(org.apache.hadoop.conf.Configuration conf) |
public static final String UNITS
public static final String TYPE
public static final String TAGS
public static final String MINIMUM_ALLOCATION
public static final String MAXIMUM_ALLOCATION
public static final String EXTERNAL_VOLUME_RESOURCE_TAG
public static final Pattern RESOURCE_REQUEST_VALUE_PATTERN
public static final String YARN_IO_OPTIONAL
public static Resource fetchMaximumAllocationFromConfig(org.apache.hadoop.conf.Configuration conf)
conf - config@VisibleForTesting public static void initializeResourcesFromResourceInformationMap(Map<String,ResourceInformation> resourceInformationMap)
resourceInformationMap - constructed resource information map.public static Map<String,Integer> getResourceTypeIndex()
public static Map<String,ResourceInformation> getResourceTypes()
public static ResourceInformation[] getResourceTypesArray()
public static int getNumberOfKnownResourceTypes()
public static int getNumberOfCountableResourceTypes()
@VisibleForTesting public static void resetResourceTypes()
@VisibleForTesting public static Map<String,ResourceInformation> resetResourceTypes(org.apache.hadoop.conf.Configuration conf)
public static String[] parseResourceValue(String resourceValue)
resourceValue - Value of the resourceIllegalArgumentException - if units contain non alpha characterspublic static long getValue(String resourceValue)
public static Map<String,ResourceInformation> getNodeResourceInformation(org.apache.hadoop.conf.Configuration conf)
YarnConfiguration.NODE_RESOURCES_CONFIGURATION_FILE to
determine the node resources.conf - configuration file@VisibleForTesting public static void resetNodeResources()
public static Resource getResourceTypesMinimumAllocation()
public static Resource getResourceTypesMaximumAllocation()
public static String getDefaultUnit(String resourceType)
resourceType - resourceTypepublic static List<ResourceTypeInfo> getResourcesTypeInfo()
public static void reinitializeResources(List<ResourceTypeInfo> resourceTypeInfo)
resourceTypeInfo - List of resource typespublic static List<ResourceInformation> getRequestedResourcesFromConfig(org.apache.hadoop.conf.Configuration configuration, String prefix)
configuration - The configurationprefix - Keys with this prefix are considered from the configurationpublic static void areMandatoryResourcesAvailable(Resource res)
res - resourceIllegalArgumentException - if mandatory resource is not available or
value is not within boundarypublic static ResourceInformation[] createResourceTypesArray(Map<String,Long> res)
ResourceInformation objects corresponding to
the passed in map of names to values. The array will be ordered according
to the order returned by getResourceTypesArray(). The value of
each resource type in the returned array will either be the value given for
that resource in the res parameter or, if none is given, 0.res - the map of resource type valuesResourceInformation instances@InterfaceAudience.Private @InterfaceStability.Unstable public static Resource createResourceWithSameValue(long value)
Resource instance with all resource values
initialized to value.value - the value to use for all resourcesResource instance@InterfaceAudience.Private @InterfaceStability.Unstable public static Resource createResourceFromString(String resourceStr, List<ResourceTypeInfo> resourceTypeInfos)
public static StringBuilder getCustomResourcesStrings(Resource resource)
Copyright © 2008–2024 Apache Software Foundation. All rights reserved.