本文整理汇总了Java中org.apache.mesos.Protos.ExecutorInfo类的典型用法代码示例。如果您正苦于以下问题:Java ExecutorInfo类的具体用法?Java ExecutorInfo怎么用?Java ExecutorInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExecutorInfo类属于org.apache.mesos.Protos包,在下文中一共展示了ExecutorInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getReplacementOfferRequirement
import org.apache.mesos.Protos.ExecutorInfo; //导入依赖的package包/类
@Override
public OfferRequirement getReplacementOfferRequirement(String type, Protos.TaskInfo taskInfo) {
LOGGER.info("Getting replacement requirement for task: {}",
taskInfo.getTaskId().getValue());
ExecutorInfo execInfo = taskInfo.getExecutor();
taskInfo = Protos.TaskInfo.newBuilder(taskInfo).clearExecutor().build();
try {
return OfferRequirement.create(type, Arrays.asList(taskInfo), Optional.of(execInfo));
} catch (InvalidRequirementException e) {
LOGGER.error("Failed to construct OfferRequirement with Exception: ", e);
return null;
}
}
示例3: LaunchOfferRecommendation
import org.apache.mesos.Protos.ExecutorInfo; //导入依赖的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: 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();
}
}
示例5: getTaskInfo
import org.apache.mesos.Protos.ExecutorInfo; //导入依赖的package包/类
/**
* Builds a TaskInfo from the given jobspec
* @param job - JobSpec to TaskInfo-ify
* @param offer - offer add extra data (SlaveId)
* @return TaskInfo fully formed
*/
private TaskInfo getTaskInfo(JobSpec job,Offer offer) {
TaskID taskId = TaskID.newBuilder().setValue(job.getJob().getId()).build();
TaskInfo info = TaskInfo.newBuilder().setName("task " + taskId.getValue())
.setTaskId(taskId)
.setSlaveId(offer.getSlaveId())
.addResources(Resource.newBuilder()
.setName("cpus")
.setType(Value.Type.SCALAR)
.setScalar(Value.Scalar.newBuilder().setValue(job.getJob().getLoadValue()*1.0)))
.addResources(Resource.newBuilder()
.setName("mem")
.setType(Value.Type.SCALAR)
.setScalar(Value.Scalar.newBuilder().setValue(job.getJob().getLoadValue()*1024.0)))
.setExecutor(ExecutorInfo.newBuilder(executor)).setData(MesosUtilities.jobSpecToByteString(job)).build();
return info;
}
示例6: assertRegisteredWithoutData
import org.apache.mesos.Protos.ExecutorInfo; //导入依赖的package包/类
@Test
public void assertRegisteredWithoutData() {
// CHECKSTYLE:OFF
HashMap<String, String> data = new HashMap<>(4, 1);
// CHECKSTYLE:ON
data.put("event_trace_rdb_driver", "org.h2.Driver");
data.put("event_trace_rdb_url", "jdbc:h2:mem:test_executor");
data.put("event_trace_rdb_username", "sa");
data.put("event_trace_rdb_password", "");
ExecutorInfo executorInfo = ExecutorInfo.newBuilder().setExecutorId(Protos.ExecutorID.newBuilder().setValue("test_executor")).setCommand(Protos.CommandInfo.getDefaultInstance())
.setData(ByteString.copyFrom(SerializationUtils.serialize(data))).build();
taskExecutor.registered(executorDriver, executorInfo, frameworkInfo, slaveInfo);
}
示例7: 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;
}
示例8: 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);
}
示例9: makeThermosExecutorSettings
import org.apache.mesos.Protos.ExecutorInfo; //导入依赖的package包/类
private static ExecutorSettings makeThermosExecutorSettings() {
List<Protos.Volume> volumeMounts =
ImmutableList.<Protos.Volume>builder()
.add(Protos.Volume.newBuilder()
.setHostPath(THERMOS_OBSERVER_ROOT.get())
.setContainerPath(THERMOS_OBSERVER_ROOT.get())
.setMode(Protos.Volume.Mode.RW)
.build())
.addAll(Iterables.transform(
GLOBAL_CONTAINER_MOUNTS.get(),
v -> Protos.Volume.newBuilder()
.setHostPath(v.getHostPath())
.setContainerPath(v.getContainerPath())
.setMode(Protos.Volume.Mode.valueOf(v.getMode().getValue()))
.build()))
.build();
return new ExecutorSettings(
new ExecutorConfig(
ExecutorInfo.newBuilder()
.setName("aurora.task")
// Necessary as executorId is a required field.
.setExecutorId(Executors.PLACEHOLDER_EXECUTOR_ID)
.setCommand(
makeExecutorCommand(
THERMOS_EXECUTOR_PATH.get(),
THERMOS_EXECUTOR_RESOURCES.get(),
THERMOS_HOME_IN_SANDBOX.get(),
THERMOS_EXECUTOR_FLAGS.get()))
.addResources(makeResource(CPUS, EXECUTOR_OVERHEAD_CPUS.get()))
.addResources(makeResource(RAM_MB, EXECUTOR_OVERHEAD_RAM.get().as(Data.MB)))
.build(),
volumeMounts),
POPULATE_DISCOVERY_INFO.get());
}
示例10: populateDynamicFields
import org.apache.mesos.Protos.ExecutorInfo; //导入依赖的package包/类
private static ExecutorInfo populateDynamicFields(ExecutorInfo executor, IAssignedTask task) {
return executor.toBuilder()
.setExecutorId(MesosTaskFactoryImpl.getExecutorId(task.getTaskId()))
.setSource(
MesosTaskFactoryImpl.getInstanceSourceName(task.getTask(), task.getInstanceId()))
.build();
}
示例11: purgeZeroResources
import org.apache.mesos.Protos.ExecutorInfo; //导入依赖的package包/类
private static ExecutorInfo purgeZeroResources(ExecutorInfo executor) {
return executor.toBuilder()
.clearResources()
.addAllResources(
executor.getResourcesList()
.stream()
.filter(
e -> !e.hasScalar() || e.getScalar().getValue() > 0)
.collect(Collectors.toList()))
.build();
}
示例12: registered
import org.apache.mesos.Protos.ExecutorInfo; //导入依赖的package包/类
@Override
public void registered(ExecutorDriver driver, ExecutorInfo executorInfo, FrameworkInfo frameworkInfo, SlaveInfo slaveInfo) {
LOG.info("Received executor data <{}>", executorInfo.getData().toStringUtf8());
Map ids = (Map) JSONValue.parse(executorInfo.getData().toStringUtf8());
_executorId = executorInfo.getExecutorId().getValue();
_supervisorId = (String) ids.get(MesosCommon.SUPERVISOR_ID);
_assignmentId = (String) ids.get(MesosCommon.ASSIGNMENT_ID);
LOG.info("Registered supervisor with Mesos: {}, {} ", _supervisorId, _assignmentId);
// Completed registration, let anything waiting for us to do so continue
_registeredLatch.countDown();
}
示例13: getCreateOfferRequirement
import org.apache.mesos.Protos.ExecutorInfo; //导入依赖的package包/类
private OfferRequirement getCreateOfferRequirement(String type, Protos.TaskInfo taskInfo) {
ExecutorInfo execInfo = taskInfo.getExecutor();
taskInfo = Protos.TaskInfo.newBuilder(taskInfo).clearExecutor().build();
try {
return OfferRequirement.create(type, Arrays.asList(taskInfo), Optional.of(execInfo));
} catch (InvalidRequirementException e) {
LOGGER.error("Failed to construct OfferRequirement with Exception: ", e);
return null;
}
}
示例14: getExistingOfferRequirement
import org.apache.mesos.Protos.ExecutorInfo; //导入依赖的package包/类
private OfferRequirement getExistingOfferRequirement(String type, Protos.TaskInfo taskInfo) {
LOGGER.info("Getting existing OfferRequirement for task: {}", taskInfo);
ExecutorInfo execInfo = taskInfo.getExecutor();
taskInfo = Protos.TaskInfo.newBuilder(taskInfo).clearExecutor().build();
try {
return OfferRequirement.create(type, Arrays.asList(taskInfo), Optional.of(execInfo));
} catch (InvalidRequirementException e) {
LOGGER.error("Failed to construct OfferRequirement with Exception: ", e);
return null;
}
}
示例15: unpack
import org.apache.mesos.Protos.ExecutorInfo; //导入依赖的package包/类
/**
* This method reverses the work done in {@link TaskPackingUtils#pack(TaskInfo)} such that the original TaskInfo is
* regenerated. If the provided {@link TaskInfo} doesn't appear to have packed data then this operation does
* nothing.
*
* @see #pack(TaskInfo)
*/
public static TaskInfo unpack(TaskInfo taskInfo) {
if (!taskInfo.hasData() || !taskInfo.hasExecutor()) {
return taskInfo;
} else {
TaskInfo.Builder taskBuilder = TaskInfo.newBuilder(taskInfo);
ExecutorInfo pkgExecutorInfo;
try {
pkgExecutorInfo = ExecutorInfo.parseFrom(taskInfo.getData());
} catch (InvalidProtocolBufferException e) {
// In practice this shouldn't happen. This TaskInfo has a data field, but it doesn't parse as an
// ExecutorInfo. Let's assume this means that the TaskInfo isn't packed and return it as-is.
return taskInfo;
}
if (pkgExecutorInfo.hasCommand()) {
taskBuilder.setCommand(pkgExecutorInfo.getCommand());
}
if (pkgExecutorInfo.hasData()) {
taskBuilder.setData(pkgExecutorInfo.getData());
} else {
taskBuilder.clearData();
}
return taskBuilder.build();
}
}