[MRM-1580] system status page display queues.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1299659 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-03-12 13:03:38 +00:00
parent 2b9a8630f1
commit 90e0bea025
13 changed files with 116 additions and 4 deletions

View File

@ -20,6 +20,7 @@ package org.apache.archiva.rest.api.model;
*/
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
/**
* AdminRepositoryConsumer
@ -28,6 +29,7 @@ import javax.xml.bind.annotation.XmlRootElement;
*/
@XmlRootElement( name = "adminRepositoryConsumer" )
public class AdminRepositoryConsumer
implements Serializable
{
private boolean enabled = false;

View File

@ -19,6 +19,7 @@ package org.apache.archiva.rest.api.model;
*/
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.Date;
/**
@ -27,6 +28,7 @@ import java.util.Date;
*/
@XmlRootElement( name = "archivaRepositoryStatistics" )
public class ArchivaRepositoryStatistics
implements Serializable
{
private Date scanEndTime;

View File

@ -19,6 +19,7 @@ package org.apache.archiva.rest.api.model;
*/
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
@ -28,6 +29,7 @@ import java.util.List;
*/
@XmlRootElement( name = "browseResult" )
public class BrowseResult
implements Serializable
{
private List<BrowseResultEntry> browseResultEntries;

View File

@ -19,6 +19,7 @@ package org.apache.archiva.rest.api.model;
*/
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
/**
* @author Olivier Lamy
@ -26,7 +27,7 @@ import javax.xml.bind.annotation.XmlRootElement;
*/
@XmlRootElement( name = "browseResultEntry" )
public class BrowseResultEntry
implements Comparable<BrowseResultEntry>
implements Comparable<BrowseResultEntry>, Serializable
{
private String name;

View File

@ -19,6 +19,7 @@ package org.apache.archiva.rest.api.model;
*/
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.List;
/**
@ -27,6 +28,7 @@ import java.util.List;
*/
@XmlRootElement( name = "policyInformation" )
public class PolicyInformation
implements Serializable
{
private List<String> options;

View File

@ -1,6 +1,7 @@
package org.apache.archiva.rest.api.model;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@ -24,6 +25,7 @@ import java.util.List;
*/
@XmlRootElement( name = "searchRequest" )
public class SearchRequest
implements Serializable
{
/**

View File

@ -19,6 +19,7 @@ package org.apache.archiva.rest.api.model;
*/
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@ -30,6 +31,7 @@ import java.util.List;
*/
@XmlRootElement( name = "stringList" )
public class StringList
implements Serializable
{
private List<String> strings;

View File

@ -19,6 +19,7 @@ package org.apache.archiva.rest.api.model;
*/
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.List;
/**
@ -26,6 +27,7 @@ import java.util.List;
*/
@XmlRootElement( name = "versionsList" )
public class VersionsList
implements Serializable
{
private List<String> versions;

View File

@ -18,6 +18,7 @@ package org.apache.archiva.rest.api.services;
* under the License.
*/
import org.apache.archiva.rest.api.model.QueueEntry;
import org.apache.archiva.security.common.ArchivaRoleConstants;
import org.codehaus.plexus.redback.authorization.RedbackAuthorization;
@ -26,6 +27,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.List;
/**
* @author Olivier Lamy
@ -48,4 +50,11 @@ public interface SystemStatusService
String getCurrentServerTime( @PathParam( "locale" ) String locale )
throws ArchivaRestServiceException;
@Path( "queueEntries" )
@GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
@RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
List<QueueEntry> getQueueEntries()
throws ArchivaRestServiceException;
}

View File

@ -18,13 +18,22 @@ package org.apache.archiva.rest.services;
* under the License.
*/
import org.apache.archiva.rest.api.model.QueueEntry;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.api.services.SystemStatusService;
import org.codehaus.plexus.taskqueue.TaskQueue;
import org.codehaus.plexus.taskqueue.TaskQueueException;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import javax.inject.Inject;
import javax.ws.rs.core.Response;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
/**
* @author Olivier Lamy
@ -32,8 +41,21 @@ import java.util.Locale;
*/
@Service( "systemStatusService#rest" )
public class DefaultSystemStatusService
extends AbstractRestService
implements SystemStatusService
{
private ApplicationContext applicationContext;
Map<String, TaskQueue> queues = null;
@Inject
public DefaultSystemStatusService( ApplicationContext applicationContext )
{
this.applicationContext = applicationContext;
queues = getBeansOfType( applicationContext, TaskQueue.class );
}
public String getMemoryStatus()
throws ArchivaRestServiceException
{
@ -56,4 +78,25 @@ public class DefaultSystemStatusService
SimpleDateFormat sdf = new SimpleDateFormat( "EEE, d MMM yyyy HH:mm:ss Z", new Locale( locale ) );
return sdf.format( new Date() );
}
public List<QueueEntry> getQueueEntries()
throws ArchivaRestServiceException
{
try
{
List<QueueEntry> queueEntries = new ArrayList<QueueEntry>( queues.size() );
for ( Map.Entry<String, TaskQueue> entry : queues.entrySet() )
{
queueEntries.add( new QueueEntry( entry.getKey(), entry.getValue().getQueueSnapshot().size() ) );
}
return queueEntries;
}
catch ( TaskQueueException e )
{
log.error( e.getMessage(), e );
throw new ArchivaRestServiceException( e.getMessage(),
Response.Status.INTERNAL_SERVER_ERROR.getStatusCode() );
}
}
}

View File

@ -295,6 +295,8 @@ system-status.header.version.info=Version Information
system-status.header.version.timestampStr=Build Timestamp
system-status.header.scanning=Repository Scans Currently in Progress
system-status.header.scanning.inprogress.none=No scans in progress.
system-status.queues.grid.header.key=Queue
system-status.queues.grid.header.number=Size

View File

@ -561,11 +561,31 @@ $(function() {
// system status part
//---------------------------
QueueEntry=function(key,entriesNumber){
this.key=key;
this.entriesNumber=entriesNumber;
}
mapQueueEntries=function(data){
if (data!=null){
return $.map(data,function(item){
return new QueueEntry(item.key,item.entriesNumber);
})
}
return null;
}
displaySystemStatus=function(){
screenChange();
var mainContent=$("#main-content");
mainContent.html($("#system-status-main").tmpl());
var versionInfo=$.i18n.prop('system-status.header.version.buildNumber')+": "+window.archivaRuntimeInfo.buildNumber
+" - "+$.i18n.prop('system-status.header.version.timestampStr')+": "+window.archivaRuntimeInfo.timestampStr;
mainContent.find("#status_version_info").html(versionInfo);
$.ajax("restServices/archivaServices/systemStatusService/memoryStatus", {
type: "GET",
dataType: "text",
@ -585,9 +605,13 @@ $(function() {
}
});
var versionInfo=$.i18n.prop('system-status.header.version.buildNumber')+": "+window.archivaRuntimeInfo.buildNumber
+" - "+$.i18n.prop('system-status.header.version.timestampStr')+": "+window.archivaRuntimeInfo.timestampStr;
mainContent.find("#status_version_info").html(versionInfo);
$.ajax("restServices/archivaServices/systemStatusService/queueEntries", {
type: "GET",
success: function(data){
var queueEntries=mapQueueEntries(data);
mainContent.find("#status_queues").html($("#status_queues_tmpl" ).tmpl({queueEntries: queueEntries}));
}
});
}

View File

@ -354,6 +354,25 @@
</script>
<script id="status_queues_tmpl" type="text/html">
<table class="table table-condensed">
<thead>
<tr>
<th>${$.i18n.prop('system-status.queues.grid.header.key')}</th>
<th>${$.i18n.prop('system-status.queues.grid.header.number')}</th>
</tr>
</thead>
<tbody>
{{each(i,queueEntry) queueEntries}}
<tr>
<td>${queueEntry.key}</td>
<td>${queueEntry.entriesNumber}</td>
</tr>
{{/each}}
</tbody>
</table>
</script>