Package io.fabric8.api

Examples of io.fabric8.api.Version


    @Override
    protected Object doExecute() throws Exception {
        FabricValidations.validateContainerNames(containerIds);

        // check and validate version
        Version version = profileService.getRequiredVersion(this.version);

        if (containerIds == null || containerIds.isEmpty()) {
            if (all) {
                containerIds = new ArrayList<String>();
                for (Container container : fabricService.getContainers()) {
                    containerIds.add(container.getId());
                }
            } else {
                containerIds = Arrays.asList(fabricService.getCurrentContainer().getId());
            }
        } else {
            if (all) {
                throw new IllegalArgumentException("Can not use --all with a list of containers simultaneously");
            }
        }

        List<Container> toRollback = new ArrayList<Container>();
        List<Container> same = new ArrayList<Container>();
        for (String containerName : containerIds) {
            Container container = FabricCommand.getContainer(fabricService, containerName);

            // check first that all can rollback
            int num = ContainerUpgradeSupport.canRollback(version, container);
            if (num < 0) {
                throw new IllegalArgumentException("Container " + container.getId() + " has already lower version " + container.getVersion().getId()
                        + " than the requested version " + version.getId() + " to rollback.");
            } else if (num == 0) {
                // same version
                same.add(container);
            } else {
                // needs rollback
                toRollback.add(container);
            }
        }

        // report same version
        for (Container container : same) {
            System.out.println("Container " + container.getId() + " is already version " + version.getId());
        }

        // report and do rollbacks
        for (Container container : toRollback) {
            Version oldVersion = container.getVersion();
            // rollback version first
            container.setVersion(version);
            log.info("Rolled back container {} from {} to {}", new Object[]{container.getId(), oldVersion.getId(), version.getId()});
            System.out.println("Rolled back container " + container.getId() + " from version " + oldVersion.getId() + " to " + version.getId());
        }

    if (all) {
      fabricService.setDefaultVersionId(version.getId());
      System.out.println("Changed default version to " + version.getId());
View Full Code Here



    @Override
    public String profileWebAppURL(String webAppId, String profileId, String versionId) {
        if (versionId == null || versionId.length() == 0) {
            Version version = getDefaultVersion();
            if (version != null) {
                versionId = version.getId();
            }
        }
        List<Container> containers = Containers.containersForProfile(getContainers(), profileId, versionId);
        for (Container container : containers) {
            String url = containerWebAppURL(webAppId, container.getId());
View Full Code Here

        String zooKeeperUrl = null;
        //We are looking directly for at the zookeeper for the url, since container might not even be mananaged.
        //Also this is required for the integration with the IDE.
        try {
            if (curator.get().getZookeeperClient().isConnected()) {
                Version defaultVersion = getDefaultVersion();
                if (defaultVersion != null) {
                    Profile profile = defaultVersion.getRequiredProfile("default");
                    if (profile != null) {
                        Map<String, String> zookeeperConfig = profile.getConfiguration(Constants.ZOOKEEPER_CLIENT_PID);
                        if (zookeeperConfig != null) {
                            zooKeeperUrl = getSubstitutedData(curator.get(), zookeeperConfig.get(name));
                        }
View Full Code Here

     * Validates that the requirements are valid; to ensure the profiles exist etc
     */
    public static void validateRequirements(FabricService fabricService, FabricRequirements requirements) {
        ProfileService profileService = fabricService.adapt(ProfileService.class);
        String versionId = requirements.getVersion();
        Version version;
        if (!Strings.isNullOrEmpty(versionId)) {
            version = profileService.getRequiredVersion(versionId);
        } else {
            version = fabricService.getDefaultVersion();
        }
        Set<String> profileIds = new HashSet<String>(Profiles.profileIds(version.getProfiles()));
        List<ProfileRequirements> profileRequirements = requirements.getProfileRequirements();
        for (ProfileRequirements profileRequirement : profileRequirements) {
            validateProfileRequirements(fabricService, requirements, profileRequirement, profileIds);
        }
    }
View Full Code Here

    }

    @Override
    public void setConfigurationValue(String versionId, String profileId, String pid, String key, String value) {
        assertValid();
        Version version = profileService.get().getRequiredVersion(versionId);
        Profile profile = version.getRequiredProfile(profileId);
       
        Map<String, byte[]> configs = profile.getFileConfigurations();
        byte[] bytes = configs.get(pid);
        Properties properties;
        if (bytes != null) {
View Full Code Here

            writeLock.unlock();
        }
    }

    private Profile getProfileFromCache(String versionId, String profileId) {
        Version version = getVersionFromCache(versionId, profileId);
        return version != null ? version.getProfile(profileId) : null;
    }
View Full Code Here

    }

    @Override
    public Version getRequiredVersion(final String versionId) {
        IllegalStateAssertion.assertNotNull(versionId, "versionId");
        Version version = getVersionFromCache(versionId, null);
        IllegalStateAssertion.assertNotNull(version, "Version does not exist: " + versionId);
        return version;
    }
View Full Code Here

            assertValid();
            GitOperation<String> gitop = new GitOperation<String>() {
                public String call(Git git, GitContext context) throws Exception {
                    String versionId = profile.getVersion();
                    String profileId = profile.getId();
                    Version version = getRequiredVersion(versionId);
                    IllegalStateAssertion.assertFalse(version.hasProfile(profileId), "Profile already exists: " + profileId);
                    checkoutRequiredProfileBranch(git, context, versionId, profileId);
                    return createOrUpdateProfile(context, null, profile, new HashSet<String>());
                }
            };
            return executeInternal(context, null, gitop);
View Full Code Here

    @Override
    public List<String> getProfiles(final String versionId) {
        IllegalStateAssertion.assertNotNull(versionId, "versionId");
        assertValid();
        Version version = getVersionFromCache(versionId, null);
        List<String> profiles = version != null ? version.getProfileIds() : Collections.<String>emptyList();
        return Collections.unmodifiableList(profiles);
    }
View Full Code Here

        return fabricService.containerWebAppURL(webAppId, name);
    }

    @Override
    public Map<String, Object> createVersion(String sourceId, String targetId) {
        Version version = profileService.createVersionFrom(sourceId, targetId, null);
        return BeanUtils.convertVersionToMap(fabricService, version, BeanUtils.getFields(Version.class));
    }
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.