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 154591 Details for
Bug 296936
[touchpoint] Performance issues when installing features
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch against 3.6 HEAD
patch.txt (text/plain), 16.99 KB, created by
John Arthorne
on 2009-12-16 15:12:15 EST
(
hide
)
Description:
Patch against 3.6 HEAD
Filename:
MIME Type:
Creator:
John Arthorne
Created:
2009-12-16 15:12:15 EST
Size:
16.99 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.p2.metadata.repository >Index: src/org/eclipse/equinox/internal/p2/metadata/repository/IUMap.java >=================================================================== >RCS file: src/org/eclipse/equinox/internal/p2/metadata/repository/IUMap.java >diff -N src/org/eclipse/equinox/internal/p2/metadata/repository/IUMap.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/internal/p2/metadata/repository/IUMap.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,106 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation 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: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.equinox.internal.p2.metadata.repository; >+ >+import java.util.*; >+import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; >+import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; >+import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; >+ >+/** >+ * A map that stores {@link IInstallableUnit} instances in a way that is efficient to query >+ */ >+public class IUMap { >+ /** >+ * Iterator over all the {@link IInstallableUnit} instances in the map. >+ */ >+ public class MapIterator implements Iterator { >+ //iterator over the keys in UIMap >+ private Iterator unitIterator; >+ //iterator over the Set inside a single value of the IUMap >+ private Iterator currentBucket; >+ >+ MapIterator() { >+ super(); >+ unitIterator = units.keySet().iterator(); >+ } >+ >+ public boolean hasNext() { >+ return unitIterator.hasNext() || (currentBucket != null && currentBucket.hasNext()); >+ } >+ >+ public Object next() { >+ if (currentBucket == null || !currentBucket.hasNext()) >+ currentBucket = ((Set) units.get(unitIterator.next())).iterator(); >+ return currentBucket.next(); >+ } >+ >+ public void remove() { >+ throw new UnsupportedOperationException(); >+ } >+ } >+ >+ /** >+ * Map<String,Set<IInstallableUnit>> mapping IU id to iu's with that id. >+ */ >+ final Map units = new HashMap(); >+ >+ public void add(IInstallableUnit unit) { >+ Set matching = (Set) units.get(unit.getId()); >+ if (matching == null) { >+ matching = new HashSet(2); >+ units.put(unit.getId(), matching); >+ } >+ matching.add(unit); >+ } >+ >+ public void addAll(IInstallableUnit[] toAdd) { >+ for (int i = 0; i < toAdd.length; i++) >+ add(toAdd[i]); >+ } >+ >+ public void clear() { >+ units.clear(); >+ } >+ >+ public Iterator iterator() { >+ return new MapIterator(); >+ } >+ >+ public Collector query(InstallableUnitQuery query, Collector result) { >+ //iterate over the entire map, or just the IU's with the given id >+ Iterator candidates; >+ if (query.getId() == null) >+ candidates = iterator(); >+ else { >+ Collection bucket = ((Collection) units.get(query.getId())); >+ if (bucket == null) >+ return result; >+ candidates = bucket.iterator(); >+ } >+ return query.perform(candidates, result); >+ >+ } >+ >+ public void remove(IInstallableUnit unit) { >+ Set matching = (Set) units.get(unit.getId()); >+ if (matching == null) >+ return; >+ matching.remove(unit); >+ if (matching.isEmpty()) >+ units.remove(unit.getId()); >+ } >+ >+ public void removeAll(Collection toRemove) { >+ for (Iterator it = toRemove.iterator(); it.hasNext();) >+ remove((IInstallableUnit) it.next()); >+ } >+} >Index: src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java >=================================================================== >RCS file: /cvsroot/rt/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.38 >diff -u -r1.38 LocalMetadataRepository.java >--- src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java 6 Oct 2009 21:25:19 -0000 1.38 >+++ src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java 16 Dec 2009 20:14:20 -0000 >@@ -11,13 +11,6 @@ > *******************************************************************************/ > package org.eclipse.equinox.internal.p2.metadata.repository; > >-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; >- >-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Query; >- >-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; >-import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent; >- > import java.io.*; > import java.net.URI; > import java.util.*; >@@ -29,7 +22,10 @@ > import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; > import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus; > import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; >+import org.eclipse.equinox.internal.provisional.p2.metadata.query.*; > import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; >+import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; >+import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent; > import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.AbstractMetadataRepository; > import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.RepositoryReference; > >@@ -46,7 +42,7 @@ > static final private String JAR_EXTENSION = ".jar"; //$NON-NLS-1$ > static final private String XML_EXTENSION = ".xml"; //$NON-NLS-1$ > >- protected HashSet units = new LinkedHashSet(); >+ protected IUMap units = new IUMap(); > protected HashSet repositories = new HashSet(); > > private static File getActualLocation(URI location, String extension) { >@@ -91,7 +87,7 @@ > public synchronized void addInstallableUnits(IInstallableUnit[] installableUnits) { > if (installableUnits == null || installableUnits.length == 0) > return; >- units.addAll(Arrays.asList(installableUnits)); >+ units.addAll(installableUnits); > save(); > } > >@@ -109,7 +105,7 @@ > this.description = state.Description; > this.location = state.Location; > this.properties = state.Properties; >- this.units.addAll(Arrays.asList(state.Units)); >+ this.units.addAll(state.Units); > this.repositories.addAll(Arrays.asList(state.Repositories)); > } > publishRepositoryReferences(); >@@ -147,6 +143,8 @@ > } > > public synchronized Collector query(Query query, Collector collector, IProgressMonitor monitor) { >+ if (query instanceof InstallableUnitQuery) >+ return units.query((InstallableUnitQuery) query, collector); > return query.perform(units.iterator(), collector); > } > >@@ -157,7 +155,7 @@ > > public synchronized boolean removeInstallableUnits(Query query, IProgressMonitor monitor) { > boolean changed = false; >- Collector results = query.perform(units.iterator(), new Collector()); >+ Collector results = query(query, new Collector(), monitor); > if (results.size() > 0) { > changed = true; > units.removeAll(results.toCollection()); >#P org.eclipse.equinox.p2.publisher >Index: src/org/eclipse/equinox/p2/publisher/PublisherResult.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/PublisherResult.java,v >retrieving revision 1.8 >diff -u -r1.8 PublisherResult.java >--- src/org/eclipse/equinox/p2/publisher/PublisherResult.java 14 Oct 2009 21:33:20 -0000 1.8 >+++ src/org/eclipse/equinox/p2/publisher/PublisherResult.java 16 Dec 2009 20:14:20 -0000 >@@ -12,8 +12,7 @@ > > import java.util.*; > import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; >-import org.eclipse.equinox.internal.provisional.p2.metadata.Version; >+import org.eclipse.equinox.internal.provisional.p2.metadata.*; > import org.eclipse.equinox.internal.provisional.p2.metadata.query.*; > > public class PublisherResult implements IPublisherResult { >@@ -104,8 +103,7 @@ > protected List flatten(Collection values) { > ArrayList result = new ArrayList(); > for (Iterator i = values.iterator(); i.hasNext();) >- for (Iterator j = ((HashSet) i.next()).iterator(); j.hasNext();) >- result.add(j.next()); >+ result.addAll((HashSet) i.next()); > return result; > } > >@@ -138,8 +136,23 @@ > * Queries both the root and non root IUs > */ > public Collector query(Query query, Collector collector, IProgressMonitor monitor) { >+ //optimize for installable unit query >+ if (query instanceof InstallableUnitQuery) >+ return queryIU((InstallableUnitQuery) query, collector, monitor); > IQueryable nonRootQueryable = new QueryableMap(nonRootIUs); > IQueryable rootQueryable = new QueryableMap(rootIUs); > return new CompoundQueryable(new IQueryable[] {nonRootQueryable, rootQueryable}).query(query, collector, monitor); > } >+ >+ private Collector queryIU(InstallableUnitQuery query, Collector collector, IProgressMonitor monitor) { >+ Collection matches = getIUs(query.getId(), null); >+ VersionRange queryRange = query.getRange(); >+ for (Iterator it = matches.iterator(); it.hasNext();) { >+ IInstallableUnit match = (IInstallableUnit) it.next(); >+ if (queryRange == null || queryRange.isIncluded(match.getVersion())) >+ if (!collector.accept(match)) >+ break; >+ } >+ return collector; >+ } > } >#P org.eclipse.equinox.p2.reconciler.dropins >Index: src/org/eclipse/equinox/internal/p2/reconciler/dropins/PlatformXmlListener.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/PlatformXmlListener.java,v >retrieving revision 1.31 >diff -u -r1.31 PlatformXmlListener.java >--- src/org/eclipse/equinox/internal/p2/reconciler/dropins/PlatformXmlListener.java 20 May 2009 04:12:11 -0000 1.31 >+++ src/org/eclipse/equinox/internal/p2/reconciler/dropins/PlatformXmlListener.java 16 Dec 2009 20:14:22 -0000 >@@ -127,7 +127,7 @@ > if (changed) { > lastModified = root.lastModified(); > try { >- Configuration configuration = ConfigurationParser.parse(root, Activator.getOSGiInstallArea()); >+ Configuration configuration = Configuration.load(root, Activator.getOSGiInstallArea()); > synchronizeConfiguration(configuration); > } catch (ProvisionException e) { > LogHelper.log(new Status(IStatus.ERROR, Activator.ID, Messages.errorProcessingConfg, e)); >#P org.eclipse.equinox.p2.touchpoint.eclipse >Index: src/org/eclipse/equinox/internal/p2/update/Configuration.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Configuration.java,v >retrieving revision 1.6 >diff -u -r1.6 Configuration.java >--- src/org/eclipse/equinox/internal/p2/update/Configuration.java 15 May 2008 03:27:04 -0000 1.6 >+++ src/org/eclipse/equinox/internal/p2/update/Configuration.java 16 Dec 2009 20:14:26 -0000 >@@ -35,7 +35,7 @@ > String shared_ur; > > public static Configuration load(File location, URL osgiInstallArea) throws ProvisionException { >- return ConfigurationParser.parse(location, osgiInstallArea); >+ return ConfigurationIO.read(location, osgiInstallArea); > } > > public Configuration() { >@@ -43,7 +43,7 @@ > } > > public void save(File location, URL osgiInstallArea) throws ProvisionException { >- ConfigurationWriter.save(this, location, osgiInstallArea); >+ ConfigurationIO.write(location, this, osgiInstallArea); > } > > public String getSharedUR() { >Index: src/org/eclipse/equinox/internal/p2/update/ConfigurationIO.java >=================================================================== >RCS file: src/org/eclipse/equinox/internal/p2/update/ConfigurationIO.java >diff -N src/org/eclipse/equinox/internal/p2/update/ConfigurationIO.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/internal/p2/update/ConfigurationIO.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,74 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation 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: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.equinox.internal.p2.update; >+ >+import java.io.File; >+import java.net.URL; >+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; >+ >+/* >+ * Class which controls the reading and writing of Configuration (platform.xml) objects. >+ * We keep a local cached copy to avoid multiple reads. When we install new features we >+ * seem to only write out the platform.xml in the "commit" phase so we don't need to >+ * batch the writes. >+ */ >+public class ConfigurationIO { >+ private static CacheEntry cache = null; >+ >+ // class used to represent cache values >+ static class CacheEntry { >+ Configuration config; >+ URL osgiInstallArea; >+ File location; >+ long timestamp; >+ } >+ >+ /* >+ * Return the configuration object which is represented by the given file. >+ */ >+ static Configuration read(File file, URL osgiInstallArea) throws ProvisionException { >+ // check the cached copy first >+ if (cache != null && file.lastModified() == cache.timestamp) >+ return cache.config; >+ >+ // cache miss or file is out of date, read from disk >+ Configuration config = ConfigurationParser.parse(file, osgiInstallArea); >+ if (config == null) >+ return null; >+ >+ // successful read, store in the cache before we return >+ cache(file, config, osgiInstallArea); >+ return config; >+ } >+ >+ /* >+ * Store the given configuration file in the local cache. >+ */ >+ private static void cache(File location, Configuration config, URL osgiInstallArea) { >+ CacheEntry entry = new CacheEntry(); >+ entry.config = config; >+ entry.osgiInstallArea = osgiInstallArea; >+ entry.location = location; >+ entry.timestamp = location.lastModified(); >+ cache = entry; >+ } >+ >+ /* >+ * Save the given configuration to the file-system. >+ */ >+ static void write(File location, Configuration config, URL osgiInstallArea) throws ProvisionException { >+ // write it to disk >+ ConfigurationWriter.save(config, location, osgiInstallArea); >+ // save a copy in the cache >+ cache(location, config, osgiInstallArea); >+ } >+ >+} >Index: src/org/eclipse/equinox/internal/p2/update/ConfigurationParser.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationParser.java,v >retrieving revision 1.8 >diff -u -r1.8 ConfigurationParser.java >--- src/org/eclipse/equinox/internal/p2/update/ConfigurationParser.java 25 Aug 2008 16:21:42 -0000 1.8 >+++ src/org/eclipse/equinox/internal/p2/update/ConfigurationParser.java 16 Dec 2009 20:14:26 -0000 >@@ -34,7 +34,7 @@ > * Parse the given file handle which points to a platform.xml file and a configuration object. > * Returns null if the file doesn't exist. > */ >- public static Configuration parse(File file, URL osgiInstallArea) throws ProvisionException { >+ static Configuration parse(File file, URL osgiInstallArea) throws ProvisionException { > return new ConfigurationParser(osgiInstallArea).internalParse(file); > } > >Index: src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java,v >retrieving revision 1.9 >diff -u -r1.9 ConfigurationWriter.java >--- src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java 25 Aug 2008 16:21:42 -0000 1.9 >+++ src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java 16 Dec 2009 20:14:26 -0000 >@@ -30,7 +30,7 @@ > /* > * Save the given configuration to the specified location. > */ >- public static void save(Configuration configuration, File location, URL osgiInstallArea) throws ProvisionException { >+ static void save(Configuration configuration, File location, URL osgiInstallArea) throws ProvisionException { > XMLWriter writer = null; > try { > OutputStream output = new BufferedOutputStream(new FileOutputStream(location));
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 296936
:
153934
|
154326
|
154591
|
154808
|
155529