mercredi 4 février 2015

Waiting for EC2 instance to launch and be in running state

I am writing a program using AWS Java SDK to create EC2 instances and do some processing once they are launched.


I have written the following code but I know there could be a better way to do this:



public static void main(String[] args) {

// Some code initialization here
Instance ec2instance;

do {
try {
Thread.sleep(sleep_cyle);
} catch (InterruptedException ex) {
System.out.println(ex.getMessage());
}

} while(ec2instance.getState().getCode() != 16);

//Proceed with processing after instance is running
}


Thank you.


Aucun commentaire:

Enregistrer un commentaire