use of com.hubspot.singularity.SingularityTaskDestroyFrameworkMessage in project Singularity by HubSpot.
the class SingularityMesosSchedulerImpl method killAndRecord.
public void killAndRecord(SingularityTaskId taskId, Optional<RequestCleanupType> requestCleanupType, Optional<TaskCleanupType> taskCleanupType, Optional<Long> originalTimestamp, Optional<Integer> retries, Optional<String> user) {
Preconditions.checkState(isRunning());
Optional<TaskCleanupType> maybeCleanupFromRequestAndTask = getTaskCleanupType(requestCleanupType, taskCleanupType);
if (maybeCleanupFromRequestAndTask.isPresent() && (maybeCleanupFromRequestAndTask.get() == TaskCleanupType.USER_REQUESTED_DESTROY || maybeCleanupFromRequestAndTask.get() == TaskCleanupType.REQUEST_DELETING)) {
Optional<SingularityTask> task = taskManager.getTask(taskId);
if (task.isPresent()) {
if (task.get().getTaskRequest().getDeploy().getCustomExecutorCmd().isPresent()) {
byte[] messageBytes = transcoder.toBytes(new SingularityTaskDestroyFrameworkMessage(taskId, user));
mesosSchedulerClient.frameworkMessage(MesosProtosUtils.toExecutorId(task.get().getMesosTask().getExecutor().getExecutorId()), MesosProtosUtils.toAgentId(task.get().getMesosTask().getAgentId()), messageBytes);
} else {
LOG.warn("Not using custom executor, will not send framework message to destroy task");
}
} else {
String message = String.format("No task data available to build kill task framework message for task %s", taskId);
exceptionNotifier.notify(message);
LOG.error(message);
}
}
mesosSchedulerClient.kill(TaskID.newBuilder().setValue(taskId.toString()).build());
taskManager.saveKilledRecord(new SingularityKilledTaskIdRecord(taskId, System.currentTimeMillis(), originalTimestamp.or(System.currentTimeMillis()), requestCleanupType, taskCleanupType, retries.or(-1) + 1));
}
Aggregations