9 Replies Latest reply on Nov 26, 2008 6:31 AM by Ciro Cavani

    JDBMCacheLoader location property

    Ciro Cavani Novice

      I am using JBC3 GA with JDBMCacheLoader, I trying change the name of the file database as described in JavaDoc. The file name change as expected but the full location is also created as an folder.

      So:

      location=/srv/cache/#data
      


      Results:

      /srv/cache/#data (folder)
      /srv/cache/data.db
      /srv/cache/data.lg
      


      JavaDoc:

      http://www.jboss.org/file-access/default/members/jbosscache/freezone/docs/3.0.0.GA/apidocs/index.html

      My config:

      <jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
      
       <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
      
       <loaders passivation="false" shared="false">
       <preload>
       <node fqn="/"/>
       </preload>
      
       <loader
       class="org.jboss.cache.loader.jdbm.JdbmCacheLoader"
       async="false"
       fetchPersistentState="true"
       ignoreModifications="false"
       purgeOnStartup="false">
      
       <properties>location=/srv/cache/#data</properties>
      
       </loader>
       </loaders>
      
      </jbosscache>
      


      I think this is a bug. If this is duplicated or know issue, sorry. Otherwise, I can open an issue in JIRA.

      Thanks,

        • 1. Re: JDBMCacheLoader location property
          Elias Ross Master

          My bad. But on the bright side at least having an extra directory around doesn't hurt.

          • 2. Re: JDBMCacheLoader location property
            Ciro Cavani Novice

            Indeed... and the fix is pretty easy too.

            But, I get another abnormality... removing all children nodes from root using the cahe instance result in a non-empty tree in JDBM (dump() shows nodes but the cache instance, no). Even using CacheLoader directly doesn't remove everything at first. Another "bad behavior" is the file size that stay big as the latest maximum size (even after entry size return 0).

            I am using List, List of Lists and List of Maps as values.

            If someone know why, it will help a lot (and should be reported in FAQ, I think).

            Anyway, I will try evaluate this soon or later.

            Thanks,

            • 4. Re: JDBMCacheLoader location property
              Elias Ross Master

              The earlier cache loader probably should be fixed, filed as JBCACHE-1447.

              For JDBM is the size of the datafile never decreases. This may be an issue to some people but in practice it's probably okay as empty space is eventually reused.

              • 5. Re: JDBMCacheLoader location property
                Ciro Cavani Novice

                After some tests, I realize the size doesn't shrink.

                I am using cache to store results from batch processing. The data are regenerated everyday. With the "remove leak", the data file grows very quick.

                Anyway, I give a second try with H2 embedded and JDBCCacheLoader. After removing transaction support from SFSB (that operates with the cache) and doing "put" with all data map per node instead "put" with each key/value pair, the full time and total size is the same as using JDBM backend. The load time is good too.

                The H2 roadmap indicates it will improve BLOB support. After removing notes, the database doesn't shrink immediately, but after some background "cleanup" when closing database.

                The size during storage stay in a reasonable limit (I really don't have idea how 200MB of data approach 13GB in "temp").

                I will do more tests but the current results are favorable.

                P.S.: the location property bug is present in BDB JE CL start too.

                Thanks,

                • 6. Re: JDBMCacheLoader location property
                  Manik Surtani Master

                   

                  "cavani" wrote:

                  
                  <jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
                  
                   <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
                  
                   <loaders passivation="false" shared="false">
                   <preload>
                   <node fqn="/"/>
                   </preload>
                  
                   <loader
                   class="org.jboss.cache.loader.jdbm.JdbmCacheLoader"
                   async="false"
                   fetchPersistentState="true"
                   ignoreModifications="false"
                   purgeOnStartup="false">
                  
                   <properties>location=/srv/cache/#data</properties>
                  
                   </loader>
                   </loaders>
                  
                  </jbosscache>
                  



                  I'm guessing the #data bit is intended as a comment? If so, have you tried putting a space between "/srv/cache/" and the comment?


                  • 8. Re: JDBMCacheLoader location property
                    Ciro Cavani Novice

                    '#data' is a parameter of location property.

                    The expected behavior is: when there is no '#databaseName', cluster name is used for this purpose.

                    The code is just inverted.

                    At JDBMCacheLoader start method:
                    (is basically the same for BDBJE)

                     // test location
                     File location = new File(locationStr);
                     if (!location.exists())
                     {
                     boolean created = location.mkdirs();
                     if (!created) throw new IOException("Unable to create cache loader location " + location);
                    
                     }
                     if (!location.isDirectory())
                     {
                     throw new IOException("Cache loader location [" + location + "] is not a directory!");
                     }
                    
                     /* Parse config string. */
                     File homeDir;
                     int offset = locationStr.indexOf('#');
                     String cacheDbName;
                     if (offset >= 0 && offset < locationStr.length() - 1)
                     {
                     homeDir = new File(locationStr.substring(0, offset));
                     cacheDbName = locationStr.substring(offset + 1);
                     }
                     else
                     {
                     homeDir = new File(locationStr);
                     cacheDbName = cache.getClusterName();
                     }
                    


                    my suggestion:
                    ('homeDir' is unnecessary, just use 'location' where it is used)

                     /* Parse config string. */
                     int offset = locationStr.indexOf('#');
                     String cacheDbName;
                     if (offset >= 0 && offset < locationStr.length() - 1)
                     {
                     cacheDbName = locationStr.substring(offset + 1);
                     locationStr = locationStr.substring(0, offset);
                     }
                     else
                     {
                     cacheDbName = cache.getClusterName();
                     }
                    
                     // test location
                     File location = new File(locationStr);
                     if (!location.exists())
                     {
                     boolean created = location.mkdirs();
                     if (!created) throw new IOException("Unable to create cache loader location " + location);
                    
                     }
                     if (!location.isDirectory())
                     {
                     throw new IOException("Cache loader location [" + location + "] is not a directory!");
                     }
                    


                    Thanks,

                    • 9. Re: JDBMCacheLoader location property
                      Ciro Cavani Novice

                       

                      "manik.surtani@jboss.com" wrote:
                      Anyway, see <a href="JBCACHE-1448">https://jira.jboss.org/jira/browse/JBCACHE-1448</a>


                      Thr link ref doesn't work to me, but the real url works.

                      https://jira.jboss.org/jira/browse/JBCACHE-1448

                      Thanks,