Examples of RichGauge


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

  }

  @ResponseBody
  @RequestMapping(value = "/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
  public RichGaugeResource display(@PathVariable("name") String name) {
    RichGauge g = repository.findOne(name);
    if (g == null) {
      throw new NoSuchMetricException(name, "There is no rich gauge named '%s'");
    }
    return gaugeResourceAssembler.toResource(g);
  }
View Full Code Here

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

  @Test
  public void gaugeRetrievalSucceedsWithCorrectValues() throws Exception {

    when(richGaugeRepository.findOne("mygauge"))
        .thenReturn(new RichGauge("mygauge", 57.0, -1.0, 56.0, 57.0, 55.0, 2));

    mockMvc.perform(get("/metrics/rich-gauges/mygauge").accept(MediaType.APPLICATION_JSON))
        .andExpect(status().isOk())
        .andExpect(jsonPath("$.name").value("mygauge"))
        .andExpect(jsonPath("$.value").value(57.0))
View Full Code Here

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

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

  @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

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

  @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

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

  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

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

    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

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

  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
Copyright © 2018 www.massapi.com. 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.