Package org.rhq.core.domain.measurement

Examples of org.rhq.core.domain.measurement.MeasurementDefinition


        baseUnitsItem.setHoverWidth(200);
        baseUnitsItem.setShowIfCondition(ifFunc);

        metricDropDownMenu.addChangedHandler(new ChangedHandler() {
            public void onChanged(ChangedEvent event) {
                MeasurementDefinition measDef = getMeasurementDefinition(metricDropDownMenu.getValueAsString());
                baseUnitsItem.setValue(measDef.getUnits() == MeasurementUnits.NONE ? MSG
                    .view_alert_definition_condition_editor_common_baseUnits_none() : measDef.getUnits().toString());
                List<MeasurementUnits> availableUnits = measDef.getUnits().getFamilyUnits();
                baseUnitsItem.setTooltip(MSG.view_alert_definition_condition_editor_common_baseUnits_availableUnits()
                    + (availableUnits.isEmpty() || availableUnits.get(0) == MeasurementUnits.NONE ? MSG
                        .view_alert_definition_condition_editor_common_baseUnits_none() : availableUnits));
            }
        });
        // initialize the field, the default will be the first entry in the value map
        MeasurementDefinition defaultMeasDef = getMeasurementDefinition((String) metricDropDownMenu
            .getAttributeAsMap("valueMap").keySet().iterator().next());
        MeasurementUnits units = defaultMeasDef.getUnits();
        baseUnitsItem.setValue(units == MeasurementUnits.NONE ? MSG
            .view_alert_definition_condition_editor_common_baseUnits_none() : units.toString());
        List<MeasurementUnits> availableUnits = units.getFamilyUnits();
        baseUnitsItem.setTooltip(MSG.view_alert_definition_condition_editor_common_baseUnits_availableUnits()
            + (availableUnits.isEmpty() || availableUnits.get(0) == MeasurementUnits.NONE ? MSG
View Full Code Here


        Set<MeasurementSchedule> schedules = res.getSchedules();
        List<MetricSchedule> ret = new ArrayList<MetricSchedule>(schedules.size());
        for (MeasurementSchedule schedule : schedules) {
            putToCache(schedule.getId(), MeasurementSchedule.class, schedule);
            MeasurementDefinition definition = schedule.getDefinition();

            // user can opt to e.g. only get "measurement" or "trait" metrics

            if ("all".equals(scheduleType)
                || scheduleType.toLowerCase().equals(definition.getDataType().toString().toLowerCase())) {
                if (!enabledOnly || (enabledOnly && schedule.isEnabled())) {
                    if (name == null || (name != null && name.equals(definition.getName()))) {
                        MetricSchedule ms = getMetricScheduleInternal(uriInfo, schedule, definition);

                        ret.add(ms);
                    }
                }
View Full Code Here

                        if (!results.isEmpty()) {

                            //load the data results for the given metric definition
                            List<MeasurementDataNumericHighLowComposite> measurementList = results.get(0);

                            MeasurementDefinition measurementDefinition = null;
                            for (MeasurementDefinition definition : group.getResourceType().getMetricDefinitions()) {
                                if (definition.getId() == definitionId) {
                                    measurementDefinition = definition;
                                    break;
                                }
View Full Code Here

        }
    }

    private List<MeasurementDefinition> filter(List<MeasurementDefinition> mds) {
        for (Iterator<MeasurementDefinition> i = mds.iterator(); i.hasNext();) {
            MeasurementDefinition md = i.next();
            // don't include the special avail metric
            if (md.getDisplayName().toLowerCase().equals("availability")) {
                i.remove();
                break;
            }
        }
        return mds;
View Full Code Here

        List<MeasurementDefinition> measurementDefinitions, Set<Integer> definitionIds) {
        int i = 0;
        for (List<MeasurementDataNumericHighLowComposite> metric : measurementData) {

            for (Integer selectedDefinitionId : definitionIds) {
                final MeasurementDefinition measurementDefinition = measurementDefinitions.get(i);
                final int measurementId = measurementDefinition.getId();

                if (null != selectedDefinitionId) {
                    // single graph case
                    if (measurementId == selectedDefinitionId) {
                        buildSingleGraph(measurementOOBCompositeList, measurementDefinition, metric,
View Full Code Here

        MediaType mediaType = headers.getAcceptableMediaTypes().get(0);
        boolean isHtml = mediaType.equals(MediaType.TEXT_HTML_TYPE);

        fetchGroup(groupId,true); // Make sure the group exists and is compatible
        MeasurementDefinition definition = definitionManager.getMeasurementDefinition(caller,definitionId);
        if (definition==null) {
            throw new StuffNotFoundException("There is no definition with id " + definitionId);
        }

        MeasurementAggregate aggr = dataManager.getAggregate(caller, groupId, definitionId, startTime, endTime);
        MetricAggregate res = new MetricAggregate(definitionId, aggr.getMin(),aggr.getAvg(),aggr.getMax());
        res.setGroup(true);

        List<List<MeasurementDataNumericHighLowComposite>> listList = dataManager.findDataForCompatibleGroup(caller,
                groupId,definitionId,startTime,endTime,dataPoints);

        if (listList.isEmpty()) {
            throw new StuffNotFoundException("Data for group with id " + groupId + " and definition " + definitionId);
        }
        List<MeasurementDataNumericHighLowComposite> list = listList.get(0);
        if (!listList.isEmpty()) {
            fillInDatapoints(res, list, definitionId, hideEmpty, isHtml);
        }

        CacheControl cc = new CacheControl();
        int maxAge = (int) (definition.getDefaultInterval() / 1000L)/2; // millis  ; half of schedule interval
        cc.setMaxAge(maxAge); // these are seconds
        cc.setPrivate(false);
        cc.setNoCache(false);

        Response.ResponseBuilder builder;
View Full Code Here

                throw new StuffNotFoundException("Schedule with id " + scheduleId);
            else
                putToCache(scheduleId, MeasurementSchedule.class, schedule);
        }

        MeasurementDefinition definition = schedule.getDefinition();
//        MetricSchedule metricSchedule = getMetricScheduleInternal(uriInfo,schedule,definition); todo
        MetricSchedule metricSchedule = new MetricSchedule(schedule.getId(), definition.getName(),
                definition.getDisplayName(),
                schedule.isEnabled(), schedule.getInterval(), definition.getUnits().toString(),
                definition.getDataType().toString());
        metricSchedule.setDefinitionId(definition.getId());
        if (schedule.getMtime()!=null)
            metricSchedule.setMtime(schedule.getMtime());


        // Check for conditional get again
        // Interestingly computing the hashCode of the original schedule is slower, as it also
        // pulls in data from the definition and the resource
        long tim = schedule.getMtime() != null ? schedule.getMtime() : 0;
        EntityTag eTag = new EntityTag(Long.toOctalString(schedule.hashCode()+tim));
        builder = request.evaluatePreconditions(new Date(tim),eTag); // factor in mtime in etag


        if (builder==null) {
            // preconditions not met, we need to send the resource

            UriBuilder uriBuilder;
            URI uri;
            Link link;
            if (definition.getDataType()==DataType.MEASUREMENT) {
                // create link to metrics
                uriBuilder = uriInfo.getBaseUriBuilder();
                uriBuilder.path("metric/data/" + scheduleId);
                uri = uriBuilder.build();
                link = new Link("metric",uri.toString());
View Full Code Here

        scheduleManager.updateSchedule(caller, schedule);

        schedule = scheduleManager.getScheduleById(caller,scheduleId);
        putToCache(scheduleId, MeasurementSchedule.class, schedule);
        MeasurementDefinition def = schedule.getDefinition();

        MetricSchedule ret = new MetricSchedule(scheduleId,def.getName(),def.getDisplayName(),
                schedule.isEnabled(),schedule.getInterval(),def.getUnits().toString(),def.getDataType().toString());
        ret.setDefinitionId(def.getId());

        return Response.ok(ret,headers.getAcceptableMediaTypes().get(0)).build();
    }
View Full Code Here

    @ApiOperation(value = "Get the definition ", responseClass = "MetricSchedule")
    @ApiError(code = 404, reason = "No definition exists for the given id.")
    public Response getDefinition(@ApiParam("Id of the definition to obtain") @PathParam("id") int definitionId,
                                @Context HttpHeaders headers) {

        MeasurementDefinition measurementDefinition = definitionManager.getMeasurementDefinition(caller, definitionId);
        if (measurementDefinition==null)
            throw new StuffNotFoundException("Definition with id " + definitionId);


        MetricSchedule schedule = new MetricSchedule(definitionId,
            measurementDefinition.getName(),
            measurementDefinition.getDisplayName(),
            measurementDefinition.isDefaultOn(),
            measurementDefinition.getDefaultInterval(),
            measurementDefinition.getUnits().getName(),
            measurementDefinition.getDataType().name());

        return Response.ok(schedule,headers.getAcceptableMediaTypes().get(0)).build();
    }
View Full Code Here

    public Response updateDefinition(@ApiParam("Id of the definition to update") @PathParam("id") int definitionId,
                                @ApiParam(value = "New definition data", required = true) MetricSchedule in,
                                @ApiParam(value = "Update existing schedules for this definition as well?") @QueryParam("updateExisting") @DefaultValue("false") boolean updateExisting,
                                @Context HttpHeaders headers) {

        MeasurementDefinition measurementDefinition = definitionManager.getMeasurementDefinition(caller, definitionId);
        if (measurementDefinition==null)
            throw new StuffNotFoundException("Definition with id " + definitionId);

        // Call an async method to do the work as this can take a looong time
        metricHandlerBean.submitDefinitionChange(definitionId, in, updateExisting);
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.measurement.MeasurementDefinition

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.