Examples of ProfileRequirements


Examples of io.fabric8.api.ProfileRequirements

     * This method is public for easier testing
     */
    public static CreateSshContainerOptions.Builder chooseHostContainerOptions(AutoScaleRequest request, HostProfileCounter hostProfileCounter) {
        CreateSshContainerOptions.Builder builder = CreateSshContainerOptions.builder();
        FabricRequirements requirements = request.getFabricRequirements();
        ProfileRequirements profileRequirements = request.getProfileRequirements();
        SshScalingRequirements sshScalingRequirements = profileRequirements.getSshScalingRequirements();
        List<SshHostConfiguration> hosts = requirements.getSshHosts();
        SortedSet<LoadSortedHostConfiguration<SshHostConfiguration>> sortedHostConfigurations = AutoScalers.filterHosts(profileRequirements, sshScalingRequirements, hostProfileCounter, hosts);
        SshHostConfiguration sshHostConfig = null;
        if (!sortedHostConfigurations.isEmpty()) {
            LoadSortedHostConfiguration<SshHostConfiguration> first = sortedHostConfigurations.first();
View Full Code Here

Examples of io.fabric8.api.ProfileRequirements

            System.out.println(e.getMessage());
            return null;
        }

        fabricService.scaleProfile(name, count);
        ProfileRequirements profileRequirements = fabricService.getRequirements().getOrCreateProfileRequirement(name);
        Integer minimumInstances = profileRequirements.getMinimumInstances();
        int size = Containers.containersForProfile(fabricService.getContainers(), name).size();
        PrintStream output = System.out;
        output.println("Profile " + name + " " + (minimumInstances != null
                ? "now requires " + minimumInstances + " container(s)"
                : "does not require any containers") + " currently has " + size + " container(s) running");
View Full Code Here

Examples of io.fabric8.api.ProfileRequirements

            CountingMap counts = entry.getValue();
            Set<String> keys = counts.keySet();
            for (String profileId : keys) {
                int count = counts.count(profileId);
                // lets see if we have a maximum number of profile count
                ProfileRequirements profileRequirement = requirements.getOrCreateProfileRequirement(profileId);
                Integer maximum = profileRequirement.getMaximumInstancesPerHost();
                if (maximum != null) {
                    assertTrue("Host " + hostName + " has " + count + " instances of " + profileId
                                    + " but this is configured to have a maximium of " + maximum + " per host",
                            count <= maximum
                    );
View Full Code Here

Examples of io.fabric8.api.ProfileRequirements

        profile = profileService.updateProfile(builder.getProfile());

        Integer minimumInstances = requirements.getMinimumInstances();
        if (minimumInstances != null) {
            FabricRequirements fabricRequirements = fabricService.get().getRequirements();
            ProfileRequirements profileRequirements = fabricRequirements.getOrCreateProfileRequirement(profile.getId());
            profileRequirements.setMinimumInstances(minimumInstances);
            fabricService.get().setRequirements(fabricRequirements);
        }

        // lets find a hawtio profile and version
        String profileUrl = findHawtioUrl(fabric);
View Full Code Here

Examples of io.fabric8.api.ProfileRequirements

            Thread.sleep(2000);
        } catch (Exception e) {
            // ignore
        }
        FabricRequirements requirements = fabricService.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);
    }
View Full Code Here

Examples of io.fabric8.api.ProfileRequirements

    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;
    }
View Full Code Here

Examples of io.fabric8.api.ProfileRequirements

        super(fabricService);
    }

    @Override
    protected boolean updateRequirements(FabricRequirements requirements) {
        ProfileRequirements requirement = new ProfileRequirements(profile);
        if (minimumInstances != null) {
            requirement.setMinimumInstances(minimumInstances);
        }
        if (maximumInstances != null) {
            requirement.setMaximumInstances(maximumInstances);
        }
        if (dependentProfiles != null) {
            requirement.setDependentProfiles(dependentProfiles);
        }
        requirements.addOrUpdateProfileRequirements(requirement);
        return true;
    }
View Full Code Here

Examples of io.fabric8.api.ProfileRequirements

    public static boolean requirementsSatisfied(FabricService service, FabricRequirements requirements, ProfileRequirements profileRequirement, AutoScaleStatus status) {
        String profile = profileRequirement.getProfile();
        List<String> dependentProfiles = profileRequirement.getDependentProfiles();
        if (dependentProfiles != null) {
            for (String dependentProfile : dependentProfiles) {
                ProfileRequirements dependentProfileRequirements = requirements.getOrCreateProfileRequirement(dependentProfile);
                Integer minimumInstances = dependentProfileRequirements.getMinimumInstances();
                if (minimumInstances != null) {
                    List<Container> containers = Containers.aliveAndSuccessfulContainersForProfile(dependentProfile, service);
                    int dependentSize = containers.size();
                    if (minimumInstances > dependentSize) {
                        status.profileStatus(profile).missingDependency(dependentProfile, dependentSize, minimumInstances);
View Full Code Here

Examples of io.fabric8.api.ProfileRequirements

        Container[] containers = fabricService.getContainers();
        List<Profile> values = getActiveOrRequiredBrokerProfileMap(defaultVersion, requirements);
        for (Profile profile : values) {
            List<MQBrokerConfigDTO> list = createConfigDTOs(mqService, profile);
            for (MQBrokerConfigDTO configDTO : list) {
                ProfileRequirements profileRequirements = requirements.findProfileRequirements(profile.getId());
                int count = 0;
                for (Container container : containers) {
                    if (Containers.containerHasProfile(container, profile)) {
                        MQBrokerStatusDTO status = createStatusDTO(profile, configDTO, profileRequirements, container);
                        count++;
View Full Code Here

Examples of io.fabric8.api.ProfileRequirements

            configuration.put(MINIMUM_INSTANCES, minInstances.toString());
        }

        Profile profile = mqService.createOrUpdateMQProfile(version, profileName, brokerName, configuration, dto.kind().equals(BrokerKind.Replicated));
        String profileId = profile.getId();
        ProfileRequirements profileRequirement = requirements.getOrCreateProfileRequirement(profileId);
        Integer minimumInstances = profileRequirement.getMinimumInstances();

        // lets reload the DTO as we may have inherited some values from the parent profile
        List<MQBrokerConfigDTO> list = createConfigDTOs(mqService, profile);

        // lets assume 2 required instances for master/slave unless folks use
        // N+1 or replicated
        int requiredInstances = 2;
        if (list.size() == 1) {
            MQBrokerConfigDTO loadedDTO = list.get(0);
            requiredInstances = loadedDTO.requiredInstances();
        } else {
            // assume N+1 broker as there's more than one broker in the profile; so lets set the required size to N+1
            requiredInstances = list.size() + 1;
        }
        if (minimumInstances == null || minimumInstances.intValue() < requiredInstances) {
            profileRequirement.setMinimumInstances(requiredInstances);
            fabricService.setRequirements(requirements);
        }

        String clientProfile = dto.clientProfile();
        if (Strings.isNotBlank(clientProfile)) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.