From f39af83be4cf828df2dbe5bc41e8ec902427b273 Mon Sep 17 00:00:00 2001 From: Fangjin Yang Date: Thu, 8 Nov 2012 09:30:32 -0800 Subject: [PATCH] make switching between scaling strategies config based --- .../config/IndexerCoordinatorConfig.java | 4 +++ .../http/IndexerCoordinatorNode.java | 32 ++++++++++++------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/merger/src/main/java/com/metamx/druid/merger/coordinator/config/IndexerCoordinatorConfig.java b/merger/src/main/java/com/metamx/druid/merger/coordinator/config/IndexerCoordinatorConfig.java index 18f317525fe..6d6218c3bff 100644 --- a/merger/src/main/java/com/metamx/druid/merger/coordinator/config/IndexerCoordinatorConfig.java +++ b/merger/src/main/java/com/metamx/druid/merger/coordinator/config/IndexerCoordinatorConfig.java @@ -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(); } diff --git a/merger/src/main/java/com/metamx/druid/merger/coordinator/http/IndexerCoordinatorNode.java b/merger/src/main/java/com/metamx/druid/merger/coordinator/http/IndexerCoordinatorNode.java index 2b689c71706..3bcfca0deff 100644 --- a/merger/src/main/java/com/metamx/druid/merger/coordinator/http/IndexerCoordinatorNode.java +++ b/merger/src/main/java/com/metamx/druid/merger/coordinator/http/IndexerCoordinatorNode.java @@ -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,