8 Replies Latest reply on Jan 2, 2007 2:50 AM by ben.wang

    FileCacheLoader partial preload

    emailmsgbox

      I?m using JBossCache-1.4.1.BETA and caching an object that contains some primitive fields, strings and a Map

      I use the following FileCacheLoader configuration

       <passivation>false</passivation>
       <preload>/</preload>
       <shared>false</shared>
      
       <cacheloader>
       <class>org.jboss.cache.loader.FileCacheLoader</class>
       <properties>location=/confCacheFile</properties>
       <async>false</async>
       <fetchPersistentState>true</fetchPersistentState>
       <ignoreModifications>false</ignoreModifications>
       <purgeOnStartup>false</purgeOnStartup>
       </cacheloader>
      
      


      I kill the JBoss and bring it back up again.
      I can re-access the object it?s fields .
      The Map however has a strange behavior: it is not null

      myObj.size() = 0
      myObj.values() is empty
      myObj.keySet () is empty
      
      But
      
      myObj.get(aKey) returns the entry
      
      


      How can I get myObj.values() to work ?



        • 1. Re: FileCacheLoader partial preload
          emailmsgbox

          the same goes for an ArrayList


          
          myArrayList.size() = 0;
          myArrayList.toArray() is an empty ArrayList
          
          but
          myArrayList.get(0) returns an Object
          
          


          why?

          • 2. Re: FileCacheLoader partial preload
            brian.stansberry

            Are you using PojoCache here? I assume yes, but you don't say this.

            • 3. Re: FileCacheLoader partial preload
              emailmsgbox

              I'm using POJO cache

              this is a test code

              @PojoCacheable
              public class TestData implements Serializable {
               Map<Integer,TestKukuData> kukuMap = new HashMap<Integer,TestKukuData>();
               String myStr;
               int myInt;
               public TestData() { }
               public TestData(String myStr, int myInt) {
               this.myStr = myStr;
               this.myInt = myInt;
               }
               public Map<Integer, TestKukuData> getKukuMap() {
               return kukuMap;
               }
               public void setKukuMap(Map<Integer, TestKukuData> kukuMap) {
               this.kukuMap = kukuMap;
               }
              
              }


              PojoCacheable
              public class TestKukuData implements Serializable {
               String id;
               int miInt;
              
               public TestKukuData() { }
               public TestKukuData(String id, int miInt) {
               this.id = id;
               this.miInt = miInt;
               }
              
               public String getId() {
               return id;
               }
              
               public void setId(String id) {
               this.id = id;
               }
              
              }
              


               public class MYCache {
               final static Fqn TEST = Fqn.fromString("/kuku/test");
               static PojoCacheIfc myCache;
              ....
              
               public static TestData setTest(Integer id, TestData data){
              
               return (TestData)myCache.putObject(new Fqn(TEST,id),data);
               }
               public static TestData getTest(Integer id){
              
               return (TestData)myCache.getObject(new Fqn(TEST,id));
               }
              
              



              
              class MainTest{
               public void do(){
               int id = 1234
               TestData tData = MYCache.getTest(id);
               if(tData == null){
               TestData data = new TestData("TestData",1);
               data.getKukuMap().put(new Integer(11),new TestKukuData("kukuID1",1+id));
               data.getKukuMap().put(new Integer(22),new TestKukuData("kukuID2",2+id));
              
               MYCache.setTest(id,data);
              
               }
               else{
               int size = tData.getKukuMap.size();
               Collection c = tData.getKukuMap.values() ;
               TestKukuData kuku = (TestKukuData )ttData.getKukuMap.getObject(11)
               }
              
              
              
              
              }
              


              I run this twice
              first time I load the cache , then I restart Jboss
              the second time size is 0 and the collection is empty

              but kuku is with the right value
              what am I missing ?

              • 4. Re: FileCacheLoader partial preload
                brian.stansberry

                This sounds like a bug. Can you create a test case from this and open a JIRA?

                • 5. Re: FileCacheLoader partial preload
                  emailmsgbox

                  where and and how do I open a JIRA?

                  • 6. Re: FileCacheLoader partial preload
                    brian.stansberry

                    http://jira.jboss.com. "Create New Issue" link. Choose the JBoss Cache project from the pull down.[/url]

                    • 7. Re: FileCacheLoader partial preload
                      emailmsgbox
                      • 8. Re: FileCacheLoader partial preload

                        Should have this fixed in post 1.4.1.CR1. Please check it out.