[MRM-1580] system status page flush cache link.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1299684 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-03-12 14:30:09 +00:00
parent fac85e0b4b
commit 97a31442ea
7 changed files with 51 additions and 0 deletions

View File

@ -65,4 +65,11 @@ public interface SystemStatusService
List<CacheEntry> getCacheEntries() List<CacheEntry> getCacheEntries()
throws ArchivaRestServiceException; throws ArchivaRestServiceException;
@Path( "clearCache/{key}" )
@GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
@RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
Boolean clearCache( @PathParam( "key" ) String cacheKey )
throws ArchivaRestServiceException;
} }

View File

@ -126,4 +126,18 @@ public class DefaultSystemStatusService
return cacheEntries; return cacheEntries;
} }
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() );
}
cache.clear();
return Boolean.TRUE;
}
} }

View File

@ -298,6 +298,14 @@ system-status.header.scanning.inprogress.none=No scans in progress.
system-status.queues.grid.header.key=Queue system-status.queues.grid.header.key=Queue
system-status.queues.grid.header.number=Size system-status.queues.grid.header.number=Size
system-status.header.main=System Status system-status.header.main=System Status
system-status.caches.grid.header.cacheHits=Hits
system-status.queues.grid.header.size=Size
system-status.caches.grid.header.cacheMiss=Misses
system-status.caches.grid.header.cacheHitRate=Hit Ratio
system-status.caches.grid.header.flush=Flush
system-status.caches.grid.header.key=Cache
system-status.caches.flushed=Cache {0} flushed.
system-status.caches.grid.header.size=Size

Binary file not shown.

After

Width:  |  Height:  |  Size: 786 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 B

View File

@ -603,6 +603,18 @@ $(function() {
}); });
} }
flushCache=function(key){
clearUserMessages();
$("#main-content #status_caches").html(smallSpinnerImg());
$.ajax("restServices/archivaServices/systemStatusService/clearCache/"+encodeURIComponent(key), {
type: "GET",
success: function(data){
displaySuccessMessage( $.i18n.prop("system-status.caches.flushed",key));
displayCacheEntries();
}
});
}
displaySystemStatus=function(){ displaySystemStatus=function(){
screenChange(); screenChange();
var mainContent=$("#main-content"); var mainContent=$("#main-content");

View File

@ -367,6 +367,7 @@
<th>${$.i18n.prop('system-status.caches.grid.header.cacheHits')}</th> <th>${$.i18n.prop('system-status.caches.grid.header.cacheHits')}</th>
<th>${$.i18n.prop('system-status.caches.grid.header.cacheMiss')}</th> <th>${$.i18n.prop('system-status.caches.grid.header.cacheMiss')}</th>
<th>${$.i18n.prop('system-status.caches.grid.header.cacheHitRate')}</th> <th>${$.i18n.prop('system-status.caches.grid.header.cacheHitRate')}</th>
<th>${$.i18n.prop('system-status.caches.grid.header.flush')}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -377,6 +378,15 @@
<td>${cacheEntry.cacheHits}</td> <td>${cacheEntry.cacheHits}</td>
<td>${cacheEntry.cacheMiss}</td> <td>${cacheEntry.cacheMiss}</td>
<td>${cacheEntry.cacheHitRate}</td> <td>${cacheEntry.cacheHitRate}</td>
<td>
<a href="#" onclick="flushCache('${cacheEntry.key}')">
{{if cacheEntry.size > 0 }}
<img src="images/user-trash-full.png"/>
{{else}}
<img src="images/user-trash.png"/>
{{/if}}
</a>
</td>
</tr> </tr>
{{/each}} {{/each}}
</tbody> </tbody>