Package io.fabric8.api

Examples of io.fabric8.api.ProfileBuilder


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


    }

    @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 deleteConfigurationFile(String versionId, String profileId, String fileName) {
        Profile profile = profileService.getRequiredProfile(versionId, profileId);
        ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile);
        builder.deleteFileConfiguration(fileName);
        profileService.updateProfile(builder.getProfile());
    }
View Full Code Here

    }

    @Override
    public void setConfigurationFile(String versionId, String profileId, String fileName, String data) {
        Profile profile = profileService.getRequiredProfile(versionId, profileId);
        ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile);
        builder.addFileConfiguration(fileName, Base64.decodeBase64(data));
        profileService.updateProfile(builder.getProfile());
    }
View Full Code Here

    }

    @Override
    public void setProfileBundles(String versionId, String profileId, List<String> bundles) {
        Profile profile = profileService.getRequiredProfile(versionId, profileId);
        ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile);
        builder.setBundles(bundles);
        profileService.updateProfile(builder.getProfile());
    }
View Full Code Here

    }

    @Override
    public void setProfileFeatures(String versionId, String profileId, List<String> features) {
        Profile profile = profileService.getRequiredProfile(versionId, profileId);
        ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile);
        builder.setFeatures(features);
        profileService.updateProfile(builder.getProfile());
    }
View Full Code Here

                        break;
                    }
                }
                if (profile == null) {
                    String versionId = version.getId();
                    ProfileBuilder builder = ProfileBuilder.Factory.create(versionId, profileId);
                    builder.setOverrides(descriptor.getBundles());
                    profile = profileService.createProfile(builder.getProfile());
                    Profile defaultProfile = version.getRequiredProfile("default");
                    List<String> parentIds = defaultProfile.getParentIds();
                    if (!parentIds.contains(profile.getId())) {
                        parentIds.add(profile.getId());
                        builder = ProfileBuilder.Factory.createFrom(defaultProfile);
                        builder.setParents(parentIds);
                        profileService.updateProfile(builder.getProfile());
                    }
                } else {
                    LOGGER.info("The patch {} has already been applied to version {}, ignoring.", descriptor.getId(), version.getId());
                }
            }
