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


Java TaskStatus类代码示例

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


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

示例1: startup

import org.apache.mesos.Protos.TaskStatus; //导入依赖的package包/类
private void startup(SchedulerDriver driver, MasterInfo masterInfo) throws Exception {
  Preconditions.checkState(state == SchedulerState.STARTUP, "Asked to startup - but in invalid state: %s", state.name());

  masterInfoHolder.set(masterInfo);

  startup.startup(masterInfo, driver);

  stateLock.lock(); // ensure we aren't adding queued updates. calls to status updates are now blocked.

  try {
    state = SchedulerState.RUNNING; // calls to resource offers will now block, since we are already scheduler locked.

    for (Protos.TaskStatus status : queuedUpdates) {
      scheduler.statusUpdate(driver, status);
    }

  } finally {
    stateLock.unlock();
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:21,代码来源:SingularityMesosSchedulerDelegator.java

示例2: startReconciliation

import org.apache.mesos.Protos.TaskStatus; //导入依赖的package包/类
public ReconciliationState startReconciliation() {
  if (!isRunningReconciliation.compareAndSet(false, true)) {
    LOG.info("Reconciliation is already running, NOT starting a new reconciliation process");
    return ReconciliationState.ALREADY_RUNNING;
  }

  Optional<SchedulerDriver> schedulerDriver = schedulerDriverSupplier.get();

  if (!schedulerDriver.isPresent()) {
    LOG.trace("Not running reconciliation - no schedulerDriver present");
    isRunningReconciliation.set(false);
    return ReconciliationState.NO_DRIVER;
  }

  final long reconciliationStart = System.currentTimeMillis();
  final List<SingularityTaskId> activeTaskIds = taskManager.getActiveTaskIds();

  LOG.info("Starting a reconciliation cycle - {} current active tasks", activeTaskIds.size());

  SchedulerDriver driver = schedulerDriver.get();
  driver.reconcileTasks(Collections.<TaskStatus> emptyList());

  scheduleReconciliationCheck(driver, reconciliationStart, activeTaskIds, 0);

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

示例3: logStatusUpdate

import org.apache.mesos.Protos.TaskStatus; //导入依赖的package包/类
private static void logStatusUpdate(Logger logger, TaskStatus status) {
  // Periodic task reconciliation runs generate a large amount of no-op messages.
  // Suppress logging for reconciliation status updates by default.
  boolean debugLevel = status.hasReason() && status.getReason() == REASON_RECONCILIATION;

  StringBuilder message = new StringBuilder("Received status update for task ")
      .append(status.getTaskId().getValue())
      .append(" in state ")
      .append(status.getState());
  if (status.hasSource()) {
    message.append(" from ").append(status.getSource());
  }
  if (status.hasReason()) {
    message.append(" with ").append(status.getReason());
  }
  if (status.hasMessage()) {
    message.append(": ").append(status.getMessage());
  }
  if (debugLevel) {
    logger.debug(message.toString());
  } else {
    logger.info(message.toString());
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:25,代码来源:MesosSchedulerImpl.java

示例4: statusUpdate

import org.apache.mesos.Protos.TaskStatus; //导入依赖的package包/类
@AllowUnchecked
@Timed("scheduler_status_update")
@Override
public void statusUpdate(SchedulerDriver driver, TaskStatus status) {
  logStatusUpdate(log, status);
  eventSink.post(new TaskStatusReceived(
      status.getState(),
      Optional.fromNullable(status.getSource()),
      status.hasReason() ? Optional.of(status.getReason()) : Optional.absent(),
      Optional.fromNullable(status.getTimestamp()).transform(SECONDS_TO_MICROS)));

  try {
    // The status handler is responsible for acknowledging the update.
    taskStatusHandler.statusUpdate(status);
  } catch (SchedulerException e) {
    log.error("Status update failed due to scheduler exception: " + e, e);
    // We re-throw the exception here to trigger an abort of the driver.
    throw e;
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:21,代码来源:MesosSchedulerImpl.java

示例5: killTask

import org.apache.mesos.Protos.TaskStatus; //导入依赖的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

示例6: killedWorker

import org.apache.mesos.Protos.TaskStatus; //导入依赖的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

示例7: start

import org.apache.mesos.Protos.TaskStatus; //导入依赖的package包/类
@Override
public void start() {
    Collection<Protos.TaskStatus> taskStatuses = new ArrayList<>();
    try {
        taskStatuses.addAll(stateStore.fetchStatuses());
    } catch (Exception e) {
        throw new RuntimeException("Failed to initialize TaskStatuses for reconciliation with exception: ", e);
    }

    synchronized (unreconciled) {
        for (TaskStatus status : taskStatuses) {
            if (!TaskUtils.isTerminal(status)) {
                unreconciled.put(status.getTaskId().getValue(), status);
            }
        }
        // even if the scheduler thinks no tasks are launched, we should still always perform
        // implicit reconciliation:
        isImplicitReconciliationTriggered.set(false);
        LOGGER.info("Added {} unreconciled tasks to reconciler: {} tasks to reconcile: {}",
                taskStatuses.size(), unreconciled.size(), unreconciled.keySet());
    }
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:23,代码来源:DefaultReconciler.java

示例8: isRecoveryNeeded

import org.apache.mesos.Protos.TaskStatus; //导入依赖的package包/类
/**
 * Returns whether the provided {@link TaskStatus} shows that the task needs to recover.
 */
public static boolean isRecoveryNeeded(TaskStatus taskStatus) {
    switch (taskStatus.getState()) {
        case TASK_FINISHED:
        case TASK_FAILED:
        case TASK_KILLED:
        case TASK_ERROR:
        case TASK_LOST:
            return true;
        case TASK_KILLING:
        case TASK_RUNNING:
        case TASK_STAGING:
        case TASK_STARTING:
            break;
    }

    return false;
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:21,代码来源:TaskUtils.java

示例9: acknowledgeStatusUpdate

import org.apache.mesos.Protos.TaskStatus; //导入依赖的package包/类
@Override
public Status acknowledgeStatusUpdate(final TaskStatus taskStatus)
{
    checkNotNull(taskStatus, "taskStatus is null");
    checkState(!implicitAcknowledges, "Can not call acknowledgeStatusUpdate with implicitAcknowledges turned off");

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

    final StatusUpdateAcknowledgementMessage message = StatusUpdateAcknowledgementMessage.newBuilder()
        .setFrameworkId(context.getFrameworkId())
        .setSlaveId(taskStatus.getSlaveId())
        .setTaskId(taskStatus.getTaskId())
        .setUuid(taskStatus.getUuid())
        .build();

    eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), message));

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

示例10: launchTask

import org.apache.mesos.Protos.TaskStatus; //导入依赖的package包/类
@Override
public void launchTask(ExecutorDriver driver, TaskInfo task) {
    int port = MesosCommon.portFromTaskId(task.getTaskId().getValue());
    try {
        LOG.info("Received task assignment for port " + port);
        _state.put(port, true);
    } catch (IOException e) {
        LOG.error("Halting process...", e);
        Runtime.getRuntime().halt(1);
    }
    TaskStatus status = TaskStatus.newBuilder()
            .setState(TaskState.TASK_RUNNING)
            .setTaskId(task.getTaskId())
            .build();
    driver.sendStatusUpdate(status);
}
 
开发者ID:deric,项目名称:storm-mesos,代码行数:17,代码来源:MesosSupervisor.java

示例11: onRuntimeError

import org.apache.mesos.Protos.TaskStatus; //导入依赖的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

示例12: assertJobRun

import org.apache.mesos.Protos.TaskStatus; //导入依赖的package包/类
@Test
public void assertJobRun() throws Exception {
    when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
    when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestScriptJobConfiguration("test.sh"));
    daemonJob.execute(jobExecutionContext);
    verify(shardingContexts).setAllowSendJobEvent(true);
    verify(executorDriver).sendStatusUpdate(TaskStatus.newBuilder().setTaskId(taskId).setState(TaskState.TASK_RUNNING).setMessage("BEGIN").build());
    verify(executorDriver).sendStatusUpdate(TaskStatus.newBuilder().setTaskId(taskId).setState(TaskState.TASK_RUNNING).setMessage("COMPLETE").build());
    verify(shardingContexts).setCurrentJobEventSamplingCount(0);
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:11,代码来源:DaemonTaskSchedulerTest.java

示例13: assertJobRunWithEventSampling

import org.apache.mesos.Protos.TaskStatus; //导入依赖的package包/类
@Test
public void assertJobRunWithEventSampling() throws Exception {
    when(shardingContexts.getJobEventSamplingCount()).thenReturn(2);
    when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
    when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestScriptJobConfiguration("test.sh"));
    daemonJob.execute(jobExecutionContext);
    verify(shardingContexts).setCurrentJobEventSamplingCount(1);
    verify(shardingContexts).setAllowSendJobEvent(false);
    when(shardingContexts.getCurrentJobEventSamplingCount()).thenReturn(1);
    daemonJob.execute(jobExecutionContext);
    verify(shardingContexts).setAllowSendJobEvent(true);
    verify(executorDriver).sendStatusUpdate(TaskStatus.newBuilder().setTaskId(taskId).setState(TaskState.TASK_RUNNING).setMessage("BEGIN").build());
    verify(executorDriver).sendStatusUpdate(TaskStatus.newBuilder().setTaskId(taskId).setState(TaskState.TASK_RUNNING).setMessage("COMPLETE").build());
    verify(shardingContexts).setCurrentJobEventSamplingCount(0);
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:16,代码来源:DaemonTaskSchedulerTest.java

示例14: statusUpdate

import org.apache.mesos.Protos.TaskStatus; //导入依赖的package包/类
@POST
@Path("/scheduler/statusUpdate/{taskId}/{taskState}")
@ApiOperation("Force an update for a specific task.")
public void statusUpdate(@PathParam("taskId") String taskId, @PathParam("taskState") String taskState) {
  checkForbidden(configuration.isAllowTestResourceCalls(), "Test resource calls are disabled (set isAllowTestResourceCalls to true in configuration)");

  driver.getScheduler().statusUpdate(null, TaskStatus.newBuilder()
      .setTaskId(TaskID.newBuilder().setValue(taskId))
      .setState(TaskState.valueOf(taskState))
      .build());
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:12,代码来源:TestResource.java

示例15: applyMigration

import org.apache.mesos.Protos.TaskStatus; //导入依赖的package包/类
@Override
public void applyMigration() {
  final long start = System.currentTimeMillis();
  final List<SingularityTaskId> taskIds = taskManager.getActiveTaskIds();

  for (SingularityTaskId taskId : taskIds) {
    List<SingularityTaskHistoryUpdate> updates = Lists.reverse(taskManager.getTaskHistoryUpdates(taskId));
    Optional<TaskStatus> taskStatus = Optional.absent();

    for (SingularityTaskHistoryUpdate update : updates) {
      if (update.getTaskState().toTaskState().isPresent()) {
        Optional<SingularityTask> task = taskManager.getTask(taskId);

        taskStatus = Optional.of(TaskStatus.newBuilder()
            .setTaskId(TaskID.newBuilder().setValue(taskId.getId()))
            .setSlaveId(task.get().getOffer().getSlaveId())
            .setState(update.getTaskState().toTaskState().get())
            .build());

        break;
      }
    }

    SingularityTaskStatusHolder taskStatusHolder = new SingularityTaskStatusHolder(taskId, taskStatus, start, serverId, Optional.<String> absent());

    taskManager.saveLastActiveTaskStatus(taskStatusHolder);
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:29,代码来源:LastTaskStatusMigration.java


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