use of com.hubspot.singularity.executor.SingularityExecutorMonitor.KillState in project Singularity by HubSpot.
the class SingularityExecutor method killTask.
/**
* Invoked when a task running within this executor has been killed
* (via SchedulerDriver::killTask). Note that no status update will
* be sent on behalf of the executor, the executor is responsible
* for creating a new TaskStatus (i.e., with TASK_KILLED) and
* invoking ExecutorDriver::sendStatusUpdate.
*/
@Override
public void killTask(ExecutorDriver executorDriver, Protos.TaskID taskID) {
final String taskId = taskID.getValue();
LOG.info("Asked to kill task {}", taskId);
KillState killState = monitor.requestKill(taskId);
switch(killState) {
case DIDNT_EXIST:
case INCONSISTENT_STATE:
LOG.warn("Couldn't kill task {} due to killState {}", taskId, killState);
break;
case DESTROYING_PROCESS:
case INTERRUPTING_PRE_PROCESS:
case KILLING_PROCESS:
LOG.info("Requested kill of task {} with killState {}", taskId, killState);
break;
}
}
use of com.hubspot.singularity.executor.SingularityExecutorMonitor.KillState in project Singularity by HubSpot.
the class SingularityExecutorThreadChecker method checkThreads.
private void checkThreads() {
for (SingularityExecutorTaskProcessCallable taskProcess : monitor.getRunningTasks()) {
if (!taskProcess.getTask().getExecutorData().getMaxTaskThreads().isPresent()) {
continue;
}
final int maxThreads = taskProcess.getTask().getExecutorData().getMaxTaskThreads().get();
int usedThreads = 0;
try {
usedThreads = getNumUsedThreads(taskProcess);
LOG.trace("{} is using {} threads", taskProcess.getTask().getTaskId(), usedThreads);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
return;
} catch (Throwable t) {
if (!taskProcess.wasKilled()) {
taskProcess.getTask().getLog().error("While fetching used threads for {}", taskProcess.getTask().getTaskId(), t);
}
continue;
}
if (usedThreads > maxThreads) {
taskProcess.getTask().getLog().info("{} using too many threads: {} (max {})", taskProcess.getTask().getTaskId(), usedThreads, maxThreads);
taskProcess.getTask().markKilledDueToThreads(usedThreads);
KillState killState = monitor.requestKill(taskProcess.getTask().getTaskId());
taskProcess.getTask().getLog().info("Killing {} due to thread overage (kill state {})", taskProcess.getTask().getTaskId(), killState);
}
}
}
Aggregations