| [CDO] Multi master (clone) [message #923803] |
Wed, 26 September 2012 03:57  |
Ricky de Klerck Messages: 282 Registered: January 2011 |
Senior Member |
|
|
I was told to ask this question on the emf forum so here it is.. I managed to create a CDO master and clone following the examples in org.eclipse.emf.cdo.examples. (I'm trying to achieve the architecture described like http://www.eclipse.org/forums/index.php/m/880089/)
I still have one problem now.. I've set up 2 clients, one connected to the master and one to the clone. When I save an object in the clone, everything is synchronized well, but the other way around (save object in master) doesn't work. The changes aren't pushed (or pulled) from master to clone. Anybody had this problem before?
Thanks in advance!
|
|
|
|
| Re: [CDO] Multi master (clone) [message #923993 is a reply to message #923816] |
Wed, 26 September 2012 07:39   |
Ricky de Klerck Messages: 282 Registered: January 2011 |
Senior Member |
|
|
Thanks for your answer. Creating an executable example is not that easy because I now have 2 seperate clients, a clone and a master.. So before I do that, some code might do the trick. First of all, the 'PassiveUpdateMode.ADDITIONS' you mentioned is part of the client, right? The session is created and a setPassiveUpdateMode() is done?
The code of my clients is identical, only the repository is different (clone or master):
System.out.println("Client starting...");
IManagedContainer container = OfflineExampleUtil.createContainer();
IConnector connector = Net4jUtil.getConnector(container, AbstractOfflineExampleServer.TRANSPORT_TYPE, "localhost:"
+ 2036);
CDONet4jSessionConfiguration configuration = CDONet4jUtil.createNet4jSessionConfiguration();
configuration.setConnector(connector);
configuration.setRepositoryName("cdo");
CDONet4jSession session = configuration.openNet4jSession();
session.options().setPassiveUpdateEnabled(true);
session.options().setPassiveUpdateMode(PassiveUpdateMode.ADDITIONS);
// session.getPackageRegistry().putEPackage(VlaamsparlementPackage.eINSTANCE);
CDORepositoryInfo repositoryInfo = session.getRepositoryInfo();
System.out.println("Connected to " + repositoryInfo.getName());
return session;
This is the code to create the master:
CDOServerUtil.createRepository(name, store, props);
And this is (some of) the code to create the clone:
...
CDOServerUtil.createOfflineClone(name, store, props, synchronizer);
...
protected IRepositorySynchronizer createRepositorySynchronizer(String connectorDescription, String repositoryName)
{
CDOSessionConfigurationFactory factory = createSessionConfigurationFactory(connectorDescription, repositoryName);
IRepositorySynchronizer synchronizer = CDOServerUtil.createRepositorySynchronizer(factory);
synchronizer.setRetryInterval(2);
synchronizer.setMaxRecommits(10);
synchronizer.setRecommitInterval(2);
synchronizer.setRawReplication(true);
return synchronizer;
}
I make use of the AbstractOfflineExampleServer which is used in org.eclipse.emf.cdo.examples.
Does this help to solve the problem in any way?
[Updated on: Wed, 26 September 2012 08:08] Report message to a moderator
|
|
|
| Re: [CDO] Multi master (clone) [message #924802 is a reply to message #923993] |
Thu, 27 September 2012 02:16   |
Eike Stepper Messages: 5148 Registered: July 2009 |
Senior Member |
|
|
Am 26.09.2012 13:39, schrieb Ricky de Klerck:
> Thanks for your answer. To create an executable example is not that easy because I now have 2 seperate clients, a
> clone and a master.. So before I do that, some code might do the trick. First of all, the
> 'PassiveUpdateMode.ADDITIONS' you mentioned is part of the client, right? The session is created and a
> setPassiveUpdateMode() is done?
No, in a "normal" client you don't need PassiveUpdateMode.ADDITIONS and probably shouldn't use it as it leads to
substantially more network traffic. I just mentioned it because the "client" in the RepositorySynchronizer uses this
mode to receive all changes and additions from the master:
CDOSessionConfiguration masterConfiguration = remoteSessionConfigurationFactory.createSessionConfiguration();
masterConfiguration.setPassiveUpdateMode(PassiveUpdateMode.ADDITIONS);
masterConfiguration.setLockNotificationMode(LockNotificationMode.ALWAYS);
remoteSession = (InternalCDOSession)masterConfiguration.openSession();
ensureNOOPRevisionCache();
> The code of my clients is identical, only the repository is different (clone or master):
That should be okay.
> System.out.println("Client starting...");
> IManagedContainer container = OfflineExampleUtil.createContainer();
> IConnector connector = Net4jUtil.getConnector(container, AbstractOfflineExampleServer.TRANSPORT_TYPE, "localhost:"
> + 2036);
The port is correct?
> CDONet4jSessionConfiguration configuration = CDONet4jUtil.createNet4jSessionConfiguration();
> configuration.setConnector(connector);
> configuration.setRepositoryName("cdo");
>
> CDONet4jSession session = configuration.openNet4jSession();
> session.options().setPassiveUpdateEnabled(true);
> session.options().setPassiveUpdateMode(PassiveUpdateMode.ADDITIONS);
It's a little bit faster to set these already on the configuration used to open the session.
> // session.getPackageRegistry().putEPackage(VlaamsparlementPackage.eINSTANCE);
putEPackage() is indeed not needed anymore for generated and deployed packages with post 3.0 versions of CDO.
> CDORepositoryInfo repositoryInfo = session.getRepositoryInfo();
> System.out.println("Connected to " + repositoryInfo.getName());
>
> return session;
>
> This is the code to create the master:
> CDOServerUtil.createRepository(name, store, props);
>
> And this is (some of) the code to create the clone:
>
> ..
> CDOServerUtil.createOfflineClone(name, store, props, synchronizer);
> ..
>
> protected IRepositorySynchronizer createRepositorySynchronizer(String connectorDescription, String repositoryName)
> {
> CDOSessionConfigurationFactory factory = createSessionConfigurationFactory(connectorDescription, repositoryName);
>
> IRepositorySynchronizer synchronizer = CDOServerUtil.createRepositorySynchronizer(factory);
> synchronizer.setRetryInterval(2);
> synchronizer.setMaxRecommits(10);
> synchronizer.setRecommitInterval(2);
> synchronizer.setRawReplication(true);
> return synchronizer;
> }
That looks okay to me.
> I make use of the AbstractOfflineExampleServer which is used in org.eclipse.emf.cdo.examples.
>
> Does this help to solve the problem in any way?
I don't think so ;-(
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
|
|
| Re: [CDO] Multi master (clone) [message #925229 is a reply to message #925095] |
Thu, 27 September 2012 10:10   |
Ricky de Klerck Messages: 282 Registered: January 2011 |
Senior Member |
|
|
Ok, i did a little test with the testsuite from org.eclipse.emf.cdo.examples (grabbed the source from http://git.eclipse.org/c/cdo/cdo.git/tree/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/server/offline). I tested it with mysql databases so this is the code I changed:
com.mysql.jdbc.jdbc2.optional.MysqlDataSource ds = new com.mysql.jdbc.jdbc2.optional.MysqlDataSource();
ds.setUrl("jdbc:mysql://localhost/" + name);
ds.setUser("cdo");
ds.setPassword("cdo");
IMappingStrategy mappingStrategy = CDODBUtil.createHorizontalMappingStrategy(true, true);
IDBAdapter dbAdapter = new MYSQLAdapter();
IDBConnectionProvider dbConnectionProvider = DBUtil.createConnectionProvider(ds);
return CDODBUtil.createStore(mappingStrategy, dbAdapter, dbConnectionProvider);
//JdbcDataSource dataSource = new JdbcDataSource();
//dataSource.setURL("jdbc:h2:database/" + name);
//
//IMappingStrategy mappingStrategy = CDODBUtil.createHorizontalMappingStrategy(true, true);
//IDBAdapter dbAdapter = new H2Adapter();
//IDBConnectionProvider dbConnectionProvider = DBUtil.createConnectionProvider(dataSource);
//return CDODBUtil.createStore(mappingStrategy, dbAdapter, dbConnectionProvider);
Test 1:
- removed all tables from both databases (clone and master)
- started master (all tables are created)
- started clone (all tables are created)
- started client (CONNECTED TO CLONE)
- added object via client
- object is added in both databases
- Result: OK
Test 2:
- removed all tables from both databases (clone and master)
- started master (all tables are created)
- started clone (all tables are created)
- started client (CONNECTED TO MASTER)
- added object via client
- object is only added in master database
- Result: NOT OK
[Updated on: Thu, 27 September 2012 10:11] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|