本文整理汇总了Java中org.apache.mesos.Protos.ExecutorInfo.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java ExecutorInfo.Builder方法的具体用法?Java ExecutorInfo.Builder怎么用?Java ExecutorInfo.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.mesos.Protos.ExecutorInfo
的用法示例。
在下文中一共展示了ExecutorInfo.Builder方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matchResourceTypes
import org.apache.mesos.Protos.ExecutorInfo; //导入方法依赖的package包/类
/**
* Ensures that the revocable setting on the executor and task CPU resources match.
*
* @param task Task to check for resource type alignment.
* @return A possibly-modified task, with aligned CPU resource types.
*/
public static TaskInfo matchResourceTypes(TaskInfo task) {
TaskInfo.Builder taskBuilder = task.toBuilder();
Optional<Resource> revocableTaskCpu = taskBuilder.getResourcesList().stream()
.filter(r -> r.getName().equals(CPUS.getMesosName()))
.filter(Resource::hasRevocable)
.findFirst();
ExecutorInfo.Builder executorBuilder = taskBuilder.getExecutorBuilder();
Consumer<Builder> matchRevocable = builder -> {
if (revocableTaskCpu.isPresent()) {
builder.setRevocable(revocableTaskCpu.get().getRevocable());
} else {
builder.clearRevocable();
}
};
executorBuilder.getResourcesBuilderList().stream()
.filter(r -> r.getName().equals(CPUS.getMesosName()))
.forEach(matchRevocable);
return taskBuilder.build();
}
示例2: pack
import org.apache.mesos.Protos.ExecutorInfo; //导入方法依赖的package包/类
/**
* Packs the TaskInfo in preparation for sending it to the Executor. For a description of how the packing works
* (and why it exists), see the class-level javadoc.
*
* @see #unpack(TaskInfo)
*/
public static TaskInfo pack(TaskInfo taskInfo) {
if (!taskInfo.hasExecutor()) {
return taskInfo;
} else {
ExecutorInfo.Builder executorInfoBuilder = ExecutorInfo.newBuilder()
.setExecutorId(ExecutorID.newBuilder().setValue(COMMAND_DATA_PACKAGE_EXECUTORID));
if (taskInfo.hasCommand()) {
executorInfoBuilder.setCommand(taskInfo.getCommand());
}
if (taskInfo.hasData()) {
executorInfoBuilder.setData(taskInfo.getData());
}
return TaskInfo.newBuilder(taskInfo)
.setData(executorInfoBuilder.build().toByteString())
.clearCommand()
.build();
}
}
示例3: configureTaskForExecutor
import org.apache.mesos.Protos.ExecutorInfo; //导入方法依赖的package包/类
private ExecutorInfo.Builder configureTaskForExecutor(
IAssignedTask task,
AcceptedOffer acceptedOffer) {
ExecutorInfo.Builder builder = executorSettings.getExecutorConfig().getExecutor().toBuilder()
.setExecutorId(getExecutorId(task.getTaskId()))
.setSource(getInstanceSourceName(task.getTask(), task.getInstanceId()));
List<Resource> executorResources = acceptedOffer.getExecutorResources();
LOG.debug(
"Setting executor resources to {}",
Iterables.transform(executorResources, Protobufs::toString));
builder.clearResources().addAllResources(executorResources);
return builder;
}
示例4: thermosOnlyWithOverhead
import org.apache.mesos.Protos.ExecutorInfo; //导入方法依赖的package包/类
public static ExecutorSettings thermosOnlyWithOverhead(ResourceSlot overhead) {
ExecutorConfig config = THERMOS_EXECUTOR.getExecutorConfig();
ExecutorInfo.Builder executor = config.getExecutor().toBuilder();
executor.clearResources().addAllResources(overhead.toResourceList(TaskTestUtil.DEV_TIER));
return new ExecutorSettings(
new ExecutorConfig(executor.build(), config.getVolumeMounts()), false);
}
示例5: getExecutorInfo
import org.apache.mesos.Protos.ExecutorInfo; //导入方法依赖的package包/类
private static ExecutorInfo getExecutorInfo() {
ExecutorInfo.Builder builder = ExecutorInfo.newBuilder();
builder.setExecutorId(Protos.ExecutorID.newBuilder().setValue(executorName));
builder.setCommand(getCommandInfo());
builder.setName(executorName);
builder.setSource("java");
return builder.build();
}
示例6: createFrom
import org.apache.mesos.Protos.ExecutorInfo; //导入方法依赖的package包/类
@Override
public TaskInfo createFrom(IAssignedTask task, Offer offer) throws SchedulerException {
requireNonNull(task);
requireNonNull(offer);
ITaskConfig config = task.getTask();
AcceptedOffer acceptedOffer;
// TODO(wfarner): Re-evaluate if/why we need to continue handling unset assignedPorts field.
try {
acceptedOffer = AcceptedOffer.create(
offer,
ResourceSlot.from(config),
executorSettings.getExecutorOverhead(),
ImmutableSet.copyOf(task.getAssignedPorts().values()),
tierManager.getTier(task.getTask()));
} catch (Resources.InsufficientResourcesException e) {
throw new SchedulerException(e);
}
List<Resource> resources = acceptedOffer.getTaskResources();
LOG.debug(
"Setting task resources to {}",
Iterables.transform(resources, Protobufs::toString));
TaskInfo.Builder taskBuilder = TaskInfo.newBuilder()
.setName(JobKeys.canonicalString(Tasks.getJob(task)))
.setTaskId(TaskID.newBuilder().setValue(task.getTaskId()))
.setSlaveId(offer.getSlaveId())
.addAllResources(resources);
configureTaskLabels(config.getMetadata(), taskBuilder);
if (executorSettings.shouldPopulateDiscoverInfo()) {
configureDiscoveryInfos(task, taskBuilder);
}
if (config.getContainer().isSetMesos()) {
configureTaskForNoContainer(task, taskBuilder, acceptedOffer);
} else if (config.getContainer().isSetDocker()) {
IDockerContainer dockerContainer = config.getContainer().getDocker();
if (config.isSetExecutorConfig()) {
ExecutorInfo.Builder execBuilder = configureTaskForExecutor(task, acceptedOffer)
.setContainer(getDockerContainerInfo(dockerContainer));
taskBuilder.setExecutor(execBuilder.build());
} else {
LOG.warn("Running Docker-based task without an executor.");
taskBuilder.setContainer(getDockerContainerInfo(dockerContainer))
.setCommand(CommandInfo.newBuilder().setShell(false));
}
} else {
throw new SchedulerException("Task had no supported container set.");
}
if (taskBuilder.hasExecutor()) {
taskBuilder.setData(ByteString.copyFrom(serializeTask(task)));
return ResourceSlot.matchResourceTypes(taskBuilder.build());
} else {
return taskBuilder.build();
}
}
示例7: getExecutor
import org.apache.mesos.Protos.ExecutorInfo; //导入方法依赖的package包/类
ExecutorInfo.Builder getExecutor() {
return executor;
}
示例8: setExecutor
import org.apache.mesos.Protos.ExecutorInfo; //导入方法依赖的package包/类
void setExecutor(ExecutorInfo.Builder executor) {
this.executor = executor;
}