コード例 #1
0
  /**
   * Convert a list of {@link com.rackspacecloud.blueflood.types.Points} into a list of {@link
   * com.rackspacecloud.blueflood.service.SingleRollupWriteContext} for the given Granularity and
   * Locator.
   *
   * @param locator
   * @param points
   * @param gran
   * @return
   */
  protected List<SingleRollupWriteContext> toWriteContext(
      Locator locator, Points<Rollup> points, Granularity gran) {

    List<SingleRollupWriteContext> resultList = new ArrayList<SingleRollupWriteContext>();

    for (Map.Entry<Long, Points.Point<Rollup>> entry : points.getPoints().entrySet()) {

      resultList.add(
          new SingleRollupWriteContext(
              entry.getValue().getData(),
              locator,
              gran,
              CassandraModel.getBasicColumnFamily(gran),
              entry.getKey()));
    }

    return resultList;
  }
コード例 #2
0
  /**
   * Create a single {@link com.rackspacecloud.blueflood.service.SingleRollupWriteContext} from the
   * given {@link com.rackspacecloud.blueflood.types.IMetric} and Granularity.
   *
   * @param destGran
   * @param metric
   * @return
   * @throws IOException
   */
  protected SingleRollupWriteContext createSingleRollupWriteContext(
      Granularity destGran, IMetric metric) throws IOException {

    Locator locator = metric.getLocator();

    Points<SimpleNumber> points = new Points<SimpleNumber>();
    points.add(
        new Points.Point<SimpleNumber>(
            metric.getCollectionTime(), new SimpleNumber(metric.getMetricValue())));

    BasicRollup rollup = BasicRollup.buildRollupFromRawSamples(points);

    return new SingleRollupWriteContext(
        rollup,
        locator,
        destGran,
        CassandraModel.getBasicColumnFamily(destGran),
        metric.getCollectionTime());
  }