Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Multi-user eviroment synchronization
[Teneo] Multi-user eviroment synchronization [message #1385012] Tue, 03 June 2014 15:53 Go to next message
Xavipen Mising name is currently offline Xavipen Mising nameFriend
Messages: 59
Registered: March 2011
Member
Hi,

We are looking into RAP/EMF/Teneo for a new project we are going to start. The combination looks great. However, after going through the documentation, it is still not clear what mechanism to use for concurrent access for a multi-user enviroment like RAP. I will try to elaborate a bit more.

As I have read in the forum it seems clear that: One session or persistence manager should be used by one thread.

The issue is that is not clear to me when this session or persistence Manager are called.

For example: A thread setting an attribute in the model will be the same thread calling the persistance Manager?

Does this means that all changes done to the model need to run in the same thread?
If this is the case, is there already a mechanism to serialize the calls from different threads. Or would i have to pass all the changes to the model to a single thread that is in charge to serialize the modifications/Queries to the model?

As an alternative, is there any locking mechanism that could be use on the model to synchronize the modifications/Queries from diferent threads?

I would be great is somebody could clarify a bit these part of the Architecture or point me to the direction where to look for further documentation.

Also were could i find more information about the persistance Manager?

Best Regards,
Javi

Re: [Teneo] Multi-user eviroment synchronization [message #1385059 is a reply to message #1385012] Wed, 04 June 2014 06:38 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Xavipen,
Not sure what a thread is in this case. You mean different users? Or multiple users each running their own thread?
In any case, with hibernate, each user-thread has its own hibernate session/entitymanager. In a 2-tier rcp architecture
the sessionfactory/entitymanagerfactory is also in this same client.
In a web environment, the session/entitymanager is mostly recreated for each http request and the
sessionfactory/entitymanagerfactory is shared among different requests/users.

The texo project could also be of interest for you, then you can support both a 2 and 3-tier architecture:
http://martintaal.wordpress.com/2012/08/30/taking-emf-to-the-third-tier-the-texo-json-resource/

gr. Martin


On 03-06-14 17:53, Xavipen Mising name wrote:
> Hi,
>
> We are looking into RAP/EMF/Teneo for a new project we are going to start. The combination looks great. However, after
> going through the documentation, it is still not clear what mechanism to use for concurrent access for a multi-user
> enviroment like RAP. I will try to elaborate a bit more.
>
> As I have read in the forum it seems clear that: One session or persistence manager should be used by one thread.
>
> The issue is that is not clear to me when this session or persistence Manager are called.
>
> For example: A thread setting an attribute in the model will be the same thread calling the persistance Manager?
> Does this means that all changes done to the model need to run in the same thread?
> If this is the case, is there already a mechanism to serialize the calls from different threads. Or would i have to pass
> all the changes to the model to a single thread that is in charge to serialize the modifications/Queries to the model?
>
> As an alternative, is there any locking mechanism that could be use on the model to synchronize the
> modifications/Queries from diferent threads?
>
> I would be great is somebody could clarify a bit these part of the Architecture or point me to the direction where to
> look for further documentation.
>
> Also were could i find more information about the persistance Manager?
>
> Best Regards,
> Javi
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Teneo] Multi-user eviroment synchronization [message #1385165 is a reply to message #1385059] Wed, 04 June 2014 17:16 Go to previous messageGo to next message
Xavipen Mising name is currently offline Xavipen Mising nameFriend
Messages: 59
Registered: March 2011
Member
Hi Martin,

Thanks for your reply.

As we are using RAP, it is kind of a web environtment but with a bit more of complication.

Quote:
In a web environment, the session/entitymanager is mostly recreated for each http request and the sessionfactory/entitymanagerfactory is shared among different requests/users.


Ok, this is understood, each thread has to use a session and perform the unit of work with in the transactions and this should take care of the concurrent changes.
Do i need to close() the session once i am done with the transaction or can i reuse it for another transaction later own?

However, my concern is how does the EMF notification mechanism fits with this?

Does the changes in one EObject in one session will be notified to an "equivalent" EObject (have the same id) loaded in a different session from the same sessionfactory?
My guess would be that it does not, although i do hope that i am wrong Smile

Would the EMF notification mechanism system work only inside the session "scope"?

The objective is to use JFace with EMF Databindings for the displays in RAP, so all users get updates when another user makes a change.

Could be a valid alternative to use the EMF Hibernate Resource. Share it on the different users and saving it when there are changes. The issue I would have here is that then I would lose the query capabilities, wouldn't I?

Best Regards,
Javi

Re: [Teneo] Multi-user eviroment synchronization [message #1385197 is a reply to message #1385165] Wed, 04 June 2014 22:45 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Javi,
Not sure about this but afaik RAP runs each user in a separate environment so I don't think you share a
hibernateresource between users. It is not possible either as the save action is shared also.

Changes are not broadcasted to other objects in other clients. I think you want to look at CDO which supports this.

EMF Notification work separately from hibernate sessions, they are not related.

You can re-use a session for new transactions. But one session should only be used by one user, a session is really a
unit of work, so it corresponds to one edit view for example or to load data in a grid. So normally sessions don't live
very long. They are like database connections, you get them use them and then close them as quickly as possible.

gr. Martin

On 04-06-14 19:16, Xavipen Mising name wrote:
> Hi Martin,
>
> Thanks for your reply.
> As we are using RAP, it is kind of a web environtment but with a bit more of complication.
>
> Quote:
>> In a web environment, the session/entitymanager is mostly recreated for each http request and the
>> sessionfactory/entitymanagerfactory is shared among different requests/users.
>
>
> Ok, this is understood, each thread has to use a session and perform the unit of work with in the transactions and this
> should take care of the concurrent changes.
> Do i need to close() the session once i am done with the transaction or can i reuse it for another transaction later own?
>
> However, my concern is how does the EMF notification mechanism fits with this?
>
> Does the changes in one EObject in one session will be notified to an "equivalent" EObject (have the same id) loaded in
> a different session from the same sessionfactory?
> My guess would be that it does not, although i do hope that i am wrong :)
>
> Would the EMF notification mechanism system work only inside the session "scope"?
>
> The objective is to use JFace with EMF Databindings for the displays in RAP, so all users get updates when another user
> makes a change.
>
> Could be a valid alternative to use the EMF Hibernate Resource. Share it on the different users and saving it when there
> are changes. The issue I would have here is that then I would lose the query capabilities, wouldn't I?
>
> Best Regards,
> Javi
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Teneo] Multi-user eviroment synchronization [message #1385273 is a reply to message #1385197] Thu, 05 June 2014 10:29 Go to previous messageGo to next message
Xavipen Mising name is currently offline Xavipen Mising nameFriend
Messages: 59
Registered: March 2011
Member
Hi Martin,

Quote:

Not sure about this but afaik RAP runs each user in a separate environment so I don't think you share a
hibernateresource between users. It is not possible either as the save action is shared also.


Actually, i have done this already in my previous project. It is posible to share an EMF Resource among the different UISessions in RAP and then synchronize the calls to save. It was not an EMF hiberanteResource, but i guess i would not be much different. The difference there is that the model was not too big an could be in memory all the time. However, for this new project the model is going to be quite big.

Quote:
Changes are not broadcasted to other objects in other clients. I think you want to look at CDO which supports this.


Thanks for the typ, i will also have a look at CDO.

Quote:
EMF Notification work separately from hibernate sessions, they are not related.

You can re-use a session for new transactions. But one session should only be used by one user, a session is really a
unit of work, so it corresponds to one edit view for example or to load data in a grid. So normally sessions don't live
very long. They are like database connections, you get them use them and then close them as quickly as possible.


I am afraid that i may have a confusion some where as Teneo is not Hibernate but uses Hibernate.

My understanding was that if i do a query and i get a list of objects in one session and then in another session i do the same query the result with hiberante is that i get two list which contain different JVM objects but that have the same ids.

When i do this in Teneo would the objects in the two list would be the same ones JVM objects or the same EMF object?

Best Regards,
Javi
Re: [Teneo] Multi-user eviroment synchronization [message #1385288 is a reply to message #1385273] Thu, 05 June 2014 11:57 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Javi,
To answer your last question, they would be different objects, only if you use the same session you get the same object.
A HibernateResource has one session, which can be shared with other hibernate resources also:
https://wiki.eclipse.org/Teneo/Hibernate/EMF_Resource#Sharing_one_Session_between_Resources.2C_One_transaction_when_saving_multiple_resources

gr. Martin

On 05-06-14 12:29, Xavipen Mising name wrote:
> Hi Martin,
>
> Quote:
>> Not sure about this but afaik RAP runs each user in a separate environment so I don't think you share a
>> hibernateresource between users. It is not possible either as the save action is shared also.
>
>
> Actually, i have done this already in my previous project. It is posible to share an EMF Resource among the different
> UISessions in RAP and then synchronize the calls to save. It was not an EMF hiberanteResource, but i guess i would not
> be much different. The difference there is that the model was not too big an could be in memory all the time. However,
> for this new project the model is going to be quite big.
>
> Quote:
>> Changes are not broadcasted to other objects in other clients. I think you want to look at CDO which supports this.
>
>
> Thanks for the typ, i will also have a look at CDO.
>
> Quote:
>> EMF Notification work separately from hibernate sessions, they are not related.
>>
>> You can re-use a session for new transactions. But one session should only be used by one user, a session is really a
>> unit of work, so it corresponds to one edit view for example or to load data in a grid. So normally sessions don't live
>> very long. They are like database connections, you get them use them and then close them as quickly as possible.
>
>
> I am afraid that i may have a confusion some where as Teneo is not Hibernate but uses Hibernate.
>
> My understanding was that if i do a query and i get a list of objects in one session and then in another session i do
> the same query the result with hiberante is that i get two list which contain different JVM objects but that have the
> same ids.
>
> When i do this in Teneo would the objects in the two list would be the same ones JVM objects or the same EMF object?
>
> Best Regards,
> Javi


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Previous Topic:Interchange ECP Version 130_M4 with 130_RC1
Next Topic:View Model NullPointerException
Goto Forum:
  


Current Time: Tue Mar 19 10:22:22 GMT 2024

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

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

Back to the top