Package org.rhq.enterprise.server.rest.domain

Examples of org.rhq.enterprise.server.rest.domain.MetricSchedule


        ResourceGroup group = fetchGroup(id, true);

        Set<MeasurementDefinition> definitions = group.getResourceType().getMetricDefinitions();
        List<MetricSchedule> schedules = new ArrayList<MetricSchedule>(definitions.size());
        for (MeasurementDefinition def : definitions) {
            MetricSchedule schedule = new MetricSchedule(def.getId(),def.getName(),def.getDisplayName(),false,def.getDefaultInterval(),
                    def.getUnits().getName(),def.getDataType().toString());
            schedule.setDefinitionId(def.getId());
            if (def.getDataType()== DataType.MEASUREMENT) {
                UriBuilder uriBuilder = uriInfo.getBaseUriBuilder();
                uriBuilder.path("/metric/data/group/{groupId}/{definitionId}");
                URI uri = uriBuilder.build(id,def.getId());
                Link link = new Link("metric",uri.toString());
                schedule.addLink(link);
            }

            schedules.add(schedule);
        }
View Full Code Here


    }

    protected MetricSchedule getMetricScheduleInternal(UriInfo uriInfo, MeasurementSchedule schedule,
                                                       MeasurementDefinition definition) {
        MetricSchedule ms = new MetricSchedule(schedule.getId(), definition.getName(),
            definition.getDisplayName(), schedule.isEnabled(), schedule.getInterval(), definition
                .getUnits().toString(), definition.getDataType().toString());
        ms.setDefinitionId(definition.getId());

        if (schedule.getMtime()!=null)
            ms.setMtime(schedule.getMtime());


        UriBuilder uriBuilder;
        URI uri;
        if (definition.getDataType() == DataType.MEASUREMENT) {
            uriBuilder = uriInfo.getBaseUriBuilder();
            uriBuilder.path("/metric/data/{id}");
            uri = uriBuilder.build(schedule.getId());
            Link metricLink = new Link("metric", uri.toString());
            ms.addLink(metricLink);
            uriBuilder = uriInfo.getBaseUriBuilder();
            uriBuilder.path("/metric/data/{id}/raw");
            uri = uriBuilder.build(schedule.getId());
            metricLink = new Link("metric-raw", uri.toString());
            ms.addLink(metricLink);
        }
        // create link to the resource
        uriBuilder = uriInfo.getBaseUriBuilder();
        uriBuilder.path("resource/" + schedule.getResource().getId());
        uri = uriBuilder.build();
        Link link = new Link("resource", uri.toString());
        ms.addLink(link);
        return ms;
    }
View Full Code Here

            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

                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());
                metricSchedule.addLink(link);
            }

            // create link to the resource
            uriBuilder = uriInfo.getBaseUriBuilder();
            uriBuilder.path("resource/" + schedule.getResource().getId());
            uri = uriBuilder.build();
            link = new Link("resource",uri.toString());
            metricSchedule.addLink(link);

            // Link for updates
            uriBuilder = uriInfo.getAbsolutePathBuilder();
            uri = uriBuilder.build();
            Link updateLink = new Link("edit",uri.toString());
            metricSchedule.addLink(updateLink);
            updateLink = new Link("self",uri.toString());
            metricSchedule.addLink(updateLink);

            metricSchedule.addLink(createUILink(uriInfo, UILinkTemplate.METRIC_SCHEDULE, schedule.getResource().getId()));

            if (mediaType.equals(MediaType.TEXT_HTML_TYPE)) {
                builder = Response.ok(renderTemplate("metricSchedule", metricSchedule), mediaType);
            }
            else {
View Full Code Here

        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

        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(),
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.rest.domain.MetricSchedule

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.