diff --git a/indexing-service/src/main/java/io/druid/indexing/overlord/scaling/AutoScalingStrategy.java b/indexing-service/src/main/java/io/druid/indexing/overlord/scaling/AutoScalingStrategy.java index 392919df039..0c9c7a06bee 100644 --- a/indexing-service/src/main/java/io/druid/indexing/overlord/scaling/AutoScalingStrategy.java +++ b/indexing-service/src/main/java/io/druid/indexing/overlord/scaling/AutoScalingStrategy.java @@ -30,6 +30,8 @@ public interface AutoScalingStrategy public AutoScalingData terminate(List ips); + public AutoScalingData terminateWithIds(List ids); + /** * Provides a lookup of ip addresses to node ids * @param ips - nodes IPs diff --git a/indexing-service/src/main/java/io/druid/indexing/overlord/scaling/EC2AutoScalingStrategy.java b/indexing-service/src/main/java/io/druid/indexing/overlord/scaling/EC2AutoScalingStrategy.java index b59f3d1e74e..ec875d0ad09 100644 --- a/indexing-service/src/main/java/io/druid/indexing/overlord/scaling/EC2AutoScalingStrategy.java +++ b/indexing-service/src/main/java/io/druid/indexing/overlord/scaling/EC2AutoScalingStrategy.java @@ -155,7 +155,7 @@ public class EC2AutoScalingStrategy implements AutoScalingStrategy } try { - log.info("Terminating instance[%s]", instances); + log.info("Terminating instances[%s]", instances); amazonEC2Client.terminateInstances( new TerminateInstancesRequest( Lists.transform( @@ -193,6 +193,28 @@ public class EC2AutoScalingStrategy implements AutoScalingStrategy return null; } + @Override + public AutoScalingData terminateWithIds(List ids) + { + if (ids.isEmpty()) { + return new AutoScalingData(Lists.newArrayList()); + } + + try { + log.info("Terminating instances[%s]", ids); + amazonEC2Client.terminateInstances( + new TerminateInstancesRequest(ids) + ); + + return new AutoScalingData(ids); + } + catch (Exception e) { + log.error(e, "Unable to terminate any instances."); + } + + return null; + } + @Override public List ipToIdLookup(List ips) { diff --git a/indexing-service/src/main/java/io/druid/indexing/overlord/scaling/NoopAutoScalingStrategy.java b/indexing-service/src/main/java/io/druid/indexing/overlord/scaling/NoopAutoScalingStrategy.java index 893f69ca9f4..8c3c14ca336 100644 --- a/indexing-service/src/main/java/io/druid/indexing/overlord/scaling/NoopAutoScalingStrategy.java +++ b/indexing-service/src/main/java/io/druid/indexing/overlord/scaling/NoopAutoScalingStrategy.java @@ -44,6 +44,13 @@ public class NoopAutoScalingStrategy implements AutoScalingStrategy return null; } + @Override + public AutoScalingData terminateWithIds(List ids) + { + log.info("If I were a real strategy I'd terminate %s now", ids); + return null; + } + @Override public List ipToIdLookup(List ips) { diff --git a/indexing-service/src/main/java/io/druid/indexing/overlord/scaling/SimpleResourceManagementStrategy.java b/indexing-service/src/main/java/io/druid/indexing/overlord/scaling/SimpleResourceManagementStrategy.java index 10e084b3c9e..76b752a707a 100644 --- a/indexing-service/src/main/java/io/druid/indexing/overlord/scaling/SimpleResourceManagementStrategy.java +++ b/indexing-service/src/main/java/io/druid/indexing/overlord/scaling/SimpleResourceManagementStrategy.java @@ -132,8 +132,7 @@ public class SimpleResourceManagementStrategy implements ResourceManagementStrat .addData("provisioningCount", currentlyProvisioning.size()) .emit(); - List nodeIps = autoScalingStrategy.idToIpLookup(Lists.newArrayList(currentlyProvisioning)); - autoScalingStrategy.terminate(nodeIps); + autoScalingStrategy.terminateWithIds(Lists.newArrayList(currentlyProvisioning)); currentlyProvisioning.clear(); } } diff --git a/indexing-service/src/test/java/io/druid/indexing/overlord/scaling/SimpleResourceManagementStrategyTest.java b/indexing-service/src/test/java/io/druid/indexing/overlord/scaling/SimpleResourceManagementStrategyTest.java index 6ffc6ae6222..aa41656aa90 100644 --- a/indexing-service/src/test/java/io/druid/indexing/overlord/scaling/SimpleResourceManagementStrategyTest.java +++ b/indexing-service/src/test/java/io/druid/indexing/overlord/scaling/SimpleResourceManagementStrategyTest.java @@ -187,9 +187,7 @@ public class SimpleResourceManagementStrategyTest EasyMock.expect(autoScalingStrategy.ipToIdLookup(EasyMock.>anyObject())) .andReturn(Lists.newArrayList()).times(2); - EasyMock.expect(autoScalingStrategy.idToIpLookup(EasyMock.>anyObject())) - .andReturn(Lists.newArrayList()); - EasyMock.expect(autoScalingStrategy.terminate(EasyMock.>anyObject())) + EasyMock.expect(autoScalingStrategy.terminateWithIds(EasyMock.>anyObject())) .andReturn(null); EasyMock.expect(autoScalingStrategy.provision()).andReturn( new AutoScalingData(Lists.newArrayList("fake")) diff --git a/indexing-service/src/test/java/io/druid/indexing/overlord/scaling/TestAutoScalingStrategy.java b/indexing-service/src/test/java/io/druid/indexing/overlord/scaling/TestAutoScalingStrategy.java index 8ef2e0513f6..d2378c38823 100644 --- a/indexing-service/src/test/java/io/druid/indexing/overlord/scaling/TestAutoScalingStrategy.java +++ b/indexing-service/src/test/java/io/druid/indexing/overlord/scaling/TestAutoScalingStrategy.java @@ -37,6 +37,12 @@ public class TestAutoScalingStrategy implements AutoScalingStrategy return null; } + @Override + public AutoScalingData terminateWithIds(List ids) + { + return null; + } + @Override public List ipToIdLookup(List ips) {