Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Model Driven Health Tools » Use MDHT Validator and EMF in multi-threaded application(MDHT Validator thread safety, best practice discussion)
Use MDHT Validator and EMF in multi-threaded application [message #1743814] Mon, 19 September 2016 21:39 Go to next message
Haiwen Zhu is currently offline Haiwen ZhuFriend
Messages: 1
Registered: September 2016
Junior Member
Dear Sean Muir and MDHT Core Team,

As recommended, I've created my Eclipse account.

1. Static vs. synchronized load of MDHT Validator libraries:

Since you said earlier "once one validation is run the libraries are cached. ", and the validator will run faster and faster after a slow few at the beginning due to the library load, I have this question:

Are the validator libraries static libs? If yes, is below the best practice?

At Java class level, load the package once:

static {

ConsolPackage.eINSTANCE.eClass(); // Static package registration
}

What made you recommend below instead in your 9/7/16 email?

synchronized (LOAD_LOCK) {
ConsolPackage.eINSTANCE.eClass();
}

2. EMF Thread Safety:

In your 9/7/16 email, you shared below. We've since upgraded our AIS application to use the 08/16/2016 MDHT jars.

I spoke with Dragon at the 9/15-16 HL7 C-CDA Implementation-A-Thon on MDHT thread safety. He said EMF uses statics and therefore is not thread safe. EMF is another Eclipse Open Source project and that it's complex.

Questions:
a. Will it take huge effort for EMF to become thread safe? By replacing the statics somehow?
b. Is EMF the only reason why we shall synchronize the call to the MDHT Validator?

====== From your 9/7/16 email ======

"Below is the official response from Eclipse EMF

Is EMF thread-safe?
EMF can safely be used in multi-threaded environments; however, EMF does not, itself, ensure thread-safety in application model implementations. Data structures are unsynchronized, for performance and to avoid potential deadlock situations. The expectation is that a complete instance of the model (including resources and resource set, if present) should only be accessed by one thread at a time, and that the synchronization should be provided by the application at a higher level.
Since it is shared among multiple instances of a given application model, Ecore metadata is intended to be thread-safe for read-only access. However, there was a thread safety bug involving Ecore annotations, which is now fixed but will still affect older releases of EMF. Also, the demand initialization of SDO metadata is not thread-safe. See the following two questions for workarounds to these issues."

Thank you so much!
Haiwen Zhu
Re: Use MDHT Validator and EMF in multi-threaded application [message #1745204 is a reply to message #1743814] Thu, 06 October 2016 13:06 Go to previous messageGo to next message
Sean Muir is currently offline Sean MuirFriend
Messages: 63
Registered: September 2015
Member
I added some initial support for multi threading and testing
The draft release is here https://github.com/mdht/mdht-models/releases/tag/MultiThreaded
This is only to make the validation reentrant - Load is already thread safe
what is not supported by this is the ability of multiple threads to manipulate the same clinical document
Re: Use MDHT Validator and EMF in multi-threaded application [message #1746024 is a reply to message #1745204] Thu, 20 October 2016 15:41 Go to previous messageGo to next message
Sean Muir is currently offline Sean MuirFriend
Messages: 63
Registered: September 2015
Member
Here is a util to load the ocl based on an operations package
Will look to add this to the initialization of the ecore package eventually
  • Attachment: LoadOCL.java
    (Size: 2.26KB, Downloaded 139 times)
Re: Use MDHT Validator and EMF in multi-threaded application [message #1805636 is a reply to message #1743814] Fri, 19 April 2019 09:09 Go to previous message
Viraj Bhosle is currently offline Viraj BhosleFriend
Messages: 1
Registered: April 2019
Junior Member
While trying to parse CCDA documents in parallel and calling getters on the Section, we are getting errors tracing back to the mdht code. It seems that getters are lazily loading data and have some static state management or context. Please confirm whether working on multiple distinct ClinicalDocument objects is thread safe.

# Error-1
java.lang.UnsupportedOperationException
at org.openhealthtools.mdht.uml.cda.operations.CustodianOrganizationOperations.getAddrs(CustodianOrganizationOperations.java:297)
at org.openhealthtools.mdht.uml.cda.impl.CustodianOrganizationImpl.getAddrs(CustodianOrganizationImpl.java:706)

# Error-2
java.lang.UnsupportedOperationException
at org.openhealthtools.mdht.uml.cda.operations.SectionOperations.getOrganizers(SectionOperations.java:585)
at org.openhealthtools.mdht.uml.cda.impl.SectionImpl.getOrganizers(SectionImpl.java:1255)
Previous Topic:How do you parse the text using content Id?
Next Topic:Version of MDHT plugin for QRDA reporting year 2019
Goto Forum:
  


Current Time: Tue Apr 23 11:32:51 GMT 2024

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

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

Back to the top