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

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


public class InMemoryRichGaugeRepository extends InMemoryMetricRepository<RichGauge>
    implements RichGaugeRepository {

  @Override
  protected RichGauge create(String name) {
    return new RichGauge(name);
  }
View Full Code Here


  }

  @Override
  protected RichGauge getOrCreate(String name) {
    Assert.notNull(name, "Gauge name can not be null");
    RichGauge gauge = findOne(name);
    if (gauge == null) {
      gauge = new RichGauge(name);
      save(gauge);
    }
    return gauge;
  }
View Full Code Here

    return gauge;
  }

  @Override
  public void setValue(String name, double value) {
    RichGauge gauge = getOrCreate(name);
    setRichGaugeValue(gauge, value);
  }
View Full Code Here

    setRichGaugeValue(gauge, value);
  }

  @Override
  public void setAlpha(String name, double value) {
    RichGauge gauge = getOrCreate(name);
    save(setRichGaugeAlpha(gauge, value));
  }
View Full Code Here

    save(setRichGaugeAlpha(gauge, value));
  }

  @Override
  public void reset(String name) {
    RichGauge gauge = getOrCreate(name);
    setRichGaugeValue(gauge, 0);
  }
View Full Code Here

  @Override
  RichGauge create(String name, String value) {
    String[] parts = StringUtils.delimitedListToStringArray(value, " ");

    return new RichGauge(name, Double.valueOf(parts[0]), Double.valueOf(parts[1]),
        Double.valueOf(parts[2]), Double.valueOf(parts[3]),
        Double.valueOf(parts[4]), Long.valueOf(parts[5]));
  }
View Full Code Here

  }

  @Override
  public void setValue(String name, double value) {
    String key = getMetricKey(name);
    RichGauge g = findOne(name);
    if (g == null) {
      g = new RichGauge(name);
    }
    MetricUtils.setRichGaugeValue(g, value);
    getValueOperations().set(key, serialize(g));
  }
View Full Code Here

    return serialize(metric);
  }

  @Override
  public void setAlpha(String name, double value) {
    RichGauge g = findOne(name);
    if (g == null) {
      g = new RichGauge(name);
    }
    MetricUtils.setRichGaugeAlpha(g, value);
    save(g);
  }
View Full Code Here

  }

  @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

  @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

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.