Search in sources :

Example 1 with ExecutorID

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);
}
Also used : MesosClientBuilder(com.mesosphere.mesos.rx.java.MesosClientBuilder) ProtobufMesosClientBuilder(com.mesosphere.mesos.rx.java.protobuf.ProtobufMesosClientBuilder) Builder(org.apache.mesos.v1.scheduler.Protos.Call.Builder)

Example 2 with ExecutorID

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);
}
Also used : MesosClientBuilder(com.mesosphere.mesos.rx.java.MesosClientBuilder) ProtobufMesosClientBuilder(com.mesosphere.mesos.rx.java.protobuf.ProtobufMesosClientBuilder) Builder(org.apache.mesos.v1.scheduler.Protos.Call.Builder)

Example 3 with ExecutorID

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));
}
Also used : ExecutorID(org.apache.mesos.v1.Protos.ExecutorID) SingularityTask(com.hubspot.singularity.SingularityTask) SingularityTaskShellCommandRequest(com.hubspot.singularity.SingularityTaskShellCommandRequest) AgentID(org.apache.mesos.v1.Protos.AgentID)

Example 4 with ExecutorID

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;
}
Also used : TaskInfo(org.apache.mesos.v1.Protos.TaskInfo) TaskID(org.apache.mesos.v1.Protos.TaskID) SingularityTask(com.hubspot.singularity.SingularityTask) Offer(org.apache.mesos.v1.Protos.Offer) SingularityPendingTask(com.hubspot.singularity.SingularityPendingTask) SingularityTaskRequest(com.hubspot.singularity.SingularityTaskRequest) SingularityTaskId(com.hubspot.singularity.SingularityTaskId)

Example 5 with ExecutorID

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);
}
Also used : MesosClientBuilder(com.mesosphere.mesos.rx.java.MesosClientBuilder) ProtobufMesosClientBuilder(com.mesosphere.mesos.rx.java.protobuf.ProtobufMesosClientBuilder) Builder(org.apache.mesos.v1.scheduler.Protos.Call.Builder)

Aggregations

MesosClientBuilder (com.mesosphere.mesos.rx.java.MesosClientBuilder)3 ProtobufMesosClientBuilder (com.mesosphere.mesos.rx.java.protobuf.ProtobufMesosClientBuilder)3 Builder (org.apache.mesos.v1.scheduler.Protos.Call.Builder)3 SingularityTask (com.hubspot.singularity.SingularityTask)2 AgentID (org.apache.mesos.v1.Protos.AgentID)2 ExecutorID (org.apache.mesos.v1.Protos.ExecutorID)2 SingularityPendingTask (com.hubspot.singularity.SingularityPendingTask)1 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)1 SingularityTaskRequest (com.hubspot.singularity.SingularityTaskRequest)1 SingularityTaskShellCommandRequest (com.hubspot.singularity.SingularityTaskShellCommandRequest)1 Offer (org.apache.mesos.v1.Protos.Offer)1 TaskID (org.apache.mesos.v1.Protos.TaskID)1 TaskInfo (org.apache.mesos.v1.Protos.TaskInfo)1