/** * <p> * The unit for the metric. * </p> * * @param unit * The unit for the metric. * @return Returns a reference to this object so that method calls can be chained together. * @see StandardUnit */ public DescribeAlarmsForMetricRequest withUnit(StandardUnit unit) { this.unit = unit.toString(); return this; }
/** * Use this in place of valueOf. * * @param value * real value * @return StandardUnit corresponding to the value * * @throws IllegalArgumentException * If the specified value does not map to one of the known values in this enum. */ public static StandardUnit fromValue(String value) { if (value == null || "".equals(value)) { throw new IllegalArgumentException("Value cannot be null or empty!"); } for (StandardUnit enumEntry : StandardUnit.values()) { if (enumEntry.toString().equals(value)) { return enumEntry; } } throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); } }
@Override protected void realAddData(String name, double value, StandardUnit unit) { MetricDatum datum = data.get(name); if (datum == null) { data.put(name, 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); } }
.withSum(value))); } else { if (!datum.getUnit().equals(unit.name())) { throw new IllegalArgumentException("Cannot add to existing metric with different unit");
/** * <p> * The standard unit for the data point. * </p> * * @param unit * The standard unit for the data point. * @return Returns a reference to this object so that method calls can be chained together. * @see StandardUnit */ public Datapoint withUnit(StandardUnit unit) { this.unit = unit.toString(); return this; }
/** * <p> * The unit of the metric. * </p> * * @param unit * The unit of the metric. * @return Returns a reference to this object so that method calls can be chained together. * @see StandardUnit */ public MetricDatum withUnit(StandardUnit unit) { this.unit = unit.toString(); return this; }
/** * <p> * The unit of the metric associated with the alarm. * </p> * * @param unit * The unit of the metric associated with the alarm. * @return Returns a reference to this object so that method calls can be chained together. * @see StandardUnit */ public MetricAlarm withUnit(StandardUnit unit) { this.unit = unit.toString(); return this; }
/** * <p> * The unit to use for the returned data points. * </p> * * @param unit * The unit to use for the returned data points. * @return Returns a reference to this object so that method calls can be chained together. * @see StandardUnit */ public MetricStat withUnit(StandardUnit unit) { this.unit = unit.toString(); return this; }
public static String getUnit(DataSourceType dataSourceType) { switch (dataSourceType) { case COUNTER: return StandardUnit.CountSecond.toString(); case GAUGE: return StandardUnit.None.toString(); case INFORMATIONAL: return StandardUnit.None.toString(); default: return StandardUnit.None.toString(); } } }
/** * <p> * The unit for a given metric. Metrics may be reported in multiple units. Not supplying a unit results in all units * being returned. If you specify only a unit that the metric does not report, the results of the call are null. * </p> * * @param unit * The unit for a given metric. Metrics may be reported in multiple units. Not supplying a unit results in * all units being returned. If you specify only a unit that the metric does not report, the results of the * call are null. * @return Returns a reference to this object so that method calls can be chained together. * @see StandardUnit */ public GetMetricStatisticsRequest withUnit(StandardUnit unit) { this.unit = unit.toString(); return this; }
/** * <p> * The unit of measure for the statistic. For example, the units for the Amazon EC2 NetworkIn metric are Bytes * because NetworkIn tracks the number of bytes that an instance receives on all network interfaces. You can also * specify a unit when you create a custom metric. Units help provide conceptual meaning to your data. Metric data * points that specify a unit of measure, such as Percent, are aggregated separately. * </p> * <p> * If you specify a unit, you must use a unit that is appropriate for the metric. Otherwise, the CloudWatch alarm * can get stuck in the <code>INSUFFICIENT DATA</code> state. * </p> * * @param unit * The unit of measure for the statistic. For example, the units for the Amazon EC2 NetworkIn metric are * Bytes because NetworkIn tracks the number of bytes that an instance receives on all network interfaces. * You can also specify a unit when you create a custom metric. Units help provide conceptual meaning to your * data. Metric data points that specify a unit of measure, such as Percent, are aggregated separately.</p> * <p> * If you specify a unit, you must use a unit that is appropriate for the metric. Otherwise, the CloudWatch * alarm can get stuck in the <code>INSUFFICIENT DATA</code> state. * @return Returns a reference to this object so that method calls can be chained together. * @see StandardUnit */ public PutMetricAlarmRequest withUnit(StandardUnit unit) { this.unit = unit.toString(); return this; }
/** * <p> * The unit of the metric. * </p> * <p> * <b>Constraints:</b><br/> * <b>Allowed Values: </b>Seconds, Microseconds, Milliseconds, Bytes, * Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, * Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, * Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, * Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, * Count/Second, None * * @param unit <p> * The unit of the metric. * </p> * @see StandardUnit */ public void setUnit(StandardUnit unit) { this.unit = unit.toString(); }
/** * <p> * The unit of the alarm's associated metric. * </p> * <p> * <b>Constraints:</b><br/> * <b>Allowed Values: </b>Seconds, Microseconds, Milliseconds, Bytes, * Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, * Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, * Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, * Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, * Count/Second, None * * @param unit <p> * The unit of the alarm's associated metric. * </p> * @see StandardUnit */ public void setUnit(StandardUnit unit) { this.unit = unit.toString(); }
/** * <p> * The unit for the metric. * </p> * <p> * <b>Constraints:</b><br/> * <b>Allowed Values: </b>Seconds, Microseconds, Milliseconds, Bytes, * Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, * Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, * Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, * Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, * Count/Second, None * * @param unit <p> * The unit for the metric. * </p> * @see StandardUnit */ public void setUnit(StandardUnit unit) { this.unit = unit.toString(); }
/** * <p> * The unit for the metric. * </p> * <p> * <b>Constraints:</b><br/> * <b>Allowed Values: </b>Seconds, Microseconds, Milliseconds, Bytes, * Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, * Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, * Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, * Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, * Count/Second, None * * @param unit <p> * The unit for the metric. * </p> * @see StandardUnit */ public void setUnit(StandardUnit unit) { this.unit = unit.toString(); }
/** * <p> * The standard unit used for the datapoint. * </p> * <p> * <b>Constraints:</b><br/> * <b>Allowed Values: </b>Seconds, Microseconds, Milliseconds, Bytes, * Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, * Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, * Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, * Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, * Count/Second, None * * @param unit <p> * The standard unit used for the datapoint. * </p> * @see StandardUnit */ public void setUnit(StandardUnit unit) { this.unit = unit.toString(); }
/** * <p> * The unit of the metric. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * <p> * <b>Constraints:</b><br/> * <b>Allowed Values: </b>Seconds, Microseconds, Milliseconds, Bytes, * Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, * Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, * Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, * Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, * Count/Second, None * * @param unit <p> * The unit of the metric. * </p> * @return A reference to this updated object so that method calls can be * chained together. * @see StandardUnit */ public MetricDatum withUnit(StandardUnit unit) { this.unit = unit.toString(); return this; }
/** * <p> * The standard unit used for the datapoint. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * <p> * <b>Constraints:</b><br/> * <b>Allowed Values: </b>Seconds, Microseconds, Milliseconds, Bytes, * Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, * Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, * Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, * Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, * Count/Second, None * * @param unit <p> * The standard unit used for the datapoint. * </p> * @return A reference to this updated object so that method calls can be * chained together. * @see StandardUnit */ public Datapoint withUnit(StandardUnit unit) { this.unit = unit.toString(); return this; }
/** * <p> * The unit of the alarm's associated metric. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * <p> * <b>Constraints:</b><br/> * <b>Allowed Values: </b>Seconds, Microseconds, Milliseconds, Bytes, * Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, * Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, * Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, * Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, * Count/Second, None * * @param unit <p> * The unit of the alarm's associated metric. * </p> * @return A reference to this updated object so that method calls can be * chained together. * @see StandardUnit */ public MetricAlarm withUnit(StandardUnit unit) { this.unit = unit.toString(); return this; }
/** * <p> * The unit for the metric. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * <p> * <b>Constraints:</b><br/> * <b>Allowed Values: </b>Seconds, Microseconds, Milliseconds, Bytes, * Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, * Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, * Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, * Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, * Count/Second, None * * @param unit <p> * The unit for the metric. * </p> * @return A reference to this updated object so that method calls can be * chained together. * @see StandardUnit */ public GetMetricStatisticsRequest withUnit(StandardUnit unit) { this.unit = unit.toString(); return this; }