Search in sources :

Example 81 with Profile

use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.

the class DownloadManagers method createDownloadManager.

/**
 * Creates a download manager using the current container's maven configuration
 */
public static DownloadManager createDownloadManager(FabricService fabricService, ScheduledExecutorService executorService) {
    Profile overlayProfile = fabricService.getCurrentContainer().getOverlayProfile();
    Profile effectiveProfile = Profiles.getEffectiveProfile(fabricService, overlayProfile);
    return createDownloadManager(fabricService, effectiveProfile, executorService);
}
Also used : Profile(io.fabric8.api.Profile)

Example 82 with Profile

use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.

the class ProfileDownloader method downloadVersion.

/**
 * Downloads the bundles, features and FABs for all the profiles in this version
 */
public void downloadVersion(Version version) throws Exception {
    List<Profile> profiles = version.getProfiles();
    Profile[] prfarray = profiles.toArray(new Profile[profiles.size()]);
    if (listener != null) {
        listener.beforeDownloadProfiles(prfarray);
    }
    for (Profile profile : profiles) {
        try {
            downloadProfile(profile);
        } catch (Exception e) {
            if (listener != null) {
                listener.onError(profile, e);
            }
            if (!stopOnFailure) {
                String id = profile.getId();
                errors.put(id, e);
                LOG.error("Failed to download profile " + id + " due " + e.getMessage(), e);
            } else {
                throw e;
            }
        }
    }
    if (listener != null) {
        listener.afterDownloadProfiles(prfarray);
    }
}
Also used : Profile(io.fabric8.api.Profile)

Example 83 with Profile

use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.

the class WatchAction method doExecute.

@Override
protected Object doExecute() throws Exception {
    if (start && stop) {
        System.err.println("Please use only one of --start and --stop options!");
        return null;
    }
    if (interval > 0) {
        System.out.println("Setting watch interval to " + interval + " ms");
        watcher.setInterval(interval);
    }
    if (stop) {
        System.out.println("Stopping watch");
        watcher.stop();
    }
    watcher.setUpload(upload);
    if (urls != null) {
        if (remove) {
            for (String url : urls) {
                watcher.remove(url);
            }
        } else {
            for (String url : urls) {
                watcher.add(url);
            }
        }
    }
    if (start) {
        System.out.println("Starting watch");
        watcher.start();
    }
    if (list) {
        // list the watched bundles.
        TablePrinter printer = new TablePrinter();
        printer.columns("url", "profile", "version", "bundle");
        for (String url : watcher.getWatchURLs()) {
            Map<ProfileVersionKey, Map<String, Parser>> profileArtifacts = watcher.getProfileArtifacts();
            if (profileArtifacts.size() > 0) {
                Set<Map.Entry<ProfileVersionKey, Map<String, Parser>>> entries = profileArtifacts.entrySet();
                for (Map.Entry<ProfileVersionKey, Map<String, Parser>> entry : entries) {
                    ProfileVersionKey key = entry.getKey();
                    Map<String, Parser> artifactMap = entry.getValue();
                    Set<Map.Entry<String, Parser>> artifactMapEntries = artifactMap.entrySet();
                    for (Map.Entry<String, Parser> artifactMapEntry : artifactMapEntries) {
                        String location = artifactMapEntry.getKey();
                        Parser parser = artifactMapEntry.getValue();
                        if (isSnapshot(parser) || watcher.wildCardMatch(location, url)) {
                            printer.row(url, key.getProfileId(), key.getVersion(), location);
                        }
                    }
                }
            } else {
                printer.row(url, "", "", "");
            }
        }
        printer.print();
    } else {
        List<String> urls = watcher.getWatchURLs();
        if (urls != null && urls.size() > 0) {
            System.out.println("Watched URLs: ");
            for (String url : watcher.getWatchURLs()) {
                System.out.println(url);
            }
        } else {
            System.out.println("No watched URLs");
        }
    }
    return null;
}
Also used : ProfileVersionKey(io.fabric8.agent.commands.support.ProfileVersionKey) Parser(io.fabric8.maven.util.Parser) TablePrinter(io.fabric8.utils.TablePrinter) Map(java.util.Map)

Example 84 with Profile

use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.

the class ProfileMetadata method findMetadataForProfile.

