Package org.jclouds.cloudwatch.options

Examples of org.jclouds.cloudwatch.options.ListMetricsOptions


   private String metricName = "TestMetricForAlarms";
   private String namespace = "JCLOUDS/Test";

   @BeforeClass
   protected void beforeClass() throws Exception {
      IterableWithMarker<Metric> metrics = metricApi().list(new ListMetricsOptions().metricName(metricName));

      if (Iterables.size(metrics) == 0) {
         metricApi().putMetricsInNamespace(ImmutableSet.of(
               MetricDatum.builder()
                          .metricName(metricName)
                          .statisticValues(StatisticValues.builder()
                                                          .maximum(4.0)
                                                          .minimum(1.0)
                                                          .sampleCount(4.0)
                                                          .sum(10.0)
                                                          .build())
                          .dimension(new Dimension("BaseMetricName", metricName))
                          .dimension(new Dimension("TestDimension2", "TEST2"))
                          .unit(Unit.COUNT)
                          .timestamp(new Date())
                          .build()
         ), namespace);

         ListMetricsOptions lmo = ListMetricsOptions.Builder.namespace(namespace)
                                                    .metricName(metricName);
         boolean success = retry(new Predicate<ListMetricsOptions>() {
            public boolean apply(ListMetricsOptions options) {
               return Iterables.size(metricApi().list(options)) == 1;
            }
View Full Code Here


                                .build());
      }

      CloudWatch.putMetricData(api, null, metrics, namespace);

      ListMetricsOptions lmo = ListMetricsOptions.Builder.namespace(namespace)
                                                 .dimension(new Dimension("BaseMetricName", metricName));
      boolean success = retry(new Predicate<ListMetricsOptions>() {
         public boolean apply(ListMetricsOptions options) {
            return Iterables.size(CloudWatch.listMetrics(api, null, options)) == 11;
         }
View Full Code Here

    */
   @Test
   public void testSinglePageResult() throws Exception {
      CloudWatchApi api = createMock(CloudWatchApi.class);
      MetricApi metricApi = createMock(MetricApi.class);
      ListMetricsOptions options = new ListMetricsOptions();
      IterableWithMarker<Metric> response = IterableWithMarkers.from(ImmutableSet.of(createMock(Metric.class)), null);
     
      expect(api.getMetricApiForRegion(null))
            .andReturn(metricApi)
            .atLeastOnce();
View Full Code Here

    */
   @Test
   public void testMultiPageResult() throws Exception {
      CloudWatchApi api = createMock(CloudWatchApi.class);
      MetricApi metricApi = createMock(MetricApi.class);
      ListMetricsOptions options = new ListMetricsOptions();
      IterableWithMarker<Metric> response1 = IterableWithMarkers.from(ImmutableSet.of(createMock(Metric.class)), "NEXTTOKEN");
      IterableWithMarker<Metric> response2 = IterableWithMarkers.from(ImmutableSet.of(createMock(Metric.class)), null);

      // Using EasyMock.eq("") because EasyMock makes it impossible to pass null as a String value here
      expect(api.getMetricApiForRegion(EasyMock.eq("")))
View Full Code Here

                                           .value(10.0)
                                           .build();

      api().putMetricsInNamespace(ImmutableSet.of(metricDatum, metricDatum2), namespace);

      ListMetricsOptions lmo = ListMetricsOptions.Builder.namespace(namespace)
                                                 .dimension(new Dimension("BaseMetricName", metricName));
      boolean success = retry(new Predicate<ListMetricsOptions>() {
         public boolean apply(ListMetricsOptions options) {
            return Iterables.size(api().list(options)) == 2;
         }
View Full Code Here

   }

   // TODO: change this test to retrieve pre-seeded custom metrics
   @Test
   protected void testGetMetricStatistics() {
      IterableWithMarker<Metric> metricsResponse = api().list(new ListMetricsOptions());

      // Walk through all datapoints in all metrics until we find a metric datapoint that returns statistics
      if (Iterables.size(metricsResponse) > 0) {
         for (Metric metric : metricsResponse) {
            Set<Dimension> dimensions = metric.getDimensions();
View Full Code Here

      String testMetricName = EC2Constants.MetricName.CPU_UTILIZATION;
      String testDimensionName = EC2Constants.Dimension.INSTANCE_TYPE;
      String testDimensionValue = "t1.micro";

      // Test an empty request (pulls all stored metric options across all products)
      response = api().list(new ListMetricsOptions());

      performDefaultMetricsTests(response);

      if (Iterables.size(response) > 0) {
         Metric metric = response.iterator().next();
View Full Code Here

   private String metricName = "TestMetricForAlarms";
   private String namespace = "JCLOUDS/Test";

   @BeforeClass
   protected void beforeClass() throws Exception {
      IterableWithMarker<Metric> metrics = metricApi().list(new ListMetricsOptions().metricName(metricName));

      if (Iterables.size(metrics) == 0) {
         metricApi().putMetricsInNamespace(ImmutableSet.of(
               MetricDatum.builder()
                          .metricName(metricName)
                          .statisticValues(StatisticValues.builder()
                                                          .maximum(4.0)
                                                          .minimum(1.0)
                                                          .sampleCount(4.0)
                                                          .sum(10.0)
                                                          .build())
                          .dimension(new Dimension("BaseMetricName", metricName))
                          .dimension(new Dimension("TestDimension2", "TEST2"))
                          .unit(Unit.COUNT)
                          .timestamp(new Date())
                          .build()
         ), namespace);

         ListMetricsOptions lmo = ListMetricsOptions.Builder.namespace(namespace)
                                                    .metricName(metricName);
         boolean success = retry(new Predicate<ListMetricsOptions>() {
            public boolean apply(ListMetricsOptions options) {
               return Iterables.size(metricApi().list(options)) == 1;
            }
View Full Code Here

                                           .value(10.0)
                                           .build();

      api().putMetricsInNamespace(ImmutableSet.of(metricDatum, metricDatum2), namespace);

      ListMetricsOptions lmo = ListMetricsOptions.Builder.namespace(namespace)
                                                 .dimension(new Dimension("BaseMetricName", metricName));
      boolean success = retry(new Predicate<ListMetricsOptions>() {
         public boolean apply(ListMetricsOptions options) {
            return Iterables.size(api().list(options)) == 2;
         }
View Full Code Here

   }

   // TODO: change this test to retrieve pre-seeded custom metrics
   @Test
   protected void testGetMetricStatistics() {
      IterableWithMarker<Metric> metricsResponse = api().list(new ListMetricsOptions());

      // Walk through all datapoints in all metrics until we find a metric datapoint that returns statistics
      if (Iterables.size(metricsResponse) > 0) {
         for (Metric metric : metricsResponse) {
            Set<Dimension> dimensions = metric.getDimensions();
View Full Code Here

TOP

Related Classes of org.jclouds.cloudwatch.options.ListMetricsOptions

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.