本文整理汇总了Java中org.apache.mesos.Protos.TaskState类的典型用法代码示例。如果您正苦于以下问题:Java TaskState类的具体用法?Java TaskState怎么用?Java TaskState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TaskState类属于org.apache.mesos.Protos包,在下文中一共展示了TaskState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runLaunchedTasks
import org.apache.mesos.Protos.TaskState; //导入依赖的package包/类
protected void runLaunchedTasks() {
for (SingularityTaskId taskId : taskManager.getActiveTaskIds()) {
Collection<SingularityTaskHistoryUpdate> updates = taskManager.getTaskHistoryUpdates(taskId);
SimplifiedTaskState currentState = SingularityTaskHistoryUpdate.getCurrentState(updates);
switch (currentState) {
case UNKNOWN:
case WAITING:
statusUpdate(taskManager.getTask(taskId).get(), TaskState.TASK_RUNNING);
break;
case DONE:
case RUNNING:
break;
}
}
}
示例2: testDeployFails
import org.apache.mesos.Protos.TaskState; //导入依赖的package包/类
@Test
public void testDeployFails() {
initRequest();
SingularityRequest request = requestResource.getRequest(requestId).getRequest();
initFirstDeploy();
SingularityTask firstTask = launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING);
deploy(secondDeployId, Optional.<Boolean>absent(), Optional.of(1), Optional.of(false), false);
deployChecker.checkDeploys();
scheduler.drainPendingQueue(stateCacheProvider.get());
Assert.assertEquals(1, taskManager.getPendingTaskIds().size());
resourceOffers();
Assert.assertEquals(1, taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId).size());
SingularityTaskId firstNewTaskId = taskManager.getActiveTaskIdsForDeploy(requestId, secondDeployId).get(0);
statusUpdate(taskManager.getTask(firstNewTaskId).get(), TaskState.TASK_FAILED);
deployChecker.checkDeploys();
Assert.assertFalse(taskManager.getCleanupTaskIds().contains(firstTask.getTaskId()));
Assert.assertEquals(DeployState.FAILED, deployManager.getDeployResult(requestId, secondDeployId).get().getDeployState());
}
示例3: testDeployFailsAfterMaxTaskRetries
import org.apache.mesos.Protos.TaskState; //导入依赖的package包/类
public void testDeployFailsAfterMaxTaskRetries() {
initRequest();
SingularityDeployBuilder db = new SingularityDeployBuilder(requestId, firstDeployId);
db.setMaxTaskRetries(Optional.of(1));
SingularityDeploy deploy = initDeploy(db, System.currentTimeMillis());
deployChecker.checkDeploys();
Assert.assertTrue(!deployManager.getDeployResult(requestId, firstDeployId).isPresent());
SingularityTask task = launchTask(request, deploy, System.currentTimeMillis(), 1, TaskState.TASK_FAILED);
deployChecker.checkDeploys();
Assert.assertEquals(deployManager.getPendingDeploys().get(0).getCurrentDeployState(), DeployState.WAITING);
SingularityTask taskTryTwo = launchTask(request, deploy, System.currentTimeMillis(), 1, TaskState.TASK_FAILED);
deployChecker.checkDeploys();
Assert.assertEquals(deployManager.getDeployResult(requestId, firstDeployId).get().getDeployState(), DeployState.FAILED);
}
示例4: testDeploySucceedsWithTaskRetries
import org.apache.mesos.Protos.TaskState; //导入依赖的package包/类
@Test
public void testDeploySucceedsWithTaskRetries() {
initRequest();
SingularityDeployBuilder db = new SingularityDeployBuilder(requestId, firstDeployId);
db.setMaxTaskRetries(Optional.of(1));
SingularityDeploy deploy = initDeploy(db, System.currentTimeMillis());
deployChecker.checkDeploys();
Assert.assertTrue(!deployManager.getDeployResult(requestId, firstDeployId).isPresent());
SingularityTask task = launchTask(request, deploy, System.currentTimeMillis(), 1, TaskState.TASK_FAILED);
deployChecker.checkDeploys();
Assert.assertEquals(deployManager.getPendingDeploys().get(0).getCurrentDeployState(), DeployState.WAITING);
SingularityTask taskTryTwo = launchTask(request, deploy, System.currentTimeMillis(), 1, TaskState.TASK_RUNNING);
deployChecker.checkDeploys();
Assert.assertEquals(deployManager.getDeployResult(requestId, firstDeployId).get().getDeployState(), DeployState.SUCCEEDED);
}
示例5: testCleanerLeavesPausedRequestTasksByDemand
import org.apache.mesos.Protos.TaskState; //导入依赖的package包/类
@Test
public void testCleanerLeavesPausedRequestTasksByDemand() {
initScheduledRequest();
initFirstDeploy();
SingularityTask firstTask = launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING);
createAndSchedulePendingTask(firstDeployId);
requestResource.pause(requestId, Optional.of(new SingularityPauseRequest(Optional.of(false), Optional.<Long> absent(), Optional.<String> absent(), Optional.<String>absent())));
cleaner.drainCleanupQueue();
Assert.assertTrue(taskManager.getKilledTaskIdRecords().isEmpty());
Assert.assertTrue(taskManager.getPendingTaskIds().isEmpty());
Assert.assertTrue(requestManager.getCleanupRequests().isEmpty());
statusUpdate(firstTask, TaskState.TASK_FINISHED);
// make sure something new isn't scheduled!
Assert.assertTrue(taskManager.getPendingTaskIds().isEmpty());
}
示例6: testCooldownOnlyWhenTasksRapidlyFail
import org.apache.mesos.Protos.TaskState; //导入依赖的package包/类
@Test
public void testCooldownOnlyWhenTasksRapidlyFail() {
initRequest();
initFirstDeploy();
configuration.setCooldownAfterFailures(1);
SingularityTask firstTask = startTask(firstDeploy);
statusUpdate(firstTask, TaskState.TASK_FAILED, Optional.of(System.currentTimeMillis() - TimeUnit.HOURS.toMillis(5)));
Assert.assertTrue(requestManager.getRequest(requestId).get().getState() == RequestState.ACTIVE);
SingularityTask secondTask = startTask(firstDeploy);
statusUpdate(secondTask, TaskState.TASK_FAILED);
Assert.assertTrue(requestManager.getRequest(requestId).get().getState() == RequestState.SYSTEM_COOLDOWN);
}
示例7: onFinish
import org.apache.mesos.Protos.TaskState; //导入依赖的package包/类
private void onFinish(SingularityExecutorTask task, Protos.TaskState taskState) {
processKiller.cancelDestroyFuture(task.getTaskId());
tasks.remove(task.getTaskId());
processRunningTasks.remove(task.getTaskId());
processBuildingTasks.remove(task.getTaskId());
task.cleanup(taskState);
ListeningExecutorService executorService = taskToShellCommandPool.remove(task.getTaskId());
if (executorService != null) {
executorService.shutdownNow();
try {
executorService.awaitTermination(5, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
LOG.warn("Awaiting shutdown of shell executor service", e);
}
}
logging.stopTaskLogger(task.getTaskId(), task.getLogbackLog());
checkIdleExecutorShutdown(task.getDriver());
}
示例8: call
import org.apache.mesos.Protos.TaskState; //导入依赖的package包/类
@Override
public ProcessBuilder call() throws Exception {
if (task.getTaskInfo().hasContainer() && task.getTaskInfo().getContainer().hasDocker()) {
executorUtils.sendStatusUpdate(task.getDriver(), task.getTaskInfo(), TaskState.TASK_STARTING, String.format("Pulling image... (executor pid: %s)", executorPid), task.getLog());
try {
dockerUtils.pull(task.getTaskInfo().getContainer().getDocker().getImage());
} catch (DockerException e) {
throw new ProcessFailedException("Could not pull docker image", e);
}
}
executorUtils.sendStatusUpdate(task.getDriver(), task.getTaskInfo(), TaskState.TASK_STARTING, String.format("Staging files... (executor pid: %s)", executorPid), task.getLog());
taskArtifactFetcher = Optional.of(artifactFetcher.buildTaskFetcher(executorData, task));
taskArtifactFetcher.get().fetchFiles();
task.getArtifactVerifier().checkSignatures();
ProcessBuilder processBuilder = buildProcessBuilder(task.getTaskInfo(), executorData);
task.getTaskLogManager().setup();
return processBuilder;
}
示例9: killedWorker
import org.apache.mesos.Protos.TaskState; //导入依赖的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);
}
示例10: isTerminal
import org.apache.mesos.Protos.TaskState; //导入依赖的package包/类
/**
* Returns whether the provided {@link TaskState} has reached a terminal state.
*/
public static boolean isTerminal(TaskState taskState) {
switch (taskState) {
case TASK_FINISHED:
case TASK_FAILED:
case TASK_KILLED:
case TASK_ERROR:
return true;
case TASK_LOST:
case TASK_KILLING:
case TASK_RUNNING:
case TASK_STAGING:
case TASK_STARTING:
break;
}
return false;
}
示例11: launchTask
import org.apache.mesos.Protos.TaskState; //导入依赖的package包/类
@Override
public void launchTask(ExecutorDriver executorDriver, TaskInfo taskInfo) {
TaskID taskId = taskInfo.getTaskId();
eventObserver.init(taskId,getDetailsFile(), this);
processObserver.init(this, taskId);
sendTaskStatusUpdate(executorDriver,taskId,TaskState.TASK_STARTING);
try {
File file = fileFetcher.getFile(taskInfo);
this.fileName = file.getAbsolutePath();
writeFileNameForHook();
startListeningToDockerBus(taskId);
updateImagesAndStartCompose(taskId);
sendTaskStatusUpdate(executorDriver,taskId,TaskState.TASK_RUNNING);
}catch (Exception e) {
log.error("exception while launching process",e);
sendTaskStatusUpdate(executorDriver,taskId,TaskState.TASK_FAILED);
}
}
示例12: launchTask
import org.apache.mesos.Protos.TaskState; //导入依赖的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);
}
示例13: onRuntimeError
import org.apache.mesos.Protos.TaskState; //导入依赖的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();
}
示例14: taskFinished
import org.apache.mesos.Protos.TaskState; //导入依赖的package包/类
@Override
public void taskFinished(Task task, org.bds.task.TaskState taskState) {
String tid = task.getId();
if (debug) Gpr.debug("Task " + tid + " finished");
CmdInfo cmdInfo = cmdInfoById.get(tid);
if (cmdInfo == null) {
if (debug) Gpr.debug("Task '" + tid + "' not found");
return;
}
// Change Mesos task status to FINISHED
changeTaskState(cmdInfo.executorDriver, cmdInfo.taskInfo, TaskState.TASK_FINISHED);
// Clean up
cmdInfoById.remove(tid);
}
示例15: assertLaunchTaskWithDaemonTaskAndJavaSimpleJob
import org.apache.mesos.Protos.TaskState; //导入依赖的package包/类
@Test
public void assertLaunchTaskWithDaemonTaskAndJavaSimpleJob() {
TaskInfo taskInfo = buildJavaTransientTaskInfo();
TaskExecutor.TaskThread taskThread = new TaskExecutor().new TaskThread(executorDriver, taskInfo);
taskThread.run();
verify(executorDriver).sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskInfo.getTaskId()).setState(TaskState.TASK_RUNNING).build());
verify(executorDriver).sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskInfo.getTaskId()).setState(Protos.TaskState.TASK_FINISHED).build());
}