Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Converting existing code to use CDO and the transaction API
[CDO] Converting existing code to use CDO and the transaction API [message #1690512] Fri, 27 March 2015 17:32 Go to next message
Simon Goodall is currently offline Simon GoodallFriend
Messages: 35
Registered: July 2009
Member
Hi,

I am looking to change our application to use CDO from .xmi files and have a few questions on how to implement the change correctly. (Note I have not converted my data models to extend CDOObject and using CDO 4.3).

Some background: Each of our data files are stored in an .xmi file and are (currently) self contained. We also have another EMF model representing the logic organisation of data files and stores transient references to the loaded data model instances. When a data file is created or deleted, a corresponding element is created or removed in the logical data model. When a data file is loaded, the transient reference is set.

Currently each data file and the logical model are loaded into separate ResourceSets, each with their own command stack and can be saved independently.

Now I have configured an embedded CDO server in my rcp product. I create a single session instance. For my logical model I call session.openTransaction() and call transaction.commit() in an EContentAdapter whenever a change to the model is made.

For my data files, I again call session.openTransaction(), then transaction.getOrCreateResource() to obtain a resource. When I save I call resource.save() and transaction.commit(). Transactions are closed when I unload the resource. To delete a data file, I first unload (and close any previous transaction) and create a new transaction and get a resource by transaction.getResource() followed by resource.delete() & transaction.commit().

Is this the correct way to use the API? I am currently seeing various problems when running with the above model. When I set ENSURE_REFERENTIAL_INTEGRITY to true, I get lots of commit timeouts. When it is false, I end up with CDO stale reference exceptions, even after restarting the application (including CDO server).

Please let me know if you need more detail anywhere.

Thanks,

Simon
Re: [CDO] Converting existing code to use CDO and the transaction API [message #1690653 is a reply to message #1690512] Mon, 30 March 2015 12:11 Go to previous messageGo to next message
Simon Goodall is currently offline Simon GoodallFriend
Messages: 35
Registered: July 2009
Member
Digging further, if I increase the commit timeout, resource.delete() completes sucessfully after several minutes rather than timing out. Should this be so slow? Is there a way to speed this up?

CDOTransaction t = session.openTransaction();
try {
  Resource r = t.getResource(".....");
  r.delete(null);
  t.commit();
} catch (Exception e) {
  log.error(e);
  t.rollback();
} finally {
  t.close();
}


Another problem if the commit times out, I attempt to rollback the transaction and this too can lead to a commit timeout.

Simon
Re: [CDO] Converting existing code to use CDO and the transaction API [message #1690699 is a reply to message #1690653] Mon, 30 March 2015 16:33 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 30.03.2015 um 14:11 schrieb Simon Goodall:
> Digging further, if I increase the commit timeout, resource.delete() completes sucessfully after several minutes
> rather than timing out. Should this be so slow? Is there a way to speed this up?
The deletion of an object (including a resource or folder) loads the entire sub tree of that object. That can be sped up
by calling object.cdoPrefetch() on that object first. Does that help?

>
> CDOTransaction t = session.openTransaction();
> try {
> Resource r = t.getResource(".....");
> r.delete(null);
> t.commit();
> } catch (Exception e) {
> log.error(e);
> t.rollback();
> } finally {
> t.close();
> }
>
> Another problem if the commit times out, I attempt to rollback the transaction and this too can lead to a commit timeout.
I can currently not remember what's all involved in such a rollback. Maybe you can find that out in the debugger? With
this information I could perhaps see if/how that can be optimized...

Cheers
/Eike

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


Re: [CDO] Converting existing code to use CDO and the transaction API [message #1690833 is a reply to message #1690512] Tue, 31 March 2015 14:22 Go to previous messageGo to next message
Simon Goodall is currently offline Simon GoodallFriend
Messages: 35
Registered: July 2009
Member
Hi Eike,

Thanks for the pointer. I switched ENSURE_REFERENTIAL_INTEGRITY to false again and this sped things up a lot. I have also not seen my stale references problem since although I'm not sure why.

Simon
Re: [CDO] Converting existing code to use CDO and the transaction API [message #1690835 is a reply to message #1690833] Tue, 31 March 2015 14:22 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 31.03.2015 um 16:22 schrieb Simon Goodall:
> Hi Eike,
>
> Thanks for the pointer. I switched ENSURE_REFERENTIAL_INTEGRITY to false again and this sped things up a lot. I have
> also not seen my stale references problem since although I'm not sure why.
Very good ;-)

Cheers
/Eike

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


Previous Topic:[Xcore] Extending the generator
Next Topic:[CDO] Comparing Historical revisions: No Permission
Goto Forum:
  


Current Time: Thu Apr 25 07:29:40 GMT 2024

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

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

Back to the top