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


Java OfferID类代码示例

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


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

示例1: offerRescinded

import org.apache.mesos.Protos.OfferID; //导入依赖的package包/类
@Override
public void offerRescinded(SchedulerDriver driver, OfferID offerId) {
  if (!isRunning()) {
    LOG.info("Ignoring offer rescind message {} because scheduler isn't running ({})", offerId, state);
    return;
  }

  lock.lock();

  try {
    scheduler.offerRescinded(driver, offerId);
  } catch (Throwable t) {
    handleUncaughtSchedulerException(t);
  } finally {
    lock.unlock();
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:18,代码来源:SingularityMesosSchedulerDelegator.java

示例2: createMocks

import org.apache.mesos.Protos.OfferID; //导入依赖的package包/类
@Before
public void createMocks() {
  pendingTask = new SingularityPendingTask(new SingularityPendingTaskId("test", "1", 0, 1, PendingType.IMMEDIATE, 0), Optional.<List<String>> absent(),
      Optional.<String> absent(), Optional.<String> absent(), Optional.<Boolean> absent(), Optional.<String> absent());

  final SingularitySlaveAndRackHelper slaveAndRackHelper = mock(SingularitySlaveAndRackHelper.class);
  final ExecutorIdGenerator idGenerator = mock(ExecutorIdGenerator.class);

  when(idGenerator.getNextExecutorId()).then(new CreateFakeId());

  builder = new SingularityMesosTaskBuilder(new ObjectMapper(), slaveAndRackHelper, idGenerator, new SingularityConfiguration());

  taskResources = new Resources(1, 1, 0);
  executorResources = new Resources(0.1, 1, 0);

  offer = Offer.newBuilder()
      .setSlaveId(SlaveID.newBuilder().setValue("1"))
      .setId(OfferID.newBuilder().setValue("1"))
      .setFrameworkId(FrameworkID.newBuilder().setValue("1"))
      .setHostname("test")
      .build();

  when(slaveAndRackHelper.getRackId(offer)).thenReturn(Optional.<String> absent());
  when(slaveAndRackHelper.getMaybeTruncatedHost(offer)).thenReturn("host");
  when(slaveAndRackHelper.getRackIdOrDefault(offer)).thenReturn("DEFAULT");
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:27,代码来源:SingularityMesosTaskBuilderTest.java

示例3: launchTask

import org.apache.mesos.Protos.OfferID; //导入依赖的package包/类
@Timed("offer_manager_launch_task")
@Override
public void launchTask(OfferID offerId, Protos.TaskInfo task) throws LaunchException {
  // Guard against an offer being removed after we grabbed it from the iterator.
  // If that happens, the offer will not exist in hostOffers, and we can immediately
  // send it back to LOST for quick reschedule.
  // Removing while iterating counts on the use of a weakly-consistent iterator being used,
  // which is a feature of ConcurrentSkipListSet.
  if (hostOffers.remove(offerId)) {
    try {
      driver.launchTask(offerId, task);
    } catch (IllegalStateException e) {
      // TODO(William Farner): Catch only the checked exception produced by Driver
      // once it changes from throwing IllegalStateException when the driver is not yet
      // registered.
      throw new LaunchException("Failed to launch task.", e);
    }
  } else {
    offerRaces.incrementAndGet();
    throw new LaunchException("Offer no longer exists in offer queue, likely data race.");
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:23,代码来源:OfferManager.java

示例4: resourceOffers

import org.apache.mesos.Protos.OfferID; //导入依赖的package包/类
@Override
public Collection<OfferID> resourceOffers(
        final SchedulerDriver driver,
        final List<Offer> offers,
        final Collection<? extends Step> steps) {
    if (driver == null || offers == null || steps == null) {
        logger.error("Unexpected null argument(s) encountered: driver='{}' offers='{}', steps='{}'",
                driver, offers, steps);
        return Collections.emptyList();
    }

    List<OfferID> acceptedOfferIds = new ArrayList<>();
    List<Offer> availableOffers = new ArrayList<>(offers);

    for (Step step : steps) {
        acceptedOfferIds.addAll(resourceOffers(driver, availableOffers, step));
        availableOffers = PlanUtils.filterAcceptedOffers(availableOffers, acceptedOfferIds);
    }

    return acceptedOfferIds;
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:22,代码来源:DefaultPlanScheduler.java

示例5: accept

import org.apache.mesos.Protos.OfferID; //导入依赖的package包/类
public List<OfferID> accept(SchedulerDriver driver, List<OfferRecommendation> recommendations) {
    if (CollectionUtils.isEmpty(recommendations)) {
        LOGGER.warn("No recommendations, nothing to do");
        return new ArrayList<>();
    }

    List<OfferID> offerIds = getOfferIds(recommendations);
    List<Operation> operations = getOperations(recommendations);

    logOperations(operations);

    try {
        record(recommendations);
    } catch (Exception ex) {
        LOGGER.error("Failed to record Operations so not launching Task", ex);
        return new ArrayList<>();
    }

    if (CollectionUtils.isNotEmpty(operations)) {
        driver.acceptOffers(offerIds, operations, FILTERS);
    } else {
        LOGGER.warn("No Operations to perform.");
    }

    return offerIds;
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:27,代码来源:OfferAccepter.java

示例6: testLaunchTransient

import org.apache.mesos.Protos.OfferID; //导入依赖的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

示例7: testLaunchTransientCustomExecutor

import org.apache.mesos.Protos.OfferID; //导入依赖的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

示例8: getValidOffers

import org.apache.mesos.Protos.OfferID; //导入依赖的package包/类
/**
 * Creates given amount of offers with adequate resources
 *
 * @param amount amount of offers to create
 * @return given amount of offers with adequate resources
 */
public static List<Offer> getValidOffers(int amount) {
    List<Offer> offers = new ArrayList<>();
    SchedulerConfiguration config = new SchedulerConfiguration();
    for (int i = 0; i < amount; i++) {
        Offer offer = Offer.newBuilder()
                .setId(OfferID.newBuilder().setValue("valid-offer-" + i).build())
                .setSlaveId(SlaveID.newBuilder().setValue("slave-" + i).build())
                .setFrameworkId(FrameworkID.newBuilder().setValue("kibana").build())
                .setHostname("localhost")
                .addResources(Resources.buildCpuResource(config.getRequiredCpu()))
                .addResources(Resources.buildMemResource(config.getRequiredMem()))
                .addResources(Resources.buildDiskResource(config.getRequiredDisk()))
                .addResources(Resources.buildPortResource(9000, (long) (8999 + SchedulerConfiguration.getRequiredPortCount())))
                .build();
        offers.add(offer);
    }
    return offers;
}
 
开发者ID:Praqma,项目名称:mesos-kibana,代码行数:25,代码来源:TestUtils.java

示例9: getInvalidOffers

import org.apache.mesos.Protos.OfferID; //导入依赖的package包/类
/**
 * Creates given amount of offers with inadequate resources
 *
 * @param amount amount of offers to create
 * @return given amount of offers with inadequate resources
 */
public static List<Offer> getInvalidOffers(int amount) {
    List<Offer> offers = new ArrayList<>();
    SchedulerConfiguration config = new SchedulerConfiguration();
    for (int i = 0; i < amount; i++) {
        Offer offer = Offer.newBuilder()
                .setId(OfferID.newBuilder().setValue("invalid-offer-" + i).build())
                .setSlaveId(SlaveID.newBuilder().setValue("slave-" + i).build())
                .setFrameworkId(FrameworkID.newBuilder().setValue("kibana").build())
                .setHostname("localhost")
                .addResources(Resources.buildCpuResource(config.getRequiredCpu() / 2))
                .addResources(Resources.buildMemResource(config.getRequiredMem() / 2))
                .addResources(Resources.buildDiskResource(config.getRequiredDisk() / 2))
                .build();
        offers.add(offer);
    }
    return offers;
}
 
开发者ID:Praqma,项目名称:mesos-kibana,代码行数:24,代码来源:TestUtils.java

示例10: launchTasks

import org.apache.mesos.Protos.OfferID; //导入依赖的package包/类
@Override
public Status launchTasks(final OfferID offerId, final Collection<TaskInfo> tasks)
{
    checkNotNull(offerId, "offerId is null");
    checkNotNull(tasks, "tasks is null");

    if (!context.isStateMachine(DRIVER_RUNNING)) {
        return context.getStateMachine();
    }

    final LaunchTasksMessage message = LaunchTasksMessage.newBuilder()
        .setFrameworkId(context.getFrameworkId())
        .addOfferIds(offerId)
        .addAllTasks(tasks)
        .setFilters(Filters.newBuilder().build())
        .build();

    doLaunchTasks(message);
    return context.getStateMachine();
}
 
开发者ID:groupon,项目名称:jesos,代码行数:21,代码来源:InternalSchedulerDriver.java

示例11: declineOffer

import org.apache.mesos.Protos.OfferID; //导入依赖的package包/类
@Override
public Status declineOffer(final OfferID offerId, final Filters filters)
{
    checkNotNull(offerId, "offerId is null");
    checkNotNull(filters, "filters is null");

    if (!context.isStateMachine(DRIVER_RUNNING)) {
        return context.getStateMachine();
    }

    final LaunchTasksMessage message = LaunchTasksMessage.newBuilder()
        .setFrameworkId(context.getFrameworkId())
        .addOfferIds(offerId)
        .setFilters(filters)
        .build();

    doLaunchTasks(message);
    return context.getStateMachine();
}
 
开发者ID:groupon,项目名称:jesos,代码行数:20,代码来源:InternalSchedulerDriver.java

示例12: findOffer

import org.apache.mesos.Protos.OfferID; //导入依赖的package包/类
private OfferID findOffer(WorkerSlot worker) {
    int port = worker.getPort();
    ArrayList<Offer> offers = new ArrayList(_offers.values());
    Collections.shuffle(offers);
    for (Offer offer : offers) {
        if (offer.getHostname().equals(worker.getNodeId())) {
            for (Resource r : offer.getResourcesList()) {
                if (r.getName().equals("ports")) {
                    for (Range range : r.getRanges().getRangeList()) {
                        if (port >= range.getBegin() && port <= range.getEnd()) {
                            return offer.getId();
                        }
                    }
                }
            }
        }
    }
    return null;
}
 
开发者ID:deric,项目名称:storm-mesos,代码行数:20,代码来源:MesosNimbus.java

示例13: getOfferIDs

import org.apache.mesos.Protos.OfferID; //导入依赖的package包/类
private List<Protos.OfferID> getOfferIDs(final List<VirtualMachineLease> leasesUsed) {
    List<Protos.OfferID> result = new ArrayList<>();
    for (VirtualMachineLease virtualMachineLease: leasesUsed) {
        result.add(virtualMachineLease.getOffer().getId());
    }
    return result;
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:8,代码来源:TaskLaunchScheduledService.java

示例14: createOffer

import org.apache.mesos.Protos.OfferID; //导入依赖的package包/类
protected Offer createOffer(double cpus, double memory, String slave, String host, Optional<String> rack, Map<String, String> attributes, String[] portRanges) {
  SlaveID slaveId = SlaveID.newBuilder().setValue(slave).build();
  FrameworkID frameworkId = FrameworkID.newBuilder().setValue("framework1").build();

  Random r = new Random();

  List<Attribute> attributesList = new ArrayList<>();
  for (Map.Entry<String, String> entry : attributes.entrySet()) {
    attributesList.add(Attribute.newBuilder()
        .setType(Type.TEXT)
        .setName(entry.getKey())
        .setText(Text.newBuilder().setValue(entry.getValue()).build())
        .build());
  }

  return Offer.newBuilder()
      .setId(OfferID.newBuilder().setValue("offer" + r.nextInt(1000)).build())
      .setFrameworkId(frameworkId)
      .setSlaveId(slaveId)
      .setHostname(host)
      .addAttributes(Attribute.newBuilder().setType(Type.TEXT).setText(Text.newBuilder().setValue(rack.or(configuration.getMesosConfiguration().getDefaultRackId()))).setName(configuration.getMesosConfiguration().getRackIdAttributeKey()))
      .addResources(Resource.newBuilder().setType(Type.SCALAR).setName(MesosUtils.CPUS).setScalar(Scalar.newBuilder().setValue(cpus)))
      .addResources(Resource.newBuilder().setType(Type.SCALAR).setName(MesosUtils.MEMORY).setScalar(Scalar.newBuilder().setValue(memory)))
      .addResources(MesosUtilsTest.buildPortRanges(portRanges))
      .addAllAttributes(attributesList)
      .build();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:28,代码来源:SingularitySchedulerTestBase.java

示例15: buildOffer

import org.apache.mesos.Protos.OfferID; //导入依赖的package包/类
private Offer buildOffer(String... ranges) {
  Offer.Builder offer = Offer.newBuilder()
      .setId(OfferID.newBuilder().setValue("offerid").build())
      .setFrameworkId(FrameworkID.newBuilder().setValue("frameworkid").build())
      .setHostname("hostname")
      .setSlaveId(SlaveID.newBuilder().setValue("slaveid").build());

  offer.addResources(buildPortRanges(ranges));

  return offer.build();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:12,代码来源:MesosUtilsTest.java


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