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


Java TaskStatus.Builder方法代码示例

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


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

示例1: checkReconciliation

import org.apache.mesos.Protos.TaskStatus; //导入方法依赖的package包/类
private void checkReconciliation(final SchedulerDriver driver, final long reconciliationStart, final Collection<SingularityTaskId> remainingTaskIds, final int numTimes) {
  final List<SingularityTaskStatusHolder> taskStatusHolders = taskManager.getLastActiveTaskStatusesFor(remainingTaskIds);
  final List<TaskStatus> taskStatuses = Lists.newArrayListWithCapacity(taskStatusHolders.size());

  for (SingularityTaskStatusHolder taskStatusHolder : taskStatusHolders) {
    if (taskStatusHolder.getServerId().equals(serverId) && taskStatusHolder.getServerTimestamp() > reconciliationStart) {
      continue;
    }

    if (taskStatusHolder.getTaskStatus().isPresent()) {
      LOG.debug("Re-requesting task status for {}", taskStatusHolder.getTaskId());
      taskStatuses.add(taskStatusHolder.getTaskStatus().get());
    } else {
      TaskStatus.Builder fakeTaskStatusBuilder = TaskStatus.newBuilder()
          .setTaskId(TaskID.newBuilder().setValue(taskStatusHolder.getTaskId().getId()))
          .setState(TaskState.TASK_STARTING);

      if (taskStatusHolder.getSlaveId().isPresent()) {
        fakeTaskStatusBuilder.setSlaveId(SlaveID.newBuilder().setValue(taskStatusHolder.getSlaveId().get()));
      }

      LOG.info("Task {} didn't have a TaskStatus yet, submitting fake status", taskStatusHolder.getTaskId());
      taskStatuses.add(fakeTaskStatusBuilder.build());
    }
  }

  if (taskStatuses.isEmpty()) {
    LOG.info("Task reconciliation ended after {} checks and {}", numTimes, JavaUtils.duration(reconciliationStart));

    isRunningReconciliation.set(false);

    return;
  }

  LOG.info("Requesting reconciliation of {} taskStatuses, task reconciliation has been running for {}", taskStatuses.size(), JavaUtils.duration(reconciliationStart));

  driver.reconcileTasks(taskStatuses);

  scheduleReconciliationCheck(driver, reconciliationStart, remainingTaskIds, numTimes);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:41,代码来源:SingularityTaskReconciliation.java

示例2: statusUpdate

import org.apache.mesos.Protos.TaskStatus; //导入方法依赖的package包/类
protected void statusUpdate(SingularityTask task, TaskState state, Optional<Long> timestamp) {
  TaskStatus.Builder bldr = TaskStatus.newBuilder()
      .setTaskId(task.getMesosTask().getTaskId())
      .setSlaveId(task.getOffer().getSlaveId())
      .setState(state);

  if (timestamp.isPresent()) {
    bldr.setTimestamp(timestamp.get() / 1000);
  }

  sms.statusUpdate(driver, bldr.build());
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:13,代码来源:SingularitySchedulerTestBase.java

示例3: testTaskOddities

import org.apache.mesos.Protos.TaskStatus; //导入方法依赖的package包/类
@Test
public void testTaskOddities() {
  // test unparseable status update
  TaskStatus.Builder bldr = TaskStatus.newBuilder()
      .setTaskId(TaskID.newBuilder().setValue("task"))
      .setSlaveId(SlaveID.newBuilder().setValue("slave1"))
      .setState(TaskState.TASK_RUNNING);

  // should not throw exception:
  sms.statusUpdate(driver, bldr.build());

  initRequest();
  initFirstDeploy();

  SingularityTask taskOne = launchTask(request, firstDeploy, 1, TaskState.TASK_STARTING);

  taskManager.deleteTaskHistory(taskOne.getTaskId());

  Assert.assertTrue(taskManager.isActiveTask(taskOne.getTaskId().getId()));

  statusUpdate(taskOne, TaskState.TASK_RUNNING);
  statusUpdate(taskOne, TaskState.TASK_FAILED);

  Assert.assertTrue(!taskManager.isActiveTask(taskOne.getTaskId().getId()));

  Assert.assertEquals(2, taskManager.getTaskHistoryUpdates(taskOne.getTaskId()).size());
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:28,代码来源:SingularitySchedulerTest.java

示例4: assertResourceLimitBehavior

import org.apache.mesos.Protos.TaskStatus; //导入方法依赖的package包/类
private void assertResourceLimitBehavior(
    TaskStatus.Reason reason,
    Optional<String> mesosMessage,
    Optional<String> expectedMessage) throws Exception {

  storageUtil.expectWrite();

  TaskStatus.Builder taskStatusBuilder = TaskStatus.newBuilder()
      .setState(TaskState.TASK_FAILED)
      .setTaskId(TaskID.newBuilder().setValue(TASK_ID_A))
      .setReason(reason);

  if (mesosMessage.isPresent()) {
    taskStatusBuilder.setMessage(mesosMessage.get());
  }

  TaskStatus status = taskStatusBuilder.build();

  expect(stateManager.changeState(
      storageUtil.mutableStoreProvider,
      TASK_ID_A,
      Optional.absent(),
      FAILED,
      expectedMessage))
      .andReturn(StateChangeResult.SUCCESS);

  CountDownLatch latch = new CountDownLatch(1);

  driver.acknowledgeStatusUpdate(status);
  waitAndAnswer(latch);

  control.replay();

  statusHandler.statusUpdate(status);

  assertTrue(latch.await(5L, TimeUnit.SECONDS));
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:38,代码来源:TaskStatusHandlerImplTest.java

示例5: sendStatus

import org.apache.mesos.Protos.TaskStatus; //导入方法依赖的package包/类
/**
 * Sends a {@link TaskStatus} to the provided {@code driver} which contains the provided information.
 */
public static void sendStatus(ExecutorDriver driver,
                              TaskState state,
                              TaskID taskID,
                              SlaveID slaveID,
                              ExecutorID executorID,
                              String message,
                              boolean isHealthy,
                              Labels labels,
                              byte[] data) {
    final TaskStatus.Builder builder = TaskStatus.newBuilder()
            .setState(state)
            .setMessage(message)
            .setTaskId(taskID)
            .setSlaveId(slaveID)
            .setExecutorId(executorID)
            .setSource(TaskStatus.Source.SOURCE_EXECUTOR)
            .setHealthy(isHealthy);

    if (data != null) {
        builder.setData(ByteString.copyFrom(data));
    }

    if (labels != null) {
        builder.setLabels(labels);
    }

    try {
        final TaskStatus taskStatus = builder.build();
        LOGGER.info("Sending task status update: {}", TextFormat.shortDebugString(taskStatus));
        driver.sendStatusUpdate(taskStatus);
    } catch (Throwable t) {
        LOGGER.error("Failed to build task status.", t);
    }
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:38,代码来源:TaskStatusUtils.java

示例6: sendStatus

import org.apache.mesos.Protos.TaskStatus; //导入方法依赖的package包/类
private void sendStatus(TaskState state, String response) {
	TaskStatus.Builder b = TaskStatus.newBuilder()
			.setHealthy(true)
			.setState(state)
			.setTaskId(taskInfo.getTaskId());
	
	if (response != null) {
		b.setData(ByteString.copyFromUtf8(response));
	}
	TaskStatus status = b.build();
	
	driver.sendStatusUpdate(status);
}
 
开发者ID:WTIGER001,项目名称:Brigade,代码行数:14,代码来源:ProcessRunner.java

示例7: buildState

import org.apache.mesos.Protos.TaskStatus; //导入方法依赖的package包/类
private TaskStatus.Builder buildState() {
	TaskStatus.Builder b = TaskStatus.newBuilder()
			.setTaskId(taskInfo.getTaskId());
	
	return b;
}
 
开发者ID:WTIGER001,项目名称:Brigade,代码行数:7,代码来源:ProcessRunner.java

示例8: frameworkStatusUpdate

import org.apache.mesos.Protos.TaskStatus; //导入方法依赖的package包/类
@Subscribe
public void frameworkStatusUpdate(final StatusUpdateMessageEnvelope envelope)
    throws IOException
{
    checkState(envelope.getRecipient().equals(context.getDriverUPID()), "Received a remote message for local delivery");

    final UPID sender = envelope.getSender();

    if (!driverIsConnected(sender)) {
        return;
    }

    final StatusUpdateMessage statusUpdateMessage = envelope.getMessage();

    final FrameworkID frameworkId = context.getFrameworkId();
    final FrameworkID messageFrameworkId = statusUpdateMessage.getUpdate().getFrameworkId();

    checkState(frameworkId.equals(messageFrameworkId), "Received Message for framework %s, but local id is %s", messageFrameworkId, frameworkId);

    final TaskStatus.Builder taskStatusBuilder = TaskStatus.newBuilder(statusUpdateMessage.getUpdate().getStatus());
    final TaskStatus taskStatus;

    // If the update is driver-generated or master-generated, it does not require acknowledgement (from Mesos source code, sched.cpp).

    final Optional<UPID> pid = statusUpdateMessage.hasPid() ? Optional.of(UPID.create(statusUpdateMessage.getPid())) : Optional.<UPID>absent();
    final boolean noAckRequired = envelope.getSender().equals(context.getDriverUPID()) || pid.isPresent() && pid.get().equals(context.getDriverUPID());

    if (noAckRequired) {
        taskStatus = taskStatusBuilder.clearUuid().build();
    }
    else {
        taskStatus = taskStatusBuilder.setUuid(statusUpdateMessage.getUpdate().getUuid()).build();
    }

    eventBus.post(new SchedulerCallback() {
        @Override
        public Runnable getCallback(final Scheduler scheduler, final SchedulerDriver schedulerDriver)
        {
            return new Runnable() {
                @Override
                public void run()
                {
                    scheduler.statusUpdate(schedulerDriver, taskStatus);
                }
            };
        }
    });

    if (implicitAcknowledgements && !noAckRequired) {
        final StatusUpdateAcknowledgementMessage statusUpdateAcknowledgementMessage = StatusUpdateAcknowledgementMessage.newBuilder()
            .setFrameworkId(frameworkId)
            .setSlaveId(statusUpdateMessage.getUpdate().getSlaveId())
            .setTaskId(taskStatus.getTaskId())
            .setUuid(statusUpdateMessage.getUpdate().getUuid())
            .build();

        eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), statusUpdateAcknowledgementMessage));
    }
}
 
开发者ID:groupon,项目名称:jesos,代码行数:60,代码来源:LocalSchedulerMessageProcessor.java


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