CapacityGroupPodResourcePoolResolver implements PodResourcePoolResolver { @Override public List<ResourcePoolAssignment> resolve(Job<?> job) { ApplicationSLA capacityGroup = JobManagerUtil.getCapacityGroupDescriptor(job.getJobDescriptor(), capacityGroupService); if (capacityGroup == null) { return Collections.emptyList(); } List<Pair<String, Pattern>> currentMappers = getCurrentMappers(); for (Pair<String, Pattern> next : currentMappers) { Pattern pattern = next.getRight(); if (pattern.matcher(capacityGroup.getAppName()).matches()) { return Collections.singletonList(ResourcePoolAssignment.newBuilder() .withResourcePoolName(next.getLeft()) .withRule(String.format("Capacity group %s matches %s", capacityGroup.getAppName(), pattern.toString())) .build() ); } } return Collections.emptyList(); } CapacityGroupPodResourcePoolResolver(DirectKubeConfiguration configuration,
                                                Config config,
                                                ApplicationSlaManagementService capacityGroupService,
                                                TitusRuntime titusRuntime); @Override List<ResourcePoolAssignment> resolve(Job<?> job);  }
@Test public void testBasic() { List<ResourcePoolAssignment> result = resolver.resolve(newJob("myFlex")); assertThat(result).hasSize(1); assertThat(result.get(0).getResourcePoolName()).isEqualTo("elastic"); result = resolver.resolve(newJob("myCritical")); assertThat(result).hasSize(1); assertThat(result.get(0).getResourcePoolName()).isEqualTo("reserved"); }
@Test public void testUpdate() { config.setProperty("anElastic", ".*Flex"); clock.advanceTime(1, TimeUnit.HOURS); List<ResourcePoolAssignment> result = resolver.resolve(newJob("myFlex")); assertThat(result).hasSize(1); assertThat(result.get(0).getResourcePoolName()).isEqualTo("anElastic"); }