Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Generate actor system from an EMF meta-model(How to generate an "EMF aware" actor system from a meta-model ?)
Generate actor system from an EMF meta-model [message #1793944] Mon, 20 August 2018 22:03 Go to next message
Emmanuel Chebbi is currently offline Emmanuel ChebbiFriend
Messages: 123
Registered: February 2018
Senior Member
Hi everyone !

I am currently working on a project for which I'd like to use an EMF meta-model to define my architecture. However, I feel that using an actor system instead of plain OOP would be relevant in my case.

I searched for a tool that would allow me to define an EMF meta-model describing an actor system but I didn't find anything. I am now willing to develop my own solution, but I am unsure about the right way to go about it.

More specifically, I have two needs:

  1. The generated code must rely on an actor framework (such as Orbit or Akka).
  2. The generated code must be "EMF aware" so that it can work out of the box with tools like Sirius or EMF.Edit.

I already know how I could tailor the generated code in order to create actors thanks to JET templates or Xtend, but I don't know how I could make it "EMF aware". I believe that I could build a "compatibility layer" that would act as a bridge between EMF and the model through inheritance but I'm afraid that the result would just be verbose and not really usable.

Does someone have an idea of how I could achieve that, or an approach that I could explore ? Or could explain to me if what I am trying to do does not really make sense / is not feasible ?

Please ask for further details if I wasn't clear enough.

Thanks,
Emmanuel
Re: Generate actor system from an EMF meta-model [message #1793950 is a reply to message #1793944] Tue, 21 August 2018 04:44 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
I don't know anything about actors so I don't know what problem you would need to solve in order to integrate that with EMF. Must the generated classes/interfaces implement some general interface or various specific interfaces?

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Generate actor system from an EMF meta-model [message #1793953 is a reply to message #1793950] Tue, 21 August 2018 07:13 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I suspect that this isn't really an EMF question; rather a concurrent information sharing problem, for which you hope that EMF will provide a magic answer.

Bottom line: EMF is not threadsafe. But, when used sympathetically, EMF can be threadsafe.

There is an informal policy that multi-threaded EMF applications such as editors/live-validators use a ResourceSet synchronization to avoid conflict. If you can live with such coarse grained synchronization then you have no real problem.

You haven't clarified the nature of your actors, so it is unclear whether they are coarse/fine-grained and whether there are many copies of the same kind of actor or many different kinds of actor. Whatever, from an EMF point of view, the 'scheduling' is a small part of the application for which EMF provides a variety of opportunities to relate your EMFActor to your OSActor. Perhaps inheritance, perhaps delegation, perhaps synonyming via the EClass.instanceClass. You might have derived EMFDumbPollingActor, EMFSmartPollingActor, EMFMessageTriggeredActor etc EClasses to share your fundamental scheduling policies with further derived Actors. No real modeling problem. (Delegation is probably best if you want to have a diversity of OSActor.)

But actors are typically concurrent and so you can easily imagine that one actor is using one end of a bidirectional reference while another actor preempts and changes the other end causing 'confusion'. I'm not sure whether CDO of EMF Transaction can help you here. What seems certain is that without strong discipline to ensure that EMF instances are private to particular actors, you will incur significant programming difficulties and run-time overheads to impose mutexes/synchronizations. Even if you can do that, you then have the problem of 'proving' that your anarchy of synchronization will never deadlock. Rather than contributing to your solution, without sympathetic usage, EMF will amplify the underlying design problems.

There is an alternative to an arms race to synchronization dystopia; no synchronization. IFF you have design control over ALL actors that access the EMF model, you can ensure that each actor's execution is sufficiently fine grained to allow any actor execution to complete before the next (highest priority) actor executes. No pre-emption gives no thread conflicts and an opportunity for a really fast trivial scheduler without multiple stacks. IMHO the only use for multiple shared-context background thread stacks is to support a concurrent debugger thread. The 'only' problem with this approach is that you must guarantee that ALL actor execution times are sufficiently short to satisfy the FASTEST response deadline. This can be achieved by breaking slow actor executions into multiple steps; tedious and fragile to do manually, but possible if you have an abstraction from which you code generate. IMHO a small price to pay for the huge benefits of no synchronization overheads and guaranteed deadlock free.

Regards

Ed Willink
Re: Generate actor system from an EMF meta-model [message #1793986 is a reply to message #1793953] Tue, 21 August 2018 22:35 Go to previous messageGo to next message
Emmanuel Chebbi is currently offline Emmanuel ChebbiFriend
Messages: 123
Registered: February 2018
Senior Member
Thank you both for your replies.

Ed Merks wrote

I don't know anything about actors so I don't know what problem you would need to solve in order to integrate that with EMF.

The main issue is that actor-oriented programming is conceptually different to OOP:

  • actors run in a concurrent way,
  • actors are not supposed to share data,
  • communication between actors relies on asynchronous messages rather than method calls.

Hence, it does not really fit EMF.

Ed Willink

You haven't clarified the nature of your actors

That's because ideally I would like to create a generic tool that would allow me to design any actor system and then to generate the corresponding Java code. I probably had not been clear enough on that point.

Ed Willink

I suspect that this isn't really an EMF question; rather a concurrent information sharing problem, for which you hope that EMF will provide a magic answer.

Actually I am not really expecting EMF to handle concurrency. I am rather thinking about a way to either adapt the code generated by EMF to make it fit within an actor-system or to create something like a bridge or an adapter allowing actors to interact with EMF and vice versa. For instance, EMF generates a lot of boilerplate methods that could, maybe, be turned into actor messages. Or maybe I could create special actors aimed to synchronize any interaction with EMF. To be honest this is not really clear in my mind.

The final goal is to be able to develop actor systems using an MDE approach and to benefit from the EMF ecosystem, but I don't know if such a tool is really feasible or if it is worth the time.

Ed Willink

There is an alternative to an arms race to synchronization dystopia; no synchronization.

In the case where I would use an existing actor framework and where I would like to allow any kind of actor system it seems difficult to achieve.
Re: Generate actor system from an EMF meta-model [message #1794001 is a reply to message #1793986] Wed, 22 August 2018 07:46 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I'm still not clear about your actors, but I'm guessing now that they come from some higher level of abstraction such as Simulink or Ptolemy diagrams.. This is good since you potentially have a sound system-level Model of Computation that enables you to decompose your system specification into sound sub-sub-sub-system (actor) specifications of communication/synchronization, security, ... You therefore 'just' need a chain of M2Ms to convert the high level abstraction to an implementation. I would certainly use EMF to ensure that everything is meta-modelled, but since you have a custom execution framework, I would almost certainly use a custom M2T for the final code generation; simple CG is really easy. If you really need some of the benefits of EMF such as XMI serialization, EMF.Edit, eClass() reflection etc, then I would look to a dual code generation, one for production without EMF support, and another for debugging with just enough EMF interface compliance to support what you need.

(It was the inadequacy of tool support for a chain of M2Ms that I encountered while collaborating on the CALtrop project with the Ptolemy guys at UCB that pushed me in my current M2M support activities. http://www.edwillink.plus.com/projects/wdl/wdl.html is an overview with many references of my vision of an actor-based MDE system.)

Regards

Ed Willink
Re: Generate actor system from an EMF meta-model [message #1820820 is a reply to message #1794001] Wed, 29 January 2020 15:16 Go to previous message
Emmanuel Chebbi is currently offline Emmanuel ChebbiFriend
Messages: 123
Registered: February 2018
Senior Member
I'd like to bring this thread back for completion purposes (for both future me and people who might stumble upon it). Since my initial post I have learned a lot about MDE & DSLs and I believe that I can now both explain the goal I had in mind and answer my own question.

So, given a model M conforming to a metamodel A, I wanted to be able to:

  1. use an actor system to define the semantics of A (i.e. what happens when M is executed),
  2. design M with an editor based on a framework like Sirius or Xtext.

I was stuck because I had the naive assumption that, in order to fulfil both wills, the semantics of A must:

  1. be written in Java,
  2. be an implementation of the interfaces generated by EMF,

which leaded to the idea of an "EMF-aware Orbit/Akka code". There are actually many better ways to define the semantics of a metamodel depending on the use case. For instance:

  • if the model should be executable then the semantics can be separately specified with EMF's Switch or languages such as Kermeta or ALE,
  • if the model should be embedded within an existing codebase then generating Java/Python/whatever code with Xtend can do the trick,
  • if the model is not very convenient for expressing the semantics then it is also possible to create two metamodels (one defining the syntax of the editor and another one defining an executable model) and use M2M transformations to convert the first into the latter,
  • etc.

In conclusion, and to answer myself, I would say that the approach depends on the requirements and that my vision of "defining an EMF meta-model describing an actor system" is a bit too vague.

Ed Willink wrote on Wed, 22 August 2018 09:46
http://www.edwillink.plus.com/projects/wdl/wdl.html is an overview with many references of my vision of an actor-based MDE system.

Thank you very much for the link! I still didn't have the time to read (and understand) everything but the documents are very interesting.
Previous Topic:Are Sirius and EMF Forms mutually exclusive?
Next Topic:[ECP] Model Explorer e4
Goto Forum:
  


Current Time: Fri Apr 19 11:46:36 GMT 2024

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

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

Back to the top