aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/server
diff options
context:
space:
mode:
authorGravatar lberki <lberki@google.com>2018-04-03 03:17:21 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-04-03 03:19:10 -0700
commitd9b1082fd2a0e9500dd0a510dc8da6c3dc87fbd2 (patch)
tree516277351dd2206f87f221d70ba33decb593f675 /src/main/java/com/google/devtools/build/lib/server
parente52c8418d37e902237c6676d06fcb4cad7fc4766 (diff)
Remove the unused method IdleServerTasks#continueProcessing() .
IdleServerTasks could probably be implemented in a much simpler way, but let's keep this change a simple deletion. One step at a time. RELNOTES: None. PiperOrigin-RevId: 191418738
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/server')
-rw-r--r--src/main/java/com/google/devtools/build/lib/server/GrpcServerImpl.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/server/IdleServerTasks.java74
2 files changed, 3 insertions, 75 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/server/GrpcServerImpl.java b/src/main/java/com/google/devtools/build/lib/server/GrpcServerImpl.java
index 1213d6e47d..fb3cbc932b 100644
--- a/src/main/java/com/google/devtools/build/lib/server/GrpcServerImpl.java
+++ b/src/main/java/com/google/devtools/build/lib/server/GrpcServerImpl.java
@@ -555,13 +555,13 @@ public class GrpcServerImpl implements RPCServer {
pidFileWatcherThread = new PidFileWatcherThread();
pidFileWatcherThread.start();
- idleServerTasks = new IdleServerTasks(workspace);
+ idleServerTasks = new IdleServerTasks();
idleServerTasks.idle();
}
private void idle() {
Preconditions.checkState(idleServerTasks == null);
- idleServerTasks = new IdleServerTasks(workspace);
+ idleServerTasks = new IdleServerTasks();
idleServerTasks.idle();
}
diff --git a/src/main/java/com/google/devtools/build/lib/server/IdleServerTasks.java b/src/main/java/com/google/devtools/build/lib/server/IdleServerTasks.java
index 64d4502e61..01e596a00c 100644
--- a/src/main/java/com/google/devtools/build/lib/server/IdleServerTasks.java
+++ b/src/main/java/com/google/devtools/build/lib/server/IdleServerTasks.java
@@ -16,37 +16,24 @@ package com.google.devtools.build.lib.server;
import com.google.common.base.Preconditions;
import com.google.devtools.build.lib.profiler.AutoProfiler;
-import com.google.devtools.build.lib.unix.ProcMeminfoParser;
-import com.google.devtools.build.lib.util.LoggingUtil;
-import com.google.devtools.build.lib.vfs.FileStatus;
-import com.google.devtools.build.lib.vfs.Path;
-import com.google.devtools.build.lib.vfs.Symlinks;
-import java.io.IOException;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
-import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.annotation.Nullable;
/**
* Run cleanup-related tasks during idle periods in the server.
* idle() and busy() must be called in that order, and only once.
*/
class IdleServerTasks {
-
- private final Path workspaceDir;
private final ScheduledThreadPoolExecutor executor;
private static final Logger logger = Logger.getLogger(IdleServerTasks.class.getName());
- private static final long FIVE_MIN_MILLIS = 1000 * 60 * 5;
-
/**
* Must be called from the main thread.
*/
- public IdleServerTasks(@Nullable Path workspaceDir) {
+ public IdleServerTasks() {
this.executor = new ScheduledThreadPoolExecutor(1);
- this.workspaceDir = workspaceDir;
}
/**
@@ -97,63 +84,4 @@ class IdleServerTasks {
Thread.currentThread().interrupt();
}
}
-
- /**
- * Return true iff the server should continue processing requests.
- * Called from the main thread, so it should return quickly.
- */
- public boolean continueProcessing(long idleMillis) {
- if (!memoryHeuristic(idleMillis)) {
- return false;
- }
- if (workspaceDir == null) {
- return false;
- }
-
- FileStatus stat;
- try {
- stat = workspaceDir.statIfFound(Symlinks.FOLLOW);
- } catch (IOException e) {
- // Do not terminate the server if the workspace is temporarily inaccessible, for example,
- // if it is on a network filesystem and the connection is down.
- return true;
- }
- return stat != null && stat.isDirectory();
- }
-
- private boolean memoryHeuristic(long idleMillis) {
- if (idleMillis < FIVE_MIN_MILLIS) {
- // Don't check memory health until after five minutes.
- return true;
- }
-
- ProcMeminfoParser memInfo = null;
- try {
- memInfo = new ProcMeminfoParser();
- } catch (IOException e) {
- logger.info("Could not process /proc/meminfo: " + e);
- return true;
- }
-
- long totalPhysical;
- long totalFree;
- try {
- totalPhysical = memInfo.getTotalKb();
- totalFree = memInfo.getFreeRamKb(); // See method javadoc.
- } catch (ProcMeminfoParser.KeywordNotFoundException e) {
- LoggingUtil.logToRemote(Level.WARNING,
- "Could not read memInfo during idle query", e);
- return true;
- }
- double fractionFree = (double) totalFree / totalPhysical;
-
- // If the system as a whole is low on memory, let this server die.
- if (fractionFree < .1) {
- logger.info("Terminating due to memory constraints");
- logger.info(String.format("Total physical:%d\nTotal free: %d\n", totalPhysical, totalFree));
- return false;
- }
-
- return true;
- }
}