本文整理汇总了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);
}
示例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());
}
示例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());
}
示例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));
}
示例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);
}
}
示例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);
}
示例7: buildState
import org.apache.mesos.Protos.TaskStatus; //导入方法依赖的package包/类
private TaskStatus.Builder buildState() {
TaskStatus.Builder b = TaskStatus.newBuilder()
.setTaskId(taskInfo.getTaskId());
return b;
}
示例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));
}
}