@Test public void checkASGNameBuildingV3() { JobGroupInfo jobGroupInfoOne = JobGroupInfo.newBuilder() .withDetail("^1.0.0") .withSequence("v001") .withStack("main") .build(); JobDescriptor<JobDescriptor.JobDescriptorExt> jobDescriptorOne = JobDescriptor.newBuilder() .withApplicationName("testapp") .withJobGroupInfo(jobGroupInfoOne).build(); String autoScalingGroup = DefaultAppScaleManager.buildAutoScalingGroupV3(jobDescriptorOne); Assertions.assertThat(autoScalingGroup).isEqualTo("testapp-main-^1.0.0-v001"); JobGroupInfo jobGroupInfoTwo = JobGroupInfo.newBuilder() .withDetail("^1.0.0") .withStack("main") .build(); JobDescriptor<JobDescriptor.JobDescriptorExt> jobDescriptorTwo = JobDescriptor.newBuilder() .withApplicationName("testapp") .withJobGroupInfo(jobGroupInfoTwo).build(); autoScalingGroup = DefaultAppScaleManager.buildAutoScalingGroupV3(jobDescriptorTwo); Assertions.assertThat(autoScalingGroup).isEqualTo("testapp-main-^1.0.0-v000"); JobGroupInfo jobGroupInfoThree = JobGroupInfo.newBuilder() .withDetail("^1.0.0") .build(); JobDescriptor<JobDescriptor.JobDescriptorExt> jobDescriptorThree = JobDescriptor.newBuilder() .withApplicationName("testapp") .withJobGroupInfo(jobGroupInfoThree).build(); autoScalingGroup = DefaultAppScaleManager.buildAutoScalingGroupV3(jobDescriptorThree); Assertions.assertThat(autoScalingGroup).isEqualTo("testapp--^1.0.0-v000"); JobGroupInfo jobGroupInfoFour = JobGroupInfo.newBuilder().build(); JobDescriptor<JobDescriptor.JobDescriptorExt> jobDescriptorFour = JobDescriptor.newBuilder() .withApplicationName("testapp") .withJobGroupInfo(jobGroupInfoFour).build(); autoScalingGroup = DefaultAppScaleManager.buildAutoScalingGroupV3(jobDescriptorFour); Assertions.assertThat(autoScalingGroup).isEqualTo("testapp-v000"); JobGroupInfo jobGroupInfoFive = JobGroupInfo.newBuilder() .withDetail("titus") .withSequence("v038") .build(); JobDescriptor<JobDescriptor.JobDescriptorExt> jobDescriptorFive = JobDescriptor.newBuilder() .withApplicationName("tbd") .withJobGroupInfo(jobGroupInfoFive) .build(); autoScalingGroup = DefaultAppScaleManager.buildAutoScalingGroupV3(jobDescriptorFive); Assertions.assertThat(autoScalingGroup).isEqualTo("tbd--titus-v038"); }
@VisibleForTesting static String buildAutoScalingGroupV3(JobDescriptor<?> jobDescriptor) { JobGroupInfo jobGroupInfo = jobDescriptor.getJobGroupInfo(); String jobGroupSequence = jobGroupInfo.getSequence() != null ? jobGroupInfo.getSequence() : DEFAULT_JOB_GROUP_SEQ; AutoScalingGroupNameBuilder autoScalingGroupNameBuilder = new AutoScalingGroupNameBuilder(); String asgWithNoSequence = autoScalingGroupNameBuilder .withAppName(jobDescriptor.getApplicationName()) .withStack(jobGroupInfo.getStack()) .withDetail(jobGroupInfo.getDetail()) .buildGroupName(); return String.format("%s-%s", asgWithNoSequence, jobGroupSequence); }
DefaultAppScaleManager implements AppScaleManager { @VisibleForTesting static String buildAutoScalingGroupV3(JobDescriptor<?> jobDescriptor) { JobGroupInfo jobGroupInfo = jobDescriptor.getJobGroupInfo(); String jobGroupSequence = jobGroupInfo.getSequence() != null ? jobGroupInfo.getSequence() : DEFAULT_JOB_GROUP_SEQ; AutoScalingGroupNameBuilder autoScalingGroupNameBuilder = new AutoScalingGroupNameBuilder(); String asgWithNoSequence = autoScalingGroupNameBuilder .withAppName(jobDescriptor.getApplicationName()) .withStack(jobGroupInfo.getStack()) .withDetail(jobGroupInfo.getDetail()) .buildGroupName(); return String.format("%s-%s", asgWithNoSequence, jobGroupSequence); } }
DefaultAppScaleManager implements AppScaleManager { @VisibleForTesting static String buildAutoScalingGroupV3(JobDescriptor<?> jobDescriptor) { JobGroupInfo jobGroupInfo = jobDescriptor.getJobGroupInfo(); String jobGroupSequence = jobGroupInfo.getSequence() != null ? jobGroupInfo.getSequence() : DEFAULT_JOB_GROUP_SEQ; AutoScalingGroupNameBuilder autoScalingGroupNameBuilder = new AutoScalingGroupNameBuilder(); String asgWithNoSequence = autoScalingGroupNameBuilder .withAppName(jobDescriptor.getApplicationName()) .withStack(jobGroupInfo.getStack()) .withDetail(jobGroupInfo.getDetail()) .buildGroupName(); return String.format("%s-%s", asgWithNoSequence, jobGroupSequence); } @Inject  DefaultAppScaleManager(AppScalePolicyStore appScalePolicyStore, CloudAlarmClient cloudAlarmClient,
                                  AppAutoScalingClient applicationAutoScalingClient,
                                  V3JobOperations v3JobOperations,
                                  Registry registry,
                                  AppScaleManagerConfiguration appScaleManagerConfiguration,
                                  TitusRuntime titusRuntime); private  DefaultAppScaleManager(AppScalePolicyStore appScalePolicyStore, CloudAlarmClient cloudAlarmClient,
                                   AppAutoScalingClient applicationAutoScalingClient,
                                   V3JobOperations v3JobOperations,
                                   Registry registry,
                                   AppScaleManagerConfiguration appScaleManagerConfiguration,
                                   ExecutorService awsInteractionExecutor,
                                   TitusRuntime titusRuntime); @VisibleForTesting  DefaultAppScaleManager(AppScalePolicyStore appScalePolicyStore, CloudAlarmClient cloudAlarmClient,
                                  AppAutoScalingClient applicationAutoScalingClient,
                                  V3JobOperations v3JobOperations,
                                  Registry registry,
                                  AppScaleManagerConfiguration appScaleManagerConfiguration,
                                  Scheduler awsInteractionScheduler,
                                  TitusRuntime titusRuntime); }
