corrected destroyNodes bug

This commit is contained in:
David Ribeiro Alves 2012-07-20 22:23:16 +01:00
parent 0949d52224
commit b45fad87d8
2 changed files with 12 additions and 6 deletions

View File

@ -144,10 +144,13 @@ public class EagerNodePoolComputeServiceAdapter extends BaseNodePoolComputeServi
logger.info(">> destroying node %s", id); logger.info(">> destroying node %s", id);
metadataStore.deleteMapping(id); metadataStore.deleteMapping(id);
if (removeDestroyed) { if (removeDestroyed) {
logger.info(">> policy is replace detroyed node, replacing node with id %s", id);
backendComputeService.get().destroyNode(id); backendComputeService.get().destroyNode(id);
Set<? extends NodeMetadata> replacement = addToPool(1); if (currentSize() < minSize) {
logger.info("<< node %s replaced with %s", id, Iterables.getOnlyElement(replacement)); logger.info(">> policy is remove destroyed node and pool "
+ "would fall below minsize, replacing node with id %s", id);
Set<? extends NodeMetadata> replacement = addToPool(1);
logger.info("<< node %s replaced with %s", id, Iterables.getOnlyElement(replacement));
}
} }
// TODO we should allow the user to hook a way to "clean" the node // TODO we should allow the user to hook a way to "clean" the node
else { else {

View File

@ -108,7 +108,6 @@ public class NodePoolComputeServiceLiveTest extends BaseComputeServiceLiveTest {
@Override @Override
@Test(enabled = true, groups = "live") @Test(enabled = true, groups = "live")
public void testCreateAndRunAService() throws Exception { public void testCreateAndRunAService() throws Exception {
this.group = this.group + "s";
final String configuration = Strings2.toStringAndClose(RunScriptData.class final String configuration = Strings2.toStringAndClose(RunScriptData.class
.getResourceAsStream("/standalone-basic.xml")); .getResourceAsStream("/standalone-basic.xml"));
@ -179,6 +178,10 @@ public class NodePoolComputeServiceLiveTest extends BaseComputeServiceLiveTest {
}), "jboss", node, JBOSS_PATTERN); }), "jboss", node, JBOSS_PATTERN);
} }
public void testListNodeInGroup() {
}
@Test(enabled = true, groups = "live", dependsOnMethods = "testCreateAndRunAService") @Test(enabled = true, groups = "live", dependsOnMethods = "testCreateAndRunAService")
public void testRebuildPoolStateFromStore() { public void testRebuildPoolStateFromStore() {
tearDownContext(); tearDownContext();
@ -213,7 +216,7 @@ public class NodePoolComputeServiceLiveTest extends BaseComputeServiceLiveTest {
NodePredicates.inGroup(ctx.getPoolGroupName())).size(), 2); NodePredicates.inGroup(ctx.getPoolGroupName())).size(), 2);
} }
@Test(enabled = false, groups = "live", dependsOnMethods = "testGetBackendComputeServiceContext") @Test(enabled = true, groups = "live", dependsOnMethods = "testGetBackendComputeServiceContext")
public void testDestroyPoolNodes() { public void testDestroyPoolNodes() {
client.destroyNodesMatching(NodePredicates.inGroup(this.group)); client.destroyNodesMatching(NodePredicates.inGroup(this.group));
// after we destroy all nodes we should still have minsize nodes in the pool // after we destroy all nodes we should still have minsize nodes in the pool
@ -221,7 +224,7 @@ public class NodePoolComputeServiceLiveTest extends BaseComputeServiceLiveTest {
assertSame(ctx.getPoolStats().currentSize(), 1); assertSame(ctx.getPoolStats().currentSize(), 1);
} }
@Test(enabled = true, groups = "live", dependsOnMethods = "testGetBackendComputeServiceContext") @Test(enabled = true, groups = "live", dependsOnMethods = "testDestroyPoolNodes")
public void testDestroyPool() { public void testDestroyPool() {
// TODO get the ctx without the injector // TODO get the ctx without the injector
NodePoolComputeServiceContext ctx = context.utils().injector().getInstance(NodePoolComputeServiceContext.class); NodePoolComputeServiceContext ctx = context.utils().injector().getInstance(NodePoolComputeServiceContext.class);