Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 270415 - Enhance islocked feature
Summary: Enhance islocked feature
Status: CLOSED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: M7   Edit
Assignee: Eike Stepper CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-30 03:54 EDT by Stephane fournier CLA
Modified: 2010-06-29 09:21 EDT (History)
2 users (show)

See Also:
stepper: galileo+
stepper: review+


Attachments
Fix for this enhancement (18.18 KB, patch)
2009-04-03 16:52 EDT, Stephane fournier CLA
stepper: iplog+
Details | Diff
Patch v2 (17.42 KB, patch)
2009-04-04 02:57 EDT, Eike Stepper CLA
no flags Details | Diff
Fix issue between ReadLock and WriteLock (4.76 KB, patch)
2009-04-04 05:31 EDT, Stephane fournier CLA
no flags Details | Diff
Patch v3 (18.52 KB, patch)
2009-04-04 11:44 EDT, Simon Mc Duff CLA
no flags Details | Diff
Patch v3 (18.51 KB, patch)
2009-04-05 04:10 EDT, 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 Stephane fournier CLA 2009-03-30 03:54:21 EDT
Build ID: I20090313-0100
CDO 2.0.0M6

The current CDOObject.isLocked() means the current CDO view owns or not a lock on this object.

It's worth having a new method to be able to know if an object is locked by other views.

See post : http://www.eclipse.org/newsportal/article.php?id=40578&group=eclipse.tools.emf#40578.

Eike suggests to keep the current isLocked() method as is to avoid breaking existing code and to add a new method isLockedByOthers() for this new semantic.
Comment 1 Stephane fournier CLA 2009-03-30 10:40:01 EDT
I've just finished to implement the isLockedByOthers feature.

