Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 257372 - Handle conflict object without rollback the view completely
Summary: Handle conflict object without rollback the view completely
Status: CLOSED WORKSFORME
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.core (show other bugs)
Version: 4.0   Edit
Hardware: PC Windows XP
: P1 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Simon Mc Duff CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 258863
Blocks: 256492
  Show dependency tree
 
Reported: 2008-12-03 09:10 EST by Bjoern Sundin CLA
Modified: 2010-09-24 02:26 EDT (History)
5 users (show)

See Also:


Attachments
Patch v1 - incomplete (12.63 KB, patch)
2008-12-14 11:39 EST, Eike Stepper CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bjoern Sundin CLA 2008-12-03 09:10:59 EST
There is no possibility to resolve a single dirty CDOObject with the state CONFLICT by "updating" it from the server.

Consider the following use case:
a) Two clients have made modifications on the same CDOObject.
b) Client A saves (transaction.commit()).
c) Client B gets notified by a CDOSessionInvalidationEvent and indicates in 
its viewer that the object now has a conflict (red, bold font).
d) The user of client B selects the conflicting object in the viewer and 
invokes a resolve conflict action from the context menu.
e) The resolve conflict action updates the selected CDOObject (with state 
CONFLICT) from the server.

See also "[CDO] Resolve single CDOObject in state CONFLICT" (http://www.eclipse.org/newsportal/article.php?id=37841&group=eclipse.tools.emf#37841)
Comment 1 Simon Mc Duff CLA 2008-12-03 10:01:04 EST
About your comments:
Bjoern Sundin wrote:
> Exactly! Though, for me I would rather see it as view.rollbackAndUpdate(object):  rollback local changes and retrieve latest version. 


First.. what I meant was more for the view completely .. not only one object.
Also the method name should be call.

view.rollbackAndUpdateAndModify(void); // :-)

TO do it for one object is complicated.. since many others changes could occured at the same time..(

e.g.:

a.getElements().add(b); // Could result in many modifications of the graphs.

Simon
Comment 2 Bjoern Sundin CLA 2008-12-03 10:41:48 EST
Simon, I didn't want to knowbest regarding names in any way. Sorry if you felt offended. I'll leave the naming to others. :-)

I guess it is a tricky matter to find a general way to handle it on one single object. In the case of a changed attribute it would probably be fairly simple. In the example with a list not... Maybe also not for a chain of changes (since I don't have any OperationHistory in my app).

I'm not so into the mechanics under the surface of CDO, but would it be possible to have something that just resolves the conflic objects of the view, then? I mean leaving local non conflicting changes intact and updating/merging the rest. Would that impact the consistency of the model?

Bjoern
Comment 3 Eike Stepper CLA 2008-12-13 12:49:04 EST
Committed initial solution to HEAD.
Comment 4 Eike Stepper CLA 2008-12-13 12:58:12 EST
/**
 * A strategy used to customize the default conflict resolution behaviour of {@link CDOTransaction transactions}.
 * 
 * @see CDOTransaction.Options#setConflictResolver(CDOConflictResolver)
 * @author Eike Stepper
 * @since 2.0
 */
public interface CDOConflictResolver
{
  public static final CDOConflictResolver NOOP = new CDOConflictResolver()
  {
    public void resolveConflicts(CDOTransaction transaction, Set<CDOObject> conflicts)
    {
      // Do nothing
    }
  };

  /**
   * Resolves conflicts after remote invalidations arrived for objects that are locally dirty or detached.
   * <p>
   * The implementor might want to use API in {@link CDOConflictUtil}.
   * <p>
   * <b>Important:</b> Those conflicts that are resolved by the implementation of this method <b>must</b> be removed
   * from the passed set of conflicts!
   */
  public void resolveConflicts(CDOTransaction transaction, Set<CDOObject> conflicts);
}
Comment 5 Eike Stepper CLA 2008-12-14 11:39:38 EST
Created attachment 120411 [details]
Patch v1 - incomplete

3 test cases in InvalidationTest are failing.
Comment 6 Simon Mc Duff CLA 2008-12-14 14:51:31 EST
I will work on it a little bit!
Comment 7 Simon Mc Duff CLA 2008-12-14 15:16:33 EST
Committed to HEAD.

I fixed failing testcases. We had 3 testcases failing all the time.. + another one that was failing once in a while...
TO fix the first 3 failed testcases, I added the following (passiveUpdate)

private void handleCommitNotification(final long timeStamp, Set<CDOIDAndVersion> dirtyOIDs,
      final Collection<CDOID> detachedObjects, final Collection<CDORevisionDelta> deltas, InternalCDOView excludedView,
      final boolean passiveUpdate, boolean async)

I override passiveUpdate since when we refresh a session... it override the passiveUpdate settings.

To fix the others testcases,  I had to change the testcase itself since changesubscription is now async...

We still need to make sure handleCOnflicts happens after invalidation and changesubscription notifications.

Simon
     
Comment 8 Eike Stepper CLA 2008-12-15 04:38:09 EST
(In reply to comment #7)
> We still need to make sure handleCOnflicts happens after invalidation and
> changesubscription notifications.

Done.
Comment 9 Eike Stepper CLA 2008-12-15 16:37:04 EST
Hand-over ;-)
Comment 10 Eike Stepper CLA 2009-07-09 04:15:04 EDT
What's the state of this?
Comment 11 Simon Mc Duff CLA 2009-07-09 06:45:09 EDT
(In reply to comment #10)
> What's the state of this?
> 

After the initial push we did, we didn't improve it.
Comment 12 Eike Stepper CLA 2009-11-01 06:00:08 EST
Rebasing all unresolved enhancement requests to 3.0
Comment 13 Eike Stepper CLA 2010-06-29 04:51:10 EDT
Rebasing all outstanding enhancements requests to version 4.0
Comment 14 Eike Stepper CLA 2010-09-24 02:26:43 EDT
Conflict resolution should now be done with the new CDOConflictResolvers like CDOMergingConflictResolver.

Please reopen if you think that's not adequate.