YARN-7589. TestPBImplRecords fails with NullPointerException. Contributed by Daniel Templeton
(cherry picked from commit 25df5054216a6a76d09d9c49984f8075ebc6a197)
This commit is contained in:
parent
a9f51e0372
commit
dbbe23f269
@ -99,9 +99,12 @@ public static Resource newInstance(long memory, int vCores) {
|
||||
@Stable
|
||||
public static Resource newInstance(long memory, int vCores,
|
||||
Map<String, Long> others) {
|
||||
ResourceInformation[] info = ResourceUtils.createResourceTypesArray(others);
|
||||
|
||||
return new LightWeightResource(memory, vCores, info);
|
||||
if (others != null) {
|
||||
return new LightWeightResource(memory, vCores,
|
||||
ResourceUtils.createResourceTypesArray(others));
|
||||
} else {
|
||||
return newInstance(memory, vCores);
|
||||
}
|
||||
}
|
||||
|
||||
@InterfaceAudience.Private
|
||||
|
@ -341,15 +341,13 @@ public static Map<String, ResourceInformation> getResourceTypes() {
|
||||
}
|
||||
|
||||
public static ResourceInformation[] getResourceTypesArray() {
|
||||
initializeResourceTypesIfNeeded(null,
|
||||
YarnConfiguration.RESOURCE_TYPES_CONFIGURATION_FILE);
|
||||
initializeResourceTypesIfNeeded();
|
||||
return resourceTypesArray;
|
||||
}
|
||||
|
||||
public static int getNumberOfKnownResourceTypes() {
|
||||
if (numKnownResourceTypes < 0) {
|
||||
initializeResourceTypesIfNeeded(null,
|
||||
YarnConfiguration.RESOURCE_TYPES_CONFIGURATION_FILE);
|
||||
initializeResourceTypesIfNeeded();
|
||||
}
|
||||
return numKnownResourceTypes;
|
||||
}
|
||||
@ -360,6 +358,11 @@ private static Map<String, ResourceInformation> getResourceTypes(
|
||||
YarnConfiguration.RESOURCE_TYPES_CONFIGURATION_FILE);
|
||||
}
|
||||
|
||||
private static void initializeResourceTypesIfNeeded() {
|
||||
initializeResourceTypesIfNeeded(null,
|
||||
YarnConfiguration.RESOURCE_TYPES_CONFIGURATION_FILE);
|
||||
}
|
||||
|
||||
private static void initializeResourceTypesIfNeeded(Configuration conf,
|
||||
String resourceFile) {
|
||||
if (!initializedResources) {
|
||||
@ -631,6 +634,8 @@ public static List<ResourceInformation> getRequestedResourcesFromConfig(
|
||||
*/
|
||||
public static ResourceInformation[] createResourceTypesArray(Map<String,
|
||||
Long> res) {
|
||||
initializeResourceTypesIfNeeded();
|
||||
|
||||
ResourceInformation[] info = new ResourceInformation[resourceTypes.size()];
|
||||
|
||||
for (Entry<String, Integer> entry : RESOURCE_NAME_TO_INDEX.entrySet()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user