Package org.jclouds.cloudwatch.features

Examples of org.jclouds.cloudwatch.features.MetricApi


      this.api = checkNotNull(api, "api");
   }

   @Override
   protected Function<Object, IterableWithMarker<Metric>> markerToNextForCallingArg0(final String arg0) {
      final MetricApi metricApi = api.getMetricApiForRegion(arg0);
      return new Function<Object, IterableWithMarker<Metric>>() {

         @Override
         public IterableWithMarker<Metric> apply(Object input) {
            return metricApi.list(ListMetricsOptions.Builder.afterMarker(input.toString()));
         }

         @Override
         public String toString() {
            return "listMetricsInRegion(" + arg0 + ")";
View Full Code Here


    * @param metrics the metrics to publish
    * @param namespace the namespace to publish the metrics in
    */
   public static void putMetricData(CloudWatchApi cloudWatchApi, String region, Iterable<MetricDatum> metrics,
            String namespace) {
      MetricApi metricApi = cloudWatchApi.getMetricApiForRegion(region);

      for (List<MetricDatum> slice : Iterables.partition(metrics, 10)) {
         metricApi.putMetricsInNamespace(slice, namespace);
      }
   }
View Full Code Here

      this.api = checkNotNull(api, "api");
   }

   @Override
   protected Function<Object, IterableWithMarker<Metric>> markerToNextForCallingArg0(final String arg0) {
      final MetricApi metricApi = api.getMetricApiForRegion(arg0);
      return new Function<Object, IterableWithMarker<Metric>>() {

         @Override
         public IterableWithMarker<Metric> apply(Object input) {
            return metricApi.list(ListMetricsOptions.Builder.afterMarker(input.toString()));
         }

         @Override
         public String toString() {
            return "listMetricsInRegion(" + arg0 + ")";
View Full Code Here

    * @throws Exception if anything goes wrong
    */
   @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();

      expect(metricApi.list(options))
            .andReturn(response)
            .once();

      EasyMock.replay(api, metricApi);

View Full Code Here

    * @throws Exception if anything goes wrong
    */
   @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("")))
            .andReturn(metricApi)
            .atLeastOnce();
     
      expect(metricApi.list(anyObject(ListMetricsOptions.class)))
            .andReturn(response1)
            .once();
      expect(metricApi.list(anyObject(ListMetricsOptions.class)))
            .andReturn(response2)
            .once();

      EasyMock.replay(api, metricApi);

View Full Code Here

    * @throws Exception if anything goes wrong
    */
   @Test
   public void testPutMetricData() throws Exception {
      CloudWatchApi api = createMock(CloudWatchApi.class);
      MetricApi metricApi = createMock(MetricApi.class);
      Set<MetricDatum> metrics = Sets.newLinkedHashSet();
      String namespace = "JCLOUDS/Test";

      for (int i = 0; i < 11; i++) {
         metrics.add(MetricDatum.builder().metricName("foo").build());
      }

      // Using EasyMock.eq("") because EasyMock makes it impossible to pass null as a String value here
      expect(api.getMetricApiForRegion(EasyMock.eq("")))
            .andReturn(metricApi)
            .atLeastOnce();
     
      for (List<MetricDatum> slice : Iterables.partition(metrics, 10)) {
         metricApi.putMetricsInNamespace(slice, namespace);
      }

      EasyMock.replay(api, metricApi);

      CloudWatch.putMetricData(api, "", metrics, namespace);
View Full Code Here

TOP

Related Classes of org.jclouds.cloudwatch.features.MetricApi

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.