3 Replies Latest reply on Sep 25, 2006 9:29 PM by Ben Wang

    replicating pojocache

    Noam Gal Newbie

      I am using PojoCache from release 1.4SP1
      I am trying to have a map of aspectesized objects in a pojocache between two websphere 6 application servers. After some fiddling around, the tests run well from within the server, but now I bumped into a new problem -

      In my setup, ServerA starts the application on the server, sees that it is the first computer on the cache, and initializes the map, filling it with objects.
      ServerB starts the application later, and gets a pointer to the map form his own PojoCache, after it was replicated to it.
      ClientA connects to ServerA asks for a portion of the map (he sends a small list of keys, and recieves a small sub-map of key->value pairs), and everything works fine. The value object has a "getTotal()" method, which returns the right number as it should.
      ClientB connects to ServerB, with the exact same list of keys, and it recieves the same map. When I iterate over the recieved map IN THE SERVER, and just print out the "getTotal()" result, I get the right number. When I get back to the client, and do the same, all the totals are "0".

      I think I have an idea as to why this is happening - in ServerA I change the objects in memory, which causes the total field to get updated both in memory, and in the cache. After the replication to ServerB, the in-memory objects contain only "0" in their fields, but each call to a method (like "getTotal()") gets transfered to the cache, and retrieves the right number. After sending it to the client, there is no connection with the cache, and the "getTotal()" just returns the in-memory value of "0".

      Am I making sense here? Is there some way to tell the cache to fill up the in-memory objects as well in some way? Or do I have to take care of it myself?

      I would much appreciate any tip on the matter, and thank you very much.


        • 1. Re: replicating pojocache
          Ben Wang Master

          Yes, this is some limitation on PojoCache with "active" updates on all nodes as discussed previously here: http://jira.jboss.com/jira/browse/JBCACHE-674

          However, I don't see why your test would fail though since field accessor should be intercepted by PojoCache on both nodes. Can you post your code snippet?



          • 2. Re: replicating pojocache
            Noam Gal Newbie

            The interceptor works fine on both ServerA and ServerB, and getTotal returns the correct value. The problem I was having was in ClientB - In the client, the interceptor sees that the object is not connected to the cache (The private field is transient, so in the client it is null), and returns the in-memory field, which is 0.
            I overcame this problem by implementing the writeObject method. I wrote into the out stream the results of getTotal(), and not the total field. This way the serialization in the server wrote the correct values, and my client sees the right number.

            • 3. Re: replicating pojocache
              Ben Wang Master

              Well, if it is transient field, then you should initialize it anyway, shouldn't you? :-)