当前位置: 首页>>代码示例>>Java>>正文


Java TaskInfo.Builder方法代码示例

本文整理汇总了Java中org.apache.mesos.Protos.TaskInfo.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java TaskInfo.Builder方法的具体用法?Java TaskInfo.Builder怎么用?Java TaskInfo.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.mesos.Protos.TaskInfo的用法示例。


在下文中一共展示了TaskInfo.Builder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: matchResourceTypes

import org.apache.mesos.Protos.TaskInfo; //导入方法依赖的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();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:30,代码来源:ResourceSlot.java

示例2: configureDiscoveryInfos

import org.apache.mesos.Protos.TaskInfo; //导入方法依赖的package包/类
private void configureDiscoveryInfos(IAssignedTask task, TaskInfo.Builder taskBuilder) {
  DiscoveryInfo.Builder builder = taskBuilder.getDiscoveryBuilder();
  builder.setVisibility(DiscoveryInfo.Visibility.CLUSTER);
  builder.setName(getInverseJobSourceName(task.getTask().getJob()));
  builder.setEnvironment(task.getTask().getJob().getEnvironment());
  // A good sane choice for default location is current Aurora cluster name.
  builder.setLocation(serverInfo.getClusterName());
  for (Map.Entry<String, Integer> entry : task.getAssignedPorts().entrySet()) {
    builder.getPortsBuilder().addPorts(
        Port.newBuilder()
            .setName(entry.getKey())
            .setNumber(entry.getValue())
            .setProtocol(DEFAULT_PORT_PROTOCOL)
    );
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:17,代码来源:MesosTaskFactory.java

示例3: LaunchOfferRecommendation

import org.apache.mesos.Protos.TaskInfo; //导入方法依赖的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();
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:23,代码来源:LaunchOfferRecommendation.java

示例4: testLaunchTransient

import org.apache.mesos.Protos.TaskInfo; //导入方法依赖的package包/类
@Test
public void testLaunchTransient() {
    Resource resource = ResourceTestUtils.getUnreservedCpus(1.0);
    Offer offer = OfferTestUtils.getCompleteOffer(resource);
    TaskInfo.Builder taskInfoBuilder = TaskTestUtils.getTaskInfo(resource).toBuilder();
    taskInfoBuilder.setLabels(new TaskLabelWriter(taskInfoBuilder).setTransient().toProto());

    TestOperationRecorder recorder = new TestOperationRecorder();
    OfferAccepter accepter = new OfferAccepter(Arrays.asList(recorder));
    accepter.accept(
            driver,
            Arrays.asList(new LaunchOfferRecommendation(
                    offer,
                    taskInfoBuilder.build(),
                    Protos.ExecutorInfo.newBuilder().setExecutorId(TestConstants.EXECUTOR_ID).build(),
                    false,
                    true)));
    Assert.assertEquals(1, recorder.getLaunches().size());
    verify(driver, times(0)).acceptOffers(
            anyCollectionOf(OfferID.class),
            anyCollectionOf(Operation.class),
            anyObject());
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:24,代码来源:OfferAccepterTest.java

示例5: testLaunchTransientCustomExecutor

import org.apache.mesos.Protos.TaskInfo; //导入方法依赖的package包/类
@Test
public void testLaunchTransientCustomExecutor() {
    Resource resource = ResourceTestUtils.getUnreservedCpus(1.0);
    Offer offer = OfferTestUtils.getOffer(resource);
    TaskInfo.Builder taskInfoBuilder = TaskTestUtils.getTaskInfo(resource).toBuilder();
    taskInfoBuilder.setLabels(new TaskLabelWriter(taskInfoBuilder).setTransient().toProto());

    TestOperationRecorder recorder = new TestOperationRecorder();
    OfferAccepter accepter = new OfferAccepter(Arrays.asList(recorder));
    accepter.accept(
            driver,
            Arrays.asList(new LaunchOfferRecommendation(
                    offer,
                    taskInfoBuilder.build(),
                    Protos.ExecutorInfo.newBuilder().setExecutorId(TestConstants.EXECUTOR_ID).build(),
                    false,
                    false)));
    Assert.assertEquals(1, recorder.getLaunches().size());
    verify(driver, times(0)).acceptOffers(
            anyCollectionOf(OfferID.class),
            anyCollectionOf(Operation.class),
            anyObject());
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:24,代码来源:OfferAccepterTest.java

示例6: prepareCommand

import org.apache.mesos.Protos.TaskInfo; //导入方法依赖的package包/类
private void prepareCommand(final TaskInfo.Builder bldr, final SingularityTaskId taskId, final SingularityTaskRequest task, final Protos.Offer offer, final Optional<long[]> ports) {
  CommandInfo.Builder commandBldr = CommandInfo.newBuilder();

  if (task.getDeploy().getCommand().isPresent()) {
    commandBldr.setValue(task.getDeploy().getCommand().get());
  }

  if (task.getDeploy().getArguments().isPresent()) {
    commandBldr.addAllArguments(task.getDeploy().getArguments().get());
  }

  if (task.getPendingTask().getCmdLineArgsList().isPresent()) {
    commandBldr.addAllArguments(task.getPendingTask().getCmdLineArgsList().get());
  }

  if (task.getDeploy().getArguments().isPresent() ||
      // Hopefully temporary workaround for
      // http://www.mail-archive.com/[email protected]/msg01449.html
      task.getDeploy().getContainerInfo().isPresent() ||
      task.getPendingTask().getCmdLineArgsList().isPresent()) {
    commandBldr.setShell(false);
  }

  for (String uri : task.getDeploy().getUris().or(Collections.<String> emptyList())) {
    commandBldr.addUris(URI.newBuilder().setValue(uri).build());
  }

  prepareEnvironment(task, taskId, commandBldr, offer, ports);

  bldr.setCommand(commandBldr);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:32,代码来源:SingularityMesosTaskBuilder.java

示例7: configureTaskForNoContainer

import org.apache.mesos.Protos.TaskInfo; //导入方法依赖的package包/类
private void configureTaskForNoContainer(
    IAssignedTask task,
    TaskInfo.Builder taskBuilder,
    AcceptedOffer acceptedOffer) {

  taskBuilder.setExecutor(configureTaskForExecutor(task, acceptedOffer).build());
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:8,代码来源:MesosTaskFactory.java

示例8: configureTaskLabels

import org.apache.mesos.Protos.TaskInfo; //导入方法依赖的package包/类
private void configureTaskLabels(Set<IMetadata> metadata, TaskInfo.Builder taskBuilder) {
  ImmutableSet<Label> labels = metadata.stream()
      .map(m -> Label.newBuilder()
          .setKey(METADATA_LABEL_PREFIX + m.getKey())
          .setValue(m.getValue())
          .build())
      .collect(GuavaUtils.toImmutableSet());

  if (!labels.isEmpty()) {
    taskBuilder.setLabels(Labels.newBuilder().addAllLabels(labels));
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:13,代码来源:MesosTaskFactory.java

示例9: clearReservationIds

import org.apache.mesos.Protos.TaskInfo; //导入方法依赖的package包/类
private static TaskInfo clearReservationIds(TaskInfo taskInfo) {
    TaskInfo.Builder taskInfoBuilder = TaskInfo.newBuilder(taskInfo)
            .clearResources()
            .addAllResources(clearReservationIds(taskInfo.getResourcesList()));

    if (taskInfo.hasExecutor()) {
        taskInfoBuilder.getExecutorBuilder()
                .clearResources()
                .addAllResources(clearReservationIds(taskInfoBuilder.getExecutor().getResourcesList()));
    }

    return taskInfoBuilder.build();
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:14,代码来源:TaskUtils.java

示例10: getTask

import org.apache.mesos.Protos.TaskInfo; //导入方法依赖的package包/类
private static TaskInfo getTask(String id, Offer offer) {
    TaskInfo.Builder taskBuilder = TaskTestUtils.getTaskInfo(Collections.emptyList()).toBuilder();
    taskBuilder.getTaskIdBuilder().setValue(id);
    try {
        taskBuilder.setName(CommonIdUtils.toTaskName(taskBuilder.getTaskId()));
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
    taskBuilder.setLabels(new TaskLabelWriter(taskBuilder).setOfferAttributes(offer).toProto());
    return taskBuilder.build();
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:12,代码来源:MaxPerAttributeRuleTest.java

示例11: getTask

import org.apache.mesos.Protos.TaskInfo; //导入方法依赖的package包/类
private static TaskInfo getTask(String id, Offer offer) {
    TaskInfo.Builder taskBuilder = TaskTestUtils.getTaskInfo(Collections.emptyList()).toBuilder();
    taskBuilder.getTaskIdBuilder().setValue(id);
    try {
        taskBuilder.setName(CommonIdUtils.toTaskName(taskBuilder.getTaskId()));
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
    taskBuilder.setLabels(new TaskLabelWriter(taskBuilder).setHostname(offer).toProto());
    return taskBuilder.build();
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:12,代码来源:MaxPerHostnameRuleTest.java

示例12: getTask

import org.apache.mesos.Protos.TaskInfo; //导入方法依赖的package包/类
private static TaskInfo getTask(String type, String id, String agent) {
    TaskInfo.Builder taskBuilder = TaskTestUtils.getTaskInfo(Collections.emptyList()).toBuilder();
    taskBuilder.getTaskIdBuilder().setValue(id);
    try {
        taskBuilder.setName(CommonIdUtils.toTaskName(taskBuilder.getTaskId()));
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
    taskBuilder.getSlaveIdBuilder().setValue(agent);
    taskBuilder.setLabels(new TaskLabelWriter(taskBuilder).setType(type).toProto());
    return taskBuilder.build();
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:13,代码来源:TaskTypeRuleTest.java

示例13: getTaskInfo

import org.apache.mesos.Protos.TaskInfo; //导入方法依赖的package包/类
private static TaskInfo getTaskInfo(String taskName, String attrName, String attrVal) {
    TaskInfo.Builder infoBuilder = TaskTestUtils.getTaskInfo(Collections.emptyList()).toBuilder()
            .setName(taskName)
            .setTaskId(CommonIdUtils.toTaskId(taskName));
    infoBuilder.setLabels(new TaskLabelWriter(infoBuilder)
            .setOfferAttributes(offerWithAttribute(attrName, attrVal))
            .toProto());
    return infoBuilder.build();
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:10,代码来源:RoundRobinByAttributeRuleTest.java

示例14: unpack

import org.apache.mesos.Protos.TaskInfo; //导入方法依赖的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();
    }
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:35,代码来源:TaskPackingUtils.java

示例15: buildTaskInfo

import org.apache.mesos.Protos.TaskInfo; //导入方法依赖的package包/类
private TaskInfo.Builder buildTaskInfo(final Map<String, String> jobConfigurationContext) {
    return TaskInfo.newBuilder().setData(ByteString.copyFrom(serialize(jobConfigurationContext)))
            .setName("test_job").setTaskId(TaskID.newBuilder().setValue(taskId)).setSlaveId(Protos.SlaveID.newBuilder().setValue("slave-S0"));
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:5,代码来源:TaskExecutorThreadTest.java


注:本文中的org.apache.mesos.Protos.TaskInfo.Builder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。