Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF / CDO Transaction conflict
EMF / CDO Transaction conflict [message #878555] Tue, 29 May 2012 14:16 Go to next message
Bernard Sarter is currently offline Bernard SarterFriend
Messages: 88
Registered: August 2011
Location: Paris, France
Member
Hi,

I have a CDO client that opens a transaction and commits periodically (eg. every 5 secs) all changes.

Under some (rare) circumstances, the same attribute of an object may have changed twice during this time interval. In that case, it seems that CDO raises a CommitException saying that there is a conflict (at least, this is my understanding).

My need would be to silently ignore all intermediate changes and just commit the final value (see example below).

T0   V=1 * COMMIT#1, V=1
T0+2 V=2
T0+4 V=3
T0+5     * COMMIT#2, V=3
T0+6 V=4 ...


Is that possible ? I saw that it is possible to add a ConflictResolver to a Transaction, but I'm lacking of an example for my use case.

I'm using Juno RC2, CDO 4.1.0.

Any support welcome,

Thanks and best regards,
Bernard.
Re: EMF / CDO Transaction conflict [message #878625 is a reply to message #878555] Tue, 29 May 2012 16:10 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 29.05.2012 16:16, schrieb Bernard SARTER:
> Hi,
>
> I have a CDO client that opens a transaction and commits periodically (eg. every 5 secs) all changes.
The changes and the commits all happen from within the same client thread?

>
> Under some (rare) circumstances, the same attribute of an object may have changed twice during this time interval.
That's something quite normal and shouldn't lead to exceptions.

> In that case, it seems that CDO raises a CommitException saying that there is a conflict (at least, this is my
> understanding).
Where is the stack trace?

Conflicts should only occur if more than one CDOTransaction are active at a time and committing.

>
> My need would be to silently ignore all intermediate changes and just commit the final value (see example below).
>
>
> T0 V=1 * COMMIT#1, V=1
> T0+2 V=2
> T0+4 V=3
> T0+5 * COMMIT#2, V=3
> T0+6 V=4 ...
>
>
> Is that possible ?
That's how it's working.

> I saw that it is possible to add a ConflictResolver to a Transaction, but I'm lacking of an example for my use case.
Let's first find out what exactly is happening.

Cheers
/Eike

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


>
> I'm using Juno RC2, CDO 4.1.0.
>
> Any support welcome,
>
> Thanks and best regards,
> Bernard.
>


Re: EMF / CDO Transaction conflict [message #878898 is a reply to message #878625] Wed, 30 May 2012 06:48 Go to previous messageGo to next message
Bernard Sarter is currently offline Bernard SarterFriend
Messages: 88
Registered: August 2011
Location: Paris, France
Member
Hello Eike,

Thanks for your quick and detailed reply.

I'm now a bit puzzled, and will add more traces in my code to better see what's actually going on and let you know about my finding.

Regards,
Bernard.
Re: EMF / CDO Transaction conflict [message #879417 is a reply to message #878898] Thu, 31 May 2012 07:32 Go to previous messageGo to next message
Bernard Sarter is currently offline Bernard SarterFriend
Messages: 88
Registered: August 2011
Location: Paris, France
Member

Ok ... I understood the problem.

Immediately after the
T0+5 * COMMIT#2, V=3
there are two distinct clients that start both the same computation and want both to commit the same result. This leads to a conflict, properly detected by CDO. Great. (Sorry, I wasn't aware about that, being not the only guy in charge of the application).

So, now I'm back to my initial concern: how to silently manage this conflict ? (I would need something very simple (in my case, both clients try to commit the same value, so it doesn't matter who wins, but I'm lacking of examples or snippets that would show how CDO conflict management actually works).

Could you provide me with some hints or redirect me to some examples ?

Thanks,
Bernard.
Re: EMF / CDO Transaction conflict [message #879682 is a reply to message #879417] Thu, 31 May 2012 16:19 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 31.05.2012 09:32, schrieb Bernard SARTER:
>
> Ok ... I understood the problem.
>
> Immediately after the T0+5 * COMMIT#2, V=3
> there are two distinct clients that start both the same computation and want both to commit the same result. This
> leads to a conflict, properly detected by CDO. Great. (Sorry, I wasn't aware about that, being not the only guy in
> charge of the application).
>
> So, now I'm back to my initial concern: how to silently manage this conflict ? (I would need something very simple (in
> my case, both clients try to commit the same value, so it doesn't matter who wins, but I'm lacking of examples or
> snippets that would show how CDO conflict management actually works).
In that case the easiest thing would be to rollback the second transaction and, optionally, do the modifications+commit
again. In many cases you can detect the conflict situation in the second client even before you commit by listening for
CDOTransactionConflictEvents.

You can also call CDOTransaction.options().addConflictResolver() and see if one of the classes implementing
CDOConflictResolver suits your needs.

>
> Could you provide me with some hints or redirect me to some examples ?
If you install the tests and follow back the callers of CDOTransaction.options().addConflictResolver() you'll find a
dozen code examples.

Cheers
/Eike

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


Previous Topic:XMI to java objects
Next Topic:EMF Framework Validation
Goto Forum:
  


Current Time: Fri Apr 26 12:00:11 GMT 2024

Powered by FUDForum. Page generated in 0.02713 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top