Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2011-10-12 15:01:08 +0000
committerThomas Watson2011-10-12 15:01:08 +0000
commit89de09e1b109112f63a804161e896ecb2facf439 (patch)
tree2ffe3a857a72524239ff7c8c556c5c0aede5583e
parentfa3fbb7a4aa2a0af8f33482f43aab49d62422eac (diff)
downloadrt.equinox.framework-89de09e1b109112f63a804161e896ecb2facf439.tar.gz
rt.equinox.framework-89de09e1b109112f63a804161e896ecb2facf439.tar.xz
rt.equinox.framework-89de09e1b109112f63a804161e896ecb2facf439.zip
Bug 359862 - Add a way of tweaking equinox resolver heuristics and
timeout values
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java56
1 files changed, 47 insertions, 9 deletions
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
index 70ec071e7..6f83a8fd4 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
@@ -51,6 +51,8 @@ public class ResolverImpl implements Resolver {
private static int MAX_MULTIPLE_SUPPLIERS_MERGE = 10;
private static int MAX_USES_TIME_BASE = 30000; // 30 seconds
private static int MAX_USES_TIME_LIMIT = 90000; // 90 seconds
+ private static final String USES_TIMEOUT_PROP = "osgi.usesTimeout"; //$NON-NLS-1$
+ private static final String MULTIPLE_SUPPLIERS_LIMIT_PROP = "osgi.usesLimit"; //$NON-NLS-1$
static final SecureAction secureAction = AccessController.doPrivileged(SecureAction.createSecureAction());
private String[][] CURRENT_EES;
@@ -80,6 +82,7 @@ public class ResolverImpl implements Resolver {
private boolean developmentMode = false;
private boolean usesCalculationTimeout = false;
private long usesTimeout = -1;
+ private int usesMultipleSuppliersLimit;
private volatile CompositeResolveHelperRegistry compositeHelpers;
public ResolverImpl(boolean checkPermissions) {
@@ -393,12 +396,9 @@ public class ResolverImpl implements Resolver {
// set developmentMode each resolution
developmentMode = platformProperties.length == 0 ? false : org.eclipse.osgi.framework.internal.core.Constants.DEVELOPMENT_MODE.equals(platformProperties[0].get(org.eclipse.osgi.framework.internal.core.Constants.OSGI_RESOLVER_MODE));
// set uses timeout each resolution
- try {
- Object timeout = platformProperties.length == 0 ? null : platformProperties[0].get("osgi.usesTimeout"); //$NON-NLS-1$
- usesTimeout = timeout == null ? -1 : Long.parseLong(timeout.toString());
- } catch (NumberFormatException e) {
- usesTimeout = -1;
- }
+ usesTimeout = getUsesTimeout(platformProperties);
+ // set limit for constraints with multiple suppliers each resolution
+ usesMultipleSuppliersLimit = getMultipleSuppliersLimit(platformProperties);
reRefresh = addDevConstraints(reRefresh);
// Unresolve all the supplied bundles and their dependents
if (reRefresh != null)
@@ -471,6 +471,44 @@ public class ResolverImpl implements Resolver {
}
}
+ private long getUsesTimeout(Dictionary<Object, Object>[] platformProperties) {
+ try {
+ Object timeout = platformProperties.length == 0 ? null : platformProperties[0].get(USES_TIMEOUT_PROP);
+ if (timeout != null) {
+ long temp = Long.parseLong(timeout.toString());
+ if (temp < 0) {
+ return -1;
+ } else if (temp == 0) {
+ return Long.MAX_VALUE;
+ } else {
+ return temp;
+ }
+ }
+ } catch (NumberFormatException e) {
+ // nothing;
+ }
+ return -1;
+ }
+
+ private int getMultipleSuppliersLimit(Dictionary<Object, Object>[] platformProperties) {
+ try {
+ Object limit = platformProperties.length == 0 ? null : platformProperties[0].get(MULTIPLE_SUPPLIERS_LIMIT_PROP);
+ if (limit != null) {
+ int temp = Integer.parseInt(limit.toString());
+ if (temp < 0) {
+ return MAX_MULTIPLE_SUPPLIERS_MERGE;
+ } else if (temp == 0) {
+ return Integer.MAX_VALUE;
+ } else {
+ return temp;
+ }
+ }
+ } catch (NumberFormatException e) {
+ // nothing;
+ }
+ return MAX_MULTIPLE_SUPPLIERS_MERGE;
+ }
+
private BundleDescription[] addDevConstraints(BundleDescription[] reRefresh) {
if (!developmentMode)
return reRefresh; // we don't care about this unless we are in development mode
@@ -832,7 +870,7 @@ public class ResolverImpl implements Resolver {
if (usesTimeout < 0)
timeLimit = Math.min(MAX_USES_TIME_BASE + (bundles.length * 30), MAX_USES_TIME_LIMIT);
else
- timeLimit = usesTimeout == 0 ? Long.MAX_VALUE : usesTimeout;
+ timeLimit = usesTimeout;
int bestConflictCount = getConflictCount(bestConflicts);
ResolverBundle[] bestConflictBundles = getConflictedBundles(bestConflicts);
@@ -1042,7 +1080,7 @@ public class ResolverImpl implements Resolver {
multipleGenericSupplierList.add(genericRequire);
}
List<ResolverConstraint[]> results = new ArrayList<ResolverConstraint[]>();
- if (multipleImportSupplierList.size() + multipleRequireSupplierList.size() + multipleGenericSupplierList.size() > MAX_MULTIPLE_SUPPLIERS_MERGE) {
+ if (multipleImportSupplierList.size() + multipleRequireSupplierList.size() + multipleGenericSupplierList.size() > usesMultipleSuppliersLimit) {
// we have hit a max on the multiple suppliers in the lists without merging.
// first merge the identical constraints that have identical suppliers
Map<String, List<List<ResolverConstraint>>> multipleImportSupplierMaps = new HashMap<String, List<List<ResolverConstraint>>>();
@@ -1058,7 +1096,7 @@ public class ResolverImpl implements Resolver {
addMergedSuppliers(results, multipleRequireSupplierMaps);
addMergedSuppliers(results, multipleGenericSupplierMaps);
// check the results to see if we have reduced the number enough
- if (results.size() > MAX_MULTIPLE_SUPPLIERS_MERGE && packageConstraints != null && bundleConstraints != null) {
+ if (results.size() > usesMultipleSuppliersLimit && packageConstraints != null && bundleConstraints != null) {
// we still have too big of a list; filter out constraints that are not in conflict
List<ResolverConstraint[]> tooBig = results;
results = new ArrayList<ResolverConstraint[]>();

Back to the top