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


Java Protos.Filters方法代码示例

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


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

示例1: declineOffers

import org.apache.mesos.Protos; //导入方法依赖的package包/类
/**
 * Decline unused {@link org.apache.mesos.Protos.Offer}s.
 *
 * @param driver The {@link SchedulerDriver} that will receive the declineOffer() calls
 * @param unusedOffers The collection of Offers to decline
 * @param refuseSeconds The number of seconds for which the offers should be refused
 */
private static void declineOffers(
        SchedulerDriver driver, Collection<Protos.Offer> unusedOffers, int refuseSeconds) {
    Collection<Protos.OfferID> offerIds = unusedOffers.stream()
            .map(offer -> offer.getId())
            .collect(Collectors.toList());
    LOGGER.info("Declining {} unused offer{} for {} seconds: {}",
            offerIds.size(),
            offerIds.size() == 1 ? "" : "s",
            refuseSeconds,
            offerIds.stream().map(Protos.OfferID::getValue).collect(Collectors.toList()));
    final Protos.Filters filters = Protos.Filters.newBuilder()
            .setRefuseSeconds(refuseSeconds)
            .build();
    offerIds.forEach(offerId -> driver.declineOffer(offerId, filters));
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:23,代码来源:OfferUtils.java

示例2: launchTasks

import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public Protos.Status launchTasks(
    Collection<Protos.OfferID> offerIds,
    Collection<Protos.TaskInfo> tasks,
    Protos.Filters filters) {
  return null;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:8,代码来源:FakeSchedulerDriver.java

示例3: acceptOffers

import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public Protos.Status acceptOffers(
    Collection<Protos.OfferID> offerIds,
    Collection<Protos.Offer.Operation> operations,
    Protos.Filters filters) {
  return null;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:8,代码来源:FakeSchedulerDriver.java

示例4: launchTasks

import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Deprecated
public Protos.Status launchTasks(Collection<Protos.OfferID> offerIds,
                                 Collection<Protos.TaskInfo> tasksToLaunch,
                                 Protos.Filters filters) {
    // Shouldn't be used
    throw new UnknownError();
}
 
开发者ID:retz,项目名称:retz,代码行数:8,代码来源:LocalSchedulerDriver.java

示例5: launchTasks

import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Deprecated
public Protos.Status launchTasks(Collection<Protos.OfferID> offerIds,
                                 Collection<Protos.TaskInfo> tasks,
                                 Protos.Filters filters) {
    // Shouldn't be used
    throw new UnknownError();
}
 
开发者ID:retz,项目名称:retz,代码行数:8,代码来源:MesosSchedulerDummyDriver.java

示例6: declineOffer

import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public Protos.Status declineOffer(
    Protos.OfferID offerId,
    Protos.Filters filters) {
  return null;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:7,代码来源:FakeSchedulerDriver.java

示例7: doRegistration

import org.apache.mesos.Protos; //导入方法依赖的package包/类
public void doRegistration(final SchedulerDriver driver, Protos.FrameworkID id) {
  _driver = driver;
  _state.put(FRAMEWORK_ID, id.getValue());
  Number filterSeconds = Optional.fromNullable((Number) _conf.get(CONF_MESOS_OFFER_FILTER_SECONDS)).or(120);
  final Protos.Filters filters = Protos.Filters.newBuilder()
      .setRefuseSeconds(filterSeconds.intValue())
      .build();
  _offers = new RotatingMap<>(
      new RotatingMap.ExpiredCallback<Protos.OfferID, Protos.Offer>() {
        @Override
        public void expire(Protos.OfferID key, Protos.Offer val) {
          driver.declineOffer(
              val.getId(),
              filters
          );
        }
      }
  );

  Number lruCacheSize = Optional.fromNullable((Number) _conf.get(CONF_MESOS_OFFER_LRU_CACHE_SIZE)).or(1000);
  final int intLruCacheSize = lruCacheSize.intValue();
  _usedOffers = Collections.synchronizedMap(new LinkedHashMap<Protos.TaskID, Protos.Offer>(intLruCacheSize + 1, .75F, true) {
    // This method is called just after a new entry has been added
    public boolean removeEldestEntry(Map.Entry eldest) {
      return size() > intLruCacheSize;
    }
  });

  Number offerExpired = Optional.fromNullable((Number) _conf.get(Config.NIMBUS_MONITOR_FREQ_SECS)).or(10);
  Number expiryMultiplier = Optional.fromNullable((Number) _conf.get(CONF_MESOS_OFFER_EXPIRY_MULTIPLIER)).or(2.5);
  _timer.scheduleAtFixedRate(new TimerTask() {
    @Override
    public void run() {
      try {
        synchronized (_offersLock) {
          _offers.rotate();
        }
      } catch (Throwable t) {
        LOG.error("Received fatal error Halting process...", t);
        Runtime.getRuntime().halt(2);
      }
    }
  }, 0, Math.round(1000 * expiryMultiplier.doubleValue() * offerExpired.intValue()));
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:45,代码来源:MesosNimbus.java

示例8: acceptOffers

import org.apache.mesos.Protos; //导入方法依赖的package包/类
public void acceptOffers(SchedulerDriver driver, Protos.Filters filters) {
    driver.acceptOffers(offers.stream().map(offer -> offer.getId()).collect(Collectors.toList()),
            operations, filters);
}
 
开发者ID:retz,项目名称:retz,代码行数:5,代码来源:OfferAcceptor.java

示例9: declineOffer

import org.apache.mesos.Protos; //导入方法依赖的package包/类
public int declineOffer(SchedulerDriver driver, Protos.Filters filters) {
    for (Protos.Offer offer : offers) {
        driver.declineOffer(offer.getId(), filters);
    }
    return offers.size();
}
 
开发者ID:retz,项目名称:retz,代码行数:7,代码来源:OfferAcceptor.java

示例10: declineOffer

import org.apache.mesos.Protos; //导入方法依赖的package包/类
public Protos.Status declineOffer(Protos.OfferID offerID, Protos.Filters filters) {
    declined.add(offerID);
    return Protos.Status.DRIVER_RUNNING;
}
 
开发者ID:retz,项目名称:retz,代码行数:5,代码来源:LocalSchedulerDriver.java

示例11: acceptOffers

import org.apache.mesos.Protos; //导入方法依赖的package包/类
public Protos.Status acceptOffers(Collection<Protos.OfferID> offerIds,
                                      Collection<Protos.Offer.Operation> operations,
                                      Protos.Filters filters) {
        // Shouldn't be used
        throw new UnknownError();
//        this.accepted.addAll(offerIds);
//        for (Protos.OfferID id : offerIds) {
//            Protos.Offer.Builder ob = offers.get(id).toBuilder();
//
//
//            for (Protos.Offer.Operation op : operations) {
//                switch (op.getType().getNumber()) {
//                    case Protos.Offer.Operation.Type.LAUNCH_VALUE: {
//                        tasks.addAll(op.getLaunch().getTaskInfosList());
//                        break;
//                    }
//                    case Protos.Offer.Operation.Type.RESERVE_VALUE: {
//                        // TODO: aggregate against same principal/roles
//                        reserved.addAll(op.getReserve().getResourcesList());
//                        break;
//                    }
//                    case Protos.Offer.Operation.Type.CREATE_VALUE: {
//                        volumes.addAll(op.getCreate().getVolumesList());
//                        break;
//                    }
//                    case Protos.Offer.Operation.Type.DESTROY_VALUE: {
//                        for (Protos.Resource r : op.getDestroy().getVolumesList()) {
//                            volumes.remove(r);
//                        }
//                        break;
//                    }
//                    case Protos.Offer.Operation.Type.UNRESERVE_VALUE: {
//                        for (Protos.Resource r : op.getUnreserve().getResourcesList()) {
//                            reserved.remove(r);
//                        }
//                        break;
//                    }
//                    default:
//                        fail();
//                }
//            }
//        }
//        return Protos.Status.DRIVER_RUNNING;
    }
 
开发者ID:retz,项目名称:retz,代码行数:45,代码来源:MesosSchedulerDummyDriver.java

示例12: resourceOffers

import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public void resourceOffers(SchedulerDriver schedulerDriver, List<Protos.Offer> offers) {

    loggerWrapper.debug("Resource offers with " + offers.size() + " offers" );

    for (Protos.Offer offer : offers) {
        if (!constraints.constraintsAllow(offer) ||
                runningInstances.size() + pendingInstances.size() >= desiredInstances) {
            schedulerDriver.declineOffer(offer.getId());
            schedulerDriver.suppressOffers();
            continue;
        }

        Double offerCpus = 0d;
        Double offerMem = 0d;
        for (Resource resource : offer.getResourcesList()) {
          if (resource.getName().equals("cpus")) {
            offerCpus += resource.getScalar().getValue();
          } else if (resource.getName().equals("mem")) {
            offerMem += resource.getScalar().getValue();
          }
        }
        if (offerCpus < cpu || offerMem < memory) {
            schedulerDriver.declineOffer(offer.getId());
            continue;
        }

        List<Protos.TaskInfo> tasks = new ArrayList<>();
        // generate a unique task ID
        Protos.TaskID taskId = Protos.TaskID.newBuilder()
                .setValue(TaskIdGeneratorHelper.getTaskId(context)).build();

        loggerWrapper.debug("Launching task " + taskId.getValue());
        pendingInstances.add(taskId.getValue());

        // docker image info
        Protos.ContainerInfo.DockerInfo.Builder dockerInfoBuilder = Protos.ContainerInfo.DockerInfo.newBuilder();
        dockerInfoBuilder.setImage(imageName);
        dockerInfoBuilder.setNetwork(Protos.ContainerInfo.DockerInfo.Network.BRIDGE);
        dockerInfoBuilder.setForcePullImage(forcePullImage);
        if (!parameters.isEmpty()) {
            dockerInfoBuilder.addAllParameters(parameters);
        }

        // container info
        Protos.ContainerInfo.Builder containerInfoBuilder = Protos.ContainerInfo.newBuilder();
        containerInfoBuilder.setType(Protos.ContainerInfo.Type.DOCKER);
        containerInfoBuilder.setDocker(dockerInfoBuilder.build());
        if (!volumes.isEmpty()) {
            containerInfoBuilder.addAllVolumes(volumes);
        }

        // create task to run
        Protos.TaskInfo task = Protos.TaskInfo.newBuilder()
                .setName("task " + taskId.getValue())
                .setTaskId(taskId)
                .setSlaveId(offer.getSlaveId())
                .addResources(Protos.Resource.newBuilder()
                        .setName("cpus")
                        .setType(Protos.Value.Type.SCALAR)
                        .setScalar(Protos.Value.Scalar.newBuilder().setValue(cpu)))
                .addResources(Protos.Resource.newBuilder()
                        .setName("mem")
                        .setType(Protos.Value.Type.SCALAR)
                        .setScalar(Protos.Value.Scalar.newBuilder().setValue(memory)))
                .setContainer(containerInfoBuilder)
                .setCommand(commandInfoBuilder)
                .build();

        tasks.add(task);

        loggerWrapper.task = task;
        loggerWrapper.stoptMesosTailWait();

        // Only accept offer when tasks size greater than 0.
        Protos.Filters filters = Protos.Filters.newBuilder().setRefuseSeconds(1).build();
        schedulerDriver.launchTasks(offer.getId(), tasks, filters);
    }
}
 
开发者ID:farmapromlab,项目名称:rundeck-mesos-plugin,代码行数:80,代码来源:DockerScheduler.java

示例13: AcceptOffers

import org.apache.mesos.Protos; //导入方法依赖的package包/类
public AcceptOffers(String hostname, Collection<Protos.OfferID> offerIds, Collection<Protos.Offer.Operation> operations, Protos.Filters filters) {
	this.hostname = hostname;
	this.offerIds = offerIds;
	this.operations = operations;
	this.filters = filters;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:7,代码来源:AcceptOffers.java

示例14: filters

import org.apache.mesos.Protos; //导入方法依赖的package包/类
public Protos.Filters filters() {
	return filters;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:4,代码来源:AcceptOffers.java

示例15: declineOffer

import org.apache.mesos.Protos; //导入方法依赖的package包/类
public Protos.Status declineOffer(Protos.OfferID id, Protos.Filters filters) {
    declinedOffers.add(id.getValue());
    return status;
}
 
开发者ID:elodina,项目名称:java-mesos-util,代码行数:5,代码来源:TestSchedulerDriver.java


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