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

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


    super(connectionFactory, gaugePrefix);
  }

  @Override
  Gauge create(String name, Long value) {
    return new Gauge(name, value);
  }
View Full Code Here


  }

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

  public void testhandler() {
    input.send(new GenericMessage<Long>(10L));
    input.send(new GenericMessage<Long>(20L));
    input.send(new GenericMessage<Long>(24L));

    Gauge gauge = repo.findOne("test");
    assertNotNull(gauge);
    assertEquals(24, gauge.getValue());
    // 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, node.get("price").asLong());

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

    Gauge gauge = repo.findOne("test");
    assertNotNull(gauge);
    assertEquals(73, gauge.getValue());
    // 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 void setValueAndResetWorkAsExpected() {
    String gaugeName = "simpleGauge";
    gaugeRepository.setValue(gaugeName, 1);
    Gauge g = gaugeRepository.findOne(gaugeName);
    assertThat(g.getValue(), equalTo(1L));

    gaugeRepository.setValue(gaugeName, 20);
    assertThat(gaugeRepository.findOne(gaugeName).getValue(), equalTo(20L));

    gaugeRepository.reset(gaugeName);
View Full Code Here

    GaugeRepository repo = gaugeRepository;
    String myGaugeName = "myGauge";
    String yourGaugeName = "yourGauge";

    // Create and save a Gauge named 'myGauge'
    Gauge g1 = new Gauge(myGaugeName);
    Gauge myGauge = repo.save(g1);
    assertThat(myGauge.getName(), is(notNullValue()));
    // Create and save a Gauge named 'yourGauge'
    Gauge g2 = new Gauge(yourGaugeName);
    Gauge yourGauge = repo.save(g2);
    assertThat(yourGauge.getName(), is(notNullValue()));
    assertTrue(repo.exists(yourGauge.getName()));

    // Retrieve by name and compare for equality to previously saved instance.
    Gauge result = repo.findOne(myGaugeName);
    assertThat(result, equalTo(myGauge));

    result = repo.findOne(yourGauge.getName());
    assertThat(result, equalTo(yourGauge));
View Full Code Here

@ContextConfiguration(classes = { RestConfiguration.class, Dependencies.class })
public class GaugeControllerIntegrationTests extends AbstractControllerIntegrationTest {

  @Test
  public void gaugeRetrievalSucceeds() throws Exception {
    when(gaugeRepository.findOne("mygauge")).thenReturn(new Gauge("mygauge", 55));
    mockMvc.perform(get("/metrics/gauges/mygauge").accept(MediaType.APPLICATION_JSON))
        .andExpect(status().isOk())
        .andExpect(jsonPath("$.name").value("mygauge"))
        .andExpect(jsonPath("$.value").value(55));
  }
View Full Code Here

public final class InMemoryGaugeRepository extends InMemoryMetricRepository<Gauge> implements
    GaugeRepository {

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

  }

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

    return gauge;
  }

  @Override
  public void setValue(String name, long value) {
    Gauge gauge = getOrCreate(name);
    setGaugeValue(gauge, value);
  }
View Full Code Here

TOP

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

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.