예제 #1
0
 @Override
 public FabricRequirements getRequirements() {
   assertValid();
   FabricRequirements requirements = getDataStore().getRequirements();
   Version defaultVersion = getDefaultVersion();
   if (defaultVersion != null) {
     requirements.setVersion(defaultVersion.getId());
   }
   return requirements;
 }
예제 #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);
 }
예제 #3
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;
 }
예제 #4
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())));
   }
 }