Package org.rhq.core.domain.alert

Examples of org.rhq.core.domain.alert.Alert


        AlertCriteria criteria = new AlertCriteria();
        criteria.addFilterId(alertId);
        GWTServiceLookup.getAlertService().findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() {
            @Override
            public void onSuccess(PageList<Alert> result) {
                Alert alert = result.get(0);
                Integer parentId = alert.getAlertDefinition().getParentId();
                AlertDefinition groupAlertDefinition = alert.getAlertDefinition().getGroupAlertDefinition();
                if (groupAlertDefinition != null || (parentId != null && parentId.intValue() != 0)) {
                    fetchDefinitionWithGroupAndTemplate(alert);
                } else {
                    show(alert);
                }
View Full Code Here


    public Response getAlert(
            @ApiParam("Id of the alert to retrieve") @PathParam("id") int id,
            @ApiParam(value = "Should full resources and definitions be sent") @QueryParam("slim") @DefaultValue("false") boolean slim,
            @Context UriInfo uriInfo, @Context Request request, @Context HttpHeaders headers) {

        Alert al = findAlertWithId(id);
        MediaType type = headers.getAcceptableMediaTypes().get(0);

        EntityTag eTag = new EntityTag(Integer.toHexString(al.hashCode()));
        Response.ResponseBuilder builder = request.evaluatePreconditions(eTag);
        if (builder==null) {
            AlertRest ar = alertToDomain(al, uriInfo, slim);
            if (type.equals(MediaType.TEXT_HTML_TYPE)) {
                builder = Response.ok(renderTemplate("alert.ftl",ar),type);
View Full Code Here

    @Cache(maxAge = 300)
    @ApiOperation(value = "Return the condition logs for the given alert")
    public Response getConditionLogs(@ApiParam("Id of the alert to retrieve") @PathParam("id") int id,
                                  @Context Request request, @Context UriInfo uriInfo, @Context HttpHeaders headers) {

        Alert al = findAlertWithId(id);
        Set<AlertConditionLog> conditions =  al.getConditionLogs();
        MediaType type = headers.getAcceptableMediaTypes().get(0);
        Response.ResponseBuilder builder;

        if (type.equals(MediaType.APPLICATION_XML_TYPE)) {
            List<StringValue> result = new ArrayList<StringValue>(conditions.size());
View Full Code Here

    @Path("/{id}/notifications")
    @Cache(maxAge = 60)
    @ApiOperation(value = "Return the notification logs for the given alert")
    public Response getNotificationLogs(@ApiParam("Id of the alert to retrieve") @PathParam("id") int id,
                                     @Context Request request, @Context UriInfo uriInfo, @Context HttpHeaders headers) {
        Alert al = findAlertWithId(id);
        MediaType type = headers.getAcceptableMediaTypes().get(0);
        Response.ResponseBuilder builder;

        List<AlertNotificationLog> notifications =  al.getAlertNotificationLogs();
        if (type.equals(MediaType.APPLICATION_XML_TYPE)) {
            List<StringValue> result = new ArrayList<StringValue>(notifications.size());
            for (AlertNotificationLog log : notifications) {
                String entry = log.getSender() + ": " + log.getResultState() + ": " + log.getMessage();
                StringValue sv = new StringValue(entry);
View Full Code Here

        findAlertWithId(id); // Ensure the alert exists
        int count = alertManager.acknowledgeAlerts(caller, new int[]{id});

        // TODO this is not reliable due to Tx constraints ( the above may only run after this ackAlert() method has finished )

        Alert al = findAlertWithId(id);
        AlertRest ar = alertToDomain(al, uriInfo, true);
        return ar;
    }
View Full Code Here

    @Cache(maxAge = 300)
    @Path("/{id}/definition")
    @ApiOperation("Get the alert definition (basics) for the alert")
    public AlertDefinitionRest getDefinitionForAlert(@ApiParam("Id of the alert to show the definition") @PathParam("id") int alertId,
                                                     @Context UriInfo uriInfo) {
        Alert al = findAlertWithId(alertId);
        AlertDefinition def = al.getAlertDefinition();
        AlertDefinitionHandlerBean adhb = new AlertDefinitionHandlerBean();
        AlertDefinitionRest ret = adhb.definitionToDomain(def, false, uriInfo); // TODO allow 'full' parameter?
        return ret;
    }
View Full Code Here

            /*
             * must be executed in a new, nested transaction so that by it completes and unlocks, the next thread
             * will see all of its results.
             */
            Alert newAlert = cachedConditionManager.processCachedConditionMessageNewTx(conditionMessage, definitionId);

            /*
             * In general it's not required to reload the caches directly. Changes made via the AlertDefinitionManager
             * will update the cache indirectly via the status fields on the server (for the global cache) and
             * owning agent (for the agent cache) and the periodic job that checks it.  But, for recovery alert
View Full Code Here

        /*
         * creating an alert via an alertDefinition automatically creates the needed auditing data structures such as
         * alertConditionLogs and alertNotificationLogs
         */
        Alert newAlert = new Alert(alertDefinition, System.currentTimeMillis());

        /*
         * the AlertConditionLog children objects are already in the database, we need to persist the alert first
         * to prevent:
         *
         * "TransientObjectException: object references an unsaved transient instance - save the transient instance before
         * flushing org.jboss.on.domain.event.alert.AlertConditionLog.alert -> org.jboss.on.domain.event.alert.Alert"
         */
        entityManager.persist(newAlert);
        if (log.isDebugEnabled()) {
            log.debug("New alert identifier=" + newAlert.getId());
        }

        //        AlertNotificationLog alertNotifLog = new AlertNotificationLog(newAlert);  TODO - is that all?
        //        entityManager.persist(alertNotifLog);

        List<AlertConditionLog> unmatchedConditionLogs = alertConditionLogManager
            .getUnmatchedLogsByAlertDefinitionId(alertDefinitionId);
        for (AlertConditionLog unmatchedLog : unmatchedConditionLogs) {
            if (log.isDebugEnabled()) {
                log.debug("Matched alert condition log for alertId=" + newAlert.getId() + ": " + unmatchedLog);
            }
            newAlert.addConditionLog(unmatchedLog); // adds both relationships
        }

        // process recovery actions
        processRecovery(alertDefinition);

View Full Code Here

            log.error("Failed to send all notifications for [" + alert.toSimpleString() + "].", t);
        }
    }

    public void addNotificationLog(int alertId, AlertNotificationLog notificationLog) {
        Alert alert = entityManager.find(Alert.class, alertId);
        if (null == alert) {
            throw new ApplicationException("Alert not found with id [" + alertId + "].");
        }

        // make sure we don't exceed the max message length for the db vendor
        DatabaseType dbType = DatabaseTypeFactory.getDefaultDatabaseType();
        String message = dbType.getString(notificationLog.getMessage(), AlertNotificationLog.MESSAGE_MAX_LENGTH);

        if (null != message && !message.equals(notificationLog.getMessage())) {
            notificationLog = new AlertNotificationLog(notificationLog.getAlert(), notificationLog.getSender(),
                notificationLog.getResultState(), message);
        }

        entityManager.persist(notificationLog);
        alert.addAlertNotificatinLog(notificationLog);
    }
View Full Code Here

    private AlertConditionLogManagerLocal alertConditionLogManager;

    @Override
    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    public Alert processCachedConditionMessageNewTx(AbstractAlertConditionMessage conditionMessage, Integer definitionId) {
        Alert result = null;

        /*
         * note that ctime is the time when the condition was known to be true, not the time we're persisting the
         * condition log message
         */
 
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.alert.Alert

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.