Exemplo n.º 1
0
  @Test
  public void test() {

    LocalDateTime now = LocalDateTime.now();
    LocalDateTime keytime = now.withMinute(0).withSecond(0).withNano(0);

    mongoMetricsRepository.prepareMinutes(keytime);

    Map<String, Long> accumulators = Maps.newHashMap();
    accumulators.put(MetricKeys.globalTotalSize(), 5l);
    metricsService.sync(accumulators);

    Timeserie serie = metricsService.serie(MetricKeys.globalTotalSize());
    System.err.println(serie);
  }
Exemplo n.º 2
0
  @Before
  public void beforeEachTest() {

    CodecRegistry codecRegistry =
        CodecRegistries.fromRegistries(
            MongoClient.getDefaultCodecRegistry(),
            CodecRegistries.fromCodecs(
                new LocalDateTimeCodec(), new HostAndPortCodec(), new LocalDateTimeCodec()));

    MongoProperties properties = new MongoProperties();

    MongoClient mongoClient =
        new MongoClient(
            new MongoClientURI(
                properties.getUri(), MongoClientOptions.builder().codecRegistry(codecRegistry)));

    mongoMetricsRepository =
        new MongoMetricsRepository(mongoClient, properties, new ObjectMapper());

    mongoMetricsRepository.init();

    metricsService = new MetricsService(mongoMetricsRepository);
  }