Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMT Transactions(EMF Transaction spanning multiple Operations/Commands)
EMT Transactions [message #637517] Sat, 06 November 2010 00:27 Go to next message
Mischa  is currently offline Mischa Friend
Messages: 4
Registered: November 2010
Junior Member
Hi all,

currently I'm trying to implement a batch job consisting of a bunch of Commands/Operations. All operation are required to run in a single "transaction".
Unfortunatelly EMF executes each operation inside a single EMFTransatcion. Using a UndoContext as logical transaction context could solve the problem but EMF internally manages the UndoContext to be bound to the underlying resource. For me this makes no sense since when rolling back I just want to undo my "own" operations, not the operations made by other threads on the same resource.

What I need is something like:
#1 BeginOfTransaction (In a custom Context, let's say "MyBatchJob")
#2 Execute Operation 1..n
#3 Commit / Rollback Transaction (of Context "MyBatchJob")

The documented "Batch-Approach" using IResourceChangeListener woun't work for the same reason. It's triggered on each Operation, not on groups of operations.

Probably I confused the sence of EMFT, can someone please tell me if EMFT is the right solution for my task?

[Updated on: Sun, 05 December 2010 00:40]

Report message to a moderator

Re: EMT Transactions [message #637541 is a reply to message #637517] Sat, 06 November 2010 10:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30544
Registered: July 2009
Senior Member
Mischa,

I'm not sure if anyone is actively monitoring questions about
transaction. One can only hope...

Mischa wrote:
> Hi all,
>
> currently I'm trying to implement a batch job consisting of a bunch of
> Commands/Operations. All operation are required to run in a single
> "transaction".
> Unfortunatelly EMF executes each operation inside a single
> EMFTransatcion. Using a UndoContext as logical transaction context
> could solve the problem but EMF internally manages the UndoContext to
> be bound to the underlying resource. For me this makes no sence since
> when rolling back I just want to undo my "own" operations, not the
> operations made by other threads on the same resource.
If other threads are making changes, those changes might well affects
the same objects you're changing, so most certainly you should expect
there to be single chain of undoable operations.
>
> What I need is something like:
> #1 BeginOfTransaction (In a custom Context, let's say "MyBatchJob")
> #2 Execute Operation 1..n
> #3 Commit / Rollback Transaction (of Context "MyBatchJob")
>
> The documented "Batch-Approach" using IResourceChangeListener woun't
> work for the same reason. It's triggered on each Operation, not on
> groups of operations.
> Probably I confused the sence of EMFT, can someone please tell me if
> EMFT is the right solution for my task?
Re: EMT Transactions [message #637550 is a reply to message #637517] Sat, 06 November 2010 15:04 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6446
Registered: July 2009
Senior Member
Hi Mischa,

I don't think that EMF Transactions can do this for you. If you need object-grained locking, transactionality without the cooperation of the applications, multiple transactions on the same object graph including rollback of individual transactions, then you may want to have a look at CDO: http://www.eclipse.org/cdo

Cheers
/Eike

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



Am 06.11.2010 01:27, schrieb Mischa:
> Hi all,
>
> currently I'm trying to implement a batch job consisting of a bunch of Commands/Operations. All operation are required to run in a single "transaction".
> Unfortunatelly EMF executes each operation inside a single EMFTransatcion. Using a UndoContext as logical transaction context could solve the problem but EMF internally manages the UndoContext to be bound to the underlying resource. For me this makes no sence since when rolling back I just want to undo my "own" operations, not the operations made by other threads on the same resource.
>
> What I need is something like:
> #1 BeginOfTransaction (In a custom Context, let's say "MyBatchJob")
> #2 Execute Operation 1..n
> #3 Commit / Rollback Transaction (of Context "MyBatchJob")
>
> The documented "Batch-Approach" using IResourceChangeListener woun't work for the same reason. It's triggered on each Operation, not on groups of operations.
> Probably I confused the sence of EMFT, can someone please tell me if EMFT is the right solution for my task?


Re: EMT Transactions [message #637551 is a reply to message #637550] Sat, 06 November 2010 15:14 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6446
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------070104020701010606050504
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

BTW., with CDO it would look like this:

|CDOSession session = config.openSession();
CDOTransaction transaction = session.openTransaction();

Resource resource = transaction.getResource("/things/res.xml");
EObject root = resource.getContents().get(0);

process_X(root);

CDOSavepoint savepoint = transaction.setSavepoint();
process_Y(root);
savepoint.rollback();

*if *(ok)
{
transaction.setCommitComment("Changes from process X");
CDOCommitInfo commitInfo = transaction.commit();
System.out.println(commitInfo.getTimeStamp());
}
*else*
{
transaction.rollback();
}

session.close();|


Note that you can open multiple transactions on the session that all share their state until objects get modified.

Cheers
/Eike

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



Am 06.11.2010 16:04, schrieb Eike Stepper:
> Hi Mischa,
>
> I don't think that EMF Transactions can do this for you. If you need object-grained locking, transactionality without the cooperation of the applications, multiple transactions on the same object graph including rollback of individual transactions, then you may want to have a look at CDO: http://www.eclipse.org/cdo
>
> Cheers
> /Eike
>
> ----
> http://www.esc-net.de
> http://thegordian.blogspot.com
> http://twitter.com/eikestepper
>
>
>
> Am 06.11.2010 01:27, schrieb Mischa:
>> Hi all,
>>
>> currently I'm trying to implement a batch job consisting of a bunch of Commands/Operations. All operation are required to run in a single "transaction".
>> Unfortunatelly EMF executes each operation inside a single EMFTransatcion. Using a UndoContext as logical transaction context could solve the problem but EMF internally manages the UndoContext to be bound to the underlying resource. For me this makes no sence since when rolling back I just want to undo my "own" operations, not the operations made by other threads on the same resource.
>>
>> What I need is something like:
>> #1 BeginOfTransaction (In a custom Context, let's say "MyBatchJob")
>> #2 Execute Operation 1..n
>> #3 Commit / Rollback Transaction (of Context "MyBatchJob")
>>
>> The documented "Batch-Approach" using IResourceChangeListener woun't work for the same reason. It's triggered on each Operation, not on groups of operations.
>> Probably I confused the sence of EMFT, can someone please tell me if EMFT is the right solution for my task?

--------------070104020701010606050504
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
BTW., with CDO it would look like this:<br>
<br>
<title></title>
<style type="text/css">
<!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- ======================================================== -->
<!-- = Java Sourcecode to HTML automatically converted code = -->
<!-- = Java2Html Converter 5.0 [2006-02-26] by Markus Gebhard markus@jave.de = -->
<!-- = Further information: http://www.java2html.de = -->
<div class="java" align="left">
<table bgcolor="#ffffff" border="0" cellpadding="3"
cellspacing="0">
<tbody>
<tr>
<!-- start source code --> <td nowrap="nowrap" align="left"
valign="top"> <code>
<font color="#ffffff">    </font><font color="#000000">CDOSession session = config.openSession </font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">    </font><font color="#000000">CDOTransaction transaction = session.openTransaction </font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">    </font><font color="#000000">Resource resource = transaction.getResource </font><font
color="#000000">(</font><font color="#2a00ff">"/things/res.xml"</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">    </font><font color="#000000">EObject root = resource.getContents</font ><font
color="#000000">()</font><font color="#000000">.get</font><font
color="#000000">(</font><font color="#990000">0</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">    </font><font color="#000000">process_X</font><font
color="#000000">(</font><font color="#000000">root</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">    </font><font color="#000000">CDOSavepoint savepoint = transaction.setSavepoint </font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">    </font><font color="#000000">process_Y</font><font
color="#000000">(</font><font color="#000000">root</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">    </font><font color="#000000">savepoint.rollback</font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">    </font><font color="#7f0055"><b>if </b></font><font
color="#000000">(</font><font color="#000000">ok</font><font
color="#000000">)</font><br>
<font color="#ffffff">    </font><font color="#000000">{</font><br>
<font color="#ffffff">      </font><font color="#000000">transaction.setCommitComment</font><font
color="#000000">(</font><font color="#2a00ff">"Changes from process X"</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">      </font><font color="#000000">CDOCommitInfo commitInfo = transaction.commit </font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">      </font><font color="#000000">System.out.println</font><font
color="#000000">(</font><font color="#000000">commitInfo.getTimeStamp</font><font
color="#000000">())</font><font color="#000000">;</font><br>
<font color="#ffffff">    </font><font color="#000000">}</font><br>
<font color="#ffffff">    </font><font color="#7f0055"><b>else</b></font><br>
<font color="#ffffff">    </font><font color="#000000">{</font><br>
<font color="#ffffff">      </font><font color="#000000">transaction.rollback</font><font
color="#000000">()</font><font color="#000000">;</font><br>
<font color="#ffffff">    </font><font color="#000000">}</font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff">    </font><font color="#000000">session.close</font><font
color="#000000">()</font><font color="#000000">;</font></code>
</td>
<!-- end source code --> </tr>
</tbody>
</table>
</div>
<!-- = END of automatically generated HTML code = -->
<!-- ======================================================== -->
<br>
Note that you can open multiple transactions on the session that all
share their state until objects get modified.<br>
<br>
Cheers<br>
/Eike<br>
<br>
----<br>
<a class="moz-txt-link-freetext" href="http://www.esc-net.de">http://www.esc-net.de</a><br>
<a class="moz-txt-link-freetext" href="http://thegordian.blogspot.com">http://thegordian.blogspot.com</a><br>
<a class="moz-txt-link-freetext" href="http://twitter.com/eikestepper">http://twitter.com/eikestepper</a><br>
<br>
<br>
<br>
Am 06.11.2010 16:04, schrieb Eike Stepper:
<blockquote cite="mid:ib3qir$jlh$1@news.eclipse.org" type="cite">Hi
Mischa,
<br>
<br>
I don't think that EMF Transactions can do this for you. If you
need object-grained locking, transactionality without the
cooperation of the applications, multiple transactions on the same
object graph including rollback of individual transactions, then
you may want to have a look at CDO: <a class="moz-txt-link-freetext" href="http://www.eclipse.org/cdo">http://www.eclipse.org/cdo</a>
<br>
<br>
Cheers
<br>
/Eike
<br>
<br>
----
<br>
<a class="moz-txt-link-freetext" href="http://www.esc-net.de">http://www.esc-net.de</a>
<br>
<a class="moz-txt-link-freetext" href="http://thegordian.blogspot.com">http://thegordian.blogspot.com</a>
<br>
<a class="moz-txt-link-freetext" href="http://twitter.com/eikestepper">http://twitter.com/eikestepper</a>
<br>
<br>
<br>
<br>
Am 06.11.2010 01:27, schrieb Mischa:
<br>
<blockquote type="cite">Hi all,
<br>
<br>
currently I'm trying to implement a batch job consisting of a
bunch of Commands/Operations. All operation are required to run
in a single "transaction".
<br>
Unfortunatelly EMF executes each operation inside a single
EMFTransatcion. Using a UndoContext as logical transaction
context could solve the problem but EMF internally manages the
UndoContext to be bound to the underlying resource. For me this
makes no sence since when rolling back I just want to undo my
"own" operations, not the operations made by other threads on
the same resource.
<br>
<br>
What I need is something like:
<br>
#1 BeginOfTransaction (In a custom Context, let's say
"MyBatchJob")
<br>
#2 Execute Operation 1..n
<br>
#3 Commit / Rollback Transaction (of Context "MyBatchJob")
<br>
<br>
The documented "Batch-Approach" using IResourceChangeListener
woun't work for the same reason. It's triggered on each
Operation, not on groups of operations.
<br>
Probably I confused the sence of EMFT, can someone please tell
me if EMFT is the right solution for my task? </blockquote>
</blockquote>
</body>
</html>

--------------070104020701010606050504--


Re: EMT Transactions [message #637555 is a reply to message #637550] Sat, 06 November 2010 15:56 Go to previous messageGo to next message
Mischa  is currently offline Mischa Friend
Messages: 4
Registered: November 2010
Junior Member
Hello Eike,

thanks a lot, this is exactly what I'm looking for. You saved me a lot of time going further with EMF-Transaction which seems to be applied for other scenarios.
Re: EMT Transactions [message #637567 is a reply to message #637555] Sat, 06 November 2010 18:28 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6446
Registered: July 2009
Senior Member
Am 06.11.2010 16:56, schrieb Mischa:
> Hello Eike,
>
> thanks a lot, this is exactly what I'm looking for. You saved me a lot of time going further with EMF-Transaction which seems to be applied for other scenarios.
You're welcome. If you're not yet familiar with CDO I guess that you'll want to come back with more questions ;-)

Note that CDO comes with its own resources, which are mapped to databases or similar backends!

Cheers
/Eike

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


Re: EMT Transactions [message #637596 is a reply to message #637567] Sun, 07 November 2010 14:30 Go to previous messageGo to next message
Mischa  is currently offline Mischa Friend
Messages: 4
Registered: November 2010
Junior Member
Hi Eike,

is there also a kind of server abstraction with direct access to ECoreResources? Let's say I use the Lecacy-API just to make use of the Transaction mechanisms but changes are populated to the underlying ECore-Resource directly instead of being delegated to a physical CDO-Server.
Re: EMT Transactions [message #637601 is a reply to message #637596] Sun, 07 November 2010 14:36 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6446
Registered: July 2009
Senior Member
Am 07.11.2010 15:30, schrieb Mischa:
> Hi Eike,
>
> is there also a kind of server abstraction with direct access to ECoreResources? Let's say I use the Lecacy-API just to make use of the Transaction mechanisms but changes are populated to the underlying ECore-Resource directly instead of being delegated to a physical CDO-Server.
As I said, CDOTransactions do only work with CDOResources.

Cheers
/Eike

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


Previous Topic:Mixing intrinsic and extrinsic IDs
Next Topic:Reference not properly loaded from XML file
Goto Forum:
  


Current Time: Tue Oct 15 23:37:00 GMT 2019

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

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

Back to the top