Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] ObjectNotFoundExceptions and StaleReferencePolicies : best practices
[CDO] ObjectNotFoundExceptions and StaleReferencePolicies : best practices [message #702298] Tue, 26 July 2011 03:37 Go to next message
Alex Lagarde is currently offline Alex Lagarde
Messages: 124
Registered: May 2010
Senior Member

Hi everyone !

I'm trying to determine the best solution for an issue I've faced while
using CDO :

in a part of my code that is not CDO-dependant, I've got listeners that
access model elements in order to do their jobs.

But if a CDO element is being deleted by a remote user and one of my
listeners is running, when calling deletedElement.eResource() I
get an ObjectNotFoundException (which is totally normal : my element has
just been deleted by some remote user).

I cannot do much : once the element is deleted, I unregister my
listener, but I cannot do anything if it is running.

I've took a look at CDOStaleReferencePolicies, which seem to do exactly
what I want : by providing my own StaleReferencePolicy, I can react to
stale references by returning default values (e.g. an empty list if
trying to access my deleted element's adapters), and avoid throwing
ObjectNotFoundExceptions.

But I'm not sure that is a clean solution : do you think providing such
a custom StalePolicy can cause other issues ? I don't think I have much
choice here...

Thanks a lot !
Alex
Re: [CDO] ObjectNotFoundExceptions and StaleReferencePolicies : best practices [message #702306 is a reply to message #702298] Tue, 26 July 2011 03:48 Go to previous messageGo to next message
Eike Stepper is currently offline Eike Stepper
Messages: 5151
Registered: July 2009
Senior Member
Am 26.07.2011 09:37, schrieb Alex Lagarde:
> Hi everyone !
>
> I'm trying to determine the best solution for an issue I've faced while using CDO :
>
> in a part of my code that is not CDO-dependant, I've got listeners that access model elements in order to do their jobs.
>
> But if a CDO element is being deleted by a remote user and one of my listeners is running, when calling deletedElement.eResource() I
> get an ObjectNotFoundException (which is totally normal : my element has just been deleted by some remote user).
>
> I cannot do much : once the element is deleted, I unregister my listener, but I cannot do anything if it is running.
>
> I've took a look at CDOStaleReferencePolicies, which seem to do exactly what I want : by providing my own StaleReferencePolicy, I can react to stale references by returning default values (e.g. an empty list if trying to access my deleted element's adapters), and avoid throwing ObjectNotFoundExceptions.
>
> But I'm not sure that is a clean solution : do you think providing such a custom StalePolicy can cause other issues ? I don't think I have much choice here...
CDOStaleReferencePolicies have been made for this purpose. Another solution would be to disable passive updates altogether and explicitely refresh the CDOSession at times of your convenience. Then you can cleanup your application after each refresh() call.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: [CDO] ObjectNotFoundExceptions and StaleReferencePolicies : best practices [message #702319 is a reply to message #702306] Tue, 26 July 2011 03:59 Go to previous messageGo to next message
Alex Lagarde is currently offline Alex Lagarde
Messages: 124
Registered: May 2010
Senior Member

> CDOStaleReferencePolicies have been made for this purpose. Another
> solution would be to disable passive updates altogether and explicitely
> refresh the CDOSession at times of your convenience. Then you can
> cleanup your application after each refresh() call.

Yeah that would be the best, but I really need to be notified in
real-time of all remote modifications.

Thanks a lot for your fast reply, and thanks for your fix on the
https://bugs.eclipse.org/bugs/show_bug.cgi?id=353076 issue, I never saw
a fix as quicly made (less that half and hour :) ).

Cheers,
Alex
Re: [CDO] ObjectNotFoundExceptions and StaleReferencePolicies : best practices [message #831508 is a reply to message #702298] Wed, 28 March 2012 21:23 Go to previous messageGo to next message
Scott Dybiec is currently offline Scott Dybiec
Messages: 67
Registered: July 2009
Member
Alex,

I'm encountering this same issue and have been reading this forum and
the newsgroup for solutions.
In this post

http://www.eclipse.org/forums/index.php/mv/msg/197340/629963/

you say: "Following Eike Stepper's idea, I use an other Session, defined
with the same connector, for getting all CDOSessionInvalidationEvent and
refresh properly the changed elements."

Which you also describe here:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=329777

Was there ever any sample code or test cases posted of how you
implemented this two session solution for this problem?

$cott

On 7/26/2011 3:37 AM, Alex Lagarde wrote:
> Hi everyone !
>
> I'm trying to determine the best solution for an issue I've faced while
> using CDO :
>
> in a part of my code that is not CDO-dependant, I've got listeners that
> access model elements in order to do their jobs.
>
> But if a CDO element is being deleted by a remote user and one of my
> listeners is running, when calling deletedElement.eResource() I
> get an ObjectNotFoundException (which is totally normal : my element has
> just been deleted by some remote user).
>
> I cannot do much : once the element is deleted, I unregister my
> listener, but I cannot do anything if it is running.
>
> I've took a look at CDOStaleReferencePolicies, which seem to do exactly
> what I want : by providing my own StaleReferencePolicy, I can react to
> stale references by returning default values (e.g. an empty list if
> trying to access my deleted element's adapters), and avoid throwing
> ObjectNotFoundExceptions.
>
> But I'm not sure that is a clean solution : do you think providing such
> a custom StalePolicy can cause other issues ? I don't think I have much
> choice here...
>
> Thanks a lot !
> Alex
>
Re: [CDO] ObjectNotFoundExceptions and StaleReferencePolicies : best practices [message #835434 is a reply to message #831508] Tue, 03 April 2012 03:47 Go to previous messageGo to next message
Alex Lagarde is currently offline Alex Lagarde
Messages: 124
Registered: May 2010
Senior Member

Hi Scott,

for performance and political reasons, we decided to use only one
session instead of two, so I don't have any code to provide.


However, it is quite straightfoward : create on session with passive
update mode disabled, create another with passive update mode enabled
with a ISessionListener notified of any commit and refreshing the first
session.

Let me know if you have any issue or need for a more detailed answer.

Best Regards,
Alex
Re: [CDO] ObjectNotFoundExceptions and StaleReferencePolicies : best practices [message #835595 is a reply to message #835434] Tue, 03 April 2012 08:45 Go to previous messageGo to next message
Scott Dybiec is currently offline Scott Dybiec
Messages: 67
Registered: July 2009
Member
Thanks, Alex. I'll give it a go.

On 4/3/2012 3:47 AM, Alex Lagarde wrote:
> Hi Scott,
>
> for performance and political reasons, we decided to use only one
> session instead of two, so I don't have any code to provide.
>
>
> However, it is quite straightfoward : create on session with passive
> update mode disabled, create another with passive update mode enabled
> with a ISessionListener notified of any commit and refreshing the first
> session.
>
> Let me know if you have any issue or need for a more detailed answer.
>
> Best Regards,
> Alex
Re: [CDO] ObjectNotFoundExceptions and StaleReferencePolicies : best practices [message #836480 is a reply to message #702298] Wed, 04 April 2012 10:29 Go to previous message
Eike Stepper is currently offline Eike Stepper
Messages: 5151
Registered: July 2009
Senior Member
Guys,

Please note that I recently (CDO 4.1!) applied some smaller fixes that can have a big positive impact:

374962: Make CDOStaleReferencePolicy.PROXY robust for eAdapters() calls
https://bugs.eclipse.org/bugs/show_bug.cgi?id=374962

374965: Make detachment notifications configurable
https://bugs.eclipse.org/bugs/show_bug.cgi?id=374965

375033: Remote notifications must be ignored in CDOPostEventTransactionHandler
https://bugs.eclipse.org/bugs/show_bug.cgi?id=375033

375034: Consolidate server-side exceptions for commit conflicts
https://bugs.eclipse.org/bugs/show_bug.cgi?id=375034

376067: CDOFeatureDelta.UNKNOWN_VALUE is not a Notifier
https://bugs.eclipse.org/bugs/show_bug.cgi?id=376067

Give next Friday's I-build a try. I'm also starting to backport these fixes to 4.0 now...

You should play with CDO's InvalidationPolicies and StaleReferencePolicies, e.g.,

CDOView.Options options = view.options();
options.setStaleReferencePolicy(CDOStaleReferencePolicy.PROXY);
options.setInvalidationPolicy(CDOInvalidationPolicy.RELAXED);

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Am 26.07.2011 09:37, schrieb Alex Lagarde:
> Hi everyone !
>
> I'm trying to determine the best solution for an issue I've faced while using CDO :
>
> in a part of my code that is not CDO-dependant, I've got listeners that access model elements in order to do their jobs.
>
> But if a CDO element is being deleted by a remote user and one of my listeners is running, when calling
> deletedElement.eResource() I
> get an ObjectNotFoundException (which is totally normal : my element has just been deleted by some remote user).
>
> I cannot do much : once the element is deleted, I unregister my listener, but I cannot do anything if it is running.
>
> I've took a look at CDOStaleReferencePolicies, which seem to do exactly what I want : by providing my own
> StaleReferencePolicy, I can react to stale references by returning default values (e.g. an empty list if trying to
> access my deleted element's adapters), and avoid throwing ObjectNotFoundExceptions.
>
> But I'm not sure that is a clean solution : do you think providing such a custom StalePolicy can cause other issues ?
> I don't think I have much choice here...
>
> Thanks a lot !
> Alex
>
Previous Topic:Importing rose(.mdl) files and converting to xsd
Next Topic:Creating then Saving really large EMF models
Goto Forum:
  


Current Time: Mon May 20 08:37:50 EDT 2013

Powered by FUDForum. Page generated in 0.02832 seconds