fixed usage for IPSocket

This commit is contained in:
Adrian Cole 2010-05-25 01:03:06 -07:00
parent f297c9d7d5
commit 44d3a3131f
2 changed files with 12 additions and 5 deletions

View File

@ -32,6 +32,11 @@
<name>jclouds ec2 sample that creates an instance and all you need to access it</name> <name>jclouds ec2 sample that creates an instance and all you need to access it</name>
<description>jclouds ec2 sample that creates an instance and all you need to access it</description> <description>jclouds ec2 sample that creates an instance and all you need to access it</description>
<dependencies> <dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-jsch</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>jclouds-scriptbuilder</artifactId> <artifactId>jclouds-scriptbuilder</artifactId>

View File

@ -37,8 +37,10 @@ import org.jclouds.aws.ec2.domain.KeyPair;
import org.jclouds.aws.ec2.domain.Reservation; import org.jclouds.aws.ec2.domain.Reservation;
import org.jclouds.aws.ec2.domain.RunningInstance; import org.jclouds.aws.ec2.domain.RunningInstance;
import org.jclouds.aws.ec2.predicates.InstanceStateRunning; import org.jclouds.aws.ec2.predicates.InstanceStateRunning;
import org.jclouds.ssh.jsch.predicates.InetSocketAddressConnect;
import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.predicates.SocketOpen; import org.jclouds.predicates.SocketOpen;
import org.jclouds.net.IPSocket;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.jclouds.scriptbuilder.ScriptBuilder; import org.jclouds.scriptbuilder.ScriptBuilder;
import org.jclouds.scriptbuilder.domain.OsFamily; import org.jclouds.scriptbuilder.domain.OsFamily;
@ -86,7 +88,7 @@ public class MainApp {
RunningInstance instance = createSecurityGroupKeyPairAndInstance(client, name); RunningInstance instance = createSecurityGroupKeyPairAndInstance(client, name);
System.out.printf("instance %s ready%n", instance.getId()); System.out.printf("instance %s ready%n", instance.getId());
System.out.printf("ip address: %s%n", instance.getIpAddress().getHostAddress()); System.out.printf("ip address: %s%n", instance.getIpAddress());
System.out.printf("dns name: %s%n", instance.getDnsName()); System.out.printf("dns name: %s%n", instance.getDnsName());
System.out.printf("login identity:%n%s%n", pair.getKeyMaterial()); System.out.printf("login identity:%n%s%n", pair.getKeyMaterial());
@ -190,11 +192,11 @@ public class MainApp {
instance = findInstanceById(client, instance.getId()); instance = findInstanceById(client, instance.getId());
RetryablePredicate<InetSocketAddress> socketTester = new RetryablePredicate<InetSocketAddress>( RetryablePredicate<IPSocket> socketTester = new RetryablePredicate<IPSocket>(
new SocketOpen(), 300, 1, TimeUnit.SECONDS); new InetSocketAddressConnect(), 300, 1, TimeUnit.SECONDS);
System.out.printf("%d: %s awaiting ssh service to start%n", System.currentTimeMillis(), System.out.printf("%d: %s awaiting ssh service to start%n", System.currentTimeMillis(),
instance.getIpAddress()); instance.getIpAddress());
if (!socketTester.apply(new InetSocketAddress(instance.getIpAddress(), 22))) if (!socketTester.apply(new IPSocket(instance.getIpAddress(), 22)))
throw new TimeoutException("timeout waiting for ssh to start: " + instance.getIpAddress()); throw new TimeoutException("timeout waiting for ssh to start: " + instance.getIpAddress());
System.out.printf("%d: %s ssh service started%n", System.currentTimeMillis(), instance System.out.printf("%d: %s ssh service started%n", System.currentTimeMillis(), instance
@ -202,7 +204,7 @@ public class MainApp {
System.out.printf("%d: %s awaiting http service to start%n", System.currentTimeMillis(), System.out.printf("%d: %s awaiting http service to start%n", System.currentTimeMillis(),
instance.getIpAddress()); instance.getIpAddress());
if (!socketTester.apply(new InetSocketAddress(instance.getIpAddress(), 80))) if (!socketTester.apply(new IPSocket(instance.getIpAddress(), 80)))
throw new TimeoutException("timeout waiting for http to start: " + instance.getIpAddress()); throw new TimeoutException("timeout waiting for http to start: " + instance.getIpAddress());
System.out.printf("%d: %s http service started%n", System.currentTimeMillis(), instance System.out.printf("%d: %s http service started%n", System.currentTimeMillis(), instance