Package io.fabric8.api

Examples of io.fabric8.api.Version


*/
public final class ProfileManagementImpl implements ProfileManagement {

    @Override
    public VersionState createVersion(VersionState versionState) {
        Version version = getProfileManager().createVersion(versionState.toVersion());
        return new VersionState(version);
    }
View Full Code Here


        return new VersionState(version);
    }

    @Override
    public VersionState createVersionFrom(String sourceId, String targetId, Map<String, String> attributes) {
        Version version = getProfileManager().createVersionFrom(sourceId, targetId, attributes);
        return new VersionState(version);
    }
View Full Code Here

    @Override
    protected Object doExecute() throws Exception {
        List<Version> versions;
        ProfileService profileService = fabricService.adapt(ProfileService.class);
        if (versionId != null && !versionId.isEmpty()) {
            Version version = profileService.getRequiredVersion(versionId);
            versions = Collections.singletonList(version);
        } else if (allVersions) {
            versions = new ArrayList<>();
            for (String versionId : profileService.getVersions()) {
                versions.add(profileService.getRequiredVersion(versionId));
View Full Code Here

        return getProfileManager().getVersions();
    }

    @Override
    public VersionState getVersion(String versionId) {
        Version version = getProfileManager().getVersion(versionId);
        return version != null ? new VersionState(version) : null;
    }
View Full Code Here

          throw new IllegalStateException("Profile " + profileId + " already exists. Use --force to recreate the profiles.");
                }
            }
        }

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

        Container container = metadatas[0].getContainer();
        return container;
    }

    private void addProfile(Container container, Profile profile) {
        Version version = profileService.getRequiredVersion(profile.getVersion());
        List<Profile> profiles = new ArrayList<Profile>();
        for (String prfId : container.getProfileIds()) {
            Profile p = version.getRequiredProfile(prfId);
            if (!isAncestor(version, prfId, profile)) {
                profiles.add(p);
            }
        }
        profiles.add(profile);
View Full Code Here

       
        // 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);
        // System.out.println(Profiles.getProfileDifference(prfA11a, prfA11b));
       
        // Verify access to original profile
        profileManager.getRequiredVersion("1.0").getRequiredProfile("prfA");
        profileManager.getRequiredVersion("1.1").getRequiredProfile("prfA");
       
        // Delete the profile/version that were added
        profileManager.deleteProfile(prfA10.getVersion(), prfA10.getId(), true);
        profileManager.deleteVersion(v11.getId());
    }
View Full Code Here

        this.profileService = fabricService.adapt(ProfileService.class);
    }

    @Override
    protected Object doExecute() throws Exception {
        Version ver = version != null ? profileService.getVersion(version) : fabricService.getDefaultVersion();
        if (ver == null) {
            if (version != null) {
                System.out.println("version " + version + " does not exist!");
            } else {
                System.out.println("No default version available!");
            }
            return null;
        }

        if (target == null) {
            String karafBase = System.getProperty("karaf.base", ".");
            target = new File(karafBase + "/system");
        }
        target.mkdirs();
        if (!target.exists()) {
            System.out.println("Could not create the target directory " + target);
            return null;
        }
        if (!target.isDirectory()) {
            System.out.println("Target is not a directory " + target);
            return null;
        }

        if (executorService == null) {
            if (threadPoolSize > 1) {
                executorService = Executors.newFixedThreadPool(threadPoolSize);
            } else {
                executorService = Executors.newSingleThreadExecutor();
            }
        }

        ProfileDownloader downloader = new ProfileDownloader(fabricService, target, force, executorService);
        downloader.setStopOnFailure(stopOnFailure);
        // we do not want to download the files from within the profile itself, only the dependencies
        downloader.setDownloadFilesFromProfile(false);
        if (verbose) {
            downloader.setListener(new ProgressIndicator());
        }
        if (profile != null) {
            Profile profileObject = null;
            if (ver.hasProfile(profile)) {
                profileObject = ver.getRequiredProfile(profile);
            }
            if (profileObject == null) {
                System.out.println("Source profile " + profile + " not found.");
                return null;
            }
View Full Code Here

                if (environment == null) {
                    // lets default to the environment from the current active
                    // set of profiles (e.g. docker or openshift)
                    environment = System.getProperty(SystemProperties.FABRIC_PROFILE_ENVIRONMENT);
                }
                Version version = getRequiredVersion(profile.getVersion());
                ProfileBuilder builder = ProfileBuilder.Factory.create(profile.getVersion(), profileId);
                builder.addOptions(new OverlayOptionsProvider(version, profile, environment));
                overlayProfile = builder.getProfile();

                // Log the overlay profile difference
View Full Code Here

     * @param version   the version to rollback to
     * @param container the container
     * @return <tt>-1</tt> if cannot rollback, <tt>0</tt> if same version, or <tt>1</tt> if can rollback
     */
    public static int canUpgrade(Version version, Container container) {
        Version current = container.getVersion();
        return version.compareTo(current);
    }
View Full Code Here

TOP

Related Classes of io.fabric8.api.Version

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.