View Full Code Here

        Version version = fabricService.getRequiredDefaultVersion();
        Profile hadoop = version.getRequiredProfile("hadoop");
        Map<String, Map<String, String>> configs;

        String versionId = version.getId();
        ProfileBuilder builder = ProfileBuilder.Factory.create(versionId, "hadoop-" + name);
        builder.addParent(hadoop.getId());
        configs = new HashMap<String, Map<String, String>>();
        configs.put("io.fabric8.hadoop", new HashMap<String, String>());
        configs.get("io.fabric8.hadoop").put("fs.default.name", "hdfs://${zk:" + nameNode + "/ip}:9000");
        configs.get("io.fabric8.hadoop").put("dfs.http.address", "hdfs://${zk:" + nameNode + "/ip}:9002");
        Profile cluster = profileService.createProfile(builder.setConfigurations(configs).getProfile());

        builder = ProfileBuilder.Factory.create(versionId, "hadoop-" + name + "-namenode");
        builder.addParent(cluster.getId());
        configs = new HashMap<String, Map<String, String>>();
        configs.put("io.fabric8.hadoop", new HashMap<String, String>());
        configs.get("io.fabric8.hadoop").put("nameNode", "true");
        Profile nameNodeProfile = profileService.createProfile(builder.setConfigurations(configs).getProfile());

        builder = ProfileBuilder.Factory.create(versionId, "hadoop-" + name + "-secondary-namenode");
        builder.addParent(cluster.getId());
        configs = new HashMap<String, Map<String, String>>();
        configs.put("io.fabric8.hadoop", new HashMap<String, String>());
        configs.get("io.fabric8.hadoop").put("secondaryNameNode", "true");
        Profile secondaryNameNodeProfile = profileService.createProfile(builder.setConfigurations(configs).getProfile());

        builder = ProfileBuilder.Factory.create(versionId, "hadoop-" + name + "-datanode");
        builder.addParent(cluster.getId());
        configs = new HashMap<String, Map<String, String>>();
        configs.put("io.fabric8.hadoop", new HashMap<String, String>());
        configs.get("io.fabric8.hadoop").put("dataNode", "true");
        Profile dataNodeProfile = profileService.createProfile(builder.setConfigurations(configs).getProfile());

        builder = ProfileBuilder.Factory.create(versionId, "hadoop-" + name + "-job-tracker");
        builder.addParent(cluster.getId());
        configs = new HashMap<String, Map<String, String>>();
        configs.put("io.fabric8.hadoop", new HashMap<String, String>());
        configs.get("io.fabric8.hadoop").put("jobTracker", "true");
        Profile jobTrackerProfile = profileService.createProfile(builder.setConfigurations(configs).getProfile());

        builder = ProfileBuilder.Factory.create(versionId, "hadoop-" + name + "-task-tracker");
        builder.addParent(cluster.getId());
        configs = new HashMap<String, Map<String, String>>();
        configs.put("io.fabric8.hadoop", new HashMap<String, String>());
        configs.get("io.fabric8.hadoop").put("taskTracker", "true");
        Profile taskTrackerProfile = profileService.createProfile(builder.setConfigurations(configs).getProfile());

        builder = ProfileBuilder.Factory.create(versionId, "insight-hdfs-" + name);
        builder.addParent(version.getRequiredProfile("insight-hdfs").getId());
        configs = new HashMap<String, Map<String, String>>();
        configs.put("io.fabric8.insight.elasticsearch-default", new HashMap<String, String>());
        configs.get("io.fabric8.insight.elasticsearch-default").put("gateway.hdfs.uri", "hdfs://${zk:" + nameNode + "/ip}:9000");
        Profile insightProfile = profileService.createProfile(builder.setConfigurations(configs).getProfile());

        // Name node
        Container nameNodeContainer = findContainer(containers, nameNode);
        if (nameNodeContainer == null && createChildren) {
            nameNodeContainer = createChild(nameNode);
View Full Code Here

    public void testProfileManager() throws Exception {
       
        ProfileManager profileManager = ProfileManagerLocator.getProfileManager();
       
        // fabric:profile-create prfA
        ProfileBuilder pbA10 = ProfileBuilder.Factory.create("1.0", "prfA")
                .addConfiguration("pidA", Collections.singletonMap("keyA", "valA"));
        Profile prfA10 = profileManager.createProfile(pbA10.getProfile());
        Assert.assertEquals("1.0", prfA10.getVersion());
        Assert.assertEquals("prfA", prfA10.getId());
        Assert.assertEquals("valA", prfA10.getConfiguration("pidA").get("keyA"));
       
        // Verify access to original profile
        profileManager.getRequiredVersion("1.0").getRequiredProfile("prfA");
       
        // fabric:version-create --parent 1.0 1.1
        Version v11 = profileManager.createVersionFrom("1.0", "1.1", null);
        Profile prfA11a = v11.getRequiredProfile("prfA");
        Assert.assertEquals("1.1", prfA11a.getVersion());
        Assert.assertEquals("prfA", prfA11a.getId());
        Assert.assertEquals("valA", prfA11a.getConfiguration("pidA").get("keyA"));
       
        // Verify access to original profile
        profileManager.getRequiredVersion("1.0").getRequiredProfile("prfA");
        profileManager.getRequiredVersion("1.1").getRequiredProfile("prfA");
       
        ProfileBuilder pbA11 = ProfileBuilder.Factory.createFrom(prfA11a)
                .addConfiguration("pidA", Collections.singletonMap("keyB", "valB"));
        Profile prfA11b = profileManager.updateProfile(pbA11.getProfile());
        Assert.assertEquals("1.1", prfA11b.getVersion());
        Assert.assertEquals("prfA", prfA11b.getId());
        Assert.assertEquals("valB", prfA11b.getConfiguration("pidA").get("keyB"));
       
        Assert.assertNotEquals(prfA11a, prfA11b);
View Full Code Here

    public void createProfile() {
       
        String versionId = "1.0";
        Assert.assertFalse(profileRegistry.hasProfile(versionId, "prfA"));
       
        ProfileBuilder pbuilder = ProfileBuilder.Factory.create(versionId, "prfA");
        String profileId = profileRegistry.createProfile(pbuilder.getProfile());
       
        // Profile already exists
        try {
            profileRegistry.createProfile(pbuilder.getProfile());
            Assert.fail("IllegalStateException expected");
        } catch (IllegalStateException ex) {
            Assert.assertTrue(ex.getMessage(), ex.getMessage().contains("Profile already exists: prfA"));
        }
       
View Full Code Here

TOP

Related Classes of io.fabric8.api.ProfileBuilder

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.