Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,7 @@ public void onSuccess(Integer exitCode) {
task.getExecutorData().getMaxTaskThreads().get()
);
} else if (task.wasKilled()) {
long shutdownTimeMs = System.currentTimeMillis() - task.getKilledAt();
taskState = TaskState.TASK_KILLED;

if (task.wasDestroyedAfterWaiting()) {
Expand All @@ -782,19 +783,32 @@ public void onSuccess(Integer exitCode) {

message =
String.format(
"Task killed forcibly after waiting at least %s",
JavaUtils.durationFromMillis(millisWaited)
"Task killed forcibly after waiting at least %s (shutdownTime: %dms)",
JavaUtils.durationFromMillis(millisWaited),
shutdownTimeMs
);
} else if (task.wasForceDestroyed()) {
if (maybeKilledBy.isPresent()) {
message =
String.format("Task killed forcibly by %s", maybeKilledBy.get());
String.format(
"Task killed forcibly by %s (shutdownTime: %dms)",
maybeKilledBy.get(),
shutdownTimeMs
);
} else {
message =
"Task killed forcibly after multiple kill requests from framework";
String.format(
"Task killed forcibly after multiple kill requests from framework, (shutdownTime: %dms)",
shutdownTimeMs
);
}
} else {
message = "Task killed. Process exited gracefully with code " + exitCode;
message =
String.format(
"Task killed. Process exited gracefully with code %d (shutdownTime: %dms)",
exitCode,
shutdownTimeMs
);
}
} else if (task.isSuccessExitCode(exitCode)) {
taskState = TaskState.TASK_FINISHED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.ReentrantLock;
import org.apache.mesos.ExecutorDriver;
Expand All @@ -29,7 +30,7 @@ public class SingularityExecutorTask {
private final Protos.TaskInfo taskInfo;
private final Logger log;
private final ReentrantLock lock;
private final AtomicBoolean killed;
private final AtomicLong killed;
private final AtomicInteger threadCountAtOverage;
private final AtomicBoolean killedAfterThreadOverage;
private final AtomicBoolean destroyedAfterWaiting;
Expand Down Expand Up @@ -62,7 +63,7 @@ public SingularityExecutorTask(
this.log = log;

this.lock = new ReentrantLock();
this.killed = new AtomicBoolean(false);
this.killed = new AtomicLong(-1);
this.destroyedAfterWaiting = new AtomicBoolean(false);
this.forceDestroyed = new AtomicBoolean(false);
this.killedBy = new AtomicReference<>(Optional.<String>empty());
Expand Down Expand Up @@ -183,11 +184,15 @@ public boolean wasDestroyedAfterWaiting() {
}

public boolean wasKilled() {
return killed.get() != -1;
}

public long getKilledAt() {
return killed.get();
}

public void markKilled(Optional<String> maybeUser) {
this.killed.set(true);
this.killed.set(System.currentTimeMillis());
this.killedBy.set(maybeUser);
}

Expand Down