Bug 561663: [RJ-Servi] Restore pool eviction resource limits
Follow-up-to: e09835c748c6a072ab4250d580011fba86df26d0
Change-Id: Iceca80cc536fb322684700e0ba1ab3901b96f667
diff --git a/servi/org.eclipse.statet.rj.servi/srcServiPool/org/eclipse/statet/internal/rj/servi/APool2.java b/servi/org.eclipse.statet.rj.servi/srcServiPool/org/eclipse/statet/internal/rj/servi/APool2.java
index 55ede38..2fa4409 100644
--- a/servi/org.eclipse.statet.rj.servi/srcServiPool/org/eclipse/statet/internal/rj/servi/APool2.java
+++ b/servi/org.eclipse.statet.rj.servi/srcServiPool/org/eclipse/statet/internal/rj/servi/APool2.java
@@ -62,7 +62,7 @@
aConfig.setMinEvictableIdleTimeMillis(0);
aConfig.setSoftMinEvictableIdleTimeMillis(config.getMinIdleTime());
aConfig.setTimeBetweenEvictionRunsMillis(5000);
- aConfig.setNumTestsPerEvictionRun(-3);
+ aConfig.setNumTestsPerEvictionRun(-4);
aConfig.setEvictorShutdownTimeoutMillis(0);
return aConfig;
diff --git a/servi/org.eclipse.statet.rj.servi/srcServiPool/org/eclipse/statet/internal/rj/servi/PoolManager.java b/servi/org.eclipse.statet.rj.servi/srcServiPool/org/eclipse/statet/internal/rj/servi/PoolManager.java
index e259fff..e2ee91d 100644
--- a/servi/org.eclipse.statet.rj.servi/srcServiPool/org/eclipse/statet/internal/rj/servi/PoolManager.java
+++ b/servi/org.eclipse.statet.rj.servi/srcServiPool/org/eclipse/statet/internal/rj/servi/PoolManager.java
@@ -84,6 +84,7 @@
this.poolConfig= new PoolConfig();
this.executor= new ScheduledThreadPoolExecutor(0);
+ configResources();
Utils.preLoad();
}
@@ -183,7 +184,8 @@
}
public boolean isStopped() {
- return (this.unclosed == 0 && this.executor.getPoolSize() == 0);
+ return (this.unclosed == 0
+ && this.executor.getQueue().isEmpty() && this.executor.getPoolSize() == 0);
}
@Override
@@ -230,11 +232,25 @@
}
}
+
+ private void configResources() {
+ final int unclosed= this.unclosed;
+ if (unclosed > 0) {
+ this.executor.setKeepAliveTime(60, TimeUnit.SECONDS);
+ this.executor.setCorePoolSize(1);
+ this.executor.setMaximumPoolSize(2);
+ }
+ else {
+ this.executor.setKeepAliveTime(0, TimeUnit.SECONDS);
+ this.executor.setCorePoolSize(0);
+ this.executor.setMaximumPoolSize(2);
+ }
+ }
+
private void onPoolCreated(final APool2 pool) {
synchronized (this.resourceLock) {
if (this.unclosed++ == 0) {
- this.executor.setKeepAliveTime(60, TimeUnit.SECONDS);
- this.executor.setCorePoolSize(1);
+ configResources();
}
}
}
@@ -242,8 +258,7 @@
private void onPoolClosed(final APool2 pool) {
synchronized (this.resourceLock) {
if (--this.unclosed == 0) {
- this.executor.setKeepAliveTime(0, TimeUnit.SECONDS);
- this.executor.setCorePoolSize(0);
+ configResources();
}
}
}