aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java
diff options
context:
space:
mode:
authorGravatar Lukacs Berki <lberki@google.com>2016-07-07 07:55:04 +0000
committerGravatar Klaus Aehlig <aehlig@google.com>2016-07-07 08:41:22 +0000
commit2896dc0aa7dc6b2ce9725e36c7dfb1e960db1ef1 (patch)
tree65de3a02ca4842cdc65c0b573381e681a7afa034 /src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java
parent5dddb00278f9fb5846d213a1239b228a3ef852e6 (diff)
Various fixes for gRPC mode:
- Use the abrupt exit protocol to return the correct exit code when the server dies unexpectedly in gRPC mode - Report the command waiting time correctly even if the waiting is done within the server -- MOS_MIGRATED_REVID=126780186
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java
index 8094094e52..171a1ffd72 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java
@@ -33,6 +33,7 @@ import com.google.devtools.build.lib.events.Reporter;
import com.google.devtools.build.lib.flags.InvocationPolicyEnforcer;
import com.google.devtools.build.lib.util.AbruptExitException;
import com.google.devtools.build.lib.util.AnsiStrippingOutputStream;
+import com.google.devtools.build.lib.util.BlazeClock;
import com.google.devtools.build.lib.util.ExitCode;
import com.google.devtools.build.lib.util.LoggingUtil;
import com.google.devtools.build.lib.util.Pair;
@@ -290,13 +291,20 @@ public class BlazeCommandDispatcher {
}
+ long waitTimeInMs = 0;
synchronized (commandLock) {
- if (currentClientDescription != null) {
+ boolean warningPrinted = false;
+ while (currentClientDescription != null) {
switch (lockingMode) {
case WAIT:
- outErr.printErrLn("Another command (" + currentClientDescription + ") is running. "
- + " Waiting for it to complete...");
+ if (!warningPrinted) {
+ outErr.printErrLn("Another command (" + currentClientDescription + ") is running. "
+ + " Waiting for it to complete...");
+ warningPrinted = true;
+ }
+ long clockBefore = BlazeClock.nanoTime();
commandLock.wait();
+ waitTimeInMs = (BlazeClock.nanoTime() - clockBefore) / (1000L * 1000L);
break;
case ERROR_OUT:
@@ -313,7 +321,7 @@ public class BlazeCommandDispatcher {
}
try {
- return execExclusively(args, outErr, firstContactTime, commandName, command);
+ return execExclusively(args, outErr, firstContactTime, commandName, command, waitTimeInMs);
} finally {
synchronized (commandLock) {
currentClientDescription = null;
@@ -323,7 +331,8 @@ public class BlazeCommandDispatcher {
}
private int execExclusively(List<String> args, OutErr outErr, long firstContactTime,
- String commandName, BlazeCommand command) throws ShutdownBlazeServerException {
+ String commandName, BlazeCommand command, long waitTimeInMs)
+ throws ShutdownBlazeServerException {
Command commandAnnotation = command.getClass().getAnnotation(Command.class);
// Record the start time for the profiler. Do not put anything before this!
@@ -462,7 +471,8 @@ public class BlazeCommandDispatcher {
try {
// Notify the BlazeRuntime, so it can do some initial setup.
- env.beforeCommand(commandAnnotation, optionsParser, commonOptions, execStartTimeNanos);
+ env.beforeCommand(commandAnnotation, optionsParser, commonOptions, execStartTimeNanos,
+ waitTimeInMs);
// Allow the command to edit options after parsing:
command.editOptions(env, optionsParser);
} catch (AbruptExitException e) {