protected void findMetadataForProfile(String versionId, String profileId, MetadataHandler handler) throws Exception {
    FabricService service = fabricService.get();
    Objects.notNull(service, "FabricService");
    ProfileService profileService = service.adapt(ProfileService.class);
    Objects.notNull(profileService, "ProfileService");
    DownloadManager downloadManager = DownloadManagers.createDownloadManager(service, executorService);
    Objects.notNull(downloadManager, "DownloadManager");
    Profile immediateProfile = profileService.getProfile(versionId, profileId);
    Objects.notNull(immediateProfile, "Profile for versionId: " + versionId + ", profileId: " + profileId);
    Profile profile = profileService.getOverlayProfile(immediateProfile);
    Set<String> pids = new HashSet<>();
    Map<String, File> fileMap = AgentUtils.downloadProfileArtifacts(service, downloadManager, profile);
    Set<Map.Entry<String, File>> entries = fileMap.entrySet();
    for (Map.Entry<String, File> entry : entries) {
        String uri = entry.getKey();
        File file = entry.getValue();
        if (!file.exists() || !file.isFile()) {
            LOG.warn("File " + file + " is not an existing file for " + uri + ". Ignoring");
            continue;
        }
        addMetaTypeInformation(handler, uri, file);
        pids.add(uri);
    }
    // lets check if the MetaType folder exists
    if (metaTypeFolder != null && metaTypeFolder.exists() && metaTypeFolder.isDirectory()) {
        Set<String> configurationFileNames = profile.getConfigurationFileNames();
        for (String configName : configurationFileNames) {
            if (configName.endsWith(PROPERTIES_SUFFIX) && configName.indexOf('/') < 0) {
                String pid = configName.substring(0, configName.length() - PROPERTIES_SUFFIX.length());
                addMetaTypeInformation(pids, handler, pid);
                String factoryPid = getFactoryPid(pid);
                addMetaTypeInformation(pids, handler, factoryPid);
            }
        }
    }
}
Also used : DownloadManager(io.fabric8.agent.download.DownloadManager) Profile(io.fabric8.api.Profile) JarEntry(java.util.jar.JarEntry) ProfileService(io.fabric8.api.ProfileService) FabricService(io.fabric8.api.FabricService) JarFile(java.util.jar.JarFile) File(java.io.File) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 85 with Profile

use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.

the class FabricDTO method createContainerDTO.

public static ContainerDTO createContainerDTO(Container container, String baseApiLink) {
    ContainerDTO answer = new ContainerDTO();
    String containerId = container.getId();
    answer.setId(containerId);
    answer.setType(container.getType());
    answer.setChildren(Containers.containerIds(container.getChildren()));
    List<String> profileIds = Profiles.profileIds(container.getProfiles());
    String profileLinkPrefix = baseApiLink + "/version/" + Profiles.versionId(container.getVersion()) + "/profile/";
    answer.setProfiles(Links.mapIdsToLinks(profileIds, profileLinkPrefix));
    answer.setVersion(Profiles.versionId(container.getVersion()));
    answer.setParent(Containers.containerId(container.getParent()));
    answer.setIp(container.getIp());
    answer.setLocalIp(container.getLocalIp());
    answer.setManualIp(container.getManualIp());
    answer.setPublicIp(container.getPublicIp());
    answer.setLocalHostName(container.getLocalHostname());
    answer.setPublicHostName(container.getPublicHostname());
    answer.setResolver(container.getResolver());
    answer.setMaximumPort(container.getMaximumPort());
    answer.setMinimumPort(container.getMinimumPort());
    answer.setGeoLocation(container.getGeoLocation());
    answer.setLocation(container.getLocation());
    answer.setProcessId(container.getProcessId());
    answer.setDebugPort(container.getDebugPort());
    answer.setHttpUrl(container.getHttpUrl());
    answer.setJmxUrl(container.getJmxUrl());
    answer.setJolokiaUrl(container.getJolokiaUrl());
    answer.setSshUrl(container.getSshUrl());
    answer.setProvisionException(container.getProvisionException());
    answer.setProvisionResult(container.getProvisionResult());
    answer.setProvisionStatus(container.getProvisionStatus());
    answer.setProvisionList(container.getProvisionList());
    answer.setJmxDomains(container.getJmxDomains());
    answer.setAlive(container.isAlive());
    answer.setAliveAndOK(container.isAliveAndOK());
    answer.setEnsembleServer(container.isEnsembleServer());
    answer.setManaged(container.isManaged());
    answer.setProvisioningComplete(container.isProvisioningComplete());
    answer.setProvisioningPending(container.isProvisioningPending());
    answer.setRoot(container.isRoot());
    answer.setStartLink(baseApiLink + "/container/" + containerId + "/start");
    return answer;
}
Also used : ContainerDTO(io.fabric8.api.jmx.ContainerDTO)

Aggregations

Profile (io.fabric8.api.Profile)125 Version (io.fabric8.api.Version)50 Container (io.fabric8.api.Container)49 ArrayList (java.util.ArrayList)37 ProfileBuilder (io.fabric8.api.ProfileBuilder)34 Test (org.junit.Test)32 FabricService (io.fabric8.api.FabricService)28 HashMap (java.util.HashMap)25 File (java.io.File)24 ProfileService (io.fabric8.api.ProfileService)23 Map (java.util.Map)22 IOException (java.io.IOException)19 ProfileRequirements (io.fabric8.api.ProfileRequirements)13 HashSet (java.util.HashSet)12 GitVersion (io.fabric8.api.commands.GitVersion)11 FabricRequirements (io.fabric8.api.FabricRequirements)10 LinkedList (java.util.LinkedList)9 TreeMap (java.util.TreeMap)9 LockHandle (io.fabric8.api.LockHandle)8 Parser (io.fabric8.maven.util.Parser)8