[CDO] Converting existing code to use CDO and the transaction API [message #1690512] |
Fri, 27 March 2015 17:32 |
Simon Goodall 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 #1690699 is a reply to message #1690653] |
Mon, 30 March 2015 16:33 |
|
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
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02616 seconds