Search in sources :

Example 1 with TaskStatsRestRep

use of com.emc.storageos.model.tasks.TaskStatsRestRep in project coprhd-controller by CoprHD.

the class TaskService method getStats.

/**
 * Returns task status count information for the specified Tenant.
 *
 * @brief Task Status count
 * @param tenantId
 *            Tenant URI of the tenant the count is required for. If not supplied, the logged in users tenant will
 *            be used.
 *            A value of 'system' will return system tasks
 * @return Count of tasks in different statuses
 */
@GET
@Path("/stats")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public TaskStatsRestRep getStats(@QueryParam(TENANT_QUERY_PARAM) URI tenantId) {
    Set<URI> tenantIds = getTenantsFromRequest(tenantId);
    verifyUserHasAccessToTenants(tenantIds);
    int ready = 0;
    int error = 0;
    int pending = 0;
    for (URI normalizedTenantId : tenantIds) {
        Constraint constraint = AggregatedConstraint.Factory.getAggregationConstraint(Task.class, "tenant", normalizedTenantId.toString(), "taskStatus");
        AggregationQueryResultList queryResults = new AggregationQueryResultList();
        _dbClient.queryByConstraint(constraint, queryResults);
        Iterator<AggregationQueryResultList.AggregatedEntry> it = queryResults.iterator();
        while (it.hasNext()) {
            AggregationQueryResultList.AggregatedEntry entry = it.next();
            if (entry.getValue().equals(Task.Status.ready.name())) {
                ready++;
            } else if (entry.getValue().equals(Task.Status.error.name())) {
                error++;
            } else {
                pending++;
            }
        }
    }
    return new TaskStatsRestRep(pending, ready, error);
}
Also used : TaskStatsRestRep(com.emc.storageos.model.tasks.TaskStatsRestRep) AggregatedConstraint(com.emc.storageos.db.client.constraint.AggregatedConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) AggregationQueryResultList(com.emc.storageos.db.client.constraint.AggregationQueryResultList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) AggregatedConstraint(com.emc.storageos.db.client.constraint.AggregatedConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with TaskStatsRestRep

use of com.emc.storageos.model.tasks.TaskStatsRestRep in project coprhd-controller by CoprHD.

the class Tasks method getCountSummary.

public static void getCountSummary(URI tenantId) {
    ViPRCoreClient client = getViprClient();
    TaskStatsRestRep stats = client.tasks().getStatsByTenant(tenantId);
    renderJSON(stats);
}
Also used : TaskStatsRestRep(com.emc.storageos.model.tasks.TaskStatsRestRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient)

Aggregations

TaskStatsRestRep (com.emc.storageos.model.tasks.TaskStatsRestRep)2 AggregatedConstraint (com.emc.storageos.db.client.constraint.AggregatedConstraint)1 AggregationQueryResultList (com.emc.storageos.db.client.constraint.AggregationQueryResultList)1 Constraint (com.emc.storageos.db.client.constraint.Constraint)1 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)1 URI (java.net.URI)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1