Package org.springframework.xd.analytics.metrics.core

Examples of org.springframework.xd.analytics.metrics.core.RichGauge


  public void getOrCreateReturnsCorrectInstance() throws Exception {
    RichGaugeRepository gs = createService();
    gs.setValue("test", 9.99);
    gs.setValue("test", 0.01);

    RichGauge g = gs.findOne("test");
    assertEquals("test", g.getName());
    assertEquals(0.01, g.getValue(), 1E-6);
    assertEquals(5.0, g.getAverage(), 1E-6);
    assertEquals(9.99, g.getMax(), 1E-6);
    assertEquals(0.01, g.getMin(), 1E-6);
  }
View Full Code Here


  @Test
  public void resetExistingGaugeCausesReset() throws Exception {
    RichGaugeRepository gs = createService();
    gs.setValue("test", 9.99);
    gs.reset("test");
    RichGauge g = gs.findOne("test");
    assertEquals(0.0, g.getValue(), 1E-6);
  }
View Full Code Here

  @Test
  public void testExponentialMovingAverage() throws Exception {
    RichGaugeRepository gs = createService();
    gs.setAlpha("test", 0.1);
    gs.setValue("test", 71.0);
    RichGauge g = gs.findOne("test");
    assertEquals(71.0, g.getAverage(), 1E-6);
    gs.setValue("test", 70.0);
    g = gs.findOne("test");
    assertEquals(71.0, g.getAverage(), 1E-6);
    gs.setValue("test", 69.0);
    g = gs.findOne("test");
    assertEquals(70.9, g.getAverage(), 1E-6);
    gs.setValue("test", 68.0);
    g = gs.findOne("test");
    assertEquals(70.71, g.getAverage(), 1E-6);
  }
View Full Code Here

  public void testhandler() {
    input.send(new GenericMessage<Double>(10.0));
    input.send(new GenericMessage<Double>(20.0));
    input.send(new GenericMessage<Double>(24.0));

    RichGauge gauge = repo.findOne("test");
    assertNotNull(gauge);
    assertEquals(3, gauge.getCount());
    assertEquals(24.0, gauge.getMax(), 0.001);
    assertEquals(10.0, gauge.getMin(), 0.001);
    assertEquals(18.0, gauge.getAverage(), 0.001);
    // Included here because the message handler constructor creates the gauge. Don't want to
    // delete it in @After.
    repo.delete("test");
  }
View Full Code Here

    JsonNode node = txf.transform(json);
    assertEquals(73.0, node.get("price").asDouble(), 0.001);

    input.send(new GenericMessage<Object>(node));

    RichGauge gauge = repo.findOne("test");
    assertNotNull(gauge);
    assertEquals(73.0, gauge.getValue(), 0.001);
    // assertEquals(1, gauge.getCount());

    // Included here because the message handler constructor creates the gauge. Don't want to
    // delete it in @After.
    repo.delete("test");
View Full Code Here

  public RichGaugeHandler(RichGaugeRepository richGaugeRepository, String name, double alpha) {
    Assert.notNull(richGaugeRepository, "Rich Gauge Service can not be null");
    Assert.notNull(name, "Rich Gauge Name can not be null");
    this.richGaugeRepository = richGaugeRepository;
    this.name = name;
    this.richGaugeRepository.save(new RichGauge(name).setAlpha(alpha));
  }
View Full Code Here

TOP

Related Classes of org.springframework.xd.analytics.metrics.core.RichGauge

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.