Search in sources :

Example 1 with EventStatsRestRep

use of com.emc.storageos.model.event.EventStatsRestRep in project coprhd-controller by CoprHD.

the class Events method getCountSummary.

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

Example 2 with EventStatsRestRep

use of com.emc.storageos.model.event.EventStatsRestRep in project coprhd-controller by CoprHD.

the class EventService method getStats.

/**
 * Get Stats
 *
 * @param tenantId
 * @brief Show numbers of pending, approved, declined, and failed events for a tenant
 * @return
 */
@GET
@Path("/stats")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public EventStatsRestRep getStats(@QueryParam(TENANT_QUERY_PARAM) URI tenantId) {
    verifyAuthorizedInTenantOrg(tenantId, getUserFromContext());
    int approved = 0;
    int declined = 0;
    int pending = 0;
    int failed = 0;
    Constraint constraint = AggregatedConstraint.Factory.getAggregationConstraint(ActionableEvent.class, "tenant", tenantId.toString(), "eventStatus");
    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(ActionableEvent.Status.approved.name())) {
            approved++;
        } else if (entry.getValue().equals(ActionableEvent.Status.declined.name())) {
            declined++;
        } else if (entry.getValue().equals(ActionableEvent.Status.failed.name())) {
            failed++;
        } else {
            pending++;
        }
    }
    return new EventStatsRestRep(pending, approved, declined, failed);
}
Also used : AggregatedConstraint(com.emc.storageos.db.client.constraint.AggregatedConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) AggregationQueryResultList(com.emc.storageos.db.client.constraint.AggregationQueryResultList) AggregatedConstraint(com.emc.storageos.db.client.constraint.AggregatedConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) EventStatsRestRep(com.emc.storageos.model.event.EventStatsRestRep) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with EventStatsRestRep

use of com.emc.storageos.model.event.EventStatsRestRep in project coprhd-controller by CoprHD.

the class Events method getPendingAndFailedCount.

public static void getPendingAndFailedCount() {
    ViPRCoreClient client = getViprClient();
    int activeCount = 0;
    Set<URI> tenants = getAccessibleTenants();
    for (URI tenant : tenants) {
        EventStatsRestRep eventStats = client.events().getStatsByTenant(tenant);
        if (eventStats != null) {
            activeCount += eventStats.getPending() + eventStats.getFailed();
        }
    }
    if (Security.isSystemAdmin()) {
        EventStatsRestRep systemEventStats = client.events().getStatsByTenant(SYSTEM_TENANT);
        if (systemEventStats != null) {
            activeCount += systemEventStats.getPending() + systemEventStats.getFailed();
        }
    }
    renderJSON(activeCount);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) URI(java.net.URI) EventStatsRestRep(com.emc.storageos.model.event.EventStatsRestRep)

Aggregations

EventStatsRestRep (com.emc.storageos.model.event.EventStatsRestRep)3 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)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 URI (java.net.URI)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1