Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF-CDO/JFace databinding issue on remote client
EMF-CDO/JFace databinding issue on remote client [message #823653] Sun, 18 March 2012 17:25 Go to next message
Bernard Sarter is currently offline Bernard SarterFriend
Messages: 88
Registered: August 2011
Location: Paris, France
Member
Hello,

I would like to set-up a platform (3 computers, C1, C2, C3) where:
- C1 shall run a CDO server (reuse of provided org.eclipse.emf.cdo.server, configured to use an underlying mySql DB)
- C2 shall run a RCP app "master client", that instantiates/populates the EMF model, and performs updates in run-time,
- C3 shall run a RCP app "slave client", that reads the model created by the "master client", and displays automatically all changes in run-time.

Both clients display the model data on tables (based on JFace TableViewer) with databinding with the EMF model.

So far, when the "master client" makes a change in the model, its own JFace table is updated immediately (Ok), and when the "master client" commits (CDO transaction), I also see the change in the mySql DB (Ok too), ** BUT ** the JFace table on the "slave client" is NOT updated automatically; If I force a refresh of the whole TableViewer, then I see the update, but I would of-course prefer to avoid to have to do such a full refresh cyclically.

Is there a specific configuration/option either of the databinding or the CDO session to be done to get an automatic refresh on the "slave client" ?

My config: Eclipse 3.7.2.

Any suggestion welcome,

Best regards,
Bernard.
Re: EMF-CDO/JFace databinding issue on remote client [message #824020 is a reply to message #823653] Mon, 19 March 2012 06:37 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6690
Registered: July 2009
Senior Member
Hi Bernard,

If your CDOSession on C3 uses

session.options().setPassiveUpdatesEnabled(true);
session.options().setPassiveUpdatesMode(PassiveUpdatesMode.INVALIDATIONS);

(which is the default) then you can add an IListener to your C3 view/tx:

view.addListener(new IListener()
{
if (event instanceof CDOViewInvalidationEvent)
{
CDOViewInvalidationEvent e = (CDOViewInvalidationEvent)event;
viewer.refresh(...);
}
}

Another common approach is to use EMF notifications. For that to work properly you'd need change deltas on C3 rather
than just invalidations:

session.options().setPassiveUpdatesEnabled(true);
session.options().setPassiveUpdatesMode(PassiveUpdatesMode.CHANGES);

No IListener on the view is needed!

PassiveUpdatesMode.CHANGES makes the server transmit *all* change deltas of *all* changed objects. If tat's too coarse
grained for your use-case you can also use the change subscription mechansim:

session.options().setPassiveUpdatesEnabled(true);
session.options().setPassiveUpdatesMode(PassiveUpdatesMode.INVALIDATIONS);
view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);

I hope this helps.

Cheers
/Eike

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


Am 18.03.2012 18:25, schrieb Bernard SARTER:
> Hello,
>
> I would like to set-up a platform (3 computers, C1, C2, C3) where:
> - C1 shall run a CDO server (reuse of provided org.eclipse.emf.cdo.server, configured to use an underlying mySql DB)
> - C2 shall run a RCP app "master client", that instantiates/populates the EMF model, and performs updates in run-time,
> - C3 shall run a RCP app "slave client", that reads the model created by the "master client", and displays
> automatically all changes in run-time.
>
> Both clients display the model data on tables (based on JFace TableViewer) with databinding with the EMF model.
>
> So far, when the "master client" makes a change in the model, its own JFace table is updated immediately (Ok), and
> when the "master client" commits (CDO transaction), I also see the change in the mySql DB (Ok too), ** BUT ** the
> JFace table on the "slave client" is NOT updated automatically; If I force a refresh of the whole TableViewer, then I
> see the update, but I would of-course prefer to avoid to have to do such a full refresh cyclically.
> Is there a specific configuration/option either of the databinding or the CDO session to be done to get an automatic
> refresh on the "slave client" ?
>
> My config: Eclipse 3.7.2.
>
> Any suggestion welcome,
>
> Best regards,
> Bernard.
>


Re: EMF-CDO/JFace databinding issue on remote client [message #824242 is a reply to message #824020] Mon, 19 March 2012 12:33 Go to previous messageGo to next message
Bernard Sarter is currently offline Bernard SarterFriend
Messages: 88
Registered: August 2011
Location: Paris, France
Member
Hello,

Thank you for this quick and precise reply !!


For the time being, I will use:
session.options().setPassiveUpdatesMode(PassiveUpdatesMode.CHANGES);


which seems to do the job, but I will keep your other recommendations in mind for the case I'd need to further optimise in the future.

Btw, I would like to get an advice - "best practices" - wrt session and transaction usage:

Currently I open a session and an unique transaction on each client, for the whole life-cycle of the application (typically two to three hours), with periodic commits (typically every 5 seconds). I'm wondering if this is the best choice, or if it would be better to close the transaction and reopen a new one more often (after each successful commit) ...

In other words, are there drawbacks (resource leakage ...) to keep an transaction open for a while ?

Thanks,
Bernard.
Re: EMF-CDO/JFace databinding issue on remote client [message #824388 is a reply to message #824242] Mon, 19 March 2012 16:08 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6690
Registered: July 2009
Senior Member
Am 19.03.2012 13:33, schrieb Bernard SARTER:
> Hello,
>
> Thank you for this quick and precise reply !!
>
> For the time being, I will use:
> session.options().setPassiveUpdatesMode(PassiveUpdatesMode.CHANGES);
>
> which seems to do the job, but I will keep your other recommendations in mind for the case I'd need to further
> optimise in the future.
>
> Btw, I would like to get an advice - "best practices" - wrt session and transaction usage:
>
> Currently I open a session and an unique transaction on each client, for the whole life-cycle of the application
> (typically two to three hours), with periodic commits (typically every 5 seconds). I'm wondering if this is the best
> choice,
That's perfect.

> or if it would be better to close the transaction and reopen a new one more often (after each successful commit) ...
No.

>
> In other words, are there drawbacks (resource leakage ...) to keep an transaction open for a while ?
No whatsoever leakage in CDO! :P

Cheers
/Eike

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


Re: EMF-CDO/JFace databinding issue on remote client [message #824585 is a reply to message #824388] Mon, 19 March 2012 21:09 Go to previous messageGo to next message
Bernard Sarter is currently offline Bernard SarterFriend
Messages: 88
Registered: August 2011
Location: Paris, France
Member
Hello Eike,

Thanks again for the advice ... and I apologize of course for my 'obviously stupid' doubts about possible CDO design flaws Wink / More seriously, I just discovered the CDO framework few days ago, and you really made a great job.

Best regards,
Bernard.
Re: EMF-CDO/JFace databinding issue on remote client [message #824857 is a reply to message #824585] Tue, 20 March 2012 06:32 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6690
Registered: July 2009
Senior Member
Am 19.03.2012 22:09, schrieb Bernard SARTER:
> Hello Eike,
> Thanks again for the advice ... and I apologize of course for my 'obviously stupid' doubts about possible CDO design
> flaws ;) / More seriously, I just discovered the CDO framework few days ago, and you really made a great job.
Don't forget about the team: http://thegordian.blogspot.de/2011/12/one-month-of-open-source-development-in.html ;-)

Cheers
/Eike

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


Previous Topic:How to handle EObject fields which are omitted by EcoreUtil.copy?
Next Topic:[CDO / Hibernate Store] "Cannot modify a frozen revision"
Goto Forum:
  


Current Time: Thu Sep 19 21:39:03 GMT 2024

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

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

Back to the top