本文整理汇总了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();
}
}
示例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;
}
示例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());
}
}
示例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;
}
}
示例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();
}
}
示例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);
}
示例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());
}
}
示例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;
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
}