Merge pull request #257 from metamx/az

Add availability zone info to autoscaling
This commit is contained in:
fjy 2013-10-07 12:17:42 -07:00
commit de71c14114
6 changed files with 18 additions and 5 deletions

View File

@ -24,6 +24,7 @@ import com.amazonaws.services.ec2.model.DescribeInstancesRequest;
import com.amazonaws.services.ec2.model.DescribeInstancesResult;
import com.amazonaws.services.ec2.model.Filter;
import com.amazonaws.services.ec2.model.Instance;
import com.amazonaws.services.ec2.model.Placement;
import com.amazonaws.services.ec2.model.Reservation;
import com.amazonaws.services.ec2.model.RunInstancesRequest;
import com.amazonaws.services.ec2.model.RunInstancesResult;
@ -88,6 +89,7 @@ public class EC2AutoScalingStrategy implements AutoScalingStrategy
)
.withInstanceType(workerConfig.getInstanceType())
.withSecurityGroupIds(workerConfig.getSecurityGroupIds())
.withPlacement(new Placement(setupData.getAvailabilityZone()))
.withKeyName(workerConfig.getKeyName())
.withUserData(
Base64.encodeBase64String(

View File

@ -31,6 +31,7 @@ public class WorkerSetupData
private final String minVersion;
private final int minNumWorkers;
private final int maxNumWorkers;
private final String availabilityZone;
private final EC2NodeData nodeData;
private final GalaxyUserData userData;
@ -39,6 +40,7 @@ public class WorkerSetupData
@JsonProperty("minVersion") String minVersion,
@JsonProperty("minNumWorkers") int minNumWorkers,
@JsonProperty("maxNumWorkers") int maxNumWorkers,
@JsonProperty("availabilityZone") String availabilityZone,
@JsonProperty("nodeData") EC2NodeData nodeData,
@JsonProperty("userData") GalaxyUserData userData
)
@ -46,6 +48,7 @@ public class WorkerSetupData
this.minVersion = minVersion;
this.minNumWorkers = minNumWorkers;
this.maxNumWorkers = maxNumWorkers;
this.availabilityZone = availabilityZone;
this.nodeData = nodeData;
this.userData = userData;
}
@ -68,6 +71,12 @@ public class WorkerSetupData
return maxNumWorkers;
}
@JsonProperty
public String getAvailabilityZone()
{
return availabilityZone;
}
@JsonProperty
public EC2NodeData getNodeData()
{
@ -87,6 +96,7 @@ public class WorkerSetupData
"minVersion='" + minVersion + '\'' +
", minNumWorkers=" + minNumWorkers +
", maxNumWorkers=" + maxNumWorkers +
", availabilityZone=" + availabilityZone +
", nodeData=" + nodeData +
", userData=" + userData +
'}';

View File

@ -392,7 +392,7 @@ public class RemoteTaskRunnerTest
},
cf,
new SimplePathChildrenCacheFactory.Builder().build(),
DSuppliers.of(new AtomicReference<WorkerSetupData>(new WorkerSetupData("0", 0, 1, null, null))),
DSuppliers.of(new AtomicReference<WorkerSetupData>(new WorkerSetupData("0", 0, 1, null, null, null))),
null
);

View File

@ -99,6 +99,7 @@ public class EC2AutoScalingStrategyTest
"0",
0,
1,
"",
new EC2NodeData(AMI_ID, INSTANCE_ID, 1, 1, Lists.<String>newArrayList(), "foo"),
new GalaxyUserData("env", "version", "type")
)

View File

@ -65,7 +65,7 @@ public class SimpleResourceManagementStrategyTest
autoScalingStrategy = EasyMock.createMock(AutoScalingStrategy.class);
workerSetupData = new AtomicReference<WorkerSetupData>(
new WorkerSetupData(
"0", 0, 2, null, null
"0", 0, 2, null, null, null
)
);
@ -237,7 +237,7 @@ public class SimpleResourceManagementStrategyTest
@Test
public void testDoSuccessfulTerminate() throws Exception
{
workerSetupData.set(new WorkerSetupData("0", 0, 1, null, null));
workerSetupData.set(new WorkerSetupData("0", 0, 1, null, null, null));
EasyMock.expect(autoScalingStrategy.ipToIdLookup(EasyMock.<List<String>>anyObject()))
.andReturn(Lists.<String>newArrayList());
@ -267,7 +267,7 @@ public class SimpleResourceManagementStrategyTest
@Test
public void testSomethingTerminating() throws Exception
{
workerSetupData.set(new WorkerSetupData("0", 0, 1, null, null));
workerSetupData.set(new WorkerSetupData("0", 0, 1, null, null, null));
EasyMock.expect(autoScalingStrategy.ipToIdLookup(EasyMock.<List<String>>anyObject()))
.andReturn(Lists.<String>newArrayList("ip")).times(2);

View File

@ -31,7 +31,7 @@ public abstract class DruidCoordinatorConfig
public abstract String getHost();
@Config("druid.coordinator.startDelay")
@Default("PT60s")
@Default("PT120s")
public abstract Duration getCoordinatorStartDelay();
@Config("druid.coordinator.period")