EMT Transactions [message #637517] |
Sat, 06 November 2010 00:27 |
Mischa 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 #637550 is a reply to message #637517] |
Sat, 06 November 2010 15:04 |
|
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?
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Re: EMT Transactions [message #637551 is a reply to message #637550] |
Sat, 06 November 2010 15:14 |
|
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--
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03381 seconds