コード例 #1
0
  /**
   * For a given list of locators, figure the shard they belong to and for all those shards get all
   * the locators in metric_locator column family
   *
   * @param ingestedLocators
   * @return
   * @throws IOException
   */
  protected Set<Locator> retrieveLocators(Set<Locator> ingestedLocators) throws IOException {

    Set<Long> shards = new HashSet<Long>();
    for (Locator locator : ingestedLocators) {
      long shard = (long) Util.getShard(locator.toString());
      shards.add(shard);
    }

    Set<Locator> locatorsFromDB = new HashSet<Locator>();
    for (Long shard : shards) {
      locatorsFromDB.addAll(locatorIO.getLocators(shard));
    }

    return locatorsFromDB;
  }
コード例 #2
0
  /**
   * For a given list of metrics, figure out the shard and slot they belong to and for those shard
   * and slot combinations, get all the locators from metrics_delayed_locator column family.
   *
   * @param metrics
   * @return
   * @throws IOException
   */
  protected Set<Locator> retrieveLocatorsByShardAndSlot(List<IMetric> metrics) throws IOException {
    Set<String> slotKeys = new HashSet<String>();

    for (IMetric metric : metrics) {
      int shard = Util.getShard(metric.getLocator().toString());
      int slot = DELAYED_METRICS_STORAGE_GRANULARITY.slot(metric.getCollectionTime());
      SlotKey slotKey = SlotKey.of(DELAYED_METRICS_STORAGE_GRANULARITY, slot, shard);

      slotKeys.add(slotKey.toString());
    }

    Set<Locator> locatorsFromDB = new HashSet<Locator>();
    for (String slotKeyStr : slotKeys) {
      locatorsFromDB.addAll(delayedLocatorIO.getLocators(SlotKey.parse(slotKeyStr)));
    }

    return locatorsFromDB;
  }