use of org.apache.mesos.v1.Protos.ExecutorID in project Singularity by HubSpot.
the class SingularityMesosSchedulerClient method shutdown.
/**
* Sent by the scheduler to shutdown a specific custom executor. When an executor gets a shutdown event,
* it is expected to kill all its tasks (and send TASK_KILLED updates) and terminate. If an executor
* doesn’t terminate within a certain timeout, the agent will forcefully destroy the container
* (executor and its tasks) and transition its active tasks to TASK_LOST.
*
* @param executorId
*/
public void shutdown(ExecutorID executorId) {
Builder shutdown = build().setShutdown(Shutdown.newBuilder().setExecutorId(executorId));
sendCall(shutdown, Type.SHUTDOWN);
}
use of org.apache.mesos.v1.Protos.ExecutorID in project Singularity by HubSpot.
the class SingularityMesosSchedulerClient method frameworkMessage.
/**
* Sent by the scheduler to send arbitrary binary data to the executor. Mesos neither interprets this data nor
* makes any guarantees about the delivery of this message to the executor. data is raw bytes encoded in Base64.
*
* @param executorId
* @param agentId
* @param data
*/
public void frameworkMessage(ExecutorID executorId, AgentID agentId, byte[] data) {
Builder message = build().setMessage(Message.newBuilder().setAgentId(agentId).setExecutorId(executorId).setData(ByteString.copyFrom(data)));
sendCall(message, Type.MESSAGE);
}
use of org.apache.mesos.v1.Protos.ExecutorID in project Singularity by HubSpot.
the class SingularityTaskShellCommandDispatchPoller method runActionOnPoll.
@Override
public void runActionOnPoll() {
final long start = System.currentTimeMillis();
final List<SingularityTaskShellCommandRequest> shellRequests = taskManager.getAllQueuedTaskShellCommandRequests();
if (!schedulerClient.isRunning()) {
LOG.warn("Unable to process shell requests because scheduler driver isn't present ({} tasks waiting)", shellRequests.size());
return;
}
if (shellRequests.isEmpty()) {
LOG.trace("No shell requests to send.");
return;
}
for (SingularityTaskShellCommandRequest shellRequest : shellRequests) {
Optional<SingularityTask> task = taskManager.getTask(shellRequest.getTaskId());
if (!task.isPresent() || !taskManager.isActiveTask(shellRequest.getTaskId().getId())) {
LOG.info("Skipping shell request {} because {} didn't exist or isn't active", shellRequest, shellRequest.getTaskId());
continue;
}
final ExecutorID executorId = MesosProtosUtils.toExecutorId(task.get().getMesosTask().getExecutor().getExecutorId());
final AgentID slaveId = MesosProtosUtils.toAgentId(task.get().getMesosTask().getAgentId());
final byte[] bytes = transcoder.toBytes(shellRequest);
schedulerClient.frameworkMessage(executorId, slaveId, bytes);
LOG.info("Sent {} ({} bytes) to {} on {}", shellRequest, bytes.length, executorId, slaveId);
taskManager.saveTaskShellCommandRequestToTask(shellRequest);
taskManager.deleteTaskShellCommandRequestFromQueue(shellRequest);
}
LOG.info("Sent {} shell requests to executors in {}", shellRequests.size(), JavaUtils.duration(start));
}
use of org.apache.mesos.v1.Protos.ExecutorID in project Singularity by HubSpot.
the class SingularitySchedulerTestBase method prepTask.
protected SingularityTask prepTask(SingularityRequest request, SingularityDeploy deploy, long launchTime, int instanceNo, boolean separateHosts, Optional<String> runId) {
SingularityPendingTask pendingTask = buildPendingTask(request, deploy, launchTime, instanceNo, runId);
SingularityTaskRequest taskRequest = new SingularityTaskRequest(request, deploy, pendingTask);
Offer offer;
if (separateHosts) {
offer = createOffer(125, 1024, 2048, String.format("slave%s", instanceNo), String.format("host%s", instanceNo));
} else {
offer = createOffer(125, 1024, 2048);
}
SingularityTaskId taskId = new SingularityTaskId(request.getId(), deploy.getId(), launchTime, instanceNo, offer.getHostname(), "rack1");
TaskID taskIdProto = TaskID.newBuilder().setValue(taskId.toString()).build();
TaskInfo taskInfo = TaskInfo.newBuilder().setAgentId(offer.getAgentId()).setExecutor(ExecutorInfo.newBuilder().setExecutorId(ExecutorID.newBuilder().setValue("executorID"))).setTaskId(taskIdProto).setName("name").build();
SingularityTask task = new SingularityTask(taskRequest, taskId, Collections.singletonList(mesosProtosUtils.offerFromProtos(offer)), mesosProtosUtils.taskFromProtos(taskInfo), Optional.of("rack1"));
taskManager.savePendingTask(pendingTask);
return task;
}
use of org.apache.mesos.v1.Protos.ExecutorID in project Singularity by HubSpot.
the class SingularityMesosSchedulerClient method shutdown.
public void shutdown(ExecutorID executorId, AgentID agentId) {
Builder shutdown = build().setShutdown(Shutdown.newBuilder().setExecutorId(executorId).setAgentId(agentId));
sendCall(shutdown, Type.SHUTDOWN);
}
Aggregations