Search in sources :

Example 6 with TaskInfo

use of org.apache.mesos.Protos.TaskInfo in project elastic-job by dangdangdotcom.

the class TaskExecutorThreadTest method assertLaunchTaskWithTransientTaskAndSpringSimpleJob.

@Test
public void assertLaunchTaskWithTransientTaskAndSpringSimpleJob() {
    TaskInfo taskInfo = buildSpringDaemonTaskInfo();
    TaskThread taskThread = new TaskExecutor().new TaskThread(executorDriver, taskInfo);
    taskThread.run();
    verify(executorDriver).sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskInfo.getTaskId()).setState(TaskState.TASK_RUNNING).build());
}
Also used : TaskInfo(org.apache.mesos.Protos.TaskInfo) TaskThread(com.dangdang.ddframe.job.cloud.executor.TaskExecutor.TaskThread) Test(org.junit.Test)

Example 7 with TaskInfo

use of org.apache.mesos.Protos.TaskInfo in project elastic-job by dangdangdotcom.

the class TaskExecutorThreadTest method assertLaunchTaskWithWrongClass.

@Test
public void assertLaunchTaskWithWrongClass() {
    TaskInfo taskInfo = buildWrongClass();
    TaskThread taskThread = new TaskExecutor().new TaskThread(executorDriver, taskInfo);
    try {
        taskThread.run();
    } catch (final JobSystemException ex) {
        assertTrue(ex.getMessage().startsWith("Elastic-Job: Class 'WrongClass' initialize failure, the error message is 'WrongClass'."));
    }
}
Also used : TaskInfo(org.apache.mesos.Protos.TaskInfo) TaskThread(com.dangdang.ddframe.job.cloud.executor.TaskExecutor.TaskThread) JobSystemException(com.dangdang.ddframe.job.exception.JobSystemException) Test(org.junit.Test)

Example 8 with TaskInfo

use of org.apache.mesos.Protos.TaskInfo in project elastic-job by dangdangdotcom.

the class TaskLaunchScheduledService method getTaskInfoList.

private List<Protos.TaskInfo> getTaskInfoList(final Collection<String> integrityViolationJobs, final VMAssignmentResult vmAssignmentResult, final String hostname, final Protos.SlaveID slaveId) {
    List<Protos.TaskInfo> result = new ArrayList<>(vmAssignmentResult.getTasksAssigned().size());
    for (TaskAssignmentResult each : vmAssignmentResult.getTasksAssigned()) {
        TaskContext taskContext = TaskContext.from(each.getTaskId());
        String jobName = taskContext.getMetaInfo().getJobName();
        if (!integrityViolationJobs.contains(jobName) && !facadeService.isRunning(taskContext) && !facadeService.isJobDisabled(jobName)) {
            Protos.TaskInfo taskInfo = getTaskInfo(slaveId, each);
            if (null != taskInfo) {
                result.add(taskInfo);
                facadeService.addMapping(taskInfo.getTaskId().getValue(), hostname);
                taskScheduler.getTaskAssigner().call(each.getRequest(), hostname);
            }
        }
    }
    return result;
}
Also used : TaskInfo(org.apache.mesos.Protos.TaskInfo) TaskContext(com.dangdang.ddframe.job.context.TaskContext) Protos(org.apache.mesos.Protos) ArrayList(java.util.ArrayList) TaskAssignmentResult(com.netflix.fenzo.TaskAssignmentResult) ByteString(com.google.protobuf.ByteString) TaskInfo(org.apache.mesos.Protos.TaskInfo)

Example 9 with TaskInfo

use of org.apache.mesos.Protos.TaskInfo in project jesos by groupon.

the class LocalExecutorMessageProcessor method runTask.

@Subscribe
public void runTask(final RunTaskMessageEnvelope envelope) {
    checkState(envelope.getRecipient().equals(context.getDriverUPID()), "Received a remote message for local delivery");
    if (context.isStateMachine(DRIVER_ABORTED)) {
        LOG.warn("driver is aborted!");
        return;
    }
    final RunTaskMessage message = envelope.getMessage();
    final TaskInfo task = message.getTask();
    checkState(!tasks.containsKey(task.getTaskId()), "Task %s already started!", task.getTaskId().getValue());
    tasks.put(task.getTaskId(), task);
    eventBus.post(new ExecutorCallback() {

        @Override
        public Runnable getCallback(final Executor executor, final ExecutorDriver executorDriver) {
            return new Runnable() {

                @Override
                public void run() {
                    executor.launchTask(executorDriver, task);
                }

                @Override
                public String toString() {
                    return "callback for launchTask()";
                }
            };
        }
    });
}
Also used : TaskInfo(org.apache.mesos.Protos.TaskInfo) Executor(org.apache.mesos.Executor) RunTaskMessage(mesos.internal.Messages.RunTaskMessage) ExecutorDriver(org.apache.mesos.ExecutorDriver) Subscribe(com.google.common.eventbus.Subscribe)

