Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] How do Passive updates work ?
[CDO] How do Passive updates work ? [message #1695074] Mon, 11 May 2015 20:09 Go to next message
Stephane  fournier is currently offline Stephane fournierFriend
Messages: 340
Registered: July 2009
Senior Member
Hi there,

I would like to get some more detailed explanations about Passive Updates.

Let me introduce a brief use case:

- 2 client JVM (A, B running on different computers) connected to a same CDO server (running on another computer) accessing a resource containing data based on the famous Company ecore model.

- Let's say that JVM A, on computer "One", commits the fact a new Employee is created and added in a containment relationship of a company. After the transaction commit operation call, JVM A uses RMI to remotely calls JVM B (in RMI threads) passing the name of the employee (for instance).
- On JVM B side, RMI implementation tries to lookup the Employee from its name.

Depending on how the Passive updates are quick or not, JVM B find or not the previously added Employee. Indeed, RMI call handling is done in another thread, and on JVM B side, it might happen the update of the CDO transaction happens after the RMI call.
If I add a sleep of 200ms after the commit operation and before the RMI call, I never faced the issue. But usage of sleep() is not a proper solution always difficult to find the right value.

It seems to me, Passive updates, to call back remote clients, are NOT done during the commit itself, but in reaction of the end of the commit on server side.
Is it right ?

To recap : when client A calls transaction.commit(); and commit() steps out, we cannot make sure other remote clients are up-to-date immediately (even with passive update set to true) ?

If'm right, how can I make sure when I commit something in CDO every remote clients are up-to-date ?

I perfectly know I can register listener (CDO ones or EMF adapters) on the model stored in the server to be notified, but for other reasons I need to use RMI and pass attribute values to identify objects to lookup on other side.

Does anyone have an idea how to solve that integration (between RMI and CDO) issue ?

Thanks in adavance,
Stéphane.
Re: [CDO] How do Passive updates work ? [message #1695079 is a reply to message #1695074] Mon, 11 May 2015 20:52 Go to previous messageGo to next message
Alexandre Borgoltz is currently offline Alexandre BorgoltzFriend
Messages: 31
Registered: July 2009
Location: France
Member
I'd say it's up to the client to ensure they are "up-to-date" when they work with the model.

One way you could do is the following:


  1. JVM A : perform your commit
  2. JVM A : retreive the corresponding repository's timestamp by CDOTransaction.getLastCommitTime()
  3. JVM A : include that timestamp as an additional parameter to your RMI call together with the employee's name
  4. JVM B : in the method called through RMI, call CDOView.waitForUpdate(timestamp) passing the timestamp received by RMI
  5. JVM B : use your model, it is up-to-date (at least enough so that the employee is there!)


I hope it helps!

--
Alexandre

Re: [CDO] How do Passive updates work ? [message #1695098 is a reply to message #1695079] Tue, 12 May 2015 05:24 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hey Guys,

Alexandre, you gave the perfect answer. Instead of CDOTransaction.getLastCommitTime() you can also use
CDOTransaction.commit().getTimeStamp(), which is a little safer when multiple threads commit the transaction.

Cheers
/Eike

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



Am 11.05.2015 um 22:52 schrieb Alexandre Borgoltz:
> I'd say it's up to the client to ensure they are "up-to-date" when they work with the model.
>
> One way you could do is the following:
>
>
> JVM A : perform your commit
> JVM A : retreive the corresponding repository's timestamp by CDOTransaction.getLastCommitTime()
> JVM A : include that timestamp as an additional parameter to your RMI call together with the employee's name
> JVM B : in the method called through RMI, call CDOView.waitForUpdate(timestamp) passing the timestamp received by RMI
> JVM B : use your model, it is up-to-date (at least enough so that the employee is there!)
>
>
> I hope it helps!
>


Re: [CDO] How do Passive updates work ? [message #1695099 is a reply to message #1695098] Tue, 12 May 2015 05:38 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 12.05.2015 um 07:24 schrieb Eike Stepper:
> Hey Guys,
>
> Alexandre, you gave the perfect answer. Instead of CDOTransaction.getLastCommitTime() you can also use
> CDOTransaction.commit().getTimeStamp(), which is a little safer when multiple threads commit the transaction.
And note that you need to do this also if you work with two views/transactions that are open on the same session because
the view invalidations are always executed on a background thread per view.

Cheers
/Eike

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


Re: [CDO] How do Passive updates work ? [message #1695122 is a reply to message #1695099] Tue, 12 May 2015 07:44 Go to previous messageGo to next message
Stephane  fournier is currently offline Stephane fournierFriend
Messages: 340
Registered: July 2009
Senior Member
Hi guys,
Thanks for your great suggestions. I will try that right now and let you know if it fixes my issue.

Stéphane.


Eike Stepper wrote on Tue, 12 May 2015 01:38
Am 12.05.2015 um 07:24 schrieb Eike Stepper:
> Hey Guys,
>
> Alexandre, you gave the perfect answer. Instead of CDOTransaction.getLastCommitTime() you can also use
> CDOTransaction.commit().getTimeStamp(), which is a little safer when multiple threads commit the transaction.
And note that you need to do this also if you work with two views/transactions that are open on the same session because
the view invalidations are always executed on a background thread per view.

Cheers
/Eike

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

Re: [CDO] How do Passive updates work ? [message #1696071 is a reply to message #1695122] Thu, 21 May 2015 13:50 Go to previous message
Stephane  fournier is currently offline Stephane fournierFriend
Messages: 340
Registered: July 2009
Senior Member
Hi guys,
Tests are successful.

Thanks.
Previous Topic:Xcore workaround for bug 89325???
Next Topic:[EMF Forms] ViewModel generation does not work with classes in packages
Goto Forum:
  


Current Time: Fri Apr 26 02:41:22 GMT 2024

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

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

Back to the top