use of com.google.gerrit.server.config.CacheResource in project gerrit by GerritCodeReview.
the class PostCaches method flush.
private void flush(List<String> cacheNames) throws UnprocessableEntityException, AuthException, PermissionBackendException {
List<CacheResource> cacheResources = new ArrayList<>(cacheNames.size());
for (String n : cacheNames) {
String pluginName = PluginName.GERRIT;
String cacheName = n;
int i = cacheName.lastIndexOf('-');
if (i != -1) {
pluginName = cacheName.substring(0, i);
cacheName = cacheName.length() > i + 1 ? cacheName.substring(i + 1) : "";
}
Cache<?, ?> cache = cacheMap.get(pluginName, cacheName);
if (cache != null) {
cacheResources.add(new CacheResource(pluginName, cacheName, cache));
} else {
throw new UnprocessableEntityException(String.format("cache %s not found", n));
}
}
for (CacheResource rsrc : cacheResources) {
flushCache.apply(rsrc, null);
}
}
use of com.google.gerrit.server.config.CacheResource in project gerrit by GerritCodeReview.
the class CachesCollection method parse.
@Override
public CacheResource parse(ConfigResource parent, IdString id) throws AuthException, ResourceNotFoundException, PermissionBackendException {
permissionBackend.currentUser().check(GlobalPermission.VIEW_CACHES);
String cacheName = id.get();
String pluginName = PluginName.GERRIT;
int i = cacheName.lastIndexOf('-');
if (i != -1) {
pluginName = cacheName.substring(0, i);
cacheName = cacheName.length() > i + 1 ? cacheName.substring(i + 1) : "";
}
Provider<Cache<?, ?>> cacheProvider = cacheMap.byPlugin(pluginName).get(cacheName);
if (cacheProvider == null) {
throw new ResourceNotFoundException(id);
}
return new CacheResource(pluginName, cacheName, cacheProvider);
}
use of com.google.gerrit.server.config.CacheResource in project gerrit by GerritCodeReview.
the class PostCaches method flushAll.
private void flushAll() throws AuthException, PermissionBackendException {
for (Extension<Cache<?, ?>> e : cacheMap) {
CacheResource cacheResource = new CacheResource(e.getPluginName(), e.getExportName(), e.getProvider());
if (FlushCache.WEB_SESSIONS.equals(cacheResource.getName())) {
continue;
}
flushCache.apply(cacheResource, null);
}
}
Aggregations