make switching between scaling strategies config based

This commit is contained in:
Fangjin Yang 2012-11-08 09:30:32 -08:00
parent 4d6cfdc774
commit f39af83be4
2 changed files with 25 additions and 11 deletions

View File

@ -83,4 +83,8 @@ public abstract class IndexerCoordinatorConfig
@Config("druid.merger.rowFlushBoundary")
@Default("500000")
public abstract long getRowFlushBoundary();
@Config("druid.indexer.strategy")
@Default("noop")
public abstract String getStrategyImpl();
}

View File

@ -468,17 +468,27 @@ public class IndexerCoordinatorNode
.build()
);
ScalingStrategy strategy = new EC2AutoScalingStrategy(
new AmazonEC2Client(
new BasicAWSCredentials(
props.getProperty("com.metamx.aws.accessKey"),
props.getProperty("com.metamx.aws.secretKey")
)
),
configFactory.build(EC2AutoScalingStrategyConfig.class)
);
// TODO: use real strategy before actual deployment
strategy = new NoopScalingStrategy();
ScalingStrategy strategy;
if (config.getStrategyImpl().equalsIgnoreCase("ec2")) {
strategy = new EC2AutoScalingStrategy(
new AmazonEC2Client(
new BasicAWSCredentials(
props.getProperty("com.metamx.aws.accessKey"),
props.getProperty("com.metamx.aws.secretKey")
)
),
configFactory.build(EC2AutoScalingStrategyConfig.class)
);
} else if (config.getStorageImpl().equalsIgnoreCase("noop")) {
strategy = new NoopScalingStrategy();
} else {
throw new IllegalStateException(
String.format(
"Invalid strategy implementation: %s",
config.getStrategyImpl()
)
);
}
return new RemoteTaskRunner(
jsonMapper,