3 Replies Latest reply on May 28, 2004 7:09 PM by erik777

    Configuring JBoss CMP for a caching enviroment

    ltcmelo

      Hi,
      does JBoss have any features like lazy loading (by configuration) or any other that improves performance?

      I'd working on a caching use case, so if JBoss have a caching enviromente configuration, it'd be nice too.

      Can anyone help at all?

        • 1. Re: Configuring JBoss CMP for a caching enviroment
          erik777

          JBoss caching is very configurable. I CMP configuration samples on this computer, but I'm sure others can show you examples of how to configure CMP's caching.

          Virtually all database caching uses "lazy loading", since you can't anticipate what the user will need to read ahead of time, and don't want to load the whole database in memory by default.

          Principally, you can primarily tweak the timings and pool sizes. With the former, you're anticipating usage patterns. With the latter, you're weighing memory usage efficiency usage versus performance.

          JBoss comes out-of-the-box with default configuration for your CMP beans. To override, you create your own configurations (can copy JBoss default, and then rename and modify.) You can then apply your configuration to beans on an individual basis. You both define configurations and then associate them with individual beans in your jboss.xml.

          • 2. Re: Configuring JBoss CMP for a caching enviroment
            ltcmelo

            Erik,
            your explanation is nice, thanks.

            Would you have some pieces of "this" configuration information you said?

            I don't mean the whole files, but just "some parts" of "some specific" files that i should make changes.

            Thanks,
            ltcmelo

            • 3. Re: Configuring JBoss CMP for a caching enviroment
              erik777

              I haven't done this in a long time, and I only did it for BMP, but the method is the same for CMP.

              You do it all in jboss.xml. Container configurations are defined as elements of the jboss tag. Here's a sample BMP custom configuration:

              <container-configurations>
               <container-configuration>
               <container-name>Custom BMP EntityBean</container-name>
               <call-logging>false</call-logging>
               <invoker-proxy-binding-name>entity-rmi-invoker</invoker-proxy-binding-name>
               <sync-on-commit-only>false</sync-on-commit-only>
               <insert-after-ejb-post-create>false</insert-after-ejb-post-create>
               <container-interceptors>
               <interceptor>org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor</interceptor>
               <interceptor>org.jboss.ejb.plugins.LogInterceptor</interceptor>
               <interceptor>org.jboss.ejb.plugins.SecurityInterceptor</interceptor>
               <interceptor>org.jboss.ejb.plugins.TxInterceptorCMT</interceptor>
               <interceptor metricsEnabled="true">org.jboss.ejb.plugins.MetricsInterceptor</interceptor>
               <interceptor>org.jboss.ejb.plugins.EntityCreationInterceptor</interceptor>
               <interceptor>org.jboss.ejb.plugins.EntityLockInterceptor</interceptor>
               <interceptor>org.jboss.ejb.plugins.EntityInstanceInterceptor</interceptor>
               <interceptor>org.jboss.ejb.plugins.EntityReentranceInterceptor</interceptor>
               <interceptor>org.jboss.resource.connectionmanager.CachedConnectionInterceptor</interceptor>
               <interceptor>org.jboss.ejb.plugins.EntitySynchronizationInterceptor</interceptor>
               </container-interceptors>
              
               <instance-pool>org.jboss.ejb.plugins.EntityInstancePool</instance-pool>
               <instance-cache>org.jboss.ejb.plugins.EntityInstanceCache</instance-cache>
               <persistence-manager>org.jboss.ejb.plugins.BMPPersistenceManager</persistence-manager>
               <locking-policy>org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock</locking-policy>
              
               <container-cache-conf>
               <cache-policy>org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy</cache-policy>
               <cache-policy-conf>
               <min-capacity>10</min-capacity>
              <!-- <min-capacity>50</min-capacity> -->
               <max-capacity>1000000</max-capacity>
               <overager-period>300</overager-period>
               <max-bean-age>600</max-bean-age>
               <resizer-period>400</resizer-period>
               <max-cache-miss-period>60</max-cache-miss-period>
               <min-cache-miss-period>1</min-cache-miss-period>
               <cache-load-factor>0.75</cache-load-factor>
               </cache-policy-conf>
               </container-cache-conf>
              
               <container-pool-conf>
               <MaximumSize>100</MaximumSize>
              <!-- <MinimumSize>10</MinimumSize> -->
              <!-- <MinimumSize>0</MinimumSize> -->
               </container-pool-conf>
               <commit-option>A</commit-option>
               </container-configuration>
               </container-configurations>
              


              Also in jboss.xml, where you define your enterprise beans, you can optionally specify a custom configuration to use:

               <entity>
               <resource-ref>
               <res-ref-name>jdbc/OSnetDataSource</res-ref-name>
               <resource-name>OSnetDataSource</resource-name>
               </resource-ref>
               <ejb-name>OSnet_OrganizationEJB</ejb-name>
               <jndi-name>OSnet/Organization</jndi-name>
               <configuration-name>Custom BMP EntityBean</configuration-name>
               </entity>
              


              I actually did created this entity back in JBoss 2.4.0. I don't use BMP anymore. I was just experimenting with it so I could objectively contrast it to CMP; so the Organizations list on http://www.OpenStandards.net happens to still be in BMP today. Everything else is in CMP.

              You can copy default container configurations from server/default/conf/standardjboss.xml into your jboss.xml, rename it, and then customize it.

              Here is the standard CMP 2.x configuration from JBoss 3.2.3:

               <container-configuration>
               <container-name>Standard CMP 2.x EntityBean</container-name>
               <call-logging>false</call-logging>
               <invoker-proxy-binding-name>entity-rmi-invoker</invoker-proxy-binding-name>
               <sync-on-commit-only>false</sync-on-commit-only>
               <insert-after-ejb-post-create>false</insert-after-ejb-post-create>
               <container-interceptors>
               <interceptor>org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor</interceptor>
               <interceptor>org.jboss.ejb.plugins.LogInterceptor</interceptor>
               <interceptor>org.jboss.ejb.plugins.SecurityInterceptor</interceptor>
               <interceptor>org.jboss.ejb.plugins.TxInterceptorCMT</interceptor>
               <interceptor metricsEnabled="true">org.jboss.ejb.plugins.MetricsInterceptor</interceptor>
               <interceptor>org.jboss.ejb.plugins.EntityCreationInterceptor</interceptor>
               <interceptor>org.jboss.ejb.plugins.EntityLockInterceptor</interceptor>
               <interceptor>org.jboss.ejb.plugins.EntityInstanceInterceptor</interceptor>
               <interceptor>org.jboss.ejb.plugins.EntityReentranceInterceptor</interceptor>
               <interceptor>org.jboss.resource.connectionmanager.CachedConnectionInterceptor</interceptor>
               <interceptor>org.jboss.ejb.plugins.EntitySynchronizationInterceptor</interceptor>
               <interceptor>org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor</interceptor>
               </container-interceptors>
               <instance-pool>org.jboss.ejb.plugins.EntityInstancePool</instance-pool>
               <instance-cache>org.jboss.ejb.plugins.InvalidableEntityInstanceCache</instance-cache>
               <persistence-manager>org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager</persistence-manager>
               <locking-policy>org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock</locking-policy>
               <container-cache-conf>
               <cache-policy>org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy</cache-policy>
               <cache-policy-conf>
               <min-capacity>50</min-capacity>
               <max-capacity>1000000</max-capacity>
               <overager-period>300</overager-period>
               <max-bean-age>600</max-bean-age>
               <resizer-period>400</resizer-period>
               <max-cache-miss-period>60</max-cache-miss-period>
               <min-cache-miss-period>1</min-cache-miss-period>
               <cache-load-factor>0.75</cache-load-factor>
               </cache-policy-conf>
               </container-cache-conf>
               <container-pool-conf>
               <MaximumSize>100</MaximumSize>
               </container-pool-conf>
               <commit-option>B</commit-option>
               </container-configuration>