Skip to content
This repository has been archived by the owner on Feb 4, 2019. It is now read-only.

Commit

Permalink
updated to 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pandriani committed Sep 19, 2012
1 parent 8409798 commit ee5e87f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ec2-createlamp/pom.xml
Expand Up @@ -33,7 +33,7 @@
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>aws-ec2</artifactId>
<version>1.0.0</version>
<version>1.5.0</version>
</dependency>
</dependencies>
<build>
Expand Down
Expand Up @@ -27,7 +27,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.ContextBuilder;
import org.jclouds.ec2.EC2AsyncClient;
import org.jclouds.ec2.EC2Client;
import org.jclouds.ec2.domain.InstanceState;
Expand All @@ -37,7 +37,6 @@
import org.jclouds.ec2.domain.Reservation;
import org.jclouds.ec2.domain.RunningInstance;
import org.jclouds.ec2.predicates.InstanceStateRunning;
import org.jclouds.net.IPSocket;
import org.jclouds.predicates.InetSocketAddressConnect;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.rest.RestContext;
Expand All @@ -47,6 +46,7 @@
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import com.google.common.net.HostAndPort;

/**
* This the Main class of an Application that demonstrates the use of the EC2Client by creating a
Expand All @@ -73,8 +73,9 @@ public static void main(String[] args) throws TimeoutException {
String name = args[3];

// Init
RestContext<EC2Client, EC2AsyncClient> context = new ComputeServiceContextFactory().createContext("aws-ec2",
accesskeyid, secretkey).getProviderSpecificContext();
RestContext<EC2Client, EC2AsyncClient> context = ContextBuilder
.newBuilder("aws-ec2").credentials(accesskeyid, secretkey)
.build();

// Get a synchronous client
EC2Client client = context.getApi();
Expand Down Expand Up @@ -189,16 +190,16 @@ static RunningInstance blockUntilInstanceRunning(EC2Client client, RunningInstan

instance = findInstanceById(client, instance.getId());

RetryablePredicate<IPSocket> socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), 300,
RetryablePredicate<HostAndPort> socketTester = new RetryablePredicate<HostAndPort>(new InetSocketAddressConnect(), 300,
1, TimeUnit.SECONDS);
System.out.printf("%d: %s awaiting ssh service to start%n", System.currentTimeMillis(), instance.getIpAddress());
if (!socketTester.apply(new IPSocket(instance.getIpAddress(), 22)))
if (!socketTester.apply(HostAndPort.fromParts(instance.getIpAddress(), 22)))
throw new TimeoutException("timeout waiting for ssh to start: " + instance.getIpAddress());

System.out.printf("%d: %s ssh service started%n", System.currentTimeMillis(), instance.getIpAddress());

System.out.printf("%d: %s awaiting http service to start%n", System.currentTimeMillis(), instance.getIpAddress());
if (!socketTester.apply(new IPSocket(instance.getIpAddress(), 80)))
if (!socketTester.apply(HostAndPort.fromParts(instance.getIpAddress(), 80)))
throw new TimeoutException("timeout waiting for http to start: " + instance.getIpAddress());

System.out.printf("%d: %s http service started%n", System.currentTimeMillis(), instance.getIpAddress());
Expand Down

0 comments on commit ee5e87f

Please sign in to comment.