protected ChildScalingRequirements getChildScalingRequirements(AutoScaleRequest request) {
   ChildScalingRequirements scalingRequirements = null;
   ProfileRequirements profileRequirements = request.getProfileRequirements();
   if (profileRequirements != null) {
     scalingRequirements = profileRequirements.getChildScalingRequirements();
   }
   return scalingRequirements;
 }
Exemple #2
0
 protected void assertProfileMinimumSize(String profile, Integer expected) throws IOException {
   FabricRequirements requirements = getFabricService().getRequirements();
   ProfileRequirements profileRequirements = requirements.getOrCreateProfileRequirement(profile);
   Assert.assertNotNull(
       "Should have profile requirements for profile " + profile, profileRequirements);
   Assert.assertEquals(
       "profile " + profile + " minimum instances",
       expected,
       profileRequirements.getMinimumInstances());
   System.out.println("Profile " + profile + " now has requirements " + profileRequirements);
 }
Exemple #3
0
 @Override
 protected void printRequirements(PrintStream out, FabricRequirements requirements) {
   out.println(
       String.format(
           "%-40s %-14s %-14s %s", "[profile]", "[# minimum]", "[# maximum]", "[depends on]"));
   List<ProfileRequirements> profileRequirements = requirements.getProfileRequirements();
   for (ProfileRequirements profile : profileRequirements) {
     out.println(
         String.format(
             "%-40s %-14s %-14s %s",
             profile.getProfile(),
             getStringOrBlank(profile.getMinimumInstances()),
             getStringOrBlank(profile.getMaximumInstances()),
             getStringOrBlank(profile.getDependentProfiles())));
   }
 }
Exemple #4
0
 @Override
 public boolean scaleProfile(String profile, int numberOfInstances) throws IOException {
   if (numberOfInstances == 0) {
     throw new IllegalArgumentException("numberOfInstances should be greater or less than zero");
   }
   FabricRequirements requirements = getRequirements();
   ProfileRequirements profileRequirements = requirements.getOrCreateProfileRequirement(profile);
   Integer minimumInstances = profileRequirements.getMinimumInstances();
   List<Container> containers = Containers.containersForProfile(getContainers(), profile);
   int containerCount = containers.size();
   int newCount = containerCount + numberOfInstances;
   if (newCount < 0) {
     newCount = 0;
   }
   boolean update = minimumInstances == null || newCount != minimumInstances;
   if (update) {
     profileRequirements.setMinimumInstances(newCount);
     setRequirements(requirements);
   }
   return update;
 }