public class ResourceUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
MAXIMUM_ALLOCATION |
static String |
MINIMUM_ALLOCATION |
static String |
TYPE |
static String |
UNITS |
static String |
YARN_IO_OPTIONAL |
| Modifier and Type | Method and Description |
|---|---|
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 |
fetchMaximumAllocationFromConfig(org.apache.hadoop.conf.Configuration conf)
Get maximum allocation from config, *THIS WILL NOT UPDATE INTERNAL DATA*
|
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 |
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 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 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 MINIMUM_ALLOCATION
public static final String MAXIMUM_ALLOCATION
public static final String YARN_IO_OPTIONAL
public static Resource fetchMaximumAllocationFromConfig(org.apache.hadoop.conf.Configuration conf)
conf - configpublic 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 void resetResourceTypes()
public static Map<String,ResourceInformation> resetResourceTypes(org.apache.hadoop.conf.Configuration conf)
public static Map<String,ResourceInformation> getNodeResourceInformation(org.apache.hadoop.conf.Configuration conf)
YarnConfiguration.NODE_RESOURCES_CONFIGURATION_FILE to
determine the node resources.conf - configuration filepublic 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 List<ResourceInformation> getRequestedResourcesFromConfig(org.apache.hadoop.conf.Configuration configuration, String prefix)
configuration - The configurationprefix - Keys with this prefix are considered from the configurationpublic 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 instancespublic static void reinitializeResources(List<ResourceTypeInfo> resourceTypeInfo)
resourceTypeInfo - List of resource typesCopyright © 2022 Apache Software Foundation. All rights reserved.