Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarsten Thoms2018-06-01 03:32:28 -0400
committerKarsten Thoms2018-06-01 09:30:27 -0400
commit757232e1946b4c1cadc5905014b83e444bd7a909 (patch)
treec5fef108feb383fe20289b3ae2aded1e14a82789
parent59d521c299c095552d2a506bc454d92292a91a7f (diff)
downloadrt.equinox.framework-757232e1946b4c1cadc5905014b83e444bd7a909.tar.gz
rt.equinox.framework-757232e1946b4c1cadc5905014b83e444bd7a909.tar.xz
rt.equinox.framework-757232e1946b4c1cadc5905014b83e444bd7a909.zip
Bug 535341 - Introduce cache for lookup of bundles by name
Added a multimap to store bundle descriptions by name and use this map for invocations of the getBundles(String) method. Speeds up access to this method with a small memory footprint. Bump version for 4.9 Change-Id: I9e102d10e46cdc0d7ea62c3f18fa33c4d24d89e1 Signed-off-by: Karsten Thoms <karsten.thoms@itemis.de>
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/pom.xml2
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java34
3 files changed, 30 insertions, 8 deletions
diff --git a/bundles/org.eclipse.osgi.compatibility.state/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.compatibility.state/META-INF/MANIFEST.MF
index 5a221e2d1..5ecb348f0 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.osgi.compatibility.state/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.osgi.compatibility.state
-Bundle-Version: 1.1.100.qualifier
+Bundle-Version: 1.1.200.qualifier
ExtensionBundle-Activator: org.eclipse.osgi.compatibility.state.Activator
Fragment-Host: org.eclipse.osgi;bundle-version="3.12.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
diff --git a/bundles/org.eclipse.osgi.compatibility.state/pom.xml b/bundles/org.eclipse.osgi.compatibility.state/pom.xml
index 1d2fe5196..f0ad4ebdf 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/pom.xml
+++ b/bundles/org.eclipse.osgi.compatibility.state/pom.xml
@@ -19,6 +19,6 @@
</parent>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi.compatibility.state</artifactId>
- <version>1.1.100-SNAPSHOT</version>
+ <version>1.1.200-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java
index a6989478a..813628928 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2017 IBM Corporation and others.
+ * Copyright (c) 2003, 2018 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
@@ -9,6 +9,7 @@
* IBM Corporation - initial API and implementation
* Danail Nachev - ProSyst - bug 218625
* Rob Harrop - SpringSource Inc. (bug 247522)
+ * Karsten Thoms (itemis) - bug 535341
*******************************************************************************/
package org.eclipse.osgi.internal.resolver;
@@ -121,6 +122,7 @@ public abstract class StateImpl implements State {
private StateObjectFactory factory;
private final KeyedHashSet resolvedBundles = new KeyedHashSet();
private final Map<BundleDescription, List<DisabledInfo>> disabledBundles = new HashMap<>();
+ private final Map<String, Set<BundleDescription>> bundleNameCache = new HashMap<>();
private boolean fullyLoaded = false;
private boolean dynamicCacheChanged = false;
// only used for lazy loading of BundleDescriptions
@@ -182,6 +184,7 @@ public abstract class StateImpl implements State {
return false;
if (!bundleDescriptions.remove(existing))
return false;
+ removeBundleNameCacheEntry(existing);
resolvedBundles.remove(existing);
List<DisabledInfo> infos = disabledBundles.remove(existing);
if (infos != null) {
@@ -237,6 +240,7 @@ public abstract class StateImpl implements State {
return false;
resolvedBundles.remove((KeyedElement) toRemove);
disabledBundles.remove(toRemove);
+ removeBundleNameCacheEntry(toRemove);
resolved = false;
getDelta().recordBundleRemoved((BundleDescriptionImpl) toRemove);
((BundleDescriptionImpl) toRemove).setStateBit(BundleDescriptionImpl.REMOVAL_PENDING, true);
@@ -282,11 +286,9 @@ public abstract class StateImpl implements State {
synchronized (this.monitor) {
if (Constants.SYSTEM_BUNDLE_SYMBOLICNAME.equals(symbolicName))
symbolicName = getSystemBundle();
- final List<BundleDescription> bundles = new ArrayList<>();
- for (Iterator<KeyedElement> iter = bundleDescriptions.iterator(); iter.hasNext();) {
- BundleDescription bundle = (BundleDescription) iter.next();
- if (symbolicName.equals(bundle.getSymbolicName()))
- bundles.add(bundle);
+ final Set<BundleDescription> bundles = bundleNameCache.get(symbolicName);
+ if (bundles == null) {
+ return new BundleDescription[0];
}
return bundles.toArray(new BundleDescription[bundles.size()]);
}
@@ -684,6 +686,7 @@ public abstract class StateImpl implements State {
if (bundleDescriptions.add((BundleDescriptionImpl) description)) {
if (description.getBundleId() > getHighestBundleId())
highestBundleId = description.getBundleId();
+ addBundleNameCacheEntry(description);
return true;
}
return false;
@@ -1331,4 +1334,23 @@ public abstract class StateImpl implements State {
}
return results.toArray(new DisabledInfo[results.size()]);
}
+
+ private void addBundleNameCacheEntry(BundleDescription description) {
+ Set<BundleDescription> descriptions = bundleNameCache.get(description.getSymbolicName());
+ if (descriptions == null) {
+ descriptions = new LinkedHashSet<>();
+ bundleNameCache.put(description.getSymbolicName(), descriptions);
+ }
+ descriptions.add(description);
+ }
+
+ private void removeBundleNameCacheEntry(BundleDescription description) {
+ Set<BundleDescription> descriptions = bundleNameCache.get(description.getSymbolicName());
+ if (descriptions != null) {
+ descriptions.remove(description);
+ if (descriptions.isEmpty()) {
+ bundleNameCache.remove(description.getSymbolicName());
+ }
+ }
+ }
}

Back to the top