[CDO] Enforce model consistency between client and server [message #1751961] |
Tue, 17 January 2017 04:08  |
Eclipse User |
|
|
|
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 02:45   |
Eclipse User |
|
|
|
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.
}
});
|
|
|
|
Powered by
FUDForum. Page generated in 0.03138 seconds