Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] CDOViews and controlling updates
[CDO] CDOViews and controlling updates [message #1735631] Tue, 21 June 2016 13:41 Go to next message
Simon Goodall is currently offline Simon GoodallFriend
Messages: 35
Registered: July 2009
Member
Hi,

I am integrating CDO into my application to avoid various concurrency issues.

Currently I have a single CDOView open on my model and I create transactions on top of this view (session.openTransaction(viewInstance)) when I need to make changes.

I am finding my view is being automatically updated when the transaction commits. This would appear to still be a source of concurrency issues i.e. the UI could be refreshing as the view state updates.

As I understand it, iterating over a list should not be a problem with a CDO generated model, but the model state could still be inconsistent as the view is updated.

Is my understanding correct? Can anybody comment on the best way to handle this situation? I am thinking I need to disable automatic view updates (can this be done on a per view basis - I have seen the passive updates option at the session level) and manually refresh on the UI thread. I am not sure how to find out when the model view is invalid.

Another question I have - how are transient fields handled? Presumably they are local only to the instance in the view/transaction?

Thanks,

Simon
Re: [CDO] CDOViews and controlling updates [message #1735843 is a reply to message #1735631] Thu, 23 June 2016 09:05 Go to previous messageGo to next message
Simon Goodall is currently offline Simon GoodallFriend
Messages: 35
Registered: July 2009
Member
To follow up it looks like I can do the following;

// Get snapshot of current state
CDOView view = session.openView(session.getLastUpdateTime());
view.addListener(new IListener() {

	@Override
	public void notifyEvent(IEvent event) {
					
		if (event instanceof CDOViewInvalidationEvent) {
			scheduleNextRefresh();
		}
	}
});


Then to update the view it looks like this is the way;
viewsetTimeStamp(session.getLastUpdateTime());
// Incase another update has come in since....
if (session.getLastUpdateTime() != baseView.getTimeStamp()) {
  scheduleNextRefresh();
}


Is this the correct way to do this?
Re: [CDO] CDOViews and controlling updates [message #1737529 is a reply to message #1735631] Sat, 09 July 2016 08:31 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Simon,

Comments below...

Cheers
/Eike

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



Am 21.06.2016 um 16:41 schrieb Simon Goodall:
> Hi,
>
> I am integrating CDO into my application to avoid various concurrency issues.
>
> Currently I have a single CDOView open on my model and I create transactions on top of this view
> (session.openTransaction(viewInstance)) when I need to make changes.
>
> I am finding my view is being automatically updated when the transaction commits. This would appear to still be a
> source of concurrency issues i.e. the UI could be refreshing as the view state updates.
Why do you think that this could be a "concurrency issue"? What exact kind of issue? Maybe you could give an example of
such an issue?

>
> As I understand it, iterating over a list should not be a problem with a CDO generated model,
Well, that can be a problem. But what you describe (just "iterating") is a little vague.

If you're really just iterating (and not modify the object or list), you should probably synchronize on the view to
prevent CDO to update the list with remote changes while you're iterating. As of CDO 4.5 the best way to synchronize on
a view is to use one of these methods:

org.eclipse.emf.cdo.view.CDOView.syncExec(Runnable)
org.eclipse.emf.cdo.view.CDOView.syncExec(Callable<V>)

I call it the best way because it transparently allows for advanced synchronization such as considering
Display.syncExec() calls as "in-thread" calls. This is pluggable and it's implemented for example in
org.eclipse.net4j.util.concurrent.DelegableReentrantLock .

Of course, if you base accumalate calculations on the list iteration (such as sums or likewise), you probably want to
prevent other transactions from modifying the list and its elements. Acquire (at least) read locks on all elements
involved in the calculation and let them be released when you comit the result of the calculation.

Before I expand on your ideas to disable automatic updates, I'd like to hear what you think about the above ;-)

Cheers
/Eike

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


> but the model state could still be inconsistent as the view is updated.
> Is my understanding correct? Can anybody comment on the best way to handle this situation? I am thinking I need to
> disable automatic view updates (can this be done on a per view basis - I have seen the passive updates option at the
> session level) and manually refresh on the UI thread. I am not sure how to find out when the model view is invalid.
>
> Another question I have - how are transient fields handled? Presumably they are local only to the instance in the
> view/transaction?
>
> Thanks,
>
> Simon


Previous Topic:[CDO] Commit memory footprint
Next Topic:[CDO] NPE in AbstractHorizintalClassMapping.initTable()
Goto Forum:
  


Current Time: Tue Apr 23 09:19:09 GMT 2024

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

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

Back to the top