-
1. Re: Replication doesn't work even with the sample code provi
manik Oct 11, 2006 11:47 AM (in response to mitra123)Does JGroups work in the first place?
See:
http://www.jgroups.org/javagroupsnew/docs/newuser/node6.html
and
http://wiki.jboss.org/wiki/Wiki.jsp?page=JGroups -
2. Re: Replication doesn't work even with the sample code provi
mitra123 Oct 11, 2006 2:03 PM (in response to mitra123)Hi,
jgroups.jar is by default included in the \lib of jbosscache download and it is included in the class path of the project I am running.
Is this enough? -
3. Re: Replication doesn't work even with the sample code provi
malek256 Oct 11, 2006 3:07 PM (in response to mitra123)We note that replication occurs if you remove and then perform a putObject, but not otherwise
That is, the following pseudo-code illustrates a pattern which returns the modified data
MyObject myObject = new MyObject();
myObject.SetValue("0");
cache1_.putObject("/key/", myObject);
myObject = cache1_.getObject("/key/");
myObject.SetValue("1");
myObject2 = cache2_.getObject("/key/");
// myObject2.GetValue returns 0
cache1_.remove("/key/");
cache1_.putObject("/key/", myObject);
myObject2 = cache2_.getObject("/key/");
// myObject2.GetValue returns 1 -
4. Re: Replication doesn't work even with the sample code provi
brian.stansberry Oct 11, 2006 3:18 PM (in response to mitra123)Has the MyObject class been instrumented (aka aspectized) for use in PojoCache?
-
5. Re: Replication doesn't work even with the sample code provi
malek256 Oct 11, 2006 4:01 PM (in response to mitra123)I can check - but can you explain why that would allow for communication after a remove/put and when the cache is created but not when it is altered?
Does the aspectizing insert hooks within the get/sets for triggers? I apologize for asking what's probably an obvious question - I am learning as we proceed. -
6. Re: Replication doesn't work even with the sample code provi
brian.stansberry Oct 11, 2006 4:40 PM (in response to mitra123)Yes, aspectizing is what makes it possible for the cache to detect changes in the object. (It actually detects changes in internal fields rather than getter/setter invocations.) Without this the cache has no idea the object has changed and needs to be replicated, unless you call putObject() again.
In your pseudo-code, the remove() call should be unnecessary. The second call to putObject should have been enough to cause the data to replicate.
See http://www.onjava.com/pub/a/onjava/2005/11/09/jboss-pojo-cache.html for a general discussion of PojoCache vs. plain TreeCache. -
7. Re: Replication doesn't work even with the sample code provi
malek256 Oct 11, 2006 5:05 PM (in response to mitra123)Thanks for the explanation - I do see the content within the jboss-aop.xml file, so this should be functional.
'myObject' is a contrived example for illustration - in fact, we are using code based upon the sample PojoCache which uses the Student, Person, Course, etc.
Without the remove(), the replication does not occur. It must have a remove then a putObject. -
8. Re: Replication doesn't work even with the sample code provi
brian.stansberry Oct 11, 2006 5:12 PM (in response to mitra123)Having a jboss-aop.xml file isn't enough; you have to aspectize your classes. The readme.txt files in the examples discuss how to do this.
I'll bug Ben Wang about the need to call removeObject() before a second putObject() if you haven't aspectized the class -- shouldn't be that way. -
9. Re: Replication doesn't work even with the sample code provi
malek256 Oct 12, 2006 11:04 AM (in response to mitra123)Yes, it is aspectized - but not really :)
The missing piece of the puzzle's looks to be located. Running the files via run.aop.example is functional.
We are running this within Eclipse. There it is only semi-functional.
We aspectized that source externally and are only referencing it's classes but I hypothesize the configuration is such that eclipse detects the .class change done outside of its control and is overwriting the aspectized class. -
10. Re: Replication doesn't work even with the sample code provi
sambitd Nov 13, 2006 7:27 PM (in response to mitra123)Hi,
Im getting the same problem here while trying to replicate pojo cache. It expects remove method to be called before putObject for replication to work properly. I'm wondering if it is mandatory to use remove method before putObject always. Using this approach we have encountered a trivial issue some thing as below. Lets say there are 2 threads running in two cache nodes. One thread is updating the cache while the other is reading the cache. Since the first thread calls remove method before putting objects into cache, at times the second thread gets null object for the same key. Do we need to handle this using transaction of jboss cache automatically handles it by any configuration.