Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation for com.rultor.agents.ec2.Amazon interface - Issue #755 #760

Closed
wants to merge 7 commits into from
Closed

Conversation

Marczeeee
Copy link
Contributor

Isse #755

@alex-palevsky
Copy link
Contributor

Thanks for your pull request, let me find someone who can review it

@alex-palevsky
Copy link
Contributor

@krzyk cuold you review this pull request

* Creates a new {@link RunInstancesRequest}.
* @return The {@link RunInstancesRequest} created
*/
private RunInstancesRequest createRequest() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just create() is enough

@krzyk
Copy link

krzyk commented Jan 27, 2015

@Marczeeee some comments above, and would be nice to have a test for this

@Marczeeee
Copy link
Contributor Author

@krzyk I made the suggested changes in the code, and please see my comment about the waiting in execution. By the way it isn't so easy to test the functionality of this class as it performs direct request to Amazon to run a new EC2 instance.

final List<Instance> instances = client.runInstances(
this.create()
).getReservation().getInstances();
if ((instances != null) && !instances.isEmpty()) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Amazon docs:

One or more instances.

So it shouldn't return null

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, please also invert the if check ( not checks are confusing, that's why PMD complains) and remove Suppress from above
So the if would look like this:

if (instances.isEmpty()) {
    throw new IllegalStateException("No Instance was available in the RunInstanceRequest reply!");
} else {
    instance = instances.get(0);
}

@krzyk
Copy link

krzyk commented Jan 27, 2015

@Marczeeee and more comment and we are ready to go

@Marczeeee
Copy link
Contributor Author

@krzyk Done.

@krzyk
Copy link

krzyk commented Jan 28, 2015

@rultor merge pls

@rultor
Copy link
Collaborator

rultor commented Jan 28, 2015

@rultor merge pls

@krzyk Thanks for your request. @yegor256 Please confirm this.

throw new IllegalStateException(
"No Instance was available in the RunInstanceRequest reply!"
);
} else {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TimeUnit.SECONDS.sleep(Tv.FIFTEEN);
} catch (final InterruptedException ex) {
Thread.currentThread().interrupt();
break;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why swallowing the exception? why can't we just throw it up, wrapped into IllegalStateException

@yegor256
Copy link
Owner

@Marczeeee a few comments from me above. besides that, what about a test? how do you know all this works?

@Marczeeee
Copy link
Contributor Author

@yegor256 The suggested changes are done. The problem with the test is that after calling 'runOnDemand()' it will connect to Amazon to run the instance.

@Marczeeee Marczeeee closed this Jan 31, 2015
@alex-palevsky
Copy link
Contributor

@krzyk Thanks a lot, I just topped your account for 18 mins, transaction ID 51191441

+18 added to your rating, current score is: +3512

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants