Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2016-01-11 23:11:28 +0000
committerThomas Watson2016-01-11 23:11:28 +0000
commitf66c5fe3d72aa35196d7de82a270c9a4bed181fc (patch)
tree0246b1abff192448c600529fa8efa8550c1bcc90 /bundles
parentc39f725ba260b275d818714bb3fa45334c967b62 (diff)
downloadrt.equinox.framework-f66c5fe3d72aa35196d7de82a270c9a4bed181fc.tar.gz
rt.equinox.framework-f66c5fe3d72aa35196d7de82a270c9a4bed181fc.tar.xz
rt.equinox.framework-f66c5fe3d72aa35196d7de82a270c9a4bed181fc.zip
Bug 485217 - Update resolver implementation and default to using batchI20160112-0800
resolves with a timeout Add an option to set the number of resolver threads. If set to 1 then only do single threaded resolve with a simple executor
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java1
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java54
2 files changed, 36 insertions, 19 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java
index b01865a47..8000f44db 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java
@@ -195,6 +195,7 @@ public class EquinoxConfiguration implements EnvironmentInfo {
public static final String PROP_ALLOW_RESTRICTED_PROVIDES = "osgi.equinox.allow.restricted.provides"; //$NON-NLS-1$
public static final String PROP_LOG_HISTORY_MAX = "equinox.log.history.max"; //$NON-NLS-1$
+ public static final String PROP_RESOLVER_THREAD_COUNT = "equinox.resolver.thead.count"; //$NON-NLS-1$
public static final String PROP_RESOLVER_REVISION_BATCH_SIZE = "equinox.resolver.revision.batch.size"; //$NON-NLS-1$
public static final String PROP_RESOLVER_BATCH_TIMEOUT = "equinox.resolver.batch.timeout"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
index e7d00d34f..e0b0f85fb 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
@@ -38,17 +38,42 @@ public class EquinoxContainerAdaptor extends ModuleContainerAdaptor {
private final ClassLoader moduleClassLoaderParent;
private final AtomicLong lastSecurityAdminFlush;
- final AtomicLazyInitializer<ExecutorService> executor = new AtomicLazyInitializer<ExecutorService>();
- final Callable<ExecutorService> lazyExecutorCreator;
+ final AtomicLazyInitializer<Executor> executor = new AtomicLazyInitializer<Executor>();
+ final Callable<Executor> lazyExecutorCreator;
- {
- lazyExecutorCreator = new Callable<ExecutorService>() {
+ public EquinoxContainerAdaptor(EquinoxContainer container, Storage storage, Map<Long, Generation> initial) {
+ this.container = container;
+ this.storage = storage;
+ this.hooks = new OSGiFrameworkHooks(container, storage);
+ this.initial = initial;
+ this.moduleClassLoaderParent = getModuleClassLoaderParent(container.getConfiguration());
+ this.lastSecurityAdminFlush = new AtomicLong();
+ this.lazyExecutorCreator = createLazyExecutorCreator(container.getConfiguration());
+ }
+
+ private Callable<Executor> createLazyExecutorCreator(EquinoxConfiguration config) {
+ String threadCntProp = config.getConfiguration(EquinoxConfiguration.PROP_RESOLVER_THREAD_COUNT);
+ int threadCntTmp;
+ try {
+ threadCntTmp = threadCntProp == null ? -1 : Integer.parseInt(threadCntProp);
+ } catch (NumberFormatException e) {
+ threadCntTmp = -1;
+ }
+ // use the number of processors - 1 because we use the current thread when rejected
+ final int maxThreads = threadCntTmp <= 0 ? Math.max(Runtime.getRuntime().availableProcessors() - 1, 1) : threadCntTmp;
+ return new Callable<Executor>() {
@Override
- public ExecutorService call() throws Exception {
+ public Executor call() throws Exception {
+ if (maxThreads == 1) {
+ return new Executor() {
+ @Override
+ public void execute(Runnable command) {
+ command.run();
+ }
+ };
+ }
// Always want to go to zero threads when idle
int coreThreads = 0;
- // use the number of processors - 1 because we use the current thread when rejected
- int maxThreads = Math.max(Runtime.getRuntime().availableProcessors() - 1, 1);
// idle timeout; make it short to get rid of threads quickly after resolve
int idleTimeout = 10;
// use sync queue to force thread creation
@@ -74,15 +99,6 @@ public class EquinoxContainerAdaptor extends ModuleContainerAdaptor {
};
}
- public EquinoxContainerAdaptor(EquinoxContainer container, Storage storage, Map<Long, Generation> initial) {
- this.container = container;
- this.storage = storage;
- this.hooks = new OSGiFrameworkHooks(container, storage);
- this.initial = initial;
- this.moduleClassLoaderParent = getModuleClassLoaderParent(container.getConfiguration());
- this.lastSecurityAdminFlush = new AtomicLong();
- }
-
private static ClassLoader getModuleClassLoaderParent(EquinoxConfiguration configuration) {
// allow hooks to determine the parent class loader
for (ClassLoaderHook hook : configuration.getHookRegistry().getClassLoaderHooks()) {
@@ -312,9 +328,9 @@ public class EquinoxContainerAdaptor extends ModuleContainerAdaptor {
}
public void shutdownResolverExecutor() {
- ExecutorService current = executor.getAndClear();
- if (current != null) {
- current.shutdown();
+ Executor current = executor.getAndClear();
+ if (current instanceof ExecutorService) {
+ ((ExecutorService) current).shutdown();
}
}
} \ No newline at end of file

Back to the top