本文整理汇总了Java中org.apache.mesos.Protos.ExecutorInfo方法的典型用法代码示例。如果您正苦于以下问题:Java Protos.ExecutorInfo方法的具体用法?Java Protos.ExecutorInfo怎么用?Java Protos.ExecutorInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.mesos.Protos
的用法示例。
在下文中一共展示了Protos.ExecutorInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSimpleShutdown
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void testSimpleShutdown() {
final Protos.ExecutorInfo executorInfo = getTestExecutorInfo();
customExecutor.registered(mockExecutorDriver, executorInfo, null, null);
final Protos.TaskInfo taskInfo = Protos.TaskInfo
.newBuilder()
.setName(TEST)
.setTaskId(Protos.TaskID.newBuilder().setValue(UUID.randomUUID().toString()))
.setSlaveId(Protos.SlaveID.newBuilder().setValue(UUID.randomUUID().toString()))
.setExecutor(executorInfo)
.setData(createCommandInfo().toByteString())
.build();
customExecutor.launchTask(mockExecutorDriver, taskInfo);
customExecutor.shutdown(mockExecutorDriver);
}
示例2: testSimpleKill
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void testSimpleKill() {
final Protos.ExecutorInfo executorInfo = getTestExecutorInfo();
customExecutor.registered(mockExecutorDriver, executorInfo, null, null);
final Protos.TaskInfo taskInfo = Protos.TaskInfo
.newBuilder()
.setName(TEST)
.setTaskId(Protos.TaskID.newBuilder().setValue(UUID.randomUUID().toString()))
.setSlaveId(Protos.SlaveID.newBuilder().setValue(UUID.randomUUID().toString()))
.setExecutor(executorInfo)
.setData(createCommandInfo().toByteString())
.build();
customExecutor.launchTask(mockExecutorDriver, taskInfo);
customExecutor.killTask(mockExecutorDriver, taskInfo.getTaskId());
}
示例3: LaunchOfferRecommendation
import org.apache.mesos.Protos; //导入方法依赖的package包/类
public LaunchOfferRecommendation(
Offer offer,
TaskInfo originalTaskInfo,
Protos.ExecutorInfo executorInfo,
boolean shouldLaunch,
boolean useDefaultExecutor) {
this.offer = offer;
this.shouldLaunch = shouldLaunch;
this.useDefaultExecutor = useDefaultExecutor;
TaskInfo.Builder taskBuilder = originalTaskInfo.toBuilder();
if (!shouldLaunch) {
new TaskLabelWriter(taskBuilder).setTransient();
taskBuilder.getTaskIdBuilder().setValue("");
}
taskBuilder.setSlaveId(offer.getSlaveId());
this.taskInfo = taskBuilder.build();
this.executorInfo = executorInfo;
this.operation = getLaunchOperation();
}
示例4: testRegisterAndReRegister
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void testRegisterAndReRegister() {
final Protos.ExecutorInfo executorInfo = getTestExecutorInfo();
final String localhost = "localhost";
final Protos.SlaveInfo oldSlaveInfo = Protos.SlaveInfo
.newBuilder()
.setId(Protos.SlaveID.newBuilder().setValue(UUID.randomUUID().toString()))
.setHostname(localhost)
.build();
customExecutor.registered(mockExecutorDriver, executorInfo, null, oldSlaveInfo);
final Protos.SlaveInfo newSlaveInfo = Protos.SlaveInfo
.newBuilder()
.setId(Protos.SlaveID.newBuilder().setValue(UUID.randomUUID().toString()))
.setHostname(localhost)
.build();
customExecutor.reregistered(mockExecutorDriver, newSlaveInfo);
}
示例5: registered
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public void registered(final ExecutorDriver executorDriver, final Protos.ExecutorInfo executorInfo, final Protos.FrameworkInfo frameworkInfo, final Protos.SlaveInfo slaveInfo) {
if (!executorInfo.getData().isEmpty()) {
Map<String, String> data = SerializationUtils.deserialize(executorInfo.getData().toByteArray());
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(data.get("event_trace_rdb_driver"));
dataSource.setUrl(data.get("event_trace_rdb_url"));
dataSource.setPassword(data.get("event_trace_rdb_password"));
dataSource.setUsername(data.get("event_trace_rdb_username"));
jobEventBus = new JobEventBus(new JobEventRdbConfiguration(dataSource));
}
}
示例6: registered
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public void registered(ExecutorDriver driver, Protos.ExecutorInfo executorInfo, Protos.FrameworkInfo frameworkInfo, Protos.SlaveInfo slaveInfo) {
final String[] bootConfig = executorInfo.getData().toStringUtf8().split(";");
this.dcosAuthToken = nullOnEmpty(bootConfig[0]);
this.metricsContainersEnabled = Boolean.parseBoolean(bootConfig[1]);
slaveId = slaveInfo.getId().getValue();
System.out.println("HumioExecutor.registered");
}
示例7: getExpectedExecutorResources
import org.apache.mesos.Protos; //导入方法依赖的package包/类
private Collection<Resource> getExpectedExecutorResources(Protos.ExecutorInfo executorInfo) {
String executorCpuId = executorInfo.getResourcesList().stream()
.filter(r -> r.getName().equals("cpus"))
.map(ResourceUtils::getResourceId)
.filter(o -> o.isPresent())
.map(o -> o.get())
.findFirst()
.get();
String executorMemId = executorInfo.getResourcesList().stream()
.filter(r -> r.getName().equals("mem"))
.map(ResourceUtils::getResourceId)
.filter(o -> o.isPresent())
.map(o -> o.get())
.findFirst()
.get();
String executorDiskId = executorInfo.getResourcesList().stream()
.filter(r -> r.getName().equals("disk"))
.map(ResourceUtils::getResourceId)
.filter(o -> o.isPresent())
.map(o -> o.get())
.findFirst()
.get();
Resource expectedExecutorCpu = ResourceTestUtils.getReservedCpus(0.1, executorCpuId);
Resource expectedExecutorMem = ResourceTestUtils.getReservedMem(32, executorMemId);
Resource expectedExecutorDisk = ResourceTestUtils.getReservedDisk(256, executorDiskId);
return new ArrayList<>(Arrays.asList(expectedExecutorCpu, expectedExecutorMem, expectedExecutorDisk));
}
示例8: testRegisterExecutor
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void testRegisterExecutor() throws Exception {
Protos.ExecutorInfo executorInfo = testBeginning.registerExecutor(System.getenv("EXECUTOR_PATH"));
Protos.ExecutorInfo mExecutorInfo = testBeginning.getTaskExecutor();
// Only really care about location of executor
assertTrue(mExecutorInfo.getCommand().getValue().equals(executorInfo.getCommand().getValue()));
}
示例9: normalizeCassandraTaskInfo
import org.apache.mesos.Protos; //导入方法依赖的package包/类
private Protos.TaskInfo normalizeCassandraTaskInfo(CassandraDaemonTask daemonTask) {
Protos.TaskInfo daemonTaskInfo = daemonTask.getTaskInfo();
Protos.ExecutorInfo expectedExecutorInfo = Protos.ExecutorInfo.newBuilder(daemonTaskInfo.getExecutor())
.setExecutorId(Protos.ExecutorID.newBuilder().setValue(""))
.build();
daemonTaskInfo = Protos.TaskInfo.newBuilder(daemonTaskInfo)
.setTaskId(Protos.TaskID.newBuilder().setValue(""))
.setExecutor(expectedExecutorInfo)
.build();
return daemonTaskInfo;
}
示例10: registered
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public void registered(
ExecutorDriver driver,
Protos.ExecutorInfo executorInfo,
Protos.FrameworkInfo frameworkInfo,
Protos.SlaveInfo agentInfo) {
LOGGER.info("Registered executor: {}", TextFormat.shortDebugString(executorInfo));
executorService.submit(launchedTaskStore.getMonitor());
}
示例11: testFailingTask
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void testFailingTask() throws Exception {
final ExecutorDriver mockExecutorDriver = Mockito.mock(ExecutorDriver.class);
final Protos.ExecutorInfo executorInfo = Protos.ExecutorInfo.newBuilder()
.setName(EXECUTOR_NAME)
.setExecutorId(CommonIdUtils.toExecutorId(EXECUTOR_NAME))
.setCommand(Protos.CommandInfo.newBuilder().setValue(""))
.build();
final Protos.TaskInfo taskInfo = Protos.TaskInfo.newBuilder()
.setName(TASK_NAME)
.setTaskId(CommonIdUtils.toTaskId(TASK_NAME))
.setSlaveId(SlaveID.newBuilder().setValue("ignored"))
.setCommand(Protos.CommandInfo.newBuilder().setValue("exit 1"))
.setExecutor(executorInfo)
.build();
final ProcessTask processTask = ProcessTask.create(mockExecutorDriver, taskInfo);
Assert.assertFalse(processTask.isAlive());
processTask.run();
Assert.assertFalse(processTask.isAlive());
// Wait for processTask to run: TASK_RUNNING + TASK_FAILED
ArgumentCaptor<Protos.TaskStatus> captor = ArgumentCaptor.forClass(Protos.TaskStatus.class);
Mockito.verify(mockExecutorDriver, times(2)).sendStatusUpdate(captor.capture());
List<Protos.TaskStatus> statuses = captor.getAllValues();
Assert.assertEquals(2, statuses.size());
Assert.assertEquals(Protos.TaskState.TASK_RUNNING, statuses.get(0).getState());
Assert.assertEquals(Protos.TaskState.TASK_FAILED, statuses.get(1).getState());
Assert.assertFalse(processTask.isAlive());
}
示例12: expect
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public void expect(ClusterState state, SchedulerDriver mockDriver) throws AssertionError {
Set<Protos.ExecutorInfo> executors = taskNames.stream()
.map(name -> state.getLastLaunchedTask(name).getExecutor())
.collect(Collectors.toSet());
Assert.assertEquals(String.format(
"Expected tasks to share a single matching executor, but had: %s",
executors.stream().map(e -> TextFormat.shortDebugString(e)).collect(Collectors.toList())),
1, executors.size());
}
示例13: isRunningExecutor
import org.apache.mesos.Protos; //导入方法依赖的package包/类
private static boolean isRunningExecutor(Protos.ExecutorInfo executorInfo, Protos.Offer offer) {
for (Protos.ExecutorID execId : offer.getExecutorIdsList()) {
if (execId.equals(executorInfo.getExecutorId())) {
return true;
}
}
return false;
}
示例14: getEvaluationPipeline
import org.apache.mesos.Protos; //导入方法依赖的package包/类
public List<OfferEvaluationStage> getEvaluationPipeline(
PodInstanceRequirement podInstanceRequirement,
Collection<Protos.TaskInfo> allTasks,
Map<String, Protos.TaskInfo> thisPodTasks,
Optional<Protos.ExecutorInfo> executorInfo) throws IOException {
boolean noLaunchedTasksExist = thisPodTasks.values().stream()
.flatMap(taskInfo -> taskInfo.getResourcesList().stream())
.map(resource -> ResourceUtils.getResourceId(resource))
.filter(resourceId -> resourceId.isPresent())
.map(Optional::get)
.filter(resourceId -> !resourceId.isEmpty())
.count() == 0;
boolean allTasksFailed = thisPodTasks.values().stream()
.allMatch(taskInfo -> FailureUtils.isPermanentlyFailed(taskInfo));
final String description;
final boolean shouldGetNewRequirement;
if (podInstanceRequirement.getRecoveryType().equals(RecoveryType.PERMANENT) || allTasksFailed) {
description = "failed";
shouldGetNewRequirement = true;
} else if (noLaunchedTasksExist) {
description = "new";
shouldGetNewRequirement = true;
} else {
description = "existing";
shouldGetNewRequirement = false;
}
logger.info("Generating requirement for {} pod '{}' containing tasks: {}.",
description,
podInstanceRequirement.getPodInstance().getName(),
podInstanceRequirement.getTasksToLaunch());
// Only create a TLS Evaluation Stage builder if the service actually uses TLS certs.
// This avoids performing TLS cert generation in cases where the cluster may not support it (e.g. DC/OS Open).
boolean anyTasksWithTLS = podInstanceRequirement.getPodInstance().getPod().getTasks().stream()
.anyMatch(taskSpec -> !taskSpec.getTransportEncryption().isEmpty());
Optional<TLSEvaluationStage.Builder> tlsStageBuilder = anyTasksWithTLS
? Optional.of(new TLSEvaluationStage.Builder(serviceName, schedulerConfig))
: Optional.empty();
List<OfferEvaluationStage> evaluationPipeline = new ArrayList<>();
if (shouldGetNewRequirement) {
evaluationPipeline.add(new ExecutorEvaluationStage(Optional.empty()));
evaluationPipeline.addAll(getNewEvaluationPipeline(podInstanceRequirement, allTasks, tlsStageBuilder));
} else {
evaluationPipeline.add(new ExecutorEvaluationStage(getExecutorInfo(thisPodTasks.values())));
evaluationPipeline.addAll(getExistingEvaluationPipeline(
podInstanceRequirement, thisPodTasks, allTasks, executorInfo.get(), tlsStageBuilder));
}
return evaluationPipeline;
}
示例15: getExecutorInfo
import org.apache.mesos.Protos; //导入方法依赖的package包/类
public static Protos.ExecutorInfo getExecutorInfo(Protos.Resource resource) {
return getExecutorInfo(Arrays.asList(resource));
}