src/main/java/com/ning/metrics/goodwill/access/CachingGoodwillAccessor.java
public void refreshSchemataCache()
    {
        try {
            final List<GoodwillSchema> schemata = delegate.getSchemata().get();

            // If Goodwill is down - keep the old cache around
            if (schemata == null) {
                return;
            }

            final Map<String,GoodwillSchema> newSchemataCache = new ConcurrentHashMap<String, GoodwillSchema>();
            for (final GoodwillSchema schema : schemata) {
                newSchemataCache.put(schema.getName(), schema);
            }

            synchronized (cacheMonitor) {
                knownSchemata.clear();
                knownSchemata.putAll(newSchemataCache);
            }
        }
        catch (InterruptedException e) {
            log.warn("Interrupted while refreshing the cache");
            Thread.currentThread().interrupt();
        }
        catch (ExecutionException e) {
            log.warn("Unable to refresh schemata cache: {}", e.getLocalizedMessage());
        }
    }
public void refreshSchemataCache()
    {
        try {
            final List<GoodwillSchema> schemata = delegate.getSchemata().get();

            // If Goodwill is down - keep the old cache around
            if (schemata == null) {
                return;
            }

            final Map<String,GoodwillSchema> newSchemataCache = new ConcurrentHashMap<String, GoodwillSchema>();
            for (final GoodwillSchema schema : schemata) {
                newSchemataCache.put(schema.getName(), schema);
            }

            synchronized (cacheMonitor) {
                knownSchemata.clear();
                knownSchemata.putAll(newSchemataCache);
            }
        }
        catch (InterruptedException e) {
            log.warn("Interrupted while refreshing the cache");
            Thread.currentThread().interrupt();
        }
        catch (ExecutionException e) {
            log.warn("Unable to refresh schemata cache: {}", e.getLocalizedMessage());
        }
    }
public void refreshSchemataCache ( ) { try { final List < GoodwillSchema > schemata = delegate . getSchemata ( ) . get ( ) ; // If Goodwill is down - keep the old cache around if ( schemata == null ) { return ; } final Map < String , GoodwillSchema > newSchemataCache = new ConcurrentHashMap < String , GoodwillSchema > ( ) ; for ( final GoodwillSchema schema : schemata ) { newSchemataCache . put ( schema . getName ( ) , schema ) ; } synchronized ( cacheMonitor ) { knownSchemata . clear ( ) ; knownSchemata . putAll ( newSchemataCache ) ; } } catch ( InterruptedException e ) { log . warn ( "Interrupted while refreshing the cache" ) ; Thread . currentThread ( ) . interrupt ( ) ; } catch ( ExecutionException e ) { log . warn ( "Unable to refresh schemata cache: {}" , e . getLocalizedMessage ( ) ) ; } }
Invalidate and refresh the cache
<p/>
This is blocking and returns when the cache has been updated
Invalidate and refresh the cache <p / > This is blocking and returns when the cache has been updated