|
@@ -345,15 +345,13 @@ public class ResourceUtils {
|
|
}
|
|
}
|
|
|
|
|
|
public static ResourceInformation[] getResourceTypesArray() {
|
|
public static ResourceInformation[] getResourceTypesArray() {
|
|
- initializeResourceTypesIfNeeded(null,
|
|
|
|
- YarnConfiguration.RESOURCE_TYPES_CONFIGURATION_FILE);
|
|
|
|
|
|
+ initializeResourceTypesIfNeeded();
|
|
return resourceTypesArray;
|
|
return resourceTypesArray;
|
|
}
|
|
}
|
|
|
|
|
|
public static int getNumberOfKnownResourceTypes() {
|
|
public static int getNumberOfKnownResourceTypes() {
|
|
if (numKnownResourceTypes < 0) {
|
|
if (numKnownResourceTypes < 0) {
|
|
- initializeResourceTypesIfNeeded(null,
|
|
|
|
- YarnConfiguration.RESOURCE_TYPES_CONFIGURATION_FILE);
|
|
|
|
|
|
+ initializeResourceTypesIfNeeded();
|
|
}
|
|
}
|
|
return numKnownResourceTypes;
|
|
return numKnownResourceTypes;
|
|
}
|
|
}
|
|
@@ -364,6 +362,11 @@ public class ResourceUtils {
|
|
YarnConfiguration.RESOURCE_TYPES_CONFIGURATION_FILE);
|
|
YarnConfiguration.RESOURCE_TYPES_CONFIGURATION_FILE);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private static void initializeResourceTypesIfNeeded() {
|
|
|
|
+ initializeResourceTypesIfNeeded(null,
|
|
|
|
+ YarnConfiguration.RESOURCE_TYPES_CONFIGURATION_FILE);
|
|
|
|
+ }
|
|
|
|
+
|
|
private static void initializeResourceTypesIfNeeded(Configuration conf,
|
|
private static void initializeResourceTypesIfNeeded(Configuration conf,
|
|
String resourceFile) {
|
|
String resourceFile) {
|
|
if (!initializedResources) {
|
|
if (!initializedResources) {
|
|
@@ -674,6 +677,8 @@ public class ResourceUtils {
|
|
*/
|
|
*/
|
|
public static ResourceInformation[] createResourceTypesArray(Map<String,
|
|
public static ResourceInformation[] createResourceTypesArray(Map<String,
|
|
Long> res) {
|
|
Long> res) {
|
|
|
|
+ initializeResourceTypesIfNeeded();
|
|
|
|
+
|
|
ResourceInformation[] info = new ResourceInformation[resourceTypes.size()];
|
|
ResourceInformation[] info = new ResourceInformation[resourceTypes.size()];
|
|
|
|
|
|
for (Entry<String, Integer> entry : RESOURCE_NAME_TO_INDEX.entrySet()) {
|
|
for (Entry<String, Integer> entry : RESOURCE_NAME_TO_INDEX.entrySet()) {
|