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


Java Ranges类代码示例

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


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

示例1: getMatchingPair

import com.google.common.collect.Ranges; //导入依赖的package包/类
/** Get Matching variant from the queue
 * @param person trio member
 * @param snpPosition
 * @return Get matching variant call pairs at matching position
 */
private Pair<Variant, VariantCall> getMatchingPair(TrioMember person, Long snpPosition) {
  for (Pair<Variant, VariantCall> pair : getQueue(person)) {
    Variant variant = pair.getValue0();

    if (Ranges.closedOpen(variant.getStart(), variant.getEnd()).contains(snpPosition)) {
      return pair;
    }
  }
  return null;
}
 
开发者ID:googlegenomics,项目名称:denovo-variant-caller-java,代码行数:16,代码来源:VariantsBuffer.java

示例2: restartRunnableInstances

import com.google.common.collect.Ranges; //导入依赖的package包/类
/**
 * Helper method to restart instances of runnables.
 */
private void restartRunnableInstances(final String runnableName, @Nullable final Set<Integer> instanceIds,
                                      final Runnable completion) {
  instanceChangeExecutor.execute(new Runnable() {
    @Override
    public void run() {
      LOG.debug("Begin restart runnable {} instances.", runnableName);
      int runningCount = runningContainers.count(runnableName);
      Set<Integer> instancesToRemove = instanceIds == null ? null : ImmutableSet.copyOf(instanceIds);
      if (instancesToRemove == null) {
        instancesToRemove = Ranges.closedOpen(0, runningCount).asSet(DiscreteDomains.integers());
      }

      LOG.info("Restarting instances {} for runnable {}", instancesToRemove, runnableName);
      RunnableContainerRequest containerRequest =
        createRunnableContainerRequest(runnableName, instancesToRemove.size(), false);
      runnableContainerRequests.add(containerRequest);

      for (int instanceId : instancesToRemove) {
        LOG.debug("Stop instance {} for runnable {}", instanceId, runnableName);
        try {
          runningContainers.stopByIdAndWait(runnableName, instanceId);
        } catch (Exception ex) {
          // could be thrown if the container already stopped.
          LOG.info("Exception thrown when stopping instance {} probably already stopped.", instanceId);
        }
      }

      LOG.info("All instances in {} for runnable {} are stopped. Ready to provision",
               instancesToRemove, runnableName);

      // set the container request to be ready
      containerRequest.setReadyToBeProvisioned();

      // For all runnables that needs to re-request for containers, update the expected count timestamp
      // so that the EventHandler would be triggered with the right expiration timestamp.
      expectedContainers.updateRequestTime(Collections.singleton(runnableName));

      completion.run();
    }
  });
}
 
开发者ID:apache,项目名称:twill,代码行数:45,代码来源:ApplicationMasterService.java

示例3: getValuesFromRange

import com.google.common.collect.Ranges; //导入依赖的package包/类
private List<Object> getValuesFromRange() {
  int rangeStart = config.getInt(RANGE_START_PROPERTY);
  int rangeEnd = config.getInt(RANGE_END_PROPERTY);
  
  return Lists.<Object>newArrayList(Ranges.closed(rangeStart, rangeEnd).asSet(DiscreteDomains.integers()));
}
 
开发者ID:cloudera-labs,项目名称:envelope,代码行数:7,代码来源:LoopStep.java

示例4: txnRange

