Package io.fabric8.api

Examples of io.fabric8.api.Profile


        Container currentContainer = fabricService.get().getCurrentContainer();
        if (currentContainer == null) {
            LOGGER.warn("No current container yet so cannot update!");
            return;
        }
        Profile overlayProfile = currentContainer.getOverlayProfile();
        Profile effectiveProfile = Profiles.getEffectiveProfile(fabricService.get(), overlayProfile);
       
        Map<String, Map<String, String>> configurations = effectiveProfile.getConfigurations();
        List<Configuration> zkConfigs = asList(configAdmin.get().listConfigurations("(" + FABRIC_ZOOKEEPER_PID + "=*)"));
       
        // FABRIC-803: the agent may use the configuration provided by features definition if not managed
        //   by fabric.  However, in order for this to work, we need to make sure managed configurations
        //   are all registered before the agent kicks in.  Hence, the agent configuration is updated
        //   after all other configurations.
       
        // Process all configurations but agent
        for (String pid : configurations.keySet()) {
            if (!pid.equals(Constants.AGENT_PID)) {
                Hashtable<String, Object> c = new Hashtable<String, Object>();
                c.putAll(configurations.get(pid));
                updateConfig(zkConfigs, pid, c);
            }
        }
        // Process agent configuration last
        for (String pid : configurations.keySet()) {
            if (pid.equals(Constants.AGENT_PID)) {
                Hashtable<String, Object> c = new Hashtable<String, Object>();
                c.putAll(configurations.get(pid));
                c.put(Profile.HASH, String.valueOf(effectiveProfile.getProfileHash()));
                updateConfig(zkConfigs, pid, c);
            }
        }
        for (Configuration config : zkConfigs) {
            LOGGER.info("Deleting configuration {}", config.getPid());
View Full Code Here


    }

    @Override
    public Map<String, Object> createProfile(String versionId, String profileId, List<String> parents) {
        ProfileBuilder builder = ProfileBuilder.Factory.create(versionId, profileId).addParents(parents);
        Profile profile = profileService.createProfile(builder.getProfile());
        return getProfile(versionId, profile.getId());
    }
View Full Code Here

        return getProfile(versionId, profile.getId());
    }

    @Override
    public Map<String, Object> changeProfileParents(String versionId, String profileId, List<String> parents) {
        Profile profile = profileService.getRequiredProfile(versionId, profileId);
        ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile).setParents(parents);
        profile = profileService.updateProfile(builder.getProfile());
        return getProfile(versionId, profile.getId());
    }
View Full Code Here

    @Override
    public Map<String, String> getProfileProperties(String versionId, String profileId, String pid) {
        Map<String, String> answer = null;
        Version version = profileService.getVersion(versionId);
        if (version != null) {
            Profile profile = version.getRequiredProfile(profileId);
            if (profile != null) {
                answer = profile.getConfiguration(pid);
            }
        }
        return answer;
    }
View Full Code Here

                    throw new IllegalArgumentException("Invalid location:" + location);
                }
                String profileId = parts[0];
                String versionId = parts[1];
                String resource = parts[2];
                Profile profile = profileRegistry.getRequiredProfile(versionId, profileId);
                String data = new String(profile.getFileConfiguration(resource));
                return data != null ? data : "";
            } catch (Exception e) {
                throw new IOException("Failed to read data from zookeeper.", e);
            }
        }
View Full Code Here

    @Override
    public Map<String, String> getOverlayProfileProperties(String versionId, String profileId, String pid) {
        Map<String, String> answer = null;
        Version version = profileService.getVersion(versionId);
        if (version != null) {
            Profile profile = version.getRequiredProfile(profileId);
            if (profile != null) {
                Profile overlayProfile = profileService.getOverlayProfile(profile);
                answer = overlayProfile.getConfiguration(pid);
            }
        }
        return answer;
    }
View Full Code Here

    @Override
    public boolean setProfileProperties(String versionId, String profileId, String pid, Map<String, String> properties) {
        boolean answer = false;
        Version version = profileService.getVersion(versionId);
        if (version != null) {
            Profile profile = profileService.getRequiredProfile(versionId, profileId);
            ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile);
            builder.addConfiguration(pid, properties);
            profileService.updateProfile(builder.getProfile());
            answer = true;
        }
View Full Code Here

                    throw new IllegalArgumentException("Invalid location:" + location);
                }
                String profileId = parts[0];
                String versionId = parts[1];
                String resource = parts[2];
                Profile profile = profileRegistry.getRequiredProfile(versionId, profileId);
                ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile);
                builder.addFileConfiguration(resource, content.getBytes());
                profileRegistry.updateProfile(builder.getProfile());
            } catch (Exception e) {
                return false;
View Full Code Here

        return answer;
    }

    @Override
    public void setProfileAttribute(String versionId, String profileId, String attributeId, String value) {
        Profile profile = profileService.getRequiredProfile(versionId, profileId);
        ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile);
        builder.addAttribute(attributeId, value);
        profileService.updateProfile(builder.getProfile());
    }
View Full Code Here

    }

    @Override
    public void setProfileSystemProperties(String versionId, String profileId, Map<String, String> systemProperties) {
        Version version = profileService.getVersion(versionId);
        Profile profile = version.getRequiredProfile(profileId);
        Map<String, String> profileProperties = getProfileProperties(versionId, profileId, Constants.AGENT_PID);
        if (profileProperties == null) {
            // is it necessary?
            profileProperties = new HashMap<String, String>();
        }
View Full Code Here

TOP

Related Classes of io.fabric8.api.Profile

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.