Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 88433 Details for
Bug 207802
[prov] Add multi-threaded download and mirror selection into p2's artifact retrieval
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch to SimpleArtifactRepository (phase 1)
patch-threadeddownload-phase1.txt (text/plain), 9.62 KB, created by
Timothy Webb
on 2008-01-31 13:01:21 EST
(
hide
)
Description:
Patch to SimpleArtifactRepository (phase 1)
Filename:
MIME Type:
Creator:
Timothy Webb
Created:
2008-01-31 13:01:21 EST
Size:
9.62 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.p2.artifact.repository >Index: src/org/eclipse/equinox/internal/p2/artifact/repository/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/equinox-incubator/provisioning/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/messages.properties,v >retrieving revision 1.7 >diff -u -r1.7 messages.properties >--- src/org/eclipse/equinox/internal/p2/artifact/repository/messages.properties 25 Jan 2008 17:03:55 -0000 1.7 >+++ src/org/eclipse/equinox/internal/p2/artifact/repository/messages.properties 31 Jan 2008 17:54:07 -0000 >@@ -26,4 +26,6 @@ > repoMan_internalError=Internal error. > repoMan_notExists=No repository found at {0}. > repoMan_unknownType=Unknown repository type at {0}. >+ >+download_thread_interrupted=Download thread {0} was interrupted, incomplete artifact retrieval. > >\ No newline at end of file >Index: src/org/eclipse/equinox/internal/p2/artifact/repository/Messages.java >=================================================================== >RCS file: /cvsroot/eclipse/equinox-incubator/provisioning/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Messages.java,v >retrieving revision 1.6 >diff -u -r1.6 Messages.java >--- src/org/eclipse/equinox/internal/p2/artifact/repository/Messages.java 25 Jan 2008 17:03:55 -0000 1.6 >+++ src/org/eclipse/equinox/internal/p2/artifact/repository/Messages.java 31 Jan 2008 17:54:07 -0000 >@@ -42,4 +42,6 @@ > public static String io_incompatibleVersion; > public static String mirroring; > >+ public static String download_thread_interrupted; >+ > } >\ No newline at end of file >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/equinox-incubator/provisioning/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF,v >retrieving revision 1.11 >diff -u -r1.11 MANIFEST.MF >--- META-INF/MANIFEST.MF 11 Dec 2007 08:31:09 -0000 1.11 >+++ META-INF/MANIFEST.MF 31 Jan 2008 17:54:07 -0000 >@@ -12,6 +12,7 @@ > org.eclipse.equinox.p2.artifact.repository.processing, > org.eclipse.equinox.spi.p2.artifact.repository > Import-Package: javax.xml.parsers, >+ org.eclipse.core.runtime.jobs, > org.eclipse.core.runtime.preferences;resolution:=optional, > org.eclipse.equinox.app;version="1.0.0", > org.eclipse.equinox.internal.p2.core.helpers, >Index: src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java >=================================================================== >RCS file: /cvsroot/eclipse/equinox-incubator/provisioning/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java,v >retrieving revision 1.29 >diff -u -r1.29 SimpleArtifactRepository.java >--- src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java 25 Jan 2008 15:53:11 -0000 1.29 >+++ src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java 31 Jan 2008 17:54:07 -0000 >@@ -24,6 +24,7 @@ > import org.eclipse.equinox.p2.core.ProvisionException; > import org.eclipse.equinox.p2.metadata.IArtifactKey; > import org.eclipse.equinox.spi.p2.artifact.repository.AbstractArtifactRepository; >+import org.eclipse.osgi.util.NLS; > > public class SimpleArtifactRepository extends AbstractArtifactRepository implements IArtifactRepository, IFileArtifactRepository { > >@@ -379,7 +380,7 @@ > return super.getAdapter(adapter); > } > >- private IStatus getArtifact(ArtifactRequest request, IProgressMonitor monitor) { >+ IStatus getArtifact(ArtifactRequest request, IProgressMonitor monitor) { > request.setSourceRepository(this); > request.perform(monitor); > return request.getResult(); >@@ -429,20 +430,52 @@ > } > > public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor) { >- SubMonitor subMonitor = SubMonitor.convert(monitor, requests.length); >- try { >- MultiStatus overallStatus = new MultiStatus(Activator.ID, IStatus.OK, null, null); >- for (int i = 0; i < requests.length; i++) { >- if (monitor.isCanceled()) >- return Status.CANCEL_STATUS; >- IStatus result = getArtifact((ArtifactRequest) requests[i], subMonitor.newChild(1)); >- if (!result.isOK()) >- overallStatus.add(result); >+ final MultiStatus overallStatus = new MultiStatus(Activator.ID, IStatus.OK, null, null); >+ LinkedList requestsPending = new LinkedList(Arrays.asList(requests)); >+ >+ // TODO : Determine number of threads to use from a property >+ int numberOfJobs = Math.min(requests.length, 4); // magic number >+ if (numberOfJobs <= 1) { >+ SubMonitor subMonitor = SubMonitor.convert(monitor, requests.length); >+ try { >+ for (int i = 0; i < requests.length; i++) { >+ if (monitor.isCanceled()) >+ return Status.CANCEL_STATUS; >+ IStatus result = getArtifact((ArtifactRequest) requests[i], subMonitor.newChild(1)); >+ if (!result.isOK()) >+ overallStatus.add(result); >+ } >+ } finally { >+ subMonitor.done(); >+ } >+ } else { >+ // initialize the various jobs needed to process the get artifact requests >+ monitor.beginTask("Download " + requests.length + " artifacts", requests.length); >+ try { >+ SimpleArtifactRepositoryDownloadJob jobs[] = new SimpleArtifactRepositoryDownloadJob[numberOfJobs]; >+ for (int i = 0; i < numberOfJobs; i++) { >+ jobs[i] = new SimpleArtifactRepositoryDownloadJob("downloadjob-" + i); >+ jobs[i].initialize(this, requestsPending, monitor, overallStatus); >+ } >+ // schedule the various jobs >+ for (int i = 0; i < numberOfJobs; i++) { >+ jobs[i].schedule(); >+ } >+ // wait for all the jobs to complete >+ for (int i = 0; i < numberOfJobs; i++) { >+ try { >+ jobs[i].join(); >+ } catch (InterruptedException e) { >+ synchronized (overallStatus) { >+ overallStatus.add(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.download_thread_interrupted, jobs[i].getName()))); >+ } >+ } >+ } >+ } finally { >+ monitor.done(); > } >- return (monitor.isCanceled() ? Status.CANCEL_STATUS : overallStatus); >- } finally { >- subMonitor.done(); > } >+ return (monitor.isCanceled() ? Status.CANCEL_STATUS : overallStatus); > } > > public synchronized IArtifactDescriptor getCompleteArtifactDescriptor(IArtifactKey key) { >Index: src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepositoryDownloadJob.java >=================================================================== >RCS file: src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepositoryDownloadJob.java >diff -N src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepositoryDownloadJob.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepositoryDownloadJob.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,70 @@ >+/******************************************************************************* >+ * Copyright (c) 2007, 2008 Genuitec, LLC and others. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Genuitec, LLC - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.equinox.internal.p2.artifact.repository.simple; >+ >+import java.util.LinkedList; >+import org.eclipse.core.runtime.*; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.equinox.internal.p2.artifact.repository.ArtifactRequest; >+import org.eclipse.equinox.p2.artifact.repository.IArtifactRequest; >+ >+public class SimpleArtifactRepositoryDownloadJob extends Job { >+ >+ private LinkedList requestsPending; >+ private SimpleArtifactRepository repository; >+ private IProgressMonitor masterMonitor; >+ private MultiStatus overallStatus; >+ >+ SimpleArtifactRepositoryDownloadJob(String name) { >+ super(name); >+ setSystem(true); >+ } >+ >+ void initialize(SimpleArtifactRepository repository, LinkedList requestsPending, IProgressMonitor masterMonitor, MultiStatus overallStatus) { >+ this.repository = repository; >+ this.requestsPending = requestsPending; >+ this.masterMonitor = masterMonitor; >+ this.overallStatus = overallStatus; >+ } >+ >+ protected IStatus run(IProgressMonitor jobMonitor) { >+ jobMonitor.beginTask("Downloading artifacts", 1); >+ boolean workRemaining = false; >+ do { >+ // get the request we are going to process >+ IArtifactRequest request; >+ synchronized (requestsPending) { >+ if (requestsPending.isEmpty()) >+ break; >+ request = (IArtifactRequest) requestsPending.removeFirst(); >+ } >+ if (masterMonitor.isCanceled()) >+ return Status.CANCEL_STATUS; >+ >+ // prepare a progress monitor that reports to both the master monitor and for the job >+ IProgressMonitor monitor = new NullProgressMonitor(); >+ // progress monitor updating from getArtifact() doesn't seem to be working >+ masterMonitor.subTask("Downloading " + request.getArtifactKey().getId() + "."); >+ >+ // process the actual request >+ IStatus status = repository.getArtifact((ArtifactRequest) request, monitor); >+ if (!status.isOK()) { >+ synchronized (overallStatus) { >+ overallStatus.add(status); >+ } >+ } >+ >+ // update progress >+ masterMonitor.worked(1); >+ } while (true); >+ >+ jobMonitor.done(); >+ return Status.OK_STATUS; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 207802
:
81472
|
83572
|
88433
|
88919