private synchronized void initializeCache() {
    if (isCacheInitialized) {
      return;
    }
    DefaultStatisticsService statisticsService = new DefaultStatisticsService();

    CacheManager manager = CacheManagerBuilder.newCacheManagerBuilder()
            .using(statisticsService)
            .build(true);

    // Create a Cache specifying its configuration.
    CacheConfigurationBuilder<TimelineAppMetricCacheKey, TimelineMetricsCacheValue> cacheConfigurationBuilder = createCacheConfiguration();
    Cache<TimelineAppMetricCacheKey, TimelineMetricsCacheValue> cache = manager.createCache(TIMELINE_METRIC_CACHE_INSTANCE_NAME, cacheConfigurationBuilder);

    // Decorate with timelineMetricsCache.
    timelineMetricsCache = new TimelineMetricCache(cache, cacheEntryFactory, statisticsService);

    LOG.info("Registering metrics cache with provider: name = " +
      TIMELINE_METRIC_CACHE_INSTANCE_NAME + ", manager = " + manager);

    isCacheInitialized = true;
  }
Cache implementation that provides ability to perform incremental reads
from Metrics backend and reduce the amount of calls between Ambari and the
Metrics backend.
ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/timeline/cache/TimelineMetricCacheProvider.java