当前位置: 首页>>代码示例>>Java>>正文


Java TaskID类代码示例

本文整理汇总了Java中org.apache.mesos.Protos.TaskID的典型用法代码示例。如果您正苦于以下问题:Java TaskID类的具体用法?Java TaskID怎么用?Java TaskID使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TaskID类属于org.apache.mesos.Protos包,在下文中一共展示了TaskID类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepTask

import org.apache.mesos.Protos.TaskID; //导入依赖的package包/类
protected SingularityTask prepTask(SingularityRequest request, SingularityDeploy deploy, long launchTime, int instanceNo, boolean separateHosts) {
  SingularityPendingTask pendingTask = buildPendingTask(request, deploy, launchTime, instanceNo);
  SingularityTaskRequest taskRequest = new SingularityTaskRequest(request, deploy, pendingTask);

  Offer offer;
  if (separateHosts) {
    offer = createOffer(125, 1024, String.format("slave%s", instanceNo), String.format("host%s", instanceNo));
  } else {
    offer = createOffer(125, 1024);
  }

  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()
      .setSlaveId(offer.getSlaveId())
      .setTaskId(taskIdProto)
      .setName("name")
      .build();

  SingularityTask task = new SingularityTask(taskRequest, taskId, offer, taskInfo, Optional.of("rack1"));

  taskManager.savePendingTask(pendingTask);

  return task;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:27,代码来源:SingularitySchedulerTestBase.java

示例2: killTask

import org.apache.mesos.Protos.TaskID; //导入依赖的package包/类
@Override
public void killTask(final ExecutorDriver driver, final TaskID taskId) {
  LOG.info("Killing task : " + taskId.getValue());
  if (taskTracker != null) {
    LOG.info("Revoking task tracker map/reduce slots");
    revokeSlots();

    // Send the TASK_FINISHED status
    new Thread("TaskFinishedUpdate") {
      @Override
      public void run() {
        driver.sendStatusUpdate(TaskStatus.newBuilder()
          .setTaskId(taskId)
          .setState(TaskState.TASK_FINISHED)
          .build());
      }
    }.start();
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:20,代码来源:MesosExecutor.java

示例3: MesosTracker

import org.apache.mesos.Protos.TaskID; //导入依赖的package包/类
public MesosTracker(HttpHost host, TaskID taskId, long mapSlots,
                    long reduceSlots, MesosScheduler scheduler) {
  this.host = host;
  this.taskId = taskId;
  this.mapSlots = mapSlots;
  this.reduceSlots = reduceSlots;
  this.scheduler = scheduler;

  if (scheduler.metrics != null) {
    this.context = scheduler.metrics.trackerTimer.time();
  }

  this.idleCheckInterval = scheduler.conf.getLong("mapred.mesos.tracker.idle.interval",
                              MesosScheduler.DEFAULT_IDLE_CHECK_INTERVAL);
  this.idleCheckMax = scheduler.conf.getLong("mapred.mesos.tracker.idle.checks",
                          MesosScheduler.DEFAULT_IDLE_REVOCATION_CHECKS);

  scheduleStartupTimer();
  if (this.idleCheckInterval > 0 && this.idleCheckMax > 0) {
    scheduleIdleCheck();
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:23,代码来源:MesosTracker.java

示例4: killedWorker

import org.apache.mesos.Protos.TaskID; //导入依赖的package包/类
@Override
public void killedWorker(int port) {
  LOG.info("killedWorker: executor {} removing port {} assignment and sending " +
      "TASK_FINISHED update to Mesos", _executorId, port);
  TaskID taskId = _taskAssignments.deregister(port);
  if (taskId == null) {
    LOG.error("killedWorker: Executor {} failed to find TaskID for port {}, so not " +
        "issuing TaskStatus update to Mesos for this dead task.", _executorId, port);
    return;
  }
  TaskStatus status = TaskStatus.newBuilder()
      .setState(TaskState.TASK_FINISHED)
      .setTaskId(taskId)
      .build();
  _driver.sendStatusUpdate(status);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:17,代码来源:MesosSupervisor.java

示例5: pickAndRegisterPortNumber

import org.apache.mesos.Protos.TaskID; //导入依赖的package包/类
/**
 * Picks a port number from the given offer's port resources
 *
 * @param taskId the TaskID to register the picked ports with
 * @param offer  the offer from which's resources to pick a port
 * @return a port number
 */
public long pickAndRegisterPortNumber(TaskID taskId, Offer offer) {
    for (Resource resource : offer.getResourcesList()) {
        if (!resource.getName().equals("ports")) continue;

        List<Value.Range> offeredRanges = resource.getRanges().getRangeList();
        for (Value.Range portRange : offeredRanges) {
            long begin = portRange.getBegin();
            long end = portRange.getEnd();
            for (long port = begin; port < end; port++) {
                if (!usedPortNumbers.values().contains(port)) {
                    usedPortNumbers.put(taskId, port);
                    LOGGER.info("Task {} received port {}.", taskId, port);
                    return port;
                }
            }
        }
    }
    LOGGER.warn("Offer {} had no unused port to offer! Task {} received no port!", offer.getId().getValue(), taskId.getValue());
    return -1;
}
 
开发者ID:Praqma,项目名称:mesos-kibana,代码行数:28,代码来源:SchedulerConfiguration.java

示例6: launchTask

import org.apache.mesos.Protos.TaskID; //导入依赖的package包/类
@Override
public void launchTask(ExecutorDriver executorDriver, TaskInfo taskInfo) {
	TaskID taskId = taskInfo.getTaskId();
	eventObserver.init(taskId,getDetailsFile(), this);
	processObserver.init(this, taskId);
	sendTaskStatusUpdate(executorDriver,taskId,TaskState.TASK_STARTING);
	try {
		File file = fileFetcher.getFile(taskInfo);
		this.fileName = file.getAbsolutePath();
		writeFileNameForHook();
		startListeningToDockerBus(taskId);
		updateImagesAndStartCompose(taskId);
		sendTaskStatusUpdate(executorDriver,taskId,TaskState.TASK_RUNNING);
	}catch (Exception e) {
		log.error("exception while launching process",e);
		sendTaskStatusUpdate(executorDriver,taskId,TaskState.TASK_FAILED);
	} 
}
 
开发者ID:mohitsoni,项目名称:compose-executor,代码行数:19,代码来源:DockerComposeExecutor.java

示例7: updateImagesAndStartCompose

import org.apache.mesos.Protos.TaskID; //导入依赖的package包/类
private void updateImagesAndStartCompose(TaskID taskId){
	Observable.create(new Observable.OnSubscribe<Integer>() {
		@Override
		public void call(Subscriber<? super Integer> subscriber) {
			String pullCommand = CommandBuilder.pullImages(fileName);
			int imageUpdateExitCode = ProcessUtils.executeCommand(pullCommand, null);
			//TODO do this based on --ignore-pull-failures flag set in config
			if(imageUpdateExitCode != 0){
				log.error("unable to pull updated images trying to bring the pod up with existing images");
			}
			String launchCommand = CommandBuilder.launchTask(fileName);
			int exitCode = ProcessUtils.executeCommand(launchCommand, null);
			subscriber.onNext(exitCode);
			subscriber.onCompleted();
		}
	}).subscribeOn(Schedulers.newThread()).subscribe(processObserver);
}
 
开发者ID:mohitsoni,项目名称:compose-executor,代码行数:18,代码来源:DockerComposeExecutor.java

示例8: getTasks

import org.apache.mesos.Protos.TaskID; //导入依赖的package包/类
/**
 * De-serialize the internal ByteBuffers back into a Task map.
 *
 * @return
 */
public Map<Protos.TaskID, NodeTask> getTasks() {
  Map<Protos.TaskID, NodeTask> map = null;
  if (taskIds != null) {
    map = new HashMap<Protos.TaskID, NodeTask>(taskIds.size());
    int idx = 0;
    for (ByteBuffer bb : taskIds) {
      final Protos.TaskID taskId = ByteBufferSupport.toTaskId(bb);
      final NodeTask task = ByteBufferSupport.toNodeTask(taskNodes.get(idx++));
      if (task.getTaskPrefix() == null && taskId != null) {
        String taskPrefix = taskIdPattern.split(taskId.getValue())[0];
        task.setTaskPrefix(taskPrefix);
      }
      map.put(taskId, task);
    }
  } else {
    map = new HashMap<Protos.TaskID, NodeTask>(0);
  }
  return map;
}
 
开发者ID:apache,项目名称:incubator-myriad,代码行数:25,代码来源:StoreContext.java

示例9: kill

import org.apache.mesos.Protos.TaskID; //导入依赖的package包/类
public Status kill(final TaskID taskId) {
  LOGGER.info("Killing task {}", taskId);
  this.driverLock.lock();
  try {
    if (isRunning()) {
      this.driverStatus = driver.kill(taskId);
      LOGGER.info("Task {} killed with status: {}", taskId, this.driverStatus);
    } else {
      LOGGER.warn("Cannot kill task, driver is not running");
    }
  } finally {
    this.driverLock.unlock();
  }

  return driverStatus;
}
 
开发者ID:apache,项目名称:incubator-myriad,代码行数:17,代码来源:MyriadDriverManager.java

示例10: handleNonPendingTask

import org.apache.mesos.Protos.TaskID; //导入依赖的package包/类
private void handleNonPendingTask(TaskID taskId) { 
  /*
   * Kill the task and decline additional offers for it, but hold off removing from SchedulerState. 
   * Removal of the killable task must be done following invocation of statusUpdate callback method
   * which constitutes acknowledgement from Mesos that the kill task request succeeded.
   */
  Status status = this.driverManager.kill(taskId);
  NodeTask task = schedulerState.getTask(taskId);

  if (task != null) {
    offerLifeCycleManager.declineOutstandingOffers(task.getHostname());
  } 
  if (status.equals(Status.DRIVER_RUNNING)) {
    LOGGER.info("Kill request for {} was submitted to a running SchedulerDriver", taskId);
  } else {
    LOGGER.warn("Kill task request for {} submitted to non-running SchedulerDriver, may fail", taskId);
  }
}
 
开发者ID:apache,项目名称:incubator-myriad,代码行数:19,代码来源:TaskTerminator.java

示例11: getSchedulerState

import org.apache.mesos.Protos.TaskID; //导入依赖的package包/类
private SchedulerState getSchedulerState() throws Exception {
  SchedulerState state = new SchedulerState(new MyriadFileSystemRMStateStore());
  idOne = Protos.TaskID.newBuilder().setValue("nt-1").build();
  idTwo = Protos.TaskID.newBuilder().setValue("nt-2").build();
  idThree = Protos.TaskID.newBuilder().setValue("nt-3").build();
  TreeMap<String, Long> ports = new TreeMap<>();

  state.addTask(idOne, new NodeTask(new ServiceResourceProfile("profile1", 0.2, 1024.0, ports), new LikeConstraint("localhost", "host-[0-9]*.example.com")));
  state.addTask(idTwo, new NodeTask(new ServiceResourceProfile("profile2", 0.4, 2048.0, ports), new LikeConstraint("localhost", "host-[0-9]*.example.com")));
  state.addTask(idThree, new NodeTask(new ServiceResourceProfile("profile3", 0.6, 3072.0, ports), new LikeConstraint("localhost", "host-[0-9]*.example.com")));

  state.setFrameworkId(FrameworkID.newBuilder().setValue("mock-framework").build());
  state.makeTaskActive(idOne);
  state.makeTaskPending(idTwo);
  state.makeTaskStaging(idThree);

  return state;
}
 
开发者ID:apache,项目名称:incubator-myriad,代码行数:19,代码来源:SchedulerStateResourceTest.java

示例12: setUp

import org.apache.mesos.Protos.TaskID; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
  super.setUp();
  sState = TestObjectFactory.getSchedulerState(this.cfg, "tmp/scheduler-utils-test");
  idOne = TaskID.newBuilder().setValue("Task1").build();
  idTwo = TaskID.newBuilder().setValue("Task2").build();
  idThree = TaskID.newBuilder().setValue("Task3").build();
  taskOne = TestObjectFactory.getNodeTask("zero", "server1", 0.0, 0.0, Long.valueOf(1), Long.valueOf(2));
  taskTwo = TestObjectFactory.getNodeTask("low", "localhost", 0.2, 1024.0, Long.valueOf(1), Long.valueOf(2));
  taskThree = TestObjectFactory.getNodeTask("medium", "localhost", 0.4, 2048.0, Long.valueOf(1), Long.valueOf(2));

  sState.addTask(idOne, taskOne);
  sState.addTask(idTwo, taskTwo);  
  sState.addTask(idThree, taskThree);
  
  this.baseStateStoreDirectory = "/tmp/scheduler-utils-test";
}
 
开发者ID:apache,项目名称:incubator-myriad,代码行数:19,代码来源:SchedulerUtilsTest.java

示例13: killTask

import org.apache.mesos.Protos.TaskID; //导入依赖的package包/类
@Override
public Status killTask(final TaskID taskId)
{
    checkNotNull(taskId, "taskId is null");

    if (!context.isStateMachine(DRIVER_RUNNING)) {
        return context.getStateMachine();
    }

    final KillTaskMessage message = KillTaskMessage.newBuilder()
        .setFrameworkId(context.getFrameworkId())
        .setTaskId(taskId)
        .build();
    eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), message));

    return context.getStateMachine();
}
 
开发者ID:groupon,项目名称:jesos,代码行数:18,代码来源:InternalSchedulerDriver.java

示例14: onRuntimeError

import org.apache.mesos.Protos.TaskID; //导入依赖的package包/类
private void onRuntimeError() {
  // Shutdown REEF Evaluator
  if (this.evaluatorProcess != null) {
    this.evaluatorProcess.destroy();
  }
  mesosExecutorDriver.sendStatusUpdate(TaskStatus.newBuilder()
      .setTaskId(TaskID.newBuilder()
          .setValue(mesosExecutorId)
          .build())
      .setState(TaskState.TASK_FAILED)
      .setMessage("Evaluator Process exited with status " + String.valueOf(evaluatorProcessExitValue))
      .build());

  // Shutdown Mesos Executor
  this.executorService.shutdown();
  this.mesosExecutorDriver.stop();
}
 
开发者ID:apache,项目名称:reef,代码行数:18,代码来源:REEFExecutor.java

示例15: kill

import org.apache.mesos.Protos.TaskID; //导入依赖的package包/类
public Status kill(final TaskID taskId) {
	LOGGER.info("Killing task {}", taskId);
	this.driverLock.lock();
	try {
		if (isRunning()) {
			this.driverStatus = driver.kill(taskId);
			LOGGER.info("Task {} killed with status: {}", taskId,
					this.driverStatus);
		} else {
			LOGGER.warn("Cannot kill task, driver is not running");
		}
	} finally {
		this.driverLock.unlock();
	}

	return driverStatus;
}
 
开发者ID:eBay,项目名称:myriad,代码行数:18,代码来源:MyriadDriverManager.java


注:本文中的org.apache.mesos.Protos.TaskID类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。