aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/actions
diff options
context:
space:
mode:
authorGravatar janakr <janakr@google.com>2017-10-12 03:42:37 +0200
committerGravatar Marcel Hlopko <hlopko@google.com>2017-10-12 10:17:14 +0200
commit8601d4a357f8c1618fb6a8144ea93736f24d973a (patch)
tree4804047242e1013cb300dc4d594ac05faa31154b /src/main/java/com/google/devtools/build/lib/actions
parent3c9ef6e814f5028817a3fc77d016edeee06d3642 (diff)
Throw a checked exception if there's an error reading /proc/meminfo, and handle it properly.
PiperOrigin-RevId: 171906091
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/actions')
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/LocalHostResourceManagerLinux.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/LocalHostResourceManagerLinux.java b/src/main/java/com/google/devtools/build/lib/actions/LocalHostResourceManagerLinux.java
index 59ab78775a..b889742bf5 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/LocalHostResourceManagerLinux.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/LocalHostResourceManagerLinux.java
@@ -43,7 +43,8 @@ public class LocalHostResourceManagerLinux {
return getPhysicalCpuCountHelper(logicalCpuCount, content);
}
- private static double getMemoryInMb() throws IOException {
+ private static double getMemoryInMb()
+ throws IOException, ProcMeminfoParser.KeywordNotFoundException {
return getMemoryInMbHelper(MEM_INFO_FILE);
}
@@ -60,7 +61,7 @@ public class LocalHostResourceManagerLinux {
logicalCpuCount * (hyperthreading ? EFFECTIVE_CPUS_PER_HYPERTHREADED_CPU : 1.0),
1.0,
Integer.MAX_VALUE);
- } catch (IOException | IllegalArgumentException e) {
+ } catch (IOException | ProcMeminfoParser.KeywordNotFoundException e) {
return null;
}
}
@@ -123,7 +124,8 @@ public class LocalHostResourceManagerLinux {
return cpuCount * coresPerCpu;
}
- public static double getMemoryInMbHelper(String memInfoFileName) throws IOException {
+ public static double getMemoryInMbHelper(String memInfoFileName)
+ throws IOException, ProcMeminfoParser.KeywordNotFoundException {
ProcMeminfoParser memInfo = new ProcMeminfoParser(memInfoFileName);
double ramMb = ProcMeminfoParser.kbToMb(memInfo.getTotalKb());
return ramMb;