本文整理汇总了Java中org.apache.mesos.Protos.TaskStatus方法的典型用法代码示例。如果您正苦于以下问题:Java Protos.TaskStatus方法的具体用法?Java Protos.TaskStatus怎么用?Java Protos.TaskStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.mesos.Protos
的用法示例。
在下文中一共展示了Protos.TaskStatus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runBenchmark
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Benchmark
public boolean runBenchmark() throws InterruptedException {
for (String taskId : org.apache.aurora.scheduler.base.Tasks.ids(tasks)) {
Protos.TaskStatus status = Protos.TaskStatus.newBuilder()
.setState(Protos.TaskState.TASK_RUNNING)
.setSource(Protos.TaskStatus.Source.SOURCE_EXECUTOR)
.setMessage("message")
.setTimestamp(1D)
.setTaskId(Protos.TaskID.newBuilder().setValue(taskId).build())
.build();
scheduler.statusUpdate(new FakeSchedulerDriver(), status);
}
// Wait for all task transitions to complete.
countDownLatch.await();
// Return an unguessable value.
return System.currentTimeMillis() % 5 == 0;
}
示例2: testRunningTaskNeedsRecoveryIfFailed
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void testRunningTaskNeedsRecoveryIfFailed() throws Exception {
ConfigStore<ServiceSpec> configStore = newConfigStore(persister);
// Create task info
Protos.TaskInfo taskInfo = newTaskInfo("name-0-node", configStore);
// Add a task to the state store
stateStore.storeTasks(ImmutableList.of(taskInfo));
Protos.TaskStatus taskStatus = newTaskStatus(taskInfo, Protos.TaskState.TASK_FAILED);
stateStore.storeStatus(taskInfo.getName(), taskStatus);
assertThat(StateStoreUtils.fetchTasksNeedingRecovery(stateStore, configStore),
is(ImmutableList.of(taskInfo)));
}
示例3: assertExplicitReconcile
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void assertExplicitReconcile() {
Map<String, Set<TaskContext>> runningTaskMap = new HashMap<>();
runningTaskMap.put("transient_test_job", Sets.newHashSet(
TaskContext.from("[email protected]@[email protected]@[email protected]@[email protected]@UUID"), TaskContext.from("[email protected]@[email protected]@[email protected]@[email protected]@UUID")));
when(facadeService.getAllRunningTasks()).thenReturn(runningTaskMap);
reconcileService.explicitReconcile();
verify(schedulerDriver).reconcileTasks(taskStatusCaptor.capture());
assertThat(taskStatusCaptor.getValue().size(), is(2));
for (Protos.TaskStatus each : taskStatusCaptor.getValue()) {
assertThat(each.getSlaveId().getValue(), is("SLAVE-S0"));
assertThat(each.getState(), is(Protos.TaskState.TASK_RUNNING));
}
}
示例4: beforeEach
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Before
public void beforeEach() {
MockitoAnnotations.initMocks(this);
final StateStore mockStateStore = Mockito.mock(StateStore.class);
final Protos.TaskStatus status = TestUtils
.generateStatus(TaskUtils.toTaskId("node-0"), Protos.TaskState.TASK_RUNNING, CassandraMode.NORMAL);
Mockito.when(mockStateStore.fetchStatus("node-0")).thenReturn(Optional.of(status));
Mockito.when(cassandraState.getStateStore()).thenReturn(mockStateStore);
}
示例5: testStateStoreWithDuplicateIdsRaisesErrorOnStatus
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test(expected = StateStoreException.class)
public void testStateStoreWithDuplicateIdsRaisesErrorOnStatus() {
// Create task info
Protos.TaskInfo taskInfo = newTaskInfo("task_1");
Protos.TaskInfo secondTask = newTaskInfo("task_2", taskInfo.getTaskId());
// Add a task to the state store
stateStore.storeTasks(ImmutableList.of(taskInfo, secondTask));
Protos.TaskStatus taskStatus = newTaskStatus(taskInfo, Protos.TaskState.TASK_UNKNOWN);
assertThat(stateStore.fetchTasks().size(), is(2));
StateStoreUtils.getTaskName(stateStore, taskStatus);
}
示例6: statusUpdate
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public void statusUpdate(SchedulerDriver driver, Protos.TaskStatus taskStatus) {
final String taskId = taskStatus.getTaskId().getValue();
loggerWrapper.taskStatus = taskStatus;
loggerWrapper.debug("Status update task " + taskId + " is in state " + taskStatus.getState());
switch (taskStatus.getState()) {
case TASK_RUNNING:
pendingInstances.remove(taskId);
runningInstances.add(taskId);
break;
case TASK_FAILED:
case TASK_LOST:
case TASK_KILLED:
pendingInstances.remove(taskId);
runningInstances.remove(taskId);
driver.stop(false);
break;
case TASK_FINISHED:
pendingInstances.remove(taskId);
runningInstances.remove(taskId);
driver.stop(false);
break;
}
loggerWrapper.debug(
"Number of instances: pending=" + pendingInstances.size() + ", running=" + runningInstances.size()
);
}
示例7: getFailedTaskStatus
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@SuppressWarnings("PMD.AvoidUsingHardCodedIP")
private Protos.TaskStatus getFailedTaskStatus(String taskId) {
return Protos.TaskStatus.newBuilder()
.setState(Protos.TaskState.TASK_FAILED)
.setTaskId(Protos.TaskID.newBuilder().setValue(taskId))
.setContainerStatus(
Protos.ContainerStatus.newBuilder()
.addNetworkInfos(Protos.NetworkInfo.newBuilder()
.addIpAddresses(Protos.NetworkInfo.IPAddress.newBuilder()
.setIpAddress("10.10.10.10"))))
.build();
}
示例8: testNonPresentTaskRaisesError
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test(expected = TaskException.class)
public void testNonPresentTaskRaisesError() throws Exception {
ConfigStore<ServiceSpec> configStore = newConfigStore(persister);
// Create task info
Protos.TaskInfo taskInfo = newTaskInfo("name-0-not-present", configStore);
// Add a task to the state store
stateStore.storeTasks(ImmutableList.of(taskInfo));
Protos.TaskStatus taskStatus = newTaskStatus(taskInfo, Protos.TaskState.TASK_RUNNING);
stateStore.storeStatus(taskInfo.getName(), taskStatus);
StateStoreUtils.fetchTasksNeedingRecovery(stateStore, configStore);
}
示例9: testMismatchedTaskIds
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void testMismatchedTaskIds() {
Protos.TaskID taskID = CommonIdUtils.toTaskId(TestConstants.TASK_NAME);
Protos.TaskInfo taskInfo = Protos.TaskInfo.newBuilder(TestConstants.TASK_INFO)
.setTaskId(taskID)
.build();
// Need the multiple storeTasks calls to trick the StateStore into doing the wrong thing
store.storeTasks(Arrays.asList(TestConstants.TASK_INFO));
store.storeStatus(TestConstants.TASK_NAME, TestConstants.TASK_STATUS);
store.storeTasks(Arrays.asList(taskInfo));
assertEquals(1, store.fetchStatuses().size());
assertEquals(1, store.fetchTasks().size());
assertNotEquals(TestConstants.TASK_ID, store.fetchTasks().stream().findAny().get().getTaskId());
assertEquals(TestConstants.TASK_ID, store.fetchStatuses().stream().findAny().get().getTaskId());
store = new StateStore(persister);
assertEquals(1, store.fetchStatuses().size());
assertEquals(1, store.fetchTasks().size());
assertEquals(TestConstants.TASK_ID, store.fetchTasks().stream().findAny().get().getTaskId());
Protos.TaskStatus taskStatus = store.fetchStatuses().stream().findAny().get();
assertEquals(TestConstants.TASK_ID, taskStatus.getTaskId());
assertEquals(Protos.TaskState.TASK_FAILED, taskStatus.getState());
taskInfo = taskInfo.toBuilder().setTaskId(TestConstants.TASK_ID).build();
assertEquals(taskInfo, store.fetchTasks().stream().findAny().get());
}
示例10: statusUpdate
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public void statusUpdate(final SchedulerDriver schedulerDriver, final Protos.TaskStatus taskStatus) {
String taskId = taskStatus.getTaskId().getValue();
TaskContext taskContext = TaskContext.from(taskId);
String jobName = taskContext.getMetaInfo().getJobName();
log.trace("call statusUpdate task state is: {}, task id is: {}", taskStatus.getState(), taskId);
jobEventBus.post(new JobStatusTraceEvent(jobName, taskContext.getId(), taskContext.getSlaveId(), JobStatusTraceEvent.Source.CLOUD_SCHEDULER,
taskContext.getType(), String.valueOf(taskContext.getMetaInfo().getShardingItems()), JobStatusTraceEvent.State.valueOf(taskStatus.getState().name()), taskStatus.getMessage()));
switch (taskStatus.getState()) {
case TASK_RUNNING:
if (!facadeService.load(jobName).isPresent()) {
schedulerDriver.killTask(Protos.TaskID.newBuilder().setValue(taskId).build());
}
if ("BEGIN".equals(taskStatus.getMessage())) {
facadeService.updateDaemonStatus(taskContext, false);
} else if ("COMPLETE".equals(taskStatus.getMessage())) {
facadeService.updateDaemonStatus(taskContext, true);
statisticManager.taskRunSuccessfully();
}
break;
case TASK_FINISHED:
facadeService.removeRunning(taskContext);
unAssignTask(taskId);
statisticManager.taskRunSuccessfully();
break;
case TASK_KILLED:
log.warn("task id is: {}, status is: {}, message is: {}, source is: {}", taskId, taskStatus.getState(), taskStatus.getMessage(), taskStatus.getSource());
facadeService.removeRunning(taskContext);
facadeService.addDaemonJobToReadyQueue(jobName);
unAssignTask(taskId);
break;
case TASK_LOST:
case TASK_DROPPED:
case TASK_GONE:
case TASK_GONE_BY_OPERATOR:
case TASK_FAILED:
case TASK_ERROR:
log.warn("task id is: {}, status is: {}, message is: {}, source is: {}", taskId, taskStatus.getState(), taskStatus.getMessage(), taskStatus.getSource());
facadeService.removeRunning(taskContext);
facadeService.recordFailoverTask(taskContext);
unAssignTask(taskId);
statisticManager.taskRunFailed();
break;
case TASK_UNKNOWN:
case TASK_UNREACHABLE:
log.error("task id is: {}, status is: {}, message is: {}, source is: {}", taskId, taskStatus.getState(), taskStatus.getMessage(), taskStatus.getSource());
statisticManager.taskRunFailed();
break;
default:
break;
}
}
示例11: create
import org.apache.mesos.Protos; //导入方法依赖的package包/类
public static BackupSnapshotStatus create(final Protos.TaskStatus status) {
return new BackupSnapshotStatus(status);
}
示例12: update
import org.apache.mesos.Protos; //导入方法依赖的package包/类
/**
* Synchronized to ensure consistency between this and {@link #updateOfferStatus(Collection)}.
*/
@Override
public synchronized void update(Protos.TaskStatus status) {
logger.debug("Step {} received status: {}", getName(), TextFormat.shortDebugString(status));
if (!tasks.containsKey(status.getTaskId())) {
logger.debug("Step {} ignoring irrelevant TaskStatus: {}",
getName(), TextFormat.shortDebugString(status));
return;
}
if (isComplete()) {
logger.debug("Step {} ignoring TaskStatus due to being Complete: {}",
getName(), TextFormat.shortDebugString(status));
return;
}
GoalState goalState = null;
try {
goalState = TaskUtils.getGoalState(
podInstanceRequirement.getPodInstance(),
CommonIdUtils.toTaskName(status.getTaskId()));
} catch (TaskException e) {
logger.error(String.format("Failed to get goal state for step %s with status %s",
getName(), getStatus()), e);
return;
}
logger.info("Goal state for: {} is: {}", status.getTaskId().getValue(), goalState.name());
switch (status.getState()) {
case TASK_ERROR:
case TASK_FAILED:
case TASK_KILLED:
case TASK_KILLING:
case TASK_LOST:
setTaskStatus(status.getTaskId(), Status.PENDING);
break;
case TASK_STAGING:
case TASK_STARTING:
setTaskStatus(status.getTaskId(), Status.STARTING);
break;
case TASK_RUNNING:
Protos.TaskInfo taskInfo = tasks.get(status.getTaskId()).getTaskInfo();
if (goalState.equals(GoalState.RUNNING)
&& new TaskLabelReader(taskInfo).isReadinessCheckSucceeded(status)) {
setTaskStatus(status.getTaskId(), Status.COMPLETE);
} else {
setTaskStatus(status.getTaskId(), Status.STARTED);
}
break;
case TASK_FINISHED:
if (
goalState.equals(GoalState.ONCE) ||
goalState.equals(GoalState.FINISH) ||
goalState.equals(GoalState.FINISHED)){
setTaskStatus(status.getTaskId(), Status.COMPLETE);
} else {
setTaskStatus(status.getTaskId(), Status.PENDING);
}
break;
default:
logger.error("Failed to process unexpected state: " + status.getState());
}
updateStatus();
}
示例13: getTasksForState
import org.apache.mesos.Protos; //导入方法依赖的package包/类
private Map<String, Protos.TaskStatus> getTasksForState(Protos.TaskState state) {
return taskStatusMap.entrySet().stream()
.filter(entry -> entry.getValue().getState().equals(state))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
示例14: processStatusUpdate
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
protected void processStatusUpdate(Protos.TaskStatus status) throws Exception {
throw new UnsupportedOperationException();
}
示例15: create
import org.apache.mesos.Protos; //导入方法依赖的package包/类
public static DownloadSnapshotStatus create(
final Protos.TaskStatus status) {
return new DownloadSnapshotStatus(status);
}