DefaultAppScaleManager implements AppScaleManager { @VisibleForTesting static String buildAutoScalingGroupV3(JobDescriptor<?> jobDescriptor) { JobGroupInfo jobGroupInfo = jobDescriptor.getJobGroupInfo(); String jobGroupSequence = jobGroupInfo.getSequence() != null ? jobGroupInfo.getSequence() : DEFAULT_JOB_GROUP_SEQ; AutoScalingGroupNameBuilder autoScalingGroupNameBuilder = new AutoScalingGroupNameBuilder(); String asgWithNoSequence = autoScalingGroupNameBuilder .withAppName(jobDescriptor.getApplicationName()) .withStack(jobGroupInfo.getStack()) .withDetail(jobGroupInfo.getDetail()) .buildGroupName(); return String.format("%s-%s", asgWithNoSequence, jobGroupSequence); } @Inject  DefaultAppScaleManager(AppScalePolicyStore appScalePolicyStore, CloudAlarmClient cloudAlarmClient,
                                  AppAutoScalingClient applicationAutoScalingClient,
                                  V3JobOperations v3JobOperations,
                                  Registry registry,
                                  AppScaleManagerConfiguration appScaleManagerConfiguration,
                                  TitusRuntime titusRuntime); private  DefaultAppScaleManager(AppScalePolicyStore appScalePolicyStore, CloudAlarmClient cloudAlarmClient,
                                   AppAutoScalingClient applicationAutoScalingClient,
                                   V3JobOperations v3JobOperations,
                                   Registry registry,
                                   AppScaleManagerConfiguration appScaleManagerConfiguration,
                                   ExecutorService awsInteractionExecutor,
                                   TitusRuntime titusRuntime); @VisibleForTesting  DefaultAppScaleManager(AppScalePolicyStore appScalePolicyStore, CloudAlarmClient cloudAlarmClient,
                                  AppAutoScalingClient applicationAutoScalingClient,
                                  V3JobOperations v3JobOperations,
                                  Registry registry,
                                  AppScaleManagerConfiguration appScaleManagerConfiguration,
                                  Scheduler awsInteractionScheduler,
                                  TitusRuntime titusRuntime); @Activator Completable enterActiveMode(); @PreDestroy void shutdown(); @Override Observable<String> createAutoScalingPolicy(AutoScalingPolicy autoScalingPolicy); @Override Completable updateAutoScalingPolicy(AutoScalingPolicy autoScalingPolicy); @Override Observable<AutoScalingPolicy> getScalingPoliciesForJob(String jobId); @Override Observable<AutoScalingPolicy> getScalingPolicy(String policyRefId); @Override Observable<AutoScalingPolicy> getAllScalingPolicies(); @Override Completable removeAutoScalingPolicy(String policyRefId); }