Example 10 with TaskInfo

use of org.apache.mesos.Protos.TaskInfo in project storm-mesos by nathanmarz.

the class MesosNimbus method assignSlots.

@Override
public void assignSlots(Topologies topologies, Map<String, Collection<WorkerSlot>> slots) {
    synchronized (OFFERS_LOCK) {
        Map<OfferID, List<TaskInfo>> toLaunch = new HashMap();
        for (String topologyId : slots.keySet()) {
            for (WorkerSlot slot : slots.get(topologyId)) {
                OfferID id = findOffer(slot);
                Offer offer = _offers.get(id);
                if (id != null) {
                    if (!toLaunch.containsKey(id)) {
                        toLaunch.put(id, new ArrayList());
                    }
                    TopologyDetails details = topologies.getById(topologyId);
                    int cpu = MesosCommon.topologyCpu(_conf, details);
                    int mem = MesosCommon.topologyMem(_conf, details);
                    Map executorData = new HashMap();
                    executorData.put(MesosCommon.SUPERVISOR_ID, slot.getNodeId() + "-" + details.getId());
                    executorData.put(MesosCommon.ASSIGNMENT_ID, slot.getNodeId());
                    String executorDataStr = JSONValue.toJSONString(executorData);
                    LOG.info("Launching task with executor data: <" + executorDataStr + ">");
                    TaskInfo task = TaskInfo.newBuilder().setName("worker " + slot.getNodeId() + ":" + slot.getPort()).setTaskId(TaskID.newBuilder().setValue(MesosCommon.taskId(slot.getNodeId(), slot.getPort()))).setSlaveId(offer.getSlaveId()).setExecutor(ExecutorInfo.newBuilder().setExecutorId(ExecutorID.newBuilder().setValue(details.getId())).setData(ByteString.copyFromUtf8(executorDataStr)).setCommand(CommandInfo.newBuilder().addUris(URI.newBuilder().setValue((String) _conf.get(CONF_EXECUTOR_URI))).setValue("cd storm-mesos* && python bin/storm-mesos supervisor"))).addResources(Resource.newBuilder().setName("cpus").setType(Type.SCALAR).setScalar(Scalar.newBuilder().setValue(cpu))).addResources(Resource.newBuilder().setName("mem").setType(Type.SCALAR).setScalar(Scalar.newBuilder().setValue(mem))).addResources(Resource.newBuilder().setName("ports").setType(Type.RANGES).setRanges(Ranges.newBuilder().addRange(Range.newBuilder().setBegin(slot.getPort()).setEnd(slot.getPort())))).build();
                    toLaunch.get(id).add(task);
                }
            }
        }
        for (OfferID id : toLaunch.keySet()) {
            List<TaskInfo> tasks = toLaunch.get(id);
            LOG.info("Launching tasks for offer " + id.getValue() + "\n" + tasks.toString());
            _driver.launchTasks(id, tasks);
            _offers.remove(id);
        }
    }
}
Also used : ByteString(com.google.protobuf.ByteString) TopologyDetails(backtype.storm.scheduler.TopologyDetails) OfferID(org.apache.mesos.Protos.OfferID) TaskInfo(org.apache.mesos.Protos.TaskInfo) WorkerSlot(backtype.storm.scheduler.WorkerSlot) Offer(org.apache.mesos.Protos.Offer)

Aggregations

TaskInfo (org.apache.mesos.Protos.TaskInfo)10 TaskThread (com.dangdang.ddframe.job.cloud.executor.TaskExecutor.TaskThread)5 Test (org.junit.Test)5 TaskContext (com.dangdang.ddframe.job.context.TaskContext)2 JobSystemException (com.dangdang.ddframe.job.exception.JobSystemException)2 ByteString (com.google.protobuf.ByteString)2 ArrayList (java.util.ArrayList)2 Protos (org.apache.mesos.Protos)2 OfferID (org.apache.mesos.Protos.OfferID)2 TopologyDetails (backtype.storm.scheduler.TopologyDetails)1 WorkerSlot (backtype.storm.scheduler.WorkerSlot)1 ImmutableList (com.google.common.collect.ImmutableList)1 Subscribe (com.google.common.eventbus.Subscribe)1 RemoteMessageEnvelope (com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope)1 TaskAssignmentResult (com.netflix.fenzo.TaskAssignmentResult)1 VMAssignmentResult (com.netflix.fenzo.VMAssignmentResult)1 VirtualMachineLease (com.netflix.fenzo.VirtualMachineLease)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1