7 Replies Latest reply on Aug 28, 2012 9:17 PM by Brian Wallis

    AS7 string-keyed-jdbc-store configuration

    Brian Wallis Master

      I don't seem to be able to get my infinispan cache configuration working with a JDBC cache loader.

       

      I'm running JDK 1.6.0_33 on Mac OSX 10.6 with JBoss AS 7.1.1.Final and Infinispan 5.1.2 as bundled with jboss.

       

      A simple configuration I have tried is

       

       

      {code}

                  <cache-container name="modeshapeCache" default-cache="default">

                      <local-cache name="testRepositoryCache">

                          <transaction mode="FULL_XA"/>

                          <string-keyed-jdbc-store datasource="java:jboss/datasources/JcrDataDS"/>

                      </local-cache>

                  </cache-container>

      {code}

       

      I have the following code in a stateless session bean

       

      {code}

      @Resource(name = "java:jboss/infinispan/container/modeshapeCache")

                private EmbeddedCacheManager container;

       

      ...

       

        this.cache = this.container.getCache("testRepositoryCache");

       

      ...

       

        Configuration cacheConfiguration = this.cache.getCacheConfiguration();

        log.info("Cache Configuration = "+cacheConfiguration);

        TransactionManager txm = this.cache.getAdvancedCache().getTransactionManager();

        log.info("Transaction Manager = "+txm);

      {code}

       

      Which outputs the following:

       

      {code}

      18:21:42,565 INFO  [au.com.infomedix.jcrloadtest.jcrserver.restapi.TestCacheBean] (http-localhost-127.0.0.1-8080-1) Cache Configuration = Configuration{classLoader=ModuleClassLoader for Module "deployment.JcrServer.war:main" from Service Module Loader, clustering=ClusteringConfiguration{async=AsyncConfiguration{asyncMarshalling=false, replicationQueue=org.infinispan.remoting.ReplicationQueueImpl@532eb0b3, replicationQueueInterval=5000, replicationQueueMaxElements=1000, useReplicationQueue=false}, cacheMode=LOCAL, hash=HashConfiguration{activated=false, consistentHash=null, hash=org.infinispan.commons.hash.MurmurHash3@1e52e26f, numOwners=2, numVirtualNodes=48, groupsConfiguration=GroupsConfiguration{enabled=false, groupers=[]}, stateTransferConfiguration=StateTransferConfiguration{chunkSize=10000, fetchInMemoryState=false, originalFetchInMemoryState=false, timeout=240000}}, l1=L1Configuration{activated=true, enabled=false, invalidationThreshold=0, lifespan=600000, onRehash=false}, stateTransfer=StateTransferConfiguration{chunkSize=10000, fetchInMemoryState=false, originalFetchInMemoryState=false, timeout=240000}, sync=SyncConfiguration{replTimeout=15000}}, customInterceptors=CustomInterceptorsConfiguration{interceptors=[]}, dataContainer=DataContainerConfiguration{dataContainer=null}, deadlockDetection=DeadlockDetectionConfiguration{enabled=false, spinDuration=100}, eviction=EvictionConfiguration{maxEntries=-1, strategy=NONE, threadPolicy=DEFAULT}, expiration=ExpirationConfiguration{lifespan=-1, maxIdle=-1, reaperEnabled=true, wakeUpInterval=60000}, indexing=IndexingConfiguration{enabled=false, indexLocalOnly=false}, invocationBatching=InvocationBatchingConfiguration{enabled=false}, jmxStatistics=JMXStatisticsConfiguration{enabled=false}, loaders=LoadersConfiguration{cacheLoaders=[], passivation=false, preload=false, shared=false}, locking=LockingConfiguration{concurrencyLevel=32, isolationLevel=READ_COMMITTED, lockAcquisitionTimeout=10000, useLockStriping=false, writeSkewCheck=false}, storeAsBinary=StoreAsBinaryConfiguration{enabled=false, storeKeysAsBinary=true, storeValuesAsBinary=true}, transaction=TransactionConfiguration{autoCommit=true, cacheStopTimeout=30000, eagerLockingSingleNode=false, lockingMode=OPTIMISTIC, syncCommitPhase=true, syncRollbackPhase=false, transactionManagerLookup=org.infinispan.transaction.lookup.GenericTransactionManagerLookup@538ff4f6, transactionSynchronizationRegistryLookup=null, transactionMode=NON_TRANSACTIONAL, useEagerLocking=false, useSynchronization=false, recovery=RecoveryConfiguration{enabled=false, recoveryInfoCacheName='__recoveryInfoCacheName__'}, use1PcForAutoCommitTransactions=false}, versioning=VersioningConfiguration{enabled=false, scheme=NONE}, unsafe=UnsafeConfiguration{unreliableReturnValues=false}}

      18:21:42,571 INFO  [au.com.infomedix.jcrloadtest.jcrserver.restapi.TestCacheBean] (http-localhost-127.0.0.1-8080-1) Transaction Manager = null

      {code}

       

      If I remove the string-keyed-jdbc-store configuration then I get a non-null transaction manager.

       

      The example given is a simplified version of attemtpting to use jdbc persistence of an infinispan cache for modeshape which is crashing with a null pointer exception when it attempts to use the transaction manager.

       

      I haven't managed to find much documentation about how to configure this beyond what is in the XSD file jboss-as-infinispan_1_2.xsd.

       

      Any help in getting this configured correctly would be most appreciated.

        • 1. Re: AS7 string-keyed-jdbc-store configuration
          Tristan Tarrant Master

          Hi Brian,

           

          it appears that when you add the <string-keyed-jdbc-store datasource="java:jboss/datasources/JcrDataDS"/> element to your cache, the cache definition itself becomes invalid and your application is instead "served" a default cache: if you check the Cache Configuration you'll see it's missing everything.

          Is the datasource working ? Any logs in the AS standalone.log file ?

           

          Tristan

          • 2. Re: AS7 string-keyed-jdbc-store configuration
            Brian Wallis Master

            Hi Tristan, you have described exactly what I am seeing.

             

            The datasource can be injected into my test app and used so it seems to be ok.

             

            There is nothing in the logs to indicate any error and i have looked through the debug logging for any mentions of infinispan and can find nothing that indicates any errors. It is curious that the definition does seem to become invalid but there is no error logging produced when this happens or even any debug logging.

             

            thanks

            • 3. Re: AS7 string-keyed-jdbc-store configuration
              Brian Wallis Master

              Hmm. Got it to work by removing the leading "java:" from the datasource name.

               

              Now I have a new issue which I think is the problem described in https://jira.jboss.org/browse/ISPN-604 and so has me stumped again. If I understand that ticket correctly there is a work around for this issue in 5.1.5 or 5.2.0 but AS 7.1.1.Final is using 5.1.2 of infinispan and EAP6 is using 5.1.4.

               

              Of course, the original problem is still a bug, either the jdbc cache loader should accept the jndi name with the "java:" on the front or it should log an error, not just ignore the whole thing.

               


              • 4. Re: AS7 string-keyed-jdbc-store configuration
                Paul Ferraro Master

                Actually, that is not a bug.  The value specified by the datasource attribute is not the jndi-name, but rather the pool-name of the datasource as specified in the datasources subsystem.

                e.g.

                 

                {code:xml}<string-keyed-jdbc-store datasource="ExampleDS"/>{code}

                • 5. Re: AS7 string-keyed-jdbc-store configuration
                  Brian Wallis Master

                  Hi Paul,

                    That is not the behaviour I am seeing.

                   

                  If I use the pool name from my datasource then my named cache disappears again and when I call getCache('testRepositoryCache") I get a default configured cache without the JDBC cache loader.

                   

                  My datasource config is:

                   

                  {code}

                      <datasource jndi-name="java:jboss/datasources/JcrDataDS" enabled="true" use-java-context="true" pool-name="JcrData">

                          <connection-url>jdbc:postgresql:jcr_data</connection-url>

                          <driver>postgresql-9.1-901.jdbc4.jar</driver>

                          <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>

                          <pool>

                              <max-pool-size>15</max-pool-size>

                              <min-pool-size>3</min-pool-size>

                              <prefill>true</prefill>

                          </pool>

                          <security>

                              <user-name>xxx</user-name>

                              <password>xxxx</password>

                          </security>

                          <validation>

                              <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker" />

                              <background-validation>false</background-validation>

                              <validate-on-match>true</validate-on-match>

                              <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter" />

                          </validation>

                          <timeout>

                              <idle-timeout-minutes>15</idle-timeout-minutes>

                              <blocking-timeout-millis>60000</blocking-timeout-millis>

                          </timeout>

                      </datasource>

                  {code}

                  My working cache container is

                   

                  {code}

                              <cache-container name="modeshapeCache" default-cache="default">

                                  <local-cache name="testRepositoryCache">

                                      <transaction mode="FULL_XA"/>

                                      <string-keyed-jdbc-store datasource="jboss/datasources/JcrDataDS" preload="false" passivation="false" purge="false">

                                          <property name="databaseType">

                                              postgres

                                          </property>

                                          <property name="createTableOnStart">

                                              true

                                          </property>

                                          <string-keyed-table prefix="stringbased">

                                              <id-column name="id" type="VARCHAR(200)"/>

                                              <data-column name="datum" type="BYTEA"/>

                                              <timestamp-column name="version" type="BIGINT"/>

                                          </string-keyed-table>

                                      </string-keyed-jdbc-store>

                                  </local-cache>

                              </cache-container>

                  {code}

                  If I replace "jboss/datasources/JcrDataDS" with "JcrData" (the pool name) then it stops working and I get the default cache instead of the one as configured above.

                   

                  In any case, when the name is not found there should be an error logged, the system shouldn't just ignore the cache declaration with out any indication that it has done so.

                  • 6. Re: AS7 string-keyed-jdbc-store configuration
                    Paul Ferraro Master

                    I see.  Thanks for the clarification.  Can you log an AS7 jira for this?  Thanks.

                    • 7. Re: AS7 string-keyed-jdbc-store configuration
                      Brian Wallis Master

                      Jira created (a few days ago, forgot to update this post)