Skip to content
Permalink
Browse files
Merge pull request #7 from jcscoobyrs/master
Updated cloudwatch-basics to use ContextBuilder.
  • Loading branch information
Adrian Cole committed May 21, 2012
2 parents 4eaf41e + 03a4dde commit 5acddbf861229a956b5c200db1c127d7cd90adcf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
@@ -6,6 +6,7 @@ test-output/
.classpath
.project
.idea/
atlassian-ide-plugin.xml
*.iml
*.ipr
*.iws
@@ -19,6 +19,9 @@
package org.jclouds.examples.cloudwatch.basics;

import com.google.common.collect.Iterators;
import org.jclouds.ContextBuilder;
import org.jclouds.aws.cloudwatch.AWSCloudWatchProviderMetadata;
import org.jclouds.aws.ec2.AWSEC2ProviderMetadata;
import org.jclouds.cloudwatch.CloudWatch;
import org.jclouds.cloudwatch.CloudWatchAsyncClient;
import org.jclouds.cloudwatch.CloudWatchClient;
@@ -33,12 +36,10 @@
import org.jclouds.cloudwatch.features.MetricClient;
import org.jclouds.cloudwatch.options.ListMetricsOptions;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationScope;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.RestContextFactory;

import java.text.DecimalFormat;
import java.util.Date;
@@ -69,8 +70,12 @@ public static void main(String[] args) {
RestContext<CloudWatchClient, CloudWatchAsyncClient> cloudWatchContext = null;

try {
awsEC2Context = new ComputeServiceContextFactory().createContext("aws-ec2", accessKeyId, secretKey);
cloudWatchContext = new RestContextFactory().createContext("aws-cloudwatch", accessKeyId, secretKey);
cloudWatchContext = ContextBuilder.newBuilder(new AWSCloudWatchProviderMetadata())
.credentials(accessKeyId, secretKey)
.build();
awsEC2Context = ContextBuilder.newBuilder(new AWSEC2ProviderMetadata())
.credentials(accessKeyId, secretKey)
.build(ComputeServiceContext.class);

// Get all nodes
Set<? extends ComputeMetadata> allNodes = awsEC2Context.getComputeService().listNodes();

0 comments on commit 5acddbf

Please sign in to comment.