From ahelsing at bbn.com Thu Feb 1 08:46:59 2007 From: ahelsing at bbn.com (Aaron Helsinger) Date: Thu, 01 Feb 2007 08:46:59 -0500 Subject: Execute works on getAddedCollection but not getChangedCollection In-Reply-To: <5E39C4594D28CB4B854E6C61FC43690A1561FF@ED.TFMT.IAC> References: <5E39C4594D28CB4B854E6C61FC43690A1561FF@ED.TFMT.IAC> Message-ID: <45C1EF53.4010309@bbn.com> The Added collection will only ever have an object _once_. In particular: When someone calls publishAdd (foo) then anyone with a matching subscription will see 'foo' on their Added Collection the next time that they execute -- and only then. After that, it is no longer on the added collection. The Changed collected will contain an object any time the object was changed -- but again, only once per change. So plugin a calls publishChange(foo) plugin B is woken up and the execute() method runs If plugin B looks, it will see 'foo' on the Changed Collection. when plugin B finishes its execute, the Changed list is cleared out. So --- make sure that you are looking each time. Also, you could try looking at the /tasks servlet or the History servlet to look for your objects to make sure that they are there and changing when you expect them to. Or you could try looking at the subscription itself, not just the added/changed lists, to see what objects are in your collection -- if you dont care whether it just was added or changed, then just do hypothesisSub.iterator() Aaron Helsinger BBN James Livingood wrote: > Hello all, > > > I?ve subscribed to the object I want: > > HypothesisSub = (IncrementalSubscription) > getBlackboardService().subscribe(HYPOTHESIS_PRED); > > > > And in my execute() I have: > > for (Iterator i = HypothesisSub.getAddedCollection().iterator(); > i.hasNext();) { > > // grabs all the information and puts it into MS SQL. > > } > > for (Iterator i = HypothesisSub.getChangedCollection().iterator(); > i.hasNext();) { > > // grab all the data AGAIN and put it into MS SQL > > } > > > > Why does the getAddedCollection run when the plugin is first started > up, but the getChangedCollection does not run when objects that I've > subscribed to change/new ones are added/etc? > > > > > > Thanks for any hints, information, things to check, etc. > > James > > ------------------------------------------------------------------------ > > _______________________________________________ > Cougaar-developers mailing list > Cougaar-developers at cougaar.org > http://cougaar.org/mailman/listinfo/cougaar-developers > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://cougaar.org/pipermail/cougaar-developers/attachments/20070201/b0b63892/attachment.html From twright at bbn.com Thu Feb 1 13:17:27 2007 From: twright at bbn.com (Todd Wright) Date: Thu, 01 Feb 2007 13:17:27 -0500 Subject: Execute works on getAddedCollection but not getChangedCollection In-Reply-To: <5E39C4594D28CB4B854E6C61FC43690A1561FF@ED.TFMT.IAC> References: <5E39C4594D28CB4B854E6C61FC43690A1561FF@ED.TFMT.IAC> Message-ID: <45C22EB7.1090503@bbn.com> Does your other plugin call "publishChange" on the object? A plugin must explicitly call "publishChange" to notify the subscribers that the object has changed. If you're calling "publishChange", what does your predicate look like? It should do a simple "instanceof" check and optionally check for immutable fields (i.e. properties you're not changing). For more information, see page 28 of the Cougaar Developers Guide: http://doc.cougaar.org Todd James Livingood wrote: > > Hello all, > > > I?ve subscribed to the object I want: > > HypothesisSub = (IncrementalSubscription) > getBlackboardService().subscribe(HYPOTHESIS_PRED); > > > > And in my execute() I have: > > for (Iterator i = HypothesisSub.getAddedCollection().iterator(); > i.hasNext();) { > > // grabs all the information and puts it into MS SQL. > > } > > for (Iterator i = HypothesisSub.getChangedCollection().iterator(); > i.hasNext();) { > > // grab all the data AGAIN and put it into MS SQL > > } > > > > Why does the getAddedCollection run when the plugin is first started up, > but the getChangedCollection does not run when objects that I've > subscribed to change/new ones are added/etc? > > > > > > Thanks for any hints, information, things to check, etc. > > James > > > ------------------------------------------------------------------------ > > _______________________________________________ > Cougaar-developers mailing list > Cougaar-developers at cougaar.org > http://cougaar.org/mailman/listinfo/cougaar-developers From ahelsing at bbn.com Fri Feb 2 09:04:52 2007 From: ahelsing at bbn.com (Aaron Helsinger) Date: Fri, 02 Feb 2007 09:04:52 -0500 Subject: Execute works on getAddedCollection but not getChangedCollection In-Reply-To: <200702021157.l12BvoV08330@zima.bbn.com> References: <200702021157.l12BvoV08330@zima.bbn.com> Message-ID: <45C34504.3090707@bbn.com> James Livingood wrote: > > Hello Aaron and Todd, > > > > If the other plugin doesn?t run publishChange(), is there still a way > to detect changes to the objects? > If no one calls publishChange, then no one knows that the object has changed. The purpose of the publishChange call is to notify plugins that something has changed -- which causes them to wake up, and their execute method to be called. This is also what puts the object on the ChangedCollection. If you do not call publishChange, then the object will not be on the ChangedCollection -- and if it is old, it also wont be on the AddedCollection. So your plugin wouldnt see it. Additionally, Subscriptions are how your plugin knows that it has work to do and should run. So if no one calls publishChange on the object, then your plugin's subscriptions will think there is nothing new for your plugin to do, so the plugin wont even run! Even if your plugin were periodically running anyway (a different subscription, or an Alarm), the only way in this case to tell that the object has changed would be to compare it with some previous memory of what the object looked like. Correct Cougaar behavior is to call publishChange on any object previously publishAdded to the Blackboard when you change it. The full Java file that you sent doesnt look at the ChangedCollection, so I assume this is a previous version. Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: http://cougaar.org/pipermail/cougaar-developers/attachments/20070202/989ed7e0/attachment.html From jlivingood at iaconline.com Fri Feb 2 12:32:46 2007 From: jlivingood at iaconline.com (James Livingood) Date: Fri, 2 Feb 2007 10:32:46 -0700 Subject: Execute works on getAddedCollection but not getChangedCollection In-Reply-To: <45C34504.3090707@bbn.com> Message-ID: <200702021732.l12HWWWx001743@cougaar.org> Hello Aaron, You are correct in assuming this is an older version. The only difference between the old and new version is that HypothesisSub.getAddedCollection().iterator(); has been changed to HypothesisSub.iterator(); to gather all objects; added or changed. I am guessing the only way to resolve this now is to create a timer and compare previous objects to new objects. (probably via their GUID) If you have any potentially useful code or suggestions, please send them my way. Otherwise I'll just proceed with the timer. Thank you VERY VERY much for helping me with this plugin. James _____ From: Aaron Helsinger [mailto:ahelsing at bbn.com] Sent: Friday, February 02, 2007 7:05 AM To: James Livingood Cc: 'Todd Wright'; 'cougaar-developers at cougaar.org' Subject: Re: Execute works on getAddedCollection but not getChangedCollection James Livingood wrote: Hello Aaron and Todd, If the other plugin doesn't run publishChange(), is there still a way to detect changes to the objects? If no one calls publishChange, then no one knows that the object has changed. The purpose of the publishChange call is to notify plugins that something has changed -- which causes them to wake up, and their execute method to be called. This is also what puts the object on the ChangedCollection. If you do not call publishChange, then the object will not be on the ChangedCollection -- and if it is old, it also wont be on the AddedCollection. So your plugin wouldnt see it. Additionally, Subscriptions are how your plugin knows that it has work to do and should run. So if no one calls publishChange on the object, then your plugin's subscriptions will think there is nothing new for your plugin to do, so the plugin wont even run! Even if your plugin were periodically running anyway (a different subscription, or an Alarm), the only way in this case to tell that the object has changed would be to compare it with some previous memory of what the object looked like. Correct Cougaar behavior is to call publishChange on any object previously publishAdded to the Blackboard when you change it. The full Java file that you sent doesnt look at the ChangedCollection, so I assume this is a previous version. Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: http://cougaar.org/pipermail/cougaar-developers/attachments/20070202/6e4825fd/attachment-0001.html