Package org.rhq.core.domain.measurement

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


    public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
        Map<String, Double> values = getNumericQueryValues(this, SQL_VALUES, this.resourceContext.getResourceKey());
        for (MeasurementScheduleRequest request : metrics) {
            Double d = values.get(request.getName().toUpperCase(Locale.US));
            if (d != null) {
                report.addData(new MeasurementDataNumeric(request, d));
            }
        }
    }
View Full Code Here


        Object entityStatistics = operation.invoke(getResourceContext().getResourceKey());

        for (MeasurementScheduleRequest request : requests) {
            Object val = super.lookupAttributeProperty(entityStatistics, request.getName());

            report.addData(new MeasurementDataNumeric(request, ((Number) val).doubleValue()));
        }
    }
View Full Code Here

                    String name = request.getName().toUpperCase(Locale.US);
                    if (request.getDataType().equals(DataType.TRAIT)) {
                        report.addData(new MeasurementDataTrait(request, resultSet.getString(name)));
                    } else {
                        try {
                            report.addData(new MeasurementDataNumeric(request, resultSet.getDouble(name)));
                        } catch (SQLException e) {
                            // Ignoring metrics that cannot be read as a double
                            LOG.warn("Ignoring metric " + name + " as it cannot be read as a double");
                        }
                    }
View Full Code Here

            } else if (request.getName().equals("hostName")) {
                report.addData(new MeasurementDataTrait(request, address.getCanonicalHostName()));
            } else if (request.getName().equals("responseTime")) {
                long start = System.currentTimeMillis();
                address.isReachable(PING_TIMEOUT);
                report.addData(new MeasurementDataNumeric(request, (double) (System.currentTimeMillis() - start)));
            }
        }
    }
View Full Code Here

                }

                // add the metric value to the measurement report
                if (dataMustBeNumeric) {
                    Double numeric = Double.parseDouble(dataValue.toString().trim());
                    report.addData(new MeasurementDataNumeric(request, numeric));
                } else {
                    report.addData(new MeasurementDataTrait(request, dataValue.toString().trim()));
                }
            } catch (Exception e) {
                LOG.error("Failed to obtain measurement [" + metricPropertyName + "]. Cause: " + e);
View Full Code Here

                if (LOG.isDebugEnabled()) {
                    LOG.debug("Result set is empty: " + QUERY_DATABASE_SIZE);
                }
            }
            for (MeasurementScheduleRequest request : metrics) {
                report.addData(new MeasurementDataNumeric(request, resultSet.getDouble(request.getName())));
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            DatabasePluginUtil.safeClose(jdbcConnection, statement, resultSet);
View Full Code Here

            HttpEntity entity = response.getEntity();

            if (metrics != null) {
                for (MeasurementScheduleRequest request : metrics) {
                    if (request.getName().equals("connectTime")) {
                        report.addData(new MeasurementDataNumeric(request, (double) connectTime));
                    } else if (request.getName().equals("readTime")) {
                        report.addData(new MeasurementDataNumeric(request, (double) readTime));
                    } else if (request.getName().equals("contentLength")) {
                        if (entity != null) {
                            report.addData(new MeasurementDataNumeric(request, (double) entity.getContentLength()));
                        }
                    } else if (request.getName().equals("contentAge")) {
                        if (contentDate != null) {
                            report.addData(new MeasurementDataNumeric(request,
                                (double) (System.currentTimeMillis() - contentDate.getTime())));
                        }
                    }
                }
            }
View Full Code Here

            values = getNumericQueryValues(this, FIND_STAT_ACTIVITY_BY_OID, pgRoleOid, pgRoleOid);
        } else {
            values = getNumericQueryValues(this, FIND_STAT_ACTIVITY_BY_OID_PRE_PG_9_2, pgRoleOid, pgRoleOid);
        }
        for (MeasurementScheduleRequest request : metrics) {
            report.addData(new MeasurementDataNumeric(request, values.get(request.getName())));
        }
    }
View Full Code Here

                    + report.getCallTimeData());
            value = null;
        } else {
            assertEquals(report.getNumericData().size(), 1,
                "Requested a single metric, but plugin returned more than one datum: " + report.getNumericData());
            MeasurementDataNumeric datum = report.getNumericData().iterator().next();
            assertEquals(datum.getName(), metricName, "Numeric metric [" + metricName + "] for Resource type "
                + resource.getResourceType() + " was requested, but the plugin returned a numeric metric with name ["
                + datum.getName() + "] and value [" + datum.getValue() + "]!");
            // Normalize NaN or infinite to null, as the PC does.
            value = (datum.getValue().isNaN() || datum.getValue().isInfinite()) ? null : datum.getValue();
        }
        System.out.println("====== Collected numeric metric [" + metricName + "] with value of [" + value + "] for "
            + resource + ".");

        return value;
View Full Code Here

        Set<MeasurementDataNumeric> data = new HashSet<MeasurementDataNumeric>(batchSize);
        long timestamp = dateTimeService.nowInMillis();
        ThreadLocalRandom random = ThreadLocalRandom.current();

        for (int i = 0; i < batchSize; ++i) {
            data.add(new MeasurementDataNumeric(timestamp, startingScheduleId + i, random.nextDouble()));
        }

        return data;
    }
View Full Code Here

TOP

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

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.