@@ -73,14 +73,7 @@ private RunDataProcessingTasks(Builder builder) {
7373 this .maximumRunningTasks = builder .maximumRunningTasks ;
7474 }
7575
76- public static void main (String [] args ) {
77- if (args .length != 2 ) {
78- System .out .println ("Usage: <instance-id> <number-of-tasks> <is-compaction-task>" );
79- return ;
80- }
81- String instanceId = args [0 ];
82- int numberOfTasks = Integer .parseInt (args [1 ]);
83- boolean compactionTask = Boolean .parseBoolean (args [2 ]);
76+ public static void run (String instanceId , int numberOfTasks , boolean compactionTask ) {
8477 try (S3Client s3Client = S3Client .create ();
8578 EcsClient ecsClient = EcsClient .create ();
8679 AutoScalingClient asClient = AutoScalingClient .create ();
@@ -90,7 +83,7 @@ public static void main(String[] args) {
9083 if (compactionTask ) {
9184 createForCompactions (instanceProperties , ecsClient , asClient , ec2Client ).runToMeetTargetTasks (numberOfTasks );
9285 } else {
93- createForBulkExport (instanceProperties , ecsClient , asClient , ec2Client ).runToMeetTargetTasks (numberOfTasks );
86+ createForBulkExport (instanceProperties , ecsClient ).runToMeetTargetTasks (numberOfTasks );
9487 }
9588 }
9689 }
@@ -99,7 +92,7 @@ public static Builder builder() {
9992 return new Builder ();
10093 }
10194
102- public static RunDataProcessingTasks createForBulkExport (InstanceProperties instanceProperties , EcsClient ecsClient , AutoScalingClient asClient , Ec2Client ec2Client ) {
95+ public static RunDataProcessingTasks createForBulkExport (InstanceProperties instanceProperties , EcsClient ecsClient ) {
10396 String clusterName = instanceProperties .get (BULK_EXPORT_CLUSTER );
10497 return builder ()
10598 .hostScaler (new BulkExportTaskHostScaler ())
@@ -113,17 +106,9 @@ public static RunDataProcessingTasks createForBulkExport(InstanceProperties inst
113106 .build ();
114107 }
115108
116- public static RunDataProcessingTasks createForCompactions (InstanceProperties instanceProperties , TaskCounts taskCounts , CompactionTaskHostScaler compactionHostScaler , TaskLauncher taskLauncher ) {
117- return setupForCompactions (instanceProperties )
118- .hostScaler (compactionHostScaler )
119- .taskCounts (taskCounts )
120- .taskLauncher (taskLauncher )
121- .build ();
122- }
123-
124109 public static RunDataProcessingTasks createForCompactions (InstanceProperties instanceProperties , EcsClient ecsClient , AutoScalingClient asClient , Ec2Client ec2Client ) {
125110 String clusterName = instanceProperties .get (COMPACTION_CLUSTER );
126- return setupForCompactions (instanceProperties )
111+ return builderForCompactions (instanceProperties )
127112 .hostScaler (EC2Scaler .create (instanceProperties , asClient , ec2Client ))
128113 .taskCounts (() -> ECSTaskCount .getNumPendingAndRunningTasks (clusterName , ecsClient ))
129114 .taskLauncher ((numberOfTasks , checkAbort ) -> launchTasks (ecsClient , instanceProperties , COMPACTION_CONTAINER_NAME , clusterName ,
@@ -132,7 +117,7 @@ public static RunDataProcessingTasks createForCompactions(InstanceProperties ins
132117 .build ();
133118 }
134119
135- private static Builder setupForCompactions (InstanceProperties instanceProperties ) {
120+ public static Builder builderForCompactions (InstanceProperties instanceProperties ) {
136121 return builder ()
137122 .sqsJobQueueUrl (instanceProperties .get (COMPACTION_JOB_QUEUE_URL ))
138123 .maximumRunningTasks (instanceProperties .getInt (MAXIMUM_CONCURRENT_COMPACTION_TASKS ));
0 commit comments