Package org.apache.mesos.Protos

Examples of org.apache.mesos.Protos.OfferID


            }
          }
        }

        for (int i = 0; i < numOffers; i++) {
          OfferID offerId = offers.get(i).getId();
          Status status = d.launchTasks(offerId, replies.get(i));
          if (status != Status.DRIVER_RUNNING) {
            LOG.warn("SchedulerDriver returned irregular status: " + status);
          }
        }
View Full Code Here


  @Override
  public Status launchTasks(Collection<OfferID> offerIds, Collection<TaskInfo> tasks) {
    assertNotStopped();

    OfferID id = Iterables.getOnlyElement(offerIds);
    Offer offer = sentOffers.remove(id);
    checkState(offer != null, "Offer " + id + " is invalid.");

    final TaskInfo task = Iterables.getOnlyElement(tasks);
    synchronized (activeTasks) {
View Full Code Here

    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);
            }           
        }
View Full Code Here

TOP

Related Classes of org.apache.mesos.Protos.OfferID

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.