[CDO] Optimistic Concurrency Control - Reg. [message #1778093] |
Sat, 09 December 2017 20:18 |
Nirmal Kanagasabai Messages: 11 Registered: July 2017 |
Junior Member |
|
|
Hello Team,
I am working on persisting the models and model elements of our stand-alone client which runs on top of EMF to a database instead of the default XMI persistence. CDO was our obvious choice and I was able to establish a session, successfully open, commit & close transactions, persist and load resource to & from the database.
I am currently investigating the concurrency control techniques that CDO offers. I did come across the Documentation which talks about 'Collaboration in Real-Time' where both Optimistic and Pessimistic Concurrency Control techniques are discussed.
Our team (group of researchers) decided to go with Optimistic Concurrency Control instead of having locks. I understand the non-zero risk of commit conflicts. I was super impressed with 'Early Conflict Detection' and 'Automatic Conflict Resolution' and would definitely have them implemented.
Here's a couple of things which I wanted to get clarified about. I hope you can help me out on this regard:
1] Similar to Early Conflict Detection, Notifying the other collaborators about the model element one is currently working on. I mean to say, if three clients Client A, B and C are collaborating, if the particular model element that Client A is currently editing gets highlighted on both Client B and C, it's more like an early alarm and they would be warned to not edit/delete it to avoid conflicts.
As far as I know, if and only if a commit is made, the other collaborators are notified about it (which is the case of Early Conflict Detection). But, something like 'Google Docs' or 'Draw.io' where the element (which currently gets edited) being highlighted would be a cool addition. I have attached an image (Query1.png) which illustrates the functionality I described above for your reference.
Is there any way this could be implemented? Can you please provide me with some pointers on the same?
2] The second question would be about the 'CDO Collaboration View'. I understand that I will be able to send a short message to the selected user. - Is there anyway I could multicast it? (instead of listing down all connected users and iterating through it)
- Also, instead of a 'short message', will we be able to send any other information? Like, a model element?
Right now, I am clueless if there already exists something which does the same and I have overlooked it or if these could actually be achieved. I humbly request your assistance on this regard.
Looking forward to your reply.
Regards,
Nirmal
-
Attachment: Query1.png
(Size: 379.46KB, Downloaded 133 times)
|
|
|
Re: [CDO] Optimistic Concurrency Control - Reg. [message #1778123 is a reply to message #1778093] |
Mon, 11 December 2017 05:17 |
|
Hi Nirmal,
ad 1] Lock notification is already supported. Just do this:
CDOView view = session.openView();
view.options().setLockNotificationEnabled(true);
view.addListener(new IListener()
{
public void notifyEvent(IEvent event)
{
if (event instanceof CDOViewLocksChangedEvent)
{
CDOViewLocksChangedEvent e = (CDOViewLocksChangedEvent)event;
// ...
}
}
});
ad 2] Multicast is already supported. Just do this:
CDOSession localSession = getSession();
CDORemoteSessionManager remoteSessionManager = localSession.getRemoteSessionManager();
CDORemoteSession[] remoteSessions = remoteSessionManager.getRemoteSessions();
remoteSessionManager.sendMessage(message, remoteSessions);
Also, you can define your own message types, see CDORemoteSessionMessage.getType(). The message data is just a byte array, so you can implement your message handler such that it decodes that data according to your message type.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
Re: [CDO] Optimistic Concurrency Control - Reg. [message #1778320 is a reply to message #1778124] |
Wed, 13 December 2017 06:38 |
|
Sorry, I missed that picture. The CDO server just sees (explicit) locks and commits, so, what you have in mind is not possible out of the box. But you could use a combination of CDOTransactionHandler and a custom remote message protocol, like so:
final CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
transaction.addTransactionHandler(new CDODefaultTransactionHandler()
{
@Override
public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureChange)
{
sendMessage("com.foo.modifyingObject", object.cdoID().toURIFragment().getBytes());
}
@Override
public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
{
sendMessage("com.foo.committedTransaction", null);
}
@Override
public void rolledBackTransaction(CDOTransaction transaction)
{
sendMessage("com.foo.rolledBackTransaction", null);
}
private void sendMessage(String type, byte[] data)
{
CDORemoteSessionMessage message = new CDORemoteSessionMessage(type, data);
CDORemoteSessionManager remoteSessionManager = session.getRemoteSessionManager();
remoteSessionManager.sendMessage(message, remoteSessionManager.getRemoteSessions());
}
});
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05129 seconds