Refactored the `AbiquoComputeServiceAdapter` to avoid creating more than one 
group with the same name, when creating multiple nodes concurrently.

There is a little room for improvement in this pull request, and I'd 
appreciate some advice. Currently I've overridden the 
[CreateNodesWithGroupEncodedIntoNameThenAddToSet#execute](https://github.com/jclouds/jclouds/blob/master/compute/src/main/java/org/jclouds/compute/strategy/impl/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java#L118-L128)
 method to create the group before starting the creation of the nodes. This 
works fine, but there are two (not expensive, though) api calls that are going 
to be repeated for each deployed node, and I'd like to save them.

In order to do that, I'd need to pass a reference to the retrieved objects 
to the `createNodeWithGroupEncodedIntoName` method. This would require to also 
override the  
[CreateNodesWithGroupEncodedIntoNameThenAddToSet#createNodeInGroupWithNameAndTemplate](https://github.com/jclouds/jclouds/blob/master/compute/src/main/java/org/jclouds/compute/strategy/impl/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java#L166-L169)
 method, and the 
[CreateNodesWithGroupEncodedIntoNameThenAddToSet#AddNode](https://github.com/jclouds/jclouds/blob/master/compute/src/main/java/org/jclouds/compute/strategy/impl/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java#L75-L83)
 class, so I can invoke the new method with the additional objects. This has 
the counterpart that the new method would not be part of the 
[CreateNodeWithGroupEncodedIntoName](https://github.com/jclouds/jclouds/blob/master/compute/src/main/java/org/jclouds/compute/strategy/CreateNodeWithGroupEncodedIntoName.java)
 strategy int
 erface. 

So:

* Do not override those method and assume those repeated api calls.
* Implement the mentioned changes even if we end up calling a method that is 
not part of the strategy interface (which shouldn't be a problem and 
shouldn't cause side-effects).
* Does anyone have better/smarter ideas?

Thx!

You can merge this Pull Request by running:

  git pull https://github.com/nacx/jclouds-labs 205-creategroup

Or you can view, comment on it, or merge it online at:

  https://github.com/jclouds/jclouds-labs/pull/25

-- Commit Summary --

  * JCLOUDS-205: Do not create duplicated groups in Abiquo

-- File Changes --

    M 
abiquo/src/main/java/org/jclouds/abiquo/compute/config/AbiquoComputeServiceContextModule.java
 (5)
    M 
abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/AbiquoComputeServiceAdapter.java
 (61)
    A 
abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/CreateGroupBeforeCreatingNodes.java
 (107)
    M 
abiquo/src/test/java/org/jclouds/abiquo/compute/AbiquoComputeServiceLiveTest.java
 (20)

-- Patch Links --

https://github.com/jclouds/jclouds-labs/pull/25.patch
https://github.com/jclouds/jclouds-labs/pull/25.diff

Reply via email to