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 93848 Details for
Bug 224269
Startup takes 20 times longer with P2 enabled
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
profilesynch.txt (text/plain), 11.27 KB, created by
Simon Kaegi
on 2008-03-27 15:20:05 EDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Simon Kaegi
Created:
2008-03-27 15:20:05 EDT
Size:
11.27 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.p2.metadata.repository >Index: src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java,v >retrieving revision 1.24 >diff -u -r1.24 LocalMetadataRepository.java >--- src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java 6 Mar 2008 21:44:03 -0000 1.24 >+++ src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java 27 Mar 2008 19:00:03 -0000 >@@ -20,6 +20,7 @@ > import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; > import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; > import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; >+import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository; > import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; > import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; > import org.eclipse.equinox.internal.provisional.p2.query.Collector; >@@ -76,6 +77,8 @@ > } > > public void addInstallableUnits(IInstallableUnit[] installableUnits) { >+ if (installableUnits == null || installableUnits.length == 0) >+ return; > units.addAll(Arrays.asList(installableUnits)); > save(); > } >@@ -110,12 +113,15 @@ > } > > public boolean removeInstallableUnits(Query query, IProgressMonitor monitor) { >- int sizeBefore = units.size(); >+ boolean changed = false; > for (Iterator it = units.iterator(); it.hasNext();) >- if (query.isMatch(it.next())) >+ if (query.isMatch(it.next())) { > it.remove(); >- save(); >- return units.size() != sizeBefore; >+ changed = true; >+ } >+ if (changed) >+ save(); >+ return changed; > } > > public void revertToBackup(LocalMetadataRepository backup) { >@@ -159,6 +165,7 @@ > jOutput.putNextEntry(jarEntry); > output = jOutput; > } >+ super.setProperty(IRepository.PROP_TIMESTAMP, Long.toString(System.currentTimeMillis())); > new MetadataRepositoryIO().write(this, output); > } catch (IOException e) { > LogHelper.log(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_WRITE, "Error saving metadata repository: " + location, e)); //$NON-NLS-1$ >#P org.eclipse.equinox.p2.reconciler.dropins >Index: src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java,v >retrieving revision 1.8 >diff -u -r1.8 ProfileSynchronizer.java >--- src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java 26 Mar 2008 23:52:34 -0000 1.8 >+++ src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java 27 Mar 2008 19:00:03 -0000 >@@ -9,7 +9,7 @@ > ******************************************************************************/ > package org.eclipse.equinox.internal.p2.reconciler.dropins; > >-import java.io.IOException; >+import java.io.*; > import java.net.MalformedURLException; > import java.net.URL; > import java.util.*; >@@ -20,6 +20,7 @@ > import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository; > import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IFileArtifactRepository; > import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; >+import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository; > import org.eclipse.equinox.internal.provisional.p2.director.*; > import org.eclipse.equinox.internal.provisional.p2.engine.*; > import org.eclipse.equinox.internal.provisional.p2.metadata.*; >@@ -33,6 +34,10 @@ > * Synchronizes a profile with a set of repositories. > */ > public class ProfileSynchronizer { >+ private static final String TIMESTAMPS_FILE_PREFIX = "timestamps"; //$NON-NLS-1$ >+ private static final String PROFILE_TIMESTAMP = "PROFILE"; //$NON-NLS-1$ >+ private static final String NO_TIMESTAMP = "-1"; //$NON-NLS-1$ >+ > private static final String SUPER_IU = "org.eclipse.equinox.p2.dropins"; //$NON-NLS-1$ > > public class ListCollector extends Collector { >@@ -46,6 +51,7 @@ > final IProfile profile; > > final Map repositoryMap; >+ private Properties timestamps; > > /* > * Constructor for the class. >@@ -63,6 +69,9 @@ > * Synchronize the profile with the list of metadata repositories. > */ > public IStatus synchronize(IProgressMonitor monitor) { >+ readTimestamps(); >+ if (isUpToDate()) >+ return Status.OK_STATUS; > > IStatus status = synchronizeCacheExtensions(); > if (!status.isOK()) >@@ -70,6 +79,7 @@ > > ProvisioningContext context = getContext(); > ProfileChangeRequest request = createProfileChangeRequest(context); >+ > if (request == null) > return Status.OK_STATUS; > >@@ -77,22 +87,112 @@ > try { > //create the provisioning plan > ProvisioningPlan plan = createProvisioningPlan(request, context, sub.newChild(50)); >+ > status = plan.getStatus(); > if (status.getSeverity() == IStatus.ERROR || plan.getOperands().length == 0) > return status; > > //invoke the engine to perform installs/uninstalls > IStatus engineResult = executePlan(plan, context, sub.newChild(50)); >+ > if (!engineResult.isOK()) > return engineResult; >+ writeTimestamps(); > > applyConfiguration(); >+ > return status; > } finally { > sub.done(); > } > } > >+ private void writeTimestamps() { >+ timestamps.clear(); >+ timestamps.put(PROFILE_TIMESTAMP, Long.toString(profile.getTimestamp())); >+ for (Iterator it = repositoryMap.entrySet().iterator(); it.hasNext();) { >+ Entry entry = (Entry) it.next(); >+ IMetadataRepository repository = (IMetadataRepository) entry.getValue(); >+ Map props = repository.getProperties(); >+ String timestamp = null; >+ if (props != null) >+ timestamp = (String) props.get(IRepository.PROP_TIMESTAMP); >+ >+ if (timestamp == null) >+ timestamp = NO_TIMESTAMP; >+ >+ timestamps.put(entry.getKey(), timestamp); >+ } >+ >+ try { >+ File file = Activator.getContext().getDataFile(TIMESTAMPS_FILE_PREFIX + profile.getProfileId().hashCode()); >+ OutputStream os = new BufferedOutputStream(new FileOutputStream(file)); >+ try { >+ timestamps.save(os, "Timestamps for " + profile.getProfileId()); //$NON-NLS-1$ >+ } finally { >+ if (os != null) >+ os.close(); >+ } >+ } catch (FileNotFoundException e) { >+ //Ignore >+ } catch (IOException e) { >+ //Ignore >+ } >+ } >+ >+ private boolean isUpToDate() { >+ String lastKnownProfileTimeStamp = (String) timestamps.remove(PROFILE_TIMESTAMP); >+ if (lastKnownProfileTimeStamp == null) >+ return false; >+ if (!lastKnownProfileTimeStamp.equals(Long.toString(profile.getTimestamp()))) >+ return false; >+ >+ //When we get here the timestamps map only contains information related to repos >+ for (Iterator it = repositoryMap.entrySet().iterator(); it.hasNext();) { >+ Entry entry = (Entry) it.next(); >+ IMetadataRepository repository = (IMetadataRepository) entry.getValue(); >+ >+ Map props = repository.getProperties(); >+ String currentTimestamp = null; >+ if (props != null) >+ currentTimestamp = (String) props.get(IRepository.PROP_TIMESTAMP); >+ >+ if (currentTimestamp == null) >+ currentTimestamp = NO_TIMESTAMP; >+ >+ String lastKnownTimestamp = (String) timestamps.remove(entry.getKey()); >+ //A repo has been added >+ if (lastKnownTimestamp == null) >+ return false; >+ if (!lastKnownTimestamp.equals(currentTimestamp)) { >+ return false; >+ } >+ } >+ //A repo has been removed >+ if (timestamps.size() != 0) >+ return false; >+ >+ return true; >+ } >+ >+ private void readTimestamps() { >+ File file = Activator.getContext().getDataFile(TIMESTAMPS_FILE_PREFIX + profile.getProfileId().hashCode()); >+ timestamps = new Properties(); >+ try { >+ InputStream is = new BufferedInputStream(new FileInputStream(file)); >+ try { >+ timestamps.load(is); >+ } finally { >+ if (is != null) >+ is.close(); >+ } >+ } catch (FileNotFoundException e) { >+ //Ignore >+ } catch (IOException e) { >+ //Ignore >+ } >+ } >+ > private ProvisioningContext getContext() { > ArrayList repoURLs = new ArrayList(); > for (Iterator iterator = repositoryMap.keySet().iterator(); iterator.hasNext();) { >#P org.eclipse.equinox.p2.core >Index: src/org/eclipse/equinox/internal/provisional/p2/core/repository/IRepository.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/provisional/p2/core/repository/IRepository.java,v >retrieving revision 1.4 >diff -u -r1.4 IRepository.java >--- src/org/eclipse/equinox/internal/provisional/p2/core/repository/IRepository.java 7 Mar 2008 22:07:37 -0000 1.4 >+++ src/org/eclipse/equinox/internal/provisional/p2/core/repository/IRepository.java 27 Mar 2008 19:00:04 -0000 >@@ -53,6 +53,11 @@ > public static final String PROP_MIRRORS_URL = "p2.mirrorsURL"; //$NON-NLS-1$ > > /** >+ * The key for a string property containing the time when the repository was last modified. >+ */ >+ public static final String PROP_TIMESTAMP = "p2.timestamp"; //$NON-NLS-1$ >+ >+ /** > * A repository type constant (value 0) representing a metadata repository. > */ > public static final int TYPE_METADATA = 0; >#P org.eclipse.equinox.p2.artifact.repository >Index: src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java,v >retrieving revision 1.51 >diff -u -r1.51 SimpleArtifactRepository.java >--- src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java 16 Mar 2008 21:20:25 -0000 1.51 >+++ src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java 27 Mar 2008 19:00:04 -0000 >@@ -24,6 +24,7 @@ > import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStep; > import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepHandler; > import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; >+import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository; > import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; > import org.eclipse.equinox.internal.provisional.spi.p2.artifact.repository.AbstractArtifactRepository; > import org.eclipse.osgi.util.NLS; >@@ -790,6 +791,7 @@ > jOs.putNextEntry(new JarEntry(new Path(actualLocation.getFile()).lastSegment())); > os = jOs; > } >+ super.setProperty(IRepository.PROP_TIMESTAMP, Long.toString(System.currentTimeMillis())); > new SimpleArtifactRepositoryIO().write(this, os); > } catch (IOException e) { > // TODO proper exception handling
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 224269
: 93848 |
93849