Package com.amazonaws.services.cloudwatch.model

Examples of com.amazonaws.services.cloudwatch.model.MetricDatum


    @Test
    public void sendManuallyCreatedMetric() throws Exception {
        template.send("direct:start", ExchangePattern.InOnly, new Processor() {
            public void process(Exchange exchange) throws Exception {
                MetricDatum metricDatum = new MetricDatum()
                        .withMetricName("errorCount")
                        .withValue(Double.valueOf(0));
                exchange.getIn().setBody(metricDatum);
            }
        });
View Full Code Here


        while(true) {
            final long elapsedNano = System.nanoTime() - startNano;
            if (elapsedNano >= timeoutNano) {
                return toPutMetricDataRequests(uniqueMetrics);
            }
            MetricDatum datum = queue.poll(timeoutNano - elapsedNano, TimeUnit.NANOSECONDS);
            if (datum == null) {
                // timed out
                if (uniqueMetrics.size() > 0) {
                    return toPutMetricDataRequests(uniqueMetrics);   // return whatever we have so far
                }
View Full Code Here

        }
        List<Dimension> dims = datum.getDimensions();
        Collections.sort(dims, DimensionComparator.INSTANCE);
        String metricName = datum.getMetricName();
        String key = metricName + Jackson.toJsonString(dims);
        MetricDatum statDatum = uniqueMetrics.get(key);
        if (statDatum == null) {
            statDatum = new MetricDatum()
                .withDimensions(datum.getDimensions())
                .withMetricName(metricName)
                .withUnit(datum.getUnit())
                .withStatisticValues(new StatisticSet()
                    .withMaximum(value)
                    .withMinimum(value)
                    .withSampleCount(0.0)
                    .withSum(0.0))
                ;
            uniqueMetrics.put(key, statDatum);
        }
        StatisticSet stat = statDatum.getStatisticValues();
        stat.setSampleCount(stat.getSampleCount() + 1.0);
        stat.setSum(stat.getSum() + value);
        if (value > stat.getMaximum()) {
            stat.setMaximum(value);
        } else if (value < stat.getMinimum()) {
View Full Code Here

        for (int i=0; i < machineMetrics.length; i++) {
            MachineMetric metric = machineMetrics[i];
            long val = values[i];
            // skip zero values in some cases
            if (val != 0 || metric.includeZeroValue()) {
                MetricDatum datum = new MetricDatum()
                    .withMetricName(metric.getMetricName())
                    .withDimensions(
                        new Dimension()
                        .withName(metric.getDimensionName())
                        .withValue(metric.name()))
View Full Code Here

     * @param key metric key to be inserted into queue
     * @param datum metric to be inserted into queue
     * @return a boolean depending on whether the datum was inserted into the queue
     */
    public synchronized boolean offer(KeyType key, MetricDatum datum) {
        MetricDatum old = map.get(key);
        if (old == null) {
            boolean offered = queue.offer(new MetricDatumWithKey<KeyType>(key, datum));
            if (offered) {
                map.put(key, datum);
            }
View Full Code Here

     *        data point unit
     */
    public void addData(KeyType key, String name, double value, StandardUnit unit) {
        super.addData(name, value, unit);

        MetricDatum datum = data.get(key);
        if (datum == null) {
            data.put(key,
                    new MetricDatum().withMetricName(name)
                            .withUnit(unit)
                            .withStatisticValues(new StatisticSet().withMaximum(value)
                                    .withMinimum(value)
                                    .withSampleCount(1.0)
                                    .withSum(value)));
        } else {
            if (!datum.getUnit().equals(unit.name())) {
                throw new IllegalArgumentException("Cannot add to existing metric with different unit");
            }

            StatisticSet statistics = datum.getStatisticValues();
            statistics.setMaximum(Math.max(value, statistics.getMaximum()));
            statistics.setMinimum(Math.min(value, statistics.getMinimum()));
            statistics.setSampleCount(statistics.getSampleCount() + 1);
            statistics.setSum(statistics.getSum() + value);
        }
View Full Code Here

        if (body instanceof MetricDatum) {
            return Arrays.asList((MetricDatum) body);
        }

        return Arrays.asList(new MetricDatum()
                .withMetricName(determineName(exchange))
                .withValue(determineValue(exchange))
                .withUnit(determineUnit(exchange))
                .withTimestamp(determineTimestamp(exchange)));
    }
View Full Code Here

    @Test
    public void sendManuallyCreatedMetric() throws Exception {
        template.send("direct:start", ExchangePattern.InOnly, new Processor() {
            public void process(Exchange exchange) throws Exception {
                MetricDatum metricDatum = new MetricDatum()
                        .withMetricName("errorCount")
                        .withValue(Double.valueOf(0));
                exchange.getIn().setBody(metricDatum);
            }
        });
View Full Code Here

                        .withValue(requestType(req)));
                // table specific
                dims.add(new Dimension()
                        .withName(DynamoDBDimensions.TableName.name())
                        .withValue(tableName));
                MetricDatum datum = new MetricDatum()
                    .withMetricName(req.getServiceName())
                    .withDimensions(dims)
                    .withUnit(StandardUnit.Count)
                    .withValue(units);
                return Collections.singletonList(datum);
View Full Code Here

                           : requestCount-1 // retryCount = requestCount - 1
                           ;
        if (count < 1) {
            return Collections.emptyList();
        } else {
            return Collections.singletonList(new MetricDatum()
                .withMetricName(req.getServiceName())
                .withDimensions(new Dimension()
                    .withName(Dimensions.MetricType.name())
                    .withValue(metricType.name()))
                .withUnit(StandardUnit.Count)
View Full Code Here

TOP

Related Classes of com.amazonaws.services.cloudwatch.model.MetricDatum

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.