Package org.apache.mesos.Protos

Examples of org.apache.mesos.Protos.TaskID


  }

  public void terminateJenkinsSlave(String name) {
    LOGGER.info("Terminating jenkins slave " + name);

    TaskID taskId = TaskID.newBuilder().setValue(name).build();

    if (results.containsKey(taskId)) {
      LOGGER.info("Killing mesos task " + taskId);
      driver.killTask(taskId);
    } else {
View Full Code Here


      return false;
    }
  }

  private void createMesosTask(Offer offer, Request request) {
    TaskID taskId = TaskID.newBuilder().setValue(request.request.slave.name).build();

    LOGGER.info("Launching task " + taskId.getValue() + " with URI " +
                joinPaths(jenkinsMaster, SLAVE_JAR_URI_SUFFIX));

    TaskInfo task = TaskInfo
        .newBuilder()
        .setName("task " + taskId.getValue())
        .setTaskId(taskId)
        .setSlaveId(offer.getSlaveId())
        .addResources(
            Resource
                .newBuilder()
View Full Code Here

    LOGGER.info("Rescinded offer " + offerId);
  }

  @Override
  public void statusUpdate(SchedulerDriver driver, TaskStatus status) {
    TaskID taskId = status.getTaskId();
    LOGGER.info("Status update: task " + taskId + " is in state " + status.getState());

    if (!results.containsKey(taskId)) {
      throw new IllegalStateException("Unknown taskId: " + taskId);
    }
View Full Code Here

        Integer[] portArray = ports.toArray(new Integer[2]);
        HttpHost httpAddress = new HttpHost(offer.getHostname(), portArray[0]);
        HttpHost reportAddress = new HttpHost(offer.getHostname(), portArray[1]);

        TaskID taskId = TaskID.newBuilder()
            .setValue("Task_Tracker_" + launchedTrackers++).build();

        LOG.info("Launching task " + taskId.getValue() + " on "
            + httpAddress.toString());

        // Add this tracker to Mesos tasks.
        mesosTrackers.put(httpAddress, new MesosTracker(httpAddress, taskId,
            mapSlots, reduceSlots));

        // Create the environment depending on whether the executor is going to be
        // run locally.
        // TODO(vinod): Do not pass the mapred config options as environment
        // variables.
        Protos.Environment.Builder envBuilder = Protos.Environment
            .newBuilder()
            .addVariables(
                Protos.Environment.Variable
                    .newBuilder()
                    .setName("mapred.job.tracker")
                    .setValue(jobTrackerAddress.getHostName() + ':'
                        + jobTrackerAddress.getPort()))
            .addVariables(
                Protos.Environment.Variable
                    .newBuilder()
                    .setName("mapred.task.tracker.http.address")
                    .setValue(
                        httpAddress.getHostName() + ':' + httpAddress.getPort()))
            .addVariables(
                Protos.Environment.Variable
                    .newBuilder()
                    .setName("mapred.task.tracker.report.address")
                    .setValue(reportAddress.getHostName() + ':'
                        + reportAddress.getPort()))
            .addVariables(
                Protos.Environment.Variable.newBuilder()
                    .setName("mapred.map.child.java.opts")
                    .setValue("-Xmx" + slotJVMHeap + "m"))
            .addVariables(
                Protos.Environment.Variable.newBuilder()
                    .setName("mapred.reduce.child.java.opts")
                    .setValue("-Xmx" + slotJVMHeap + "m"))
            .addVariables(
                Protos.Environment.Variable.newBuilder()
                    .setName("HADOOP_HEAPSIZE")
                    .setValue("" + TASKTRACKER_JVM_HEAP));

        // Set java specific environment, appropriately.
        Map<String, String> env = System.getenv();
        if (env.containsKey("JAVA_HOME")) {
          envBuilder.addVariables(Protos.Environment.Variable.newBuilder()
              .setName("JAVA_HOME")
              .setValue(env.get("JAVA_HOME")));
        }

        if (env.containsKey("JAVA_LIBRARY_PATH")) {
          envBuilder.addVariables(Protos.Environment.Variable.newBuilder()
              .setName("JAVA_LIBRARY_PATH")
              .setValue(env.get("JAVA_LIBRARY_PATH")));
        }

        // Command info differs when performing a local run.
        CommandInfo commandInfo = null;
        String master = conf.get("mapred.mesos.master", "local");

        if (master.equals("local")) {
          try {
            commandInfo = CommandInfo.newBuilder()
                .setEnvironment(envBuilder)
                .setValue(new File("bin/mesos-executor").getCanonicalPath())
                .build();
          } catch (IOException e) {
            LOG.fatal("Failed to find Mesos executor ", e);
            System.exit(1);
          }
        } else {
          String uri = conf.get("mapred.mesos.executor");
          commandInfo = CommandInfo.newBuilder()
              .setEnvironment(envBuilder)
              .setValue("cd hadoop && ./bin/mesos-executor")
              .addUris(CommandInfo.URI.newBuilder().setValue(uri)).build();
        }

        TaskInfo info = TaskInfo
            .newBuilder()
            .setName(taskId.getValue())
            .setTaskId(taskId)
            .setSlaveId(offer.getSlaveId())
            .addResources(
                Resource
                    .newBuilder()
                    .setName("cpus")
                    .setType(Value.Type.SCALAR)
                    .setScalar(Value.Scalar.newBuilder().setValue(
                        (mapSlots + reduceSlots) * slotCpus)))
            .addResources(
                Resource
                    .newBuilder()
                    .setName("mem")
                    .setType(Value.Type.SCALAR)
                    .setScalar(Value.Scalar.newBuilder().setValue(
                        (mapSlots + reduceSlots) * slotMem)))
            .addResources(
                Resource
                    .newBuilder()
                    .setName("disk")
                    .setType(Value.Type.SCALAR)
                    .setScalar(Value.Scalar.newBuilder().setValue(
                        (mapSlots + reduceSlots) * slotDisk)))
            .addResources(
                Resource
                    .newBuilder()
                    .setName("ports")
                    .setType(Value.Type.RANGES)
                    .setRanges(
                        Value.Ranges
                            .newBuilder()
                            .addRange(Value.Range.newBuilder()
                                .setBegin(httpAddress.getPort())
                                .setEnd(httpAddress.getPort()))
                            .addRange(Value.Range.newBuilder()
                                .setBegin(reportAddress.getPort())
                                .setEnd(reportAddress.getPort()))))
            .setExecutor(
                ExecutorInfo
                    .newBuilder()
                    .setExecutorId(ExecutorID.newBuilder().setValue(
                        "executor_" + taskId.getValue()))
                    .setName("Hadoop TaskTracker")
                    .setSource(taskId.getValue())
                    .addResources(
                        Resource
                            .newBuilder()
                            .setName("cpus")
                            .setType(Value.Type.SCALAR)
View Full Code Here

      HttpHost httpAddress = new HttpHost(offer.getHostname(), portArray[0]);
      HttpHost reportAddress = new HttpHost(offer.getHostname(), portArray[1]);
      HttpHost jobTrackerAddress = new HttpHost(jobTracker.getHostname(),
          jobTracker.getTrackerPort());

      TaskID taskId = TaskID.newBuilder()
          .setValue("Task_Tracker_" + launchedTrackers++).build();

      LOG.info("Launching task " + taskId.getValue() + " on "
          + httpAddress.toString());

      // Add this tracker to Mesos tasks.
      mesosTrackers.put(httpAddress, new MesosTracker(httpAddress, taskId,
          mapSlots, reduceSlots));

      // Create the environment depending on whether the executor is going to be
      // run locally.
      // TODO(vinod): Do not pass the mapred config options as environment
      // variables.
      Protos.Environment.Builder envBuilder = Protos.Environment
          .newBuilder()
          .addVariables(
              Protos.Environment.Variable
                  .newBuilder()
                  .setName("mapred.job.tracker")
                  .setValue(jobTrackerAddress.getHostName() + ':'
                      + jobTrackerAddress.getPort()))
          .addVariables(
              Protos.Environment.Variable
                  .newBuilder()
                  .setName("mapred.task.tracker.http.address")
                  .setValue(
                      httpAddress.getHostName() + ':' + httpAddress.getPort()))
          .addVariables(
              Protos.Environment.Variable
                  .newBuilder()
                  .setName("mapred.task.tracker.report.address")
                  .setValue(reportAddress.getHostName() + ':'
                      + reportAddress.getPort()))
          .addVariables(
              Protos.Environment.Variable.newBuilder()
                  .setName("mapred.map.child.java.opts")
                  .setValue("-Xmx" + slotJVMHeap + "m"))
          .addVariables(
              Protos.Environment.Variable.newBuilder()
                  .setName("mapred.reduce.child.java.opts")
                  .setValue("-Xmx" + slotJVMHeap + "m"))
          .addVariables(
              Protos.Environment.Variable.newBuilder()
                  .setName("HADOOP_HEAPSIZE")
                  .setValue("" + TASKTRACKER_JVM_HEAP));

      // Set java specific environment, appropriately.
      Map<String, String> env = System.getenv();
      if (env.containsKey("JAVA_HOME")) {
        envBuilder.addVariables(Protos.Environment.Variable.newBuilder()
            .setName("JAVA_HOME")
            .setValue(env.get("JAVA_HOME")));
      }

      if (env.containsKey("JAVA_LIBRARY_PATH")) {
        envBuilder.addVariables(Protos.Environment.Variable.newBuilder()
            .setName("JAVA_LIBRARY_PATH")
            .setValue(env.get("JAVA_LIBRARY_PATH")));
      }

      // Command info differs when performing a local run.
      CommandInfo commandInfo = null;
      String master = conf.get("mapred.mesos.master", "local");

      if (master.equals("local")) {
        try {
          commandInfo = CommandInfo.newBuilder()
              .setEnvironment(envBuilder)
              .setValue(new File("bin/mesos-executor").getCanonicalPath())
              .build();
        } catch (IOException e) {
          LOG.fatal("Failed to find Mesos executor ", e);
          System.exit(1);
        }
      } else {
        String uri = conf.get("mapred.mesos.executor");
        commandInfo = CommandInfo.newBuilder()
            .setEnvironment(envBuilder)
            .setValue("cd hadoop && ./bin/mesos-executor")
            .addUris(CommandInfo.URI.newBuilder().setValue(uri)).build();
      }

      TaskInfo info = TaskInfo
          .newBuilder()
          .setName(taskId.getValue())
          .setTaskId(taskId)
          .setSlaveId(offer.getSlaveId())
          .addResources(
              Resource
                  .newBuilder()
                  .setName("cpus")
                  .setType(Value.Type.SCALAR)
                  .setScalar(Value.Scalar.newBuilder().setValue(
                      (mapSlots + reduceSlots) * slotCpus)))
          .addResources(
              Resource
                  .newBuilder()
                  .setName("mem")
                  .setType(Value.Type.SCALAR)
                  .setScalar(Value.Scalar.newBuilder().setValue(
                      (mapSlots + reduceSlots) * slotMem)))
          .addResources(
              Resource
                  .newBuilder()
                  .setName("disk")
                  .setType(Value.Type.SCALAR)
                  .setScalar(Value.Scalar.newBuilder().setValue(
                      (mapSlots + reduceSlots) * slotDisk)))
          .addResources(
              Resource
                  .newBuilder()
                  .setName("ports")
                  .setType(Value.Type.RANGES)
                  .setRanges(
                      Value.Ranges
                          .newBuilder()
                          .addRange(Value.Range.newBuilder()
                                        .setBegin(httpAddress.getPort())
                                        .setEnd(httpAddress.getPort()))
                          .addRange(Value.Range.newBuilder()
                                        .setBegin(reportAddress.getPort())
                                        .setEnd(reportAddress.getPort()))))
          .setExecutor(
              ExecutorInfo
                  .newBuilder()
                  .setExecutorId(ExecutorID.newBuilder().setValue(
                      "executor_" + taskId.getValue()))
                  .setName("Hadoop TaskTracker")
                  .setSource(taskId.getValue())
                  .addResources(
                      Resource
                          .newBuilder()
                          .setName("cpus")
                          .setType(Value.Type.SCALAR)
View Full Code Here

    }
  }

  private void launchTasks(SchedulerDriver schedulerDriver,
      java.util.Queue<TaskInProgress> tips, ResourceOffer offer) {
    TaskID taskId = TaskID.newBuilder().setValue("Task_" + launchedTasks++)
        .build();

    List<Long> ports = claimPorts(offer.ports, 2);

    double taskCpus = 1 * tips.size() + groomCpus;
    double taskMem = slotMemory * tips.size() + groomMem;
    double taskDisk = 10 + groomDisk;

    String uri = conf.get("hama.mesos.executor.uri");
    if (uri == null) {
      throw new RuntimeException(
          "Expecting configuration property 'mapred.mesos.executor.uri'");
    }

    String directory = conf.get("hama.mesos.executor.directory");
    if (directory == null || directory.equals("")) {
      log.info("URI: " + uri + ", name: " + new File(uri).getName());

      directory = new File(uri).getName().split("\\.")[0] + "*";
    }
    log.debug("Directory: " + directory);
    String command = conf.get("hama.mesos.executor.command");
    if (command == null || command.equals("")) {
      command = "env ; bash -x ./bin/hama org.apache.hama.bsp.MesosExecutor";
    }

    // Set up the environment for running the TaskTracker.
    Protos.Environment.Builder envBuilder = Protos.Environment.newBuilder();

    // Set java specific environment, appropriately.
    Map<String, String> env = System.getenv();
    if (env.containsKey("JAVA_HOME")) {
      envBuilder.addVariables(Protos.Environment.Variable.newBuilder()
          .setName("JAVA_HOME").setValue(env.get("JAVA_HOME")));
    }

    envBuilder.addVariables(Protos.Environment.Variable.newBuilder()
        .setName("HAMA_LOG_DIR").setValue("logs"));

    log.debug("JAVA_HOME: " + env.get("JAVA_HOME"));
    if (env.containsKey("JAVA_LIBRARY_PATH")) {
      envBuilder.addVariables(Protos.Environment.Variable.newBuilder()
          .setName("JAVA_LIBRARY_PATH").setValue(env.get("JAVA_LIBRARY_PATH")));
    }
    log.debug("JAVA_LIBRARY_PATH: " + env.get("JAVA_LIBRARY_PATH"));

    CommandInfo commandInfo = CommandInfo.newBuilder()
        .setEnvironment(envBuilder)
        .setValue(String.format("cd %s && %s", directory, command))
        .addUris(CommandInfo.URI.newBuilder().setValue(uri)).build();

    log.debug("Offer: cpus:  " + offer.cpus + " mem: " + offer.mem + "disk: "
        + offer.disk);
    log.debug("Cpu: " + taskCpus + " Mem: " + taskMem + " Disk: " + taskDisk
        + " port: " + ports.get(0));
    TaskInfo info = TaskInfo
        .newBuilder()
        .setName(taskId.getValue())
        .setTaskId(taskId)
        .setSlaveId(offer.offer.getSlaveId())
        .addResources(
            Resource.newBuilder().setName("cpus").setType(Value.Type.SCALAR)
                .setRole(offer.cpuRole)
                .setScalar(Value.Scalar.newBuilder().setValue(taskCpus)))
        .addResources(
            Resource.newBuilder().setName("mem").setType(Value.Type.SCALAR)
                .setRole(offer.memRole)
                .setScalar(Value.Scalar.newBuilder().setValue(taskMem)))
        .addResources(
            Resource.newBuilder().setName("disk").setType(Value.Type.SCALAR)
                .setRole(offer.diskRole)
                .setScalar(Value.Scalar.newBuilder().setValue(taskDisk)))
        .addResources(
            Resource
                .newBuilder()
                .setName("ports")
                .setType(Value.Type.RANGES)
                .setRole(offer.portRole)
                .setRanges(
                    Value.Ranges
                        .newBuilder()
                        .addRange(
                            Value.Range.newBuilder().setBegin(ports.get(0))
                                .setEnd(ports.get(0)))
                        .addRange(
                            Value.Range.newBuilder().setBegin(ports.get(1))
                                .setEnd(ports.get(1)))))
        .setExecutor(
            ExecutorInfo
                .newBuilder()
                .setExecutorId(
                    ExecutorID.newBuilder().setValue(
                        "executor_" + taskId.getValue()))
                .setName("Hama Groom Server").setSource(taskId.getValue())
                .setCommand(commandInfo))
        .setData(
            ByteString.copyFrom(getConfigurationOverride(ports.get(0),
                ports.get(1), tips.size(), (long) taskMem))).build();

View Full Code Here

    SingularityTaskId taskId = new SingularityTaskId(request.getId(), deploy.getId(), System.currentTimeMillis(), 1, "host", "rack");
    SingularityPendingTaskId pendingTaskId = new SingularityPendingTaskId(request.getId(), deploy.getId(), System.currentTimeMillis(), 1, PendingType.IMMEDIATE);
    SingularityPendingTask pendingTask = new SingularityPendingTask(pendingTaskId, Optional.<String> absent());
    SingularityTaskRequest taskRequest = new SingularityTaskRequest(request, deploy, pendingTask);

    TaskID taskIdProto = TaskID.newBuilder().setValue(taskId.toString()).build();

    Offer offer = createOffer(125, 1024);
    TaskInfo taskInfo = TaskInfo.newBuilder()
        .setSlaveId(offer.getSlaveId())
        .setTaskId(taskIdProto)
View Full Code Here

      LOG.info("Ignoring status update for task " + task);
      return;
    }

    // Create a Mesos TaskID from extraData.
    TaskID taskId = TaskID.newBuilder()
      .setValue(task.extraData)
      .build();

    // It appears as though we can get multiple duplicate status
    // updates for the same task, so check if we still have an active
View Full Code Here

        taskType = "map";
    }
    //LOG.info("Task type chosen: " + taskType);

    // Get a Mesos task ID for the new task
    TaskID mesosId = newMesosTaskId();

    // Remember that it is launched
    boolean isMap = taskType.equals("map");
    if (isMap) {
      unassignedMaps++;
    } else {
      unassignedReduces++;
    }
    MesosTask nt = new MesosTask(isMap, mesosId, host);
    mesosIdToMesosTask.put(mesosId, nt);
    ttInfo.add(nt);

    LOG.info("Launching Mesos task " + mesosId.getValue() +
             " as " + taskType + " on " + host);

    // Create a task description to pass back to Mesos.
    return TaskInfo.newBuilder()
        .setTaskId(mesosId)
        .setSlaveId(slaveId)
        .setName("task " + mesosId.getValue() + " (" + taskType + ")")
        .addResources(makeResource("cpus", cpusPerTask))
        .addResources(makeResource("mem", memPerTask))
        .setExecutor(getExecutorInfo())
        .build();
  }
View Full Code Here

    TaskState state = status.getState();
    LOG.info("Task " + status.getTaskId().getValue() + " is " + state);
    if (state == TaskState.TASK_FINISHED || state == TaskState.TASK_FAILED ||
        state == TaskState.TASK_KILLED || state == TaskState.TASK_LOST) {
      synchronized (jobTracker) {
        TaskID mesosId = status.getTaskId();
        MesosTask nt = mesosIdToMesosTask.get(mesosId);
        if (nt == null) {
          throw new RuntimeException(
              "Received status update for unknown task " + status.getTaskId());
        }
View Full Code Here

TOP

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

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.