Package io.fabric8.api

Examples of io.fabric8.api.FabricRequirements


        return fabricService.getRequirements();
    }

    @Override
    public String requirementsAsJson() {
        FabricRequirements dto = requirements();

        try {
            return getObjectMapper()
                    .writerWithDefaultPrettyPrinter()
                    .withType(FabricRequirements.class)
View Full Code Here


            Set<String> previousValidProfileIds = new HashSet<String>();

            @Override
            public Boolean call() throws Exception {
                controller.setRequirements(requirements);
                FabricRequirements actual = controller.getRequirements();
                String actualVersion = actual.getVersion();
                // lets clear the actualVersion as we usually don't set one and it gets defaulted
                actual.setVersion(requirements.getVersion());

                // lets sort them both to ensure ordering
                requirements.sortProfilesRequirements();
                actual.sortProfilesRequirements();

                boolean valid = RequirementsJson.equal(requirements, actual);
                if (!valid) {
                    System.out.println("Expected: " + RequirementsJson.toJSON(requirements));
                    System.out.println("Actual:   " + RequirementsJson.toJSON(actual));
View Full Code Here

    @Override
    protected Object doExecute() throws Exception {
        outputFile.getParentFile().mkdirs();

        FabricRequirements requirements = getFabricService().getRequirements();
        RequirementsJson.writeRequirements(new FileOutputStream(outputFile), requirements);
        System.out.println("Exported the fabric requirements to " + outputFile.getCanonicalPath());
        return null;
    }
View Full Code Here

        return answer;
    }

    @Override
    public List<MQBrokerStatusDTO> loadBrokerStatus() throws Exception {
        FabricRequirements requirements = fabricService.getRequirements();
        List<MQBrokerStatusDTO> answer = new ArrayList<MQBrokerStatusDTO>();
        Version defaultVersion = fabricService.getDefaultVersion();
        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

    /**
     * Creates or updates the broker profile for the given DTO and updates the requirements so that the
     * minimum number of instances of the profile is updated
     */
    public static Profile createOrUpdateProfile(MQBrokerConfigDTO dto, FabricService fabricService, RuntimeProperties runtimeProperties) throws IOException {
        FabricRequirements requirements = fabricService.getRequirements();
        MQService mqService = createMQService(fabricService, runtimeProperties);
        Map<String, String> configuration = new HashMap<String, String>();

        List<String> properties = dto.getProperties();
        String version = dto.version();

        if (properties != null) {
            for (String entry : properties) {
                String[] parts = entry.split("=", 2);
                if (parts.length == 2) {
                    configuration.put(parts[0], parts[1]);
                } else {
                    configuration.put(parts[0], "");
                }
            }
        }

        String data = dto.getData();
        String profileName = dto.profile();
        String brokerName = dto.getBrokerName();
        if (data == null) {
            // lets use a relative path so we work on any karaf container
            data = "${runtime.data}" + brokerName;
        }
        configuration.put(DATA, data);


        for (Map.Entry<String,String> port: dto.getPorts().entrySet()) {
            configuration.put(port.getKey() + "-port", port.getValue());
        }

        BrokerKind kind = dto.kind();
        configuration.put(KIND, kind.toString());

        String config = dto.getConfigUrl();
        if (config != null) {
            configuration.put(CONFIG_URL, mqService.getConfig(version, config));
        }

        String group = dto.getGroup();
        if (group != null) {
            configuration.put(GROUP, group);
        }

        Maps.setStringValues(configuration, NETWORKS, dto.getNetworks());

        String networksUserName = dto.getNetworksUserName();
        if (networksUserName != null) {
            configuration.put(NETWORK_USER_NAME, networksUserName);
        }

        String networksPassword = dto.getNetworksPassword();
        if (networksPassword != null) {
            configuration.put(NETWORK_PASSWORD, networksPassword);
        }

        String parentProfile = dto.getParentProfile();
        if (parentProfile != null) {
            configuration.put(PARENT, parentProfile);
        }

        Boolean ssl = dto.getSsl();
        if (ssl != null) {
            configuration.put(SSL, ssl.toString());
        }

        Integer replicas = dto.getReplicas();
        if (replicas != null) {
            configuration.put(REPLICAS, replicas.toString());
        }
        Integer minInstances = dto.getMinimumInstances();
        if (minInstances != null) {
            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);

View Full Code Here

    }

    @Override
    protected Object doExecute() throws Exception {
        PrintStream out = System.out;
        FabricRequirements requirements = getFabricService().getRequirements();
        printRequirements(out, requirements);
        return null;
    }
View Full Code Here

            sb.append(". Use force option to also remove the profile from the containers.");
            throw new FabricException(sb.toString());
        }

        // lets remove any pending requirements on this profile
        FabricRequirements requirements = fabricService != null ? fabricService.getRequirements() : null;
        if (requirements != null && requirements.removeProfileRequirements(profileId)) {
            try {
                fabricService.setRequirements(requirements);
            } catch (IOException e) {
                throw new FabricException("Failed to update requirements after deleting profile " + profileId + ". " + e, e);
            }
View Full Code Here

        return fabricService;
    }

    @Override
    protected Object doExecute() throws Exception {
        FabricRequirements requirements = getFabricService().getRequirements();
        if (requirements == null) {
            requirements = new FabricRequirements();
        }
        if (updateRequirements(requirements)) {
            getFabricService().setRequirements(requirements);
        }
        return null;
View Full Code Here

        String version = request.getVersion();
        FabricService fabricService = request.getFabricService();
        if (fabricService != null) {

            Container[] containers = fabricService.getContainers();
            FabricRequirements requirements = request.getFabricRequirements();
            List<? extends HostConfiguration> hostConfigurations = requirements.getDockerHosts();
            HostProfileCounter hostProfileCounter = new HostProfileCounter();
            AutoScalers.createHostToProfileScaleMap(hostProfileCounter, hostConfigurations, containers);


            // TODO this is actually generic to all providers! :)
View Full Code Here

    /**
     * This method is public for easier testing
     */
    public static CreateDockerContainerOptions.Builder chooseHostOptions(AutoScaleRequest request, HostProfileCounter hostProfileCounter) {
        CreateDockerContainerOptions.Builder builder = CreateDockerContainerOptions.builder();
        FabricRequirements requirements = request.getFabricRequirements();
        ProfileRequirements profileRequirements = request.getProfileRequirements();
        DockerScalingRequirements scalingRequirements = profileRequirements.getDockerScalingRequirements();
        List<DockerHostConfiguration> hosts = requirements.getDockerHosts();
        if (hosts.isEmpty()) {
            // lets default to use the current docker container provider as there are no others configured
            return builder;
        }
        SortedSet<LoadSortedHostConfiguration<DockerHostConfiguration>> sortedHostConfigurations = filterHosts(profileRequirements, scalingRequirements, hostProfileCounter, hosts);
View Full Code Here

TOP

Related Classes of io.fabric8.api.FabricRequirements

Copyright © 2018 www.massapicom. 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.