DefaultAppScaleManager implements AppScaleManager { @VisibleForTesting static String buildAutoScalingGroupV3(JobDescriptor<?> jobDescriptor) { JobGroupInfo jobGroupInfo = jobDescriptor.getJobGroupInfo(); String jobGroupSequence = jobGroupInfo.getSequence() != null ? jobGroupInfo.getSequence() : DEFAULT_JOB_GROUP_SEQ; AutoScalingGroupNameBuilder autoScalingGroupNameBuilder = new AutoScalingGroupNameBuilder(); String asgWithNoSequence = autoScalingGroupNameBuilder .withAppName(jobDescriptor.getApplicationName()) .withStack(jobGroupInfo.getStack()) .withDetail(jobGroupInfo.getDetail()) .buildGroupName(); return String.format("%s-%s", asgWithNoSequence, jobGroupSequence); } @Inject  DefaultAppScaleManager(AppScalePolicyStore appScalePolicyStore, CloudAlarmClient cloudAlarmClient,
                                  AppAutoScalingClient applicationAutoScalingClient,
                                  V3JobOperations v3JobOperations,
                                  Registry registry,
                                  AppScaleManagerConfiguration appScaleManagerConfiguration,
                                  TitusRuntime titusRuntime); private  DefaultAppScaleManager(AppScalePolicyStore appScalePolicyStore, CloudAlarmClient cloudAlarmClient,
                                   AppAutoScalingClient applicationAutoScalingClient,
                                   V3JobOperations v3JobOperations,
                                   Registry registry,
                                   AppScaleManagerConfiguration appScaleManagerConfiguration,
                                   ExecutorService awsInteractionExecutor,
                                   TitusRuntime titusRuntime); @VisibleForTesting  DefaultAppScaleManager(AppScalePolicyStore appScalePolicyStore, CloudAlarmClient cloudAlarmClient,
                                  AppAutoScalingClient applicationAutoScalingClient,
                                  V3JobOperations v3JobOperations,
                                  Registry registry,
                                  AppScaleManagerConfiguration appScaleManagerConfiguration,
                                  Scheduler awsInteractionScheduler,
                                  TitusRuntime titusRuntime); @Activator Completable enterActiveMode(); @PreDestroy void shutdown(); @Override Observable<String> createAutoScalingPolicy(AutoScalingPolicy autoScalingPolicy); @Override Completable updateAutoScalingPolicy(AutoScalingPolicy autoScalingPolicy); @Override Observable<AutoScalingPolicy> getScalingPoliciesForJob(String jobId); @Override Observable<AutoScalingPolicy> getScalingPolicy(String policyRefId); @Override Observable<AutoScalingPolicy> getAllScalingPolicies(); @Override Completable removeAutoScalingPolicy(String policyRefId); static final long INITIAL_RETRY_DELAY_SEC; static final long MAX_RETRY_DELAY_SEC; }