Package org.rhq.enterprise.server.plugin.pc.content

Examples of org.rhq.enterprise.server.plugin.pc.content.SyncProgressWeight


        return tracker;
    }

    public SyncTracker synchronizePackageBits(SyncTracker tracker, ContentProvider provider)
        throws InterruptedException, SyncException {
        SyncProgressWeight sw = provider.getSyncProgressWeight();

        // Determine if the sync even needs to take place
        if (!(provider instanceof PackageSource)) {
            return tracker;
        }

        if (source.getDownloadMode() == DownloadMode.NEVER) {
            String msg = "Download mode of NEVER for source [" + source.getName() + "], skipping "
                + "package bits sync for repo [" + repo.getName() + "]";
            log.info(msg);
            tracker.getRepoSyncResults().appendResults(msg);
            tracker.setRepoSyncResults(repoManager.mergeRepoSyncResults(tracker.getRepoSyncResults()));
            tracker.getProgressWatcher().finishWork(sw.getPackageBitsWeight() * tracker.getPackageSyncCount());
            return tracker;
        }

        if (source.isLazyLoad()) {
            String msg = "Lazy load enabled for source [" + source.getName() + "], skipping "
                + "package bits sync for repo [" + repo.getName() + "]";
            log.info(msg);
            tracker.getRepoSyncResults().appendResults(msg);
            tracker.setRepoSyncResults(repoManager.mergeRepoSyncResults(tracker.getRepoSyncResults()));
            tracker.getProgressWatcher().finishWork(sw.getPackageBitsWeight() * tracker.getPackageSyncCount());
            return tracker;
        }

        long start;

        // Determine which packages need bit synccing
        /* If there become performance issues here, consider paging. So we have to load them all
           in at once or can we do them in chunks?
         */
        start = System.currentTimeMillis();
        PageControl pc = PageControl.getUnlimitedInstance();
        Subject overlord = subjectManager.getOverlord();

        List<PackageVersionContentSource> packageVersionContentSources = contentSourceManager
            .getUnloadedPackageVersionsFromContentSourceInRepo(overlord, source.getId(), repo.getId(), pc);
        String msg = "Synchronize Package Bits: [" + source.getName() + "], repo [" + repo.getName()
            + "]: loaded package list for sync (" + (System.currentTimeMillis() - start) + ")ms";
        log.info(msg);
        tracker.getRepoSyncResults().appendResults(msg);
        tracker.setRepoSyncResults(repoManager.mergeRepoSyncResults(tracker.getRepoSyncResults()));

        // Download the bits for each unloaded package version. Abort the entire download if we
        // fail getting just one package.

        // Note: This can potentially take a very long time.
        for (PackageVersionContentSource item : packageVersionContentSources) {
            PackageVersionContentSourcePK pk = item.getPackageVersionContentSourcePK();

            try {
                log.info("Downloading package version [" + pk.getPackageVersion() + "] located at ["
                    + item.getLocation() + "]" + "] from [" + pk.getContentSource() + "]...");

                tracker.getRepoSyncResults().appendResults(
                    "Downloading package version [" + pk.getPackageVersion() + "] located at [" + item.getLocation()
                        + "]");
                tracker.setRepoSyncResults(repoManager.mergeRepoSyncResults(tracker.getRepoSyncResults()));

                overlord = subjectManager.getOverlord();
                contentSourceManager.downloadPackageBits(overlord, item);

                // Tick off each package as completed work
                tracker.getProgressWatcher().finishWork(sw.getPackageBitsWeight() * 1);
                tracker.getRepoSyncResults().setPercentComplete(
                    new Long(tracker.getProgressWatcher().getPercentComplete()));
                tracker.setRepoSyncResults(repoManager.mergeRepoSyncResults(tracker.getRepoSyncResults()));
            } catch (Exception e) {
                String errorMsg = "Failed to load package bits for package version [" + pk.getPackageVersion()
View Full Code Here


        public String resourceTypeName;
        public String resourceTypePluginName;
    }

    public SyncProgressWeight getSyncProgressWeight() {
        return new SyncProgressWeight(10, 1, 0, 0, 0);
    }
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.plugin.pc.content.SyncProgressWeight

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.