3 Replies Latest reply on Feb 9, 2006 7:57 AM by Jerry Gauthier

    CacheLoader transactions

    Jerry Gauthier Apprentice

      I need to count various cache loader operations (e.g., stores) that are committed within transactions. The operations are passed to the cache loader via a prepare(List) method. I can't "count" the operations at this point since they haven't been committed.

      Subsequently I can detect that the cache loader is being invoked to commit the transaction containing the accumulated operations. But it doesn't look like I can access the list being committed so that I can determine how many operations it contains.

      Assuming I'm not overlooking anything here, I have the following options.

      1) Just count the operations when they are added to the list (i.e., before commit). The activation interceptor sends out activation notifications at this point rather than waiting for commit so this would be similar.

      2) Count the commit as a single operation instead of counting individual operations within it. (This doesn't seem reasonable.)

      3) Add a method to the cache loader interface (and potentially all cache loader implementations) to allow callers to retrieve its modifications list (read only)

      4) Count the operations during the prepare phase, store the count with a correlating key, and retrieve this data when the transaction is committed or rolled back (assuming a transaction contains some unique identifier or that one can be inserted into it)

      Any suggestions?

        • 1. Re: CacheLoader transactions
          Jerry Gauthier Apprentice

          This may be a non-issue for the ActivationInterceptor. Since transactions are only handled by JBossCache on remote nodes and evictions are never forwarded to remote nodes, it looks like the transaction code in the ActivationInterceptor will never be executed. I've tried various operations using transactions (inserts, removals, evictions) in a cluster and the interceptor's transaction code never seems to be invoked.

          • 2. Re: CacheLoader transactions
            Manik Surtani Master

            1) This is a possibility, although if the transaction doesn't commit should we count this? Then again, depending on the CacheLoader implementation, maybe we should count this - JDBC cache loaders actually make JDBC calls during the prepare phase, and then call a commit() on the JDBC connection when cacheloader.commit() is called. So these operations should really be counted.

            2) You're right, this is not reasonable.

            3) Hmm, don't like this - will break a lot of custom CacheLoaders out there.

            4) Again a possibility.

            • 3. Re: CacheLoader transactions
              Jerry Gauthier Apprentice

              Implemented in ActivationInterceptor and CacheStoreInterceptor using option 4 (counting in prepare phase, retrieving count and incrementing statistic during commit phase)