import com.google.common.collect.Ranges; //导入依赖的package包/类
private Range<Long> txnRange(SegmentStateProto seg) {
  Preconditions.checkArgument(seg.hasEndTxId(),
      "invalid segment: %s", seg);
  return Ranges.closed(seg.getStartTxId(), seg.getEndTxId());
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:6,代码来源:Journal.java

示例5: txnRange

import com.google.common.collect.Ranges; //导入依赖的package包/类
private Range<Long> txnRange(SegmentStateProto seg) {
  return Ranges.closed(seg.getStartTxId(), seg.getEndTxId());
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:4,代码来源:Journal.java

示例6: run

import com.google.common.collect.Ranges; //导入依赖的package包/类
@Override
public int run(String[] args) throws Exception {
  // going to generate a lot of random log messages
  final Random rand = new Random();

  // open the repository
  final DatasetRepository repo = DatasetRepositories.open("repo:file:/tmp/data");

  // data is written to the staging dataset
  final Dataset<GenericRecord> staging = repo.load("logs-staging");
  final DatasetWriter<GenericRecord> writer = staging.newWriter();

  // this is going to build our simple log records
  final GenericRecordBuilder builder = new GenericRecordBuilder(
      staging.getDescriptor().getSchema());

  // generate timestamps 1 second apart starting... now
  final Calendar now = Calendar.getInstance();
  final long yesterday = now.getTimeInMillis() - DAY_IN_MILLIS;

  try {
    writer.open();

    // generate 15,000 messages, each 5 seconds apart, starting 24 hours ago
    // this is a little less than 24 hours worth of messages
    for (int second : Ranges.closed(0, 15000).asSet(DiscreteDomains.integers())) {
      LOG.info("Generating log message " + second);

      builder.set("timestamp", yesterday + second * 5000);
      builder.set("component", "GenerateSimpleLogs");

      int level = rand.nextInt(LOG_LEVELS.length);
      builder.set("level", LOG_LEVELS[level]);
      builder.set("message", LOG_MESSAGES[level]);

      writer.write(builder.build());
    }
  } finally {
    writer.flush();
    writer.close();
  }

  return 0;
}
 
开发者ID:cloudera,项目名称:cdk-examples,代码行数:45,代码来源:GenerateSimpleLogs.java

示例7: run

import com.google.common.collect.Ranges; //导入依赖的package包/类
@Override
public int run(String[] args) throws Exception {
  // going to generate a lot of random log messages
  final Random rand = new Random();

  // data is written to the staging dataset
  Dataset<Record> staging = Datasets.load(
      "dataset:file:/tmp/data/logs_staging", Record.class);

  // this is going to build our simple log records
  GenericRecordBuilder builder = new GenericRecordBuilder(
      staging.getDescriptor().getSchema());

  // generate timestamps 1 second apart starting 1 day ago
  final Calendar now = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
  final long yesterday = now.getTimeInMillis() - DAY_IN_MILLIS;

  DatasetWriter<Record> writer = null;
  try {
    writer = staging.newWriter();

    // generate 15,000 messages, each 5 seconds apart, starting 24 hours ago
    // this is a little less than 24 hours worth of messages
    for (int second : Ranges.closed(0, 15000).asSet(DiscreteDomains.integers())) {
      LOG.info("Generating log message " + second);

      builder.set("timestamp", yesterday + second * 5000);
      builder.set("component", "GenerateSimpleLogs");

      int level = rand.nextInt(LOG_LEVELS.length);
      builder.set("level", LOG_LEVELS[level]);
      builder.set("message", LOG_MESSAGES[level]);

      writer.write(builder.build());
    }

    if (writer instanceof Flushable) {
      ((Flushable) writer).flush();
    }
  } finally {
    if (writer != null) {
      writer.close();
    }
  }

  return 0;
}
 
开发者ID:kite-sdk,项目名称:kite-examples,代码行数:48,代码来源:GenerateSimpleLogs.java

示例8: ports

import com.google.common.collect.Ranges; //导入依赖的package包/类
public RuleBuilder ports(int lowerPort, int upperPort) {
    return ports(Ranges.closed(lowerPort, upperPort));
}
 
开发者ID:apache,项目名称:incubator-provisionr,代码行数:4,代码来源:RuleBuilder.java

示例9: partitionExists

import com.google.common.collect.Ranges; //导入依赖的package包/类
/**
 * Checks whether the provided partition exists on the {@link Broker}.
 * 
 * @param broker
 *            the broker.
 * @param topic
 *            the topic.
 * @param partId
 *            the partition id.
 * @return true if this partition exists on the {@link Broker}, false otherwise.
 */
public boolean partitionExists(final Broker broker, final String topic, final int partId) {
    final String parts = client.readData(getTopicBrokerIdPath(topic, broker.getId()), true);
    return !Strings.isNullOrEmpty(parts) && Ranges.closedOpen(0, Integer.parseInt(parts)).contains(partId);
}
 
开发者ID:Conductor,项目名称:kangaroo,代码行数:16,代码来源:ZkUtils.java


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