Recently I came accross very interesting study on how
EBs are managed by JBoss by 'Scott Crawford'
(http://www.scottcrawford.com/undercover/Undercover
%20Report%20-%20JBoss%203.pdf : Page # 12).
According to Scott's study, total number of EBs created
during his tests is exactly the number of distinct primary
keys plus number of clients (home client). I was very
curious about this, and wrote a smiple client which
makes direct calls to EntityBean (CMP) and saw the
same behaviour. For example, if a single client makes a
call to EB (findByPK + get + set), total number of EB
instances created by JBoss-3.0.4 is 2 (one instance for
the the requested bean and one for the client).
I found that "EntityInstanceInterceptor.invokeHome"
function is responsible for creating this extra bean for
client. If I am correct the bean instance created in
EntityInstanceInterceptor.invokeHome is not put into
cache, and hence never gets pooled back (even when
there is no client activity).
I tried removing the piece of code in
EntityInstanceInterceptor.invokeHome which creates
seperate instance for each client and ran my little
sample program and it worked without any problem.
I had to modify two other server side interceptor classes
(mentioned at the bottom) in order to support the
changes made in EntityInstanceInterceptor class.
I ran ECperf load against JBoss with/without piece of
code that creates sperate bean instance for each client
and here are results:
Without any changes to JBoss code:
-----------------------------------
BBops/min = 12
After removing piece of code that create seperate bean
for client:
--------------------------------------------
BBops/min = 66
Mainly I have changed source code in following three
files:
1) org.jboss.ejb.plugins.EntityInstanceInterceptor
2) org.jboss.ejb.plugins.EntityCreationInterceptor
3) org.jboss.ejb.plugins.EntitySynchronizationInterceptor
In all the above files, invokeHome function is modified
(some piece of code is commented out).
If anything is not clear or you need more information,
please feel free to contact me on
atul_dedhia@yahoo.com
Thanks,
Atul
JBoss-BeanManagementStratergy.zip: Contains EntityInstanceInterceptor.java, EntityCreationInterceptor.java, EntitySynchronizationInterceptor.java