Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Enforce model consistency between client and server
[CDO] Enforce model consistency between client and server [message #1751961] Tue, 17 January 2017 09:08 Go to next message
Robert Schulk is currently offline Robert SchulkFriend
Messages: 118
Registered: July 2015
Senior Member
We are frequently updating our emf model which is used by CDO.
Now, usually if a client connects with a deprecated version, the connection will fail.
Sometimes though, it IS possible to connect to the server, but "strange" behavior and exceptions occur.

Is it possible to damage a repository when connecting with an outdated client?
Is there any mechanism to ensure consistency between client and server?

We were thinking about adding a simple version string in the database to prevent outdated clients from connecting.
Re: [CDO] Enforce model consistency between client and server [message #1752037 is a reply to message #1751961] Wed, 18 January 2017 07:45 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6579
Registered: July 2009
Senior Member
Unfortunately Ecore has no means to specify/determine that two EPackages are two different versions of the same semantic model. There's just the nsURI that can be used to determine whether two EPackages are different or identical.

I assume that, when you change your model, you also change the nsURI, probably by increasing a version segment, or so. Now, when an outdated client commits changes that are based on the old model, the repository can not distinguish this "old" model from any other valid model and can, hence, not reject the commit. As a consequence you'll likely end up with both versions of our model being deployed and mapped in the repository. Corruption can probably only happen if the two versions of your models map to the same tables in the database. You could prevent that by specifying one of the following properties in your cdo-server.xml:

      <mappingStrategy type="horizontal">
        <property name="qualifiedNames" value="true"/>
      </mappingStrategy>


      <mappingStrategy type="horizontal">
        <property name="forceNamesWithID" value="true"/>
      </mappingStrategy>


See http://download.eclipse.org/modeling/emf/cdo/drops/R20160607-1209/help/org.eclipse.emf.cdo.doc/html/operators/Doc01_ConfiguringRepositories.html for details.

But what you probably really want is to prevent the use of these outdated models at all, once the newer version is deployed to the repository. You can easily do that with code like this:

    getRepository().addHandler(new WriteAccessHandler()
    {
      public void handleTransactionBeforeCommitting(ITransaction transaction, CommitContext commitContext, OMMonitor monitor) throws RuntimeException
      {
        for (InternalCDOPackageUnit packageUnit : commitContext.getNewPackageUnits())
        {
          for (InternalCDOPackageInfo packageInfo : packageUnit.getPackageInfos())
          {
            String nsURI = packageInfo.getPackageURI();
            if (isOutdated(nsURI))
            {
              throw new RuntimeException("Outdated model: " + nsURI);
            }
          }
        }
      }

      public void handleTransactionAfterCommitted(ITransaction transaction, CommitContext commitContext, OMMonitor monitor)
      {
        // Do nothing.
      }
    });


Re: [CDO] Enforce model consistency between client and server [message #1752349 is a reply to message #1752037] Sun, 22 January 2017 19:36 Go to previous message
Robert Schulk is currently offline Robert SchulkFriend
Messages: 118
Registered: July 2015
Senior Member
Thank you for the sample code! That would be a clean solution, but on the other hand: I fear that we are not organized enough to consequently change the ns uri for each package whenever there is a change Smile.

We will go with a version identifier in the repository. I guess that this is safe enough for our purposes.
Previous Topic:[CDO] High level change notifications between clients
Next Topic:(CDO-Server) Mongo DB
Goto Forum:
  


Current Time: Tue Jun 22 15:20:57 GMT 2021

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

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

Back to the top