Search in sources :

Example 1 with Cache

use of org.apache.archiva.redback.components.cache.Cache in project archiva by apache.

the class DefaultSystemStatusService method getCacheEntries.

@Override
public List<CacheEntry> getCacheEntries() throws ArchivaRestServiceException {
    List<CacheEntry> cacheEntries = new ArrayList<CacheEntry>(caches.size());
    DecimalFormat decimalFormat = new DecimalFormat("#%");
    for (Map.Entry<String, Cache> entry : caches.entrySet()) {
        CacheStatistics cacheStatistics = entry.getValue().getStatistics();
        cacheEntries.add(new CacheEntry(entry.getKey(), cacheStatistics.getSize(), cacheStatistics.getCacheHits(), cacheStatistics.getCacheMiss(), decimalFormat.format(cacheStatistics.getCacheHitRate()).toString(), cacheStatistics.getInMemorySize()));
    }
    Collections.sort(cacheEntries, new CacheEntryComparator());
    return cacheEntries;
}
Also used : CacheStatistics(org.apache.archiva.redback.components.cache.CacheStatistics) DecimalFormat(java.text.DecimalFormat) ArrayList(java.util.ArrayList) CacheEntry(org.apache.archiva.rest.api.model.CacheEntry) Map(java.util.Map) Cache(org.apache.archiva.redback.components.cache.Cache)

Example 2 with Cache

use of org.apache.archiva.redback.components.cache.Cache in project archiva by apache.

the class DefaultSystemStatusService method clearCache.

@Override
public Boolean clearCache(String cacheKey) throws ArchivaRestServiceException {
    Cache cache = caches.get(cacheKey);
    if (cache == null) {
        throw new ArchivaRestServiceException("no cache for key: " + cacheKey, Response.Status.BAD_REQUEST.getStatusCode(), null);
    }
    cache.clear();
    return Boolean.TRUE;
}
Also used : ArchivaRestServiceException(org.apache.archiva.rest.api.services.ArchivaRestServiceException) Cache(org.apache.archiva.redback.components.cache.Cache)

Aggregations

Cache (org.apache.archiva.redback.components.cache.Cache)2 DecimalFormat (java.text.DecimalFormat)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 CacheStatistics (org.apache.archiva.redback.components.cache.CacheStatistics)1 CacheEntry (org.apache.archiva.rest.api.model.CacheEntry)1 ArchivaRestServiceException (org.apache.archiva.rest.api.services.ArchivaRestServiceException)1