Author: dblevins
Date: Thu Feb 25 05:33:59 2010
New Revision: 916130
URL: http://svn.apache.org/viewvc?rev=916130&view=rev
Log:
OPENEJB-1235: Stateless pool min/max and reduction
Can set minimum pool size on a per-container level.
Modified:
openejb/trunk/openejb3/assembly/openejb-jetty/openejb-jetty-webapp/src/main/resources/META-INF/org.apache.openejb.jetty/service-jar.xml
openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/resources/META-INF/org.apache.openejb.tomcat/service-jar.xml
openejb/trunk/openejb3/assembly/openejb-webapp/src/main/resources/META-INF/org.apache.openejb.tomcat/service-jar.xml
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainer.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessInstanceManager.java
openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb.embedded/service-jar.xml
openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml
openejb/trunk/openejb3/container/openejb-core/src/main/resources/default.openejb.conf
openejb/trunk/openejb3/container/openejb-osgi/src/main/resources/META-INF/org.apache.openejb/service-jar.xml
openejb/trunk/openejb3/pom.xml
Modified:
openejb/trunk/openejb3/assembly/openejb-jetty/openejb-jetty-webapp/src/main/resources/META-INF/org.apache.openejb.jetty/service-jar.xml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-jetty/openejb-jetty-webapp/src/main/resources/META-INF/org.apache.openejb.jetty/service-jar.xml?rev=916130&r1=916129&r2=916130&view=diff
==============================================================================
---
openejb/trunk/openejb3/assembly/openejb-jetty/openejb-jetty-webapp/src/main/resources/META-INF/org.apache.openejb.jetty/service-jar.xml
(original)
+++
openejb/trunk/openejb3/assembly/openejb-jetty/openejb-jetty-webapp/src/main/resources/META-INF/org.apache.openejb.jetty/service-jar.xml
Thu Feb 25 05:33:59 2010
@@ -87,18 +87,31 @@
id="Default Stateless Container"
service="Container"
types="STATELESS"
- constructor="id, securityService, TimeOut, PoolSize, StrictPooling"
+ constructor="id, securityService, TimeOut, PoolMin, PoolSize,
StrictPooling"
class-name="org.apache.openejb.core.stateless.StatelessContainer">
- # Specifies the time to wait between invocations. This
- # value is measured in milliseconds. A value of 5 would
- # result in a time-out of 5 milliseconds between invocations.
- # A value of zero would mean no timeout.
+ # Specifies the time an invokation should wait for an instance
+ # of the pool to become available. This measured by default in
+ # milliseconds, but other time units can be specified, such as
+ # nanoseconds, microsecons, seconds or minutes. After the timeout
+ # is reached, if an instance in the pool cannot be obtained, the
+ # method invocation will fail.
+
+ TimeOut = 0 milliseconds
+
+ # Specifies the minimum number of bean instances that should be
+ # in the pool for each bean. Pools are prefilled to the minimum
+ # on startup. Pool "shrinking" is achived through WeakReferences
+ # and natural vm garbage collection. All but the minimum are allowed
+ # to be garbage collected by the VM when memory is needed.
- TimeOut 0
+ PoolMin 0
# Specifies the size of the bean pools for this
- # stateless SessionBean container.
+ # stateless SessionBean container. If StrictPooling is not
+ # used, instances will still be created beyond this number if
+ # there is demand, but they will not be returned to the pool
+ # and instead will be immediately destroyed.
PoolSize 10
Modified:
openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/resources/META-INF/org.apache.openejb.tomcat/service-jar.xml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/resources/META-INF/org.apache.openejb.tomcat/service-jar.xml?rev=916130&r1=916129&r2=916130&view=diff
==============================================================================
---
openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/resources/META-INF/org.apache.openejb.tomcat/service-jar.xml
(original)
+++
openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/resources/META-INF/org.apache.openejb.tomcat/service-jar.xml
Thu Feb 25 05:33:59 2010
@@ -87,18 +87,31 @@
id="Default Stateless Container"
service="Container"
types="STATELESS"
- constructor="id, securityService, TimeOut, PoolSize, StrictPooling"
+ constructor="id, securityService, TimeOut, PoolMin, PoolSize,
StrictPooling"
class-name="org.apache.openejb.core.stateless.StatelessContainer">
- # Specifies the time to wait between invocations. This
- # value is measured in milliseconds. A value of 5 would
- # result in a time-out of 5 milliseconds between invocations.
- # A value of zero would mean no timeout.
+ # Specifies the time an invokation should wait for an instance
+ # of the pool to become available. This measured by default in
+ # milliseconds, but other time units can be specified, such as
+ # nanoseconds, microsecons, seconds or minutes. After the timeout
+ # is reached, if an instance in the pool cannot be obtained, the
+ # method invocation will fail.
+
+ TimeOut = 0 milliseconds
+
+ # Specifies the minimum number of bean instances that should be
+ # in the pool for each bean. Pools are prefilled to the minimum
+ # on startup. Pool "shrinking" is achived through WeakReferences
+ # and natural vm garbage collection. All but the minimum are allowed
+ # to be garbage collected by the VM when memory is needed.
- TimeOut 0
+ PoolMin 0
# Specifies the size of the bean pools for this
- # stateless SessionBean container.
+ # stateless SessionBean container. If StrictPooling is not
+ # used, instances will still be created beyond this number if
+ # there is demand, but they will not be returned to the pool
+ # and instead will be immediately destroyed.
PoolSize 10
Modified:
openejb/trunk/openejb3/assembly/openejb-webapp/src/main/resources/META-INF/org.apache.openejb.tomcat/service-jar.xml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-webapp/src/main/resources/META-INF/org.apache.openejb.tomcat/service-jar.xml?rev=916130&r1=916129&r2=916130&view=diff
==============================================================================
---
openejb/trunk/openejb3/assembly/openejb-webapp/src/main/resources/META-INF/org.apache.openejb.tomcat/service-jar.xml
(original)
+++
openejb/trunk/openejb3/assembly/openejb-webapp/src/main/resources/META-INF/org.apache.openejb.tomcat/service-jar.xml
Thu Feb 25 05:33:59 2010
@@ -87,18 +87,31 @@
id="Default Stateless Container"
service="Container"
types="STATELESS"
- constructor="id, securityService, TimeOut, PoolSize, StrictPooling"
+ constructor="id, securityService, TimeOut, PoolMin, PoolSize,
StrictPooling"
class-name="org.apache.openejb.core.stateless.StatelessContainer">
- # Specifies the time to wait between invocations. This
- # value is measured in milliseconds. A value of 5 would
- # result in a time-out of 5 milliseconds between invocations.
- # A value of zero would mean no timeout.
+ # Specifies the time an invokation should wait for an instance
+ # of the pool to become available. This measured by default in
+ # milliseconds, but other time units can be specified, such as
+ # nanoseconds, microsecons, seconds or minutes. After the timeout
+ # is reached, if an instance in the pool cannot be obtained, the
+ # method invocation will fail.
+
+ TimeOut = 0 milliseconds
+
+ # Specifies the minimum number of bean instances that should be
+ # in the pool for each bean. Pools are prefilled to the minimum
+ # on startup. Pool "shrinking" is achived through WeakReferences
+ # and natural vm garbage collection. All but the minimum are allowed
+ # to be garbage collected by the VM when memory is needed.
- TimeOut 0
+ PoolMin 0
# Specifies the size of the bean pools for this
- # stateless SessionBean container.
+ # stateless SessionBean container. If StrictPooling is not
+ # used, instances will still be created beyond this number if
+ # there is demand, but they will not be returned to the pool
+ # and instead will be immediately destroyed.
PoolSize 10
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainer.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainer.java?rev=916130&r1=916129&r2=916130&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainer.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainer.java
Thu Feb 25 05:33:59 2010
@@ -62,11 +62,11 @@
private Object containerID = null;
private SecurityService securityService;
- public StatelessContainer(Object id, SecurityService securityService, int
timeOut, int poolSize, boolean strictPooling) throws OpenEJBException {
+ public StatelessContainer(Object id, SecurityService securityService,
Duration timeOut, int poolMin, int poolSize, boolean strictPooling) throws
OpenEJBException {
this.containerID = id;
this.securityService = securityService;
- instanceManager = new StatelessInstanceManager(securityService, new
Duration(timeOut,TimeUnit.MILLISECONDS), poolSize, strictPooling);
+ instanceManager = new StatelessInstanceManager(securityService,
timeOut, poolMin, poolSize, strictPooling);
for (DeploymentInfo deploymentInfo : deploymentRegistry.values()) {
org.apache.openejb.core.CoreDeploymentInfo di =
(org.apache.openejb.core.CoreDeploymentInfo) deploymentInfo;
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessInstanceManager.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessInstanceManager.java?rev=916130&r1=916129&r2=916130&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessInstanceManager.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessInstanceManager.java
Thu Feb 25 05:33:59 2010
@@ -24,6 +24,7 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeoutException;
+import java.util.concurrent.TimeUnit;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
@@ -60,14 +61,21 @@
protected final SafeToolkit toolkit =
SafeToolkit.getToolkit("StatefulInstanceManager");
private SecurityService securityService;
+ private int poolMin = 0;
- public StatelessInstanceManager(SecurityService securityService, Duration
timeout, int poolSize, boolean strictPooling) {
+ public StatelessInstanceManager(SecurityService securityService, Duration
timeout, int poolMin, int poolMax, boolean strictPooling) {
this.securityService = securityService;
- this.poolLimit = poolSize;
+ this.poolLimit = poolMax;
this.strictPooling = strictPooling;
this.timeout = timeout;
+ this.poolMin = poolMin;
+
+ if (timeout.getUnit() == null) timeout.setUnit(TimeUnit.MILLISECONDS);
+ if (this.poolMin > poolLimit) {
+ throw new IllegalArgumentException("Minimum pool size cannot be
larger than the maximum pool size: min="+ this.poolMin +", max="+poolLimit);
+ }
- if (strictPooling && poolSize < 1) {
+ if (strictPooling && poolMax < 1) {
throw new IllegalArgumentException("Cannot use strict pooling with
a pool size less than one. Strict pooling blocks threads till an instance in
the pool is available. Please increase the pool size or set strict pooling to
false");
}
@@ -334,7 +342,7 @@
}
public void deploy(CoreDeploymentInfo deploymentInfo) {
- Data data = new Data(poolLimit, this.strictPooling);
+ Data data = new Data(poolLimit, this.strictPooling, poolMin);
deploymentInfo.setContainerData(data);
}
@@ -349,8 +357,8 @@
private static final class Data {
private final Pool<Instance> pool;
- public Data(int poolLimit, boolean strictPooling) {
- pool = new Pool<Instance>(poolLimit, 0, strictPooling);
+ public Data(int poolLimit, boolean strictPooling, int min) {
+ pool = new Pool<Instance>(poolLimit, min, strictPooling);
}
public Pool<Instance> getPool() {
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb.embedded/service-jar.xml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb.embedded/service-jar.xml?rev=916130&r1=916129&r2=916130&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb.embedded/service-jar.xml
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb.embedded/service-jar.xml
Thu Feb 25 05:33:59 2010
@@ -80,18 +80,31 @@
id="Default Stateless Container"
service="Container"
types="STATELESS"
- constructor="id, securityService, TimeOut, PoolSize, StrictPooling"
+ constructor="id, securityService, TimeOut, PoolMin, PoolSize,
StrictPooling"
class-name="org.apache.openejb.core.stateless.StatelessContainer">
- # Specifies the time to wait between invocations. This
- # value is measured in milliseconds. A value of 5 would
- # result in a time-out of 5 milliseconds between invocations.
- # A value of zero would mean no timeout.
+ # Specifies the time an invokation should wait for an instance
+ # of the pool to become available. This measured by default in
+ # milliseconds, but other time units can be specified, such as
+ # nanoseconds, microsecons, seconds or minutes. After the timeout
+ # is reached, if an instance in the pool cannot be obtained, the
+ # method invocation will fail.
+
+ TimeOut = 0 milliseconds
+
+ # Specifies the minimum number of bean instances that should be
+ # in the pool for each bean. Pools are prefilled to the minimum
+ # on startup. Pool "shrinking" is achived through WeakReferences
+ # and natural vm garbage collection. All but the minimum are allowed
+ # to be garbage collected by the VM when memory is needed.
- TimeOut 0
+ PoolMin 0
# Specifies the size of the bean pools for this
- # stateless SessionBean container.
+ # stateless SessionBean container. If StrictPooling is not
+ # used, instances will still be created beyond this number if
+ # there is demand, but they will not be returned to the pool
+ # and instead will be immediately destroyed.
PoolSize 10
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml?rev=916130&r1=916129&r2=916130&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml
Thu Feb 25 05:33:59 2010
@@ -82,18 +82,31 @@
id="Default Stateless Container"
service="Container"
types="STATELESS"
- constructor="id, securityService, TimeOut, PoolSize, StrictPooling"
+ constructor="id, securityService, TimeOut, PoolMin, PoolSize,
StrictPooling"
class-name="org.apache.openejb.core.stateless.StatelessContainer">
- # Specifies the time to wait between invocations. This
- # value is measured in milliseconds. A value of 5 would
- # result in a time-out of 5 milliseconds between invocations.
- # A value of zero would mean no timeout.
+ # Specifies the time an invokation should wait for an instance
+ # of the pool to become available. This measured by default in
+ # milliseconds, but other time units can be specified, such as
+ # nanoseconds, microsecons, seconds or minutes. After the timeout
+ # is reached, if an instance in the pool cannot be obtained, the
+ # method invocation will fail.
+
+ TimeOut = 0 milliseconds
+
+ # Specifies the minimum number of bean instances that should be
+ # in the pool for each bean. Pools are prefilled to the minimum
+ # on startup. Pool "shrinking" is achived through WeakReferences
+ # and natural vm garbage collection. All but the minimum are allowed
+ # to be garbage collected by the VM when memory is needed.
- TimeOut 0
+ PoolMin 0
# Specifies the size of the bean pools for this
- # stateless SessionBean container.
+ # stateless SessionBean container. If StrictPooling is not
+ # used, instances will still be created beyond this number if
+ # there is demand, but they will not be returned to the pool
+ # and instead will be immediately destroyed.
PoolSize 10
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/resources/default.openejb.conf
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/resources/default.openejb.conf?rev=916130&r1=916129&r2=916130&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/resources/default.openejb.conf
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/resources/default.openejb.conf
Thu Feb 25 05:33:59 2010
@@ -64,31 +64,45 @@
<Container id="My Stateless Container" type="STATELESS">
- # Specifies the time to wait between invocations. This
- # value is measured in milliseconds. A value of 5 would
- # result in a time-out of 5 milliseconds between invocations.
- # A value of zero would mean no timeout.
- TimeOut 0
-
- # Specifies the size of the bean pools for this
- # stateless SessionBean container.
-
- PoolSize 10
-
- # StrictPooling tells the container what to do when the pool
- # reaches it's maximum size and there are incoming requests
- # that need instances.
+ # Specifies the time an invokation should wait for an instance
+ # of the pool to become available. This measured by default in
+ # milliseconds, but other time units can be specified, such as
+ # nanoseconds, microsecons, seconds or minutes. After the timeout
+ # is reached, if an instance in the pool cannot be obtained, the
+ # method invocation will fail.
+
+ TimeOut = 0 milliseconds
+
+ # Specifies the minimum number of bean instances that should be
+ # in the pool for each bean. Pools are prefilled to the minimum
+ # on startup. Pool "shrinking" is achived through WeakReferences
+ # and natural vm garbage collection. All but the minimum are allowed
+ # to be garbage collected by the VM when memory is needed.
+
+ PoolMin 0
+
+ # Specifies the size of the bean pools for this
+ # stateless SessionBean container. If StrictPooling is not
+ # used, instances will still be created beyond this number if
+ # there is demand, but they will not be returned to the pool
+ # and instead will be immediately destroyed.
+
+ PoolSize 10
+
+ # StrictPooling tells the container what to do when the pool
+ # reaches it's maximum size and there are incoming requests
+ # that need instances.
#
- # With strict pooling, requests will have to wait for instances
- # to become available. The pool size will never grow beyond the
- # the set PoolSize value.
+ # With strict pooling, requests will have to wait for instances
+ # to become available. The pool size will never grow beyond the
+ # the set PoolSize value.
#
- # Without strict pooling, the container will create temporary
- # instances to meet demand. The instances will last for just one
- # method invocation and then are removed.
+ # Without strict pooling, the container will create temporary
+ # instances to meet demand. The instances will last for just one
+ # method invocation and then are removed.
- StrictPooling true
+ StrictPooling true
</Container>
Modified:
openejb/trunk/openejb3/container/openejb-osgi/src/main/resources/META-INF/org.apache.openejb/service-jar.xml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-osgi/src/main/resources/META-INF/org.apache.openejb/service-jar.xml?rev=916130&r1=916129&r2=916130&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-osgi/src/main/resources/META-INF/org.apache.openejb/service-jar.xml
(original)
+++
openejb/trunk/openejb3/container/openejb-osgi/src/main/resources/META-INF/org.apache.openejb/service-jar.xml
Thu Feb 25 05:33:59 2010
@@ -82,18 +82,31 @@
id="Default Stateless Container"
service="Container"
types="STATELESS"
- constructor="id, securityService, TimeOut, PoolSize, StrictPooling"
+ constructor="id, securityService, TimeOut, PoolMin, PoolSize,
StrictPooling"
class-name="org.apache.openejb.core.stateless.StatelessContainer">
- # Specifies the time to wait between invocations. This
- # value is measured in milliseconds. A value of 5 would
- # result in a time-out of 5 milliseconds between invocations.
- # A value of zero would mean no timeout.
+ # Specifies the time an invokation should wait for an instance
+ # of the pool to become available. This measured by default in
+ # milliseconds, but other time units can be specified, such as
+ # nanoseconds, microsecons, seconds or minutes. After the timeout
+ # is reached, if an instance in the pool cannot be obtained, the
+ # method invocation will fail.
+
+ TimeOut = 0 milliseconds
+
+ # Specifies the minimum number of bean instances that should be
+ # in the pool for each bean. Pools are prefilled to the minimum
+ # on startup. Pool "shrinking" is achived through WeakReferences
+ # and natural vm garbage collection. All but the minimum are allowed
+ # to be garbage collected by the VM when memory is needed.
- TimeOut 0
+ PoolMin 0
# Specifies the size of the bean pools for this
- # stateless SessionBean container.
+ # stateless SessionBean container. If StrictPooling is not
+ # used, instances will still be created beyond this number if
+ # there is demand, but they will not be returned to the pool
+ # and instead will be immediately destroyed.
PoolSize 10
Modified: openejb/trunk/openejb3/pom.xml
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/pom.xml?rev=916130&r1=916129&r2=916130&view=diff
==============================================================================
--- openejb/trunk/openejb3/pom.xml (original)
+++ openejb/trunk/openejb3/pom.xml Thu Feb 25 05:33:59 2010
@@ -564,7 +564,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.4</version>
+ <version>4.5</version>
<scope>test</scope>
</dependency>
<dependency>