Exemple #1
0
  static {
    // TODO where to obtain this from?
    CONFIGURATION = new HashConfiguration();

    LOOKUPS =
        WealdMetrics.getMetricRegistry()
            .meter(com.codahale.metrics.MetricRegistry.name(Hash.class, "lookups"));
    MISSES =
        WealdMetrics.getMetricRegistry()
            .meter(com.codahale.metrics.MetricRegistry.name(Hash.class, "misses"));
    GETS =
        WealdMetrics.getMetricRegistry()
            .timer(com.codahale.metrics.MetricRegistry.name(Hash.class, "gets"));
    final CacheBuilder<Object, Object> cb =
        CacheBuilder.newBuilder()
            .maximumSize(CONFIGURATION.getCacheConfiguration().getMaxEntries())
            .expireAfterWrite(
                CONFIGURATION.getCacheConfiguration().getMaxDuration(), TimeUnit.SECONDS);
    CACHE =
        cb.recordStats()
            .build(
                new CacheLoader<TwoTuple<String, String>, Boolean>() {
                  @Override
                  public Boolean load(final TwoTuple<String, String> input) {
                    MISSES.mark();
                    return calculateMatches(input.getS(), input.getT());
                  }
                });
  }
 public com.google.common.cache.CacheBuilder<Object, Object> recordStats() {
   return builder.recordStats();
 }