Would you like to have the code ?
I do not have access to the CVS repository from my Eclipse SDK at office :(
Nevertheless, I can provide you with a zip file containing all cdo projects I modified. You will have to search a specific TODO task identified by this bug url (i.e https://bugs.eclipse.org/bugs/show_bug.cgi?id=270415)



Comment 2 Simon Mc Duff CLA 2009-03-30 20:08:15 EDT
(In reply to comment #1)
> I've just finished to implement the isLockedByOthers feature.
> 
> Would you like to have the code ?
> I do not have access to the CVS repository from my Eclipse SDK at office :(
> Nevertheless, I can provide you with a zip file containing all cdo projects I
> modified. You will have to search a specific TODO task identified by this bug
> url (i.e https://bugs.eclipse.org/bugs/show_bug.cgi?id=270415)
> 

Yes please attached it to this bugs! I will be very happy to review it!

Simon
Comment 3 Stephane fournier CLA 2009-03-31 04:51:48 EDT
Again, I am sorry to be not able to provide you with a patch.
You can find in this bugzilla https://bugs.eclipse.org/bugs/show_bug.cgi?id=265136 a zip file that contains different CDO projects with different fixes I made.

To get the fixe for this bugzilla search for a Task named : FIX https://bugs.eclipse.org/bugs/show_bug.cgi?id=270415

Comment 4 Stephane fournier CLA 2009-04-02 10:42:01 EDT
Hi Simon,
Did you retrieve the code that implements isLockedByOthers() ?

Stéphane.
Comment 5 Simon Mc Duff CLA 2009-04-02 10:53:37 EDT
Yes I looked at it briefly.. but I didn't extract it so far from the project you submitted.
I will do it as soon as I have time !
1 - Extract the patch from project that Stephane provide
2 - Create testcases
3 - Change java doc!
4 - Review by Eike!

I will start step 1 as soon as I can.


Simon

Comment 6 Stephane fournier CLA 2009-04-02 12:29:33 EDT
To help you, I will make a real patch by the end of the week-end.
I noticed, I forgot to give you the new Indication class I added in org.eclipse.emf.cdo.server :(

Stephane.
Comment 7 Simon Mc Duff CLA 2009-04-02 13:46:13 EDT
This will be awesome!
Comment 8 Stephane fournier CLA 2009-04-03 16:52:18 EDT
Created attachment 130887 [details]
Fix for this enhancement

Hi Eike and Simon.

I've just finished a real patch :)
I do hope you are happy guys.

I'm not a patch expert, hence I do hope the file contains all the materials.
Let me know if you can manage it.
This patch should contain code modifications and 2 new classes : one for the request and the other one for the Indication.
You will find after integration 19 TODO task containing this bugzilla number.
Stephane
Comment 9 Eike Stepper CLA 2009-04-04 02:57:43 EDT
Created attachment 130908 [details]
Patch v2

I consolidated the network protocol and a reformatted everything.
I added test cases in LockingManagerTest, which are failing.
The distiction between read locks and write locks gets lost somewhere.

Stephane, can you dig a bit deeper? Thx for your effort ;-)
Comment 10 Eike Stepper CLA 2009-04-04 02:58:28 EDT
Simon, can you please also have a look at this patch?
Comment 11 Stephane fournier CLA 2009-04-04 05:31:16 EDT
Created attachment 130912 [details]
Fix issue between ReadLock and WriteLock

Hi Eike,
You are right, there is a mess, between read locks and write locks.

When I made the first patch, I missed one thing.
writeLocks and readLocks are held in the same collection.
Hence, RWLockManager#getLockEntry method gets existing locks for given object.
Even if the right lock strategy is retrieved we can't unify the call to the LockEntry.
In fact, we need two methods (that's already the case for isLocked())
LockEntry<K, V> entry = getLockEntry(objectToLock);

This new patch (changes in RWLockManager.java) in addition to your one, fixes the bug.

Let me know the result of your test case.
Stephane.
Comment 12 Simon Mc Duff CLA 2009-04-04 08:17:28 EDT

I will review this two patchs before the end of the day.

I look at them quickly and I think something is missing.
Comment 13 Simon Mc Duff CLA 2009-04-04 11:44:57 EDT
Created attachment 130916 [details]
Patch v3

RWLockManager had 2 issues.
- ReadLockEntry.isReadLockByOthers
- WriteLockEntry.isReadLockByOthers

I change one testcase as well to test that.
Comment 14 Stephane fournier CLA 2009-04-04 12:30:34 EDT
Hi Simon,

I don't understand why in your patch, I didn't see the changes I did today to solve the issue pointed by Eike ?

Did you have a try to the last patch I submitted ?

Did you fix the issue pointed by Eike in another way ?

Stephane.
Comment 15 Stephane fournier CLA 2009-04-04 12:39:50 EDT
Simon,
I introduced two methods as you did to implement isLocked().
The problem is that getLockEntry(object) (called from hasLockByOther()) returns a LockEntry without testing against the requested lock type. That's why you need 2 methods afterwards.

The ReadLockStrategy tests against isReadLock() while the WriteLockStrategy tests again isWriteLock().

I tried to implement isLockByOthers in the same way in the last patch I submitted.

Stephane.
Comment 16 Stephane fournier CLA 2009-04-04 13:47:46 EDT
Guys,

My mistake !
Forget my last two message, I made an error in applying the patch v3.
Hence, I did get the code submitted by Simon.

Sorry to disturb you with useless messages ;)

Stephane.


Comment 17 Simon Mc Duff CLA 2009-04-04 15:34:25 EDT
Let us know if this path doesn't work well for you.

Simon
Comment 18 Stephane fournier CLA 2009-04-04 17:29:36 EDT
It still works well for me.
Your test cases are very useful to have a good code coverage :)

When will you commit the code to HEAD ?
Comment 19 Simon Mc Duff CLA 2009-04-04 21:01:53 EDT
As soon as Eike review the final patch!!! 
Comment 20 Eike Stepper CLA 2009-04-05 04:10:13 EDT
Created attachment 130930 [details]
Patch v3

Ready to be committed
Comment 21 Eike Stepper CLA 2009-04-05 04:24:58 EDT
Wait a minute!

This patch contains a substantial contributionby non-committers and we need to follow the IP process:

Confirm on Bugzilla that the
Contributor: (a) wrote 100% of
the code; (b) that they have the
right to contribute the code to
Eclipse; and (c) the file header
contains the EPL License
header.

Stephane, can you provide your company name and confirm the above items?

I filed CQ:
https://dev.eclipse.org/ipzilla/show_bug.cgi?id=3234

Comment 22 Simon Mc Duff CLA 2009-04-05 09:15:00 EDT
I will wait until the CQ is completed.

I thought we only need to do that if more than  250 lines ?

Simon
Comment 23 Stephane fournier CLA 2009-04-05 11:34:53 EDT
Hi,

To answer your questions :

I'm working for Thales.

a) I wrote 100% of the code contained in the patch I submitted.

For b) and c) I will check that tomorrow morning with my boss. 

To be honest, I don't think there is a problem :

1) My company is submitting a proposal (http://www.eclipse.org/proposals/egf/) to start a new EMFT component project and is ready to give the initial code contribution.
This code contribution is far more important than the lines I give you :).
In the proposal, you can find my business e-mail ;).
Guillaume Brocard (working on Oracle CDO db adapter) and I, are the guys who wrote the EGF code. For 2 months, we've moved on a new project that needs CDO.

2) We need the isLockedByOthers feature that's why I give it a try. It's really better if the feature is included in CDO rather than some proprietary code where you found bugs.

I let you know asap for b) and c) questions.

Stéphane.
Comment 24 Eike Stepper CLA 2009-04-05 11:38:28 EDT
c) is already clear. IIRC after our rework, there are no new files at all.
Comment 25 Stephane fournier CLA 2009-04-06 03:00:41 EDT
Hi guys,
I've just checked with my Hierarchy.
No problem to contribute the code to Eclipse.

Stéphane.
Comment 26 Eike Stepper CLA 2009-04-06 03:13:41 EDT
Great! In the meantime I 've withdrawn the CQ since only 29 LOC of your initial contribution made it to the final patch (250+ requires a CQ). That makes it even easier for us. Thank you again for your engagement!

Committed to HEAD.
Comment 27 Stephane fournier CLA 2009-04-23 04:28:09 EDT
Hi guys,

I'm back to business :)
The isObjectLockedByOthers method works fine.
Nevertheless, I'm wondering if we could improve it in returning a list of view ids rather than a boolean. If the returned list is empty that means no lock, otherwise we have the lockers.

From my opinion, It could be useful to know, what are the views that lock the related object.

Let me know what you think about that and I can have a try to implement it.

Stephane


Comment 28 Simon Mc Duff CLA 2009-04-23 06:56:48 EDT
(In reply to comment #27)
> Hi guys,
> 
Hi Stephane,

> I'm back to business :)
Good!!!

> The isObjectLockedByOthers method works fine.
Perfect.

> Nevertheless, I'm wondering if we could improve it in returning a list of view
> ids rather than a boolean. If the returned list is empty that means no lock,
> otherwise we have the lockers.
>  
> From my opinion, It could be useful to know, what are the views that lock the
> related object. 
Could remote view could be useful ? I understand your point and I think it could be valid. I don`t see the business case at the moment. :-) You can create a bugzilla :-).

> 
> Let me know what you think about that and I can have a try to implement it.
> 
> Stephane
> 

Comment 29 Stephane fournier CLA 2009-04-23 07:46:13 EDT
Hi Simon,

I've filed a bugzilla to discuss the comment #28 : https://bugs.eclipse.org/bugs/show_bug.cgi?id=273411.

Stéphane.
Comment 30 Eike Stepper CLA 2009-05-06 06:40:14 EDT
Fix available in EMF CDO 2.0.0M7
Comment 31 Eike Stepper CLA 2009-06-27 11:54:17 EDT
Generally available.