public static Points<String> generateFakeStringPoints() {
   Points<String> points = new Points<String>();
   long startTime = 1234567L;
   for (int i = 0; i < 5; i++) {
     long timeNow = startTime + i * 1000;
     Points.Point<String> point = new Points.Point<String>(timeNow, String.valueOf(timeNow));
     points.add(point);
   }
   return points;
 }
  public static Points<Long> generateFakeFullResPoints() {
    Points<Long> points = Points.create(Granularity.FULL);

    long baseTime = 1234567L;
    for (int count = 0; count < 5; count++) {
      Points.Point<Long> point = new Points.Point<Long>(baseTime + (count * 1000), (long) count);
      points.add(point);
    }

    return points;
  }
 public static Points<HistogramRollup> generateFakeHistogramRollupPoints() {
   Points<HistogramRollup> points = new Points<HistogramRollup>();
   long startTime = 1234567L;
   for (int i = 0; i < 5; i++) {
     long timeNow = startTime + i * 1000;
     Points.Point<HistogramRollup> point =
         new Points.Point<HistogramRollup>(timeNow, new HistogramRollup(getBins()));
     points.add(point);
   }
   return points;
 }
 public static Points<GaugeRollup> generateFakeGaugeRollups() {
   Points<GaugeRollup> points = new Points<GaugeRollup>();
   long startTime = 1234567L;
   for (int i = 0; i < 5; i++) {
     long timeNow = startTime + i * 1000;
     Points.Point<GaugeRollup> point =
         new Points.Point<GaugeRollup>(timeNow, new GaugeRollup().withLatest(timeNow, i));
     points.add(point);
   }
   return points;
 }
  public static Points<SimpleNumber> generateFakeFullResPoints() {
    Points<SimpleNumber> points = new Points<SimpleNumber>();

    long baseTime = 1234567L;
    for (int count = 0; count < 5; count++) {
      Points.Point<SimpleNumber> point =
          new Points.Point<SimpleNumber>(baseTime + (count * 1000), new SimpleNumber((long) count));
      points.add(point);
    }

    return points;
  }
 public static Points<SetRollup> generateFakeSetRollupPoints() {
   Points<SetRollup> points = new Points<SetRollup>();
   long startTime = 1234567L;
   for (int i = 0; i < 5; i++) {
     long timeNow = startTime + i * 1000;
     Points.Point<SetRollup> point =
         new Points.Point<SetRollup>(
             timeNow, new SetRollup().withObject(i).withObject(i % 2).withObject(i / 2));
     points.add(point);
   }
   return points;
 }
 public static Points<CounterRollup> generateFakeCounterRollupPoints() {
   Points<CounterRollup> points = new Points<CounterRollup>();
   long startTime = 1234567L;
   for (int i = 0; i < 5; i++) {
     long timeNow = startTime + i * 1000;
     Points.Point<CounterRollup> point =
         new Points.Point<CounterRollup>(
             timeNow,
             new CounterRollup().withCount(i + 1000).withRate((double) i).withSampleCount(1));
     points.add(point);
   }
   return points;
 }
  public static Points<Rollup> generateFakeRollupPoints() {
    Points<Rollup> points = Points.create(Granularity.MIN_5);

    long baseTime = 1234567L;
    for (int count = 0; count < 5; count++) {
      final Rollup rollup = new Rollup();
      rollup.setCount(count * 100);
      rollup.getAverage().setLongValue(count);
      Points.Point<Rollup> point = new Points.Point<Rollup>(baseTime + (count * 1000), rollup);
      points.add(point);
    }

    return points;
  }
  public static Points<BasicRollup> generateFakeRollupPoints() {
    Points<BasicRollup> points = new Points<BasicRollup>();

    long baseTime = 1234567L;
    for (int count = 0; count < 5; count++) {
      final BasicRollup basicRollup = new BasicRollup();
      basicRollup.setCount(count * 100);
      basicRollup.getAverage().setLongValue(count);
      Points.Point<BasicRollup> point =
          new Points.Point<BasicRollup>(baseTime + (count * 1000), basicRollup);
      points.add(point);
    }

    return points;
  }
Ejemplo n.º 10
0
 public static Points<String> generateFakeStringPoints() {
   Points<String> points = Points.create(Granularity.FULL);
   long startTime = 1234567L;
   for (int i = 0; i < 5; i++) {
     long timeNow = startTime + i * 1000;
     Points.Point<String> point = new Points.Point<String>(timeNow, String.valueOf(timeNow));
   }
   return points;
 }
  /**
   * 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());
  }
 public static Points<TimerRollup> generateFakeTimerRollups() {
   Points<TimerRollup> points = new Points<TimerRollup>();
   long startTime = 1234567L;
   for (int i = 0; i < 5; i++) {
     long timeNow = startTime + i * 1000;
     TimerRollup rollup =
         new TimerRollup()
             .withAverage(i)
             .withCount(i)
             .withCountPS(i * 0.1d)
             .withMaxValue(i)
             .withMinValue(i)
             .withSum(i + i)
             .withVariance(i);
     rollup.setPercentile("50", i);
     rollup.setPercentile("99", i * 2 + 1);
     Points.Point<TimerRollup> point = new Points.Point<TimerRollup>(timeNow, rollup);
     points.add(point);
   }
   return points;
 }
  /**
   * 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;
  }