Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Starting a CDO server programatically
[CDO] Starting a CDO server programatically [message #429302] Fri, 17 April 2009 15:45 Go to next message
Anders Forsell is currently offline Anders ForsellFriend
Messages: 127
Registered: July 2009
Senior Member
I want to start and configure a CDO server inside my application.
The cdo-config.xml I was using with the CDO server application looked
like this:

<?xml version="1.0" encoding="UTF-8"?>
<cdoServer>
<acceptor type="tcp" listenAddr="0.0.0.0" port="2036">
<!-- negotiator type="challenge" description="/temp/users.db"/ -->
</acceptor>
<repository name="repo1">
<property name="overrideUUID"
value="1ff5d226-b1f0-40fb-aba2-0c31b38c764f"/>
<property name="supportingAudits" value="false"/>
<property name="verifyingRevisions" value="false"/>
<property name="currentLRUCapacity" value="10000"/>
<property name="revisedLRUCapacity" value="100"/>

<store type="mem"/>
</repository>
</cdoServer>

Will the below code be equivalent to running the CDO server application
with the above config file?

IMEMStore store = MEMStoreUtil.createMEMStore();
Map<String, String> props = new HashMap<String, String>();
props.put(Props.SUPPORTING_AUDITS, "false");
props.put(Props.VERIFYING_REVISIONS, "false");
props.put(Props.CURRENT_LRU_CAPACITY, "10000");
props.put(Props.REVISED_LRU_CAPACITY, "100");
repository = CDOServerUtil.createRepository("repo1", store, props);
serverContainer = IPluginContainer.INSTANCE;
LifecycleUtil.activate(serverContainer);
CDOServerUtil.addRepository(serverContainer, repository);
acceptor = TCPUtil.getAcceptor(serverContainer, "0.0.0.0:2036");

( I did not include the 'overrideUUID'. Is it needed and if so why? )

---
Anders
Re: [CDO] Starting a CDO server programatically [message #429307 is a reply to message #429302] Fri, 17 April 2009 17:03 Go to previous messageGo to next message
Simon Mc Duff is currently offline Simon Mc DuffFriend
Messages: 596
Registered: July 2009
Senior Member
Anders Forsell wrote:

> I want to start and configure a CDO server inside my application.
> The cdo-config.xml I was using with the CDO server application looked
> like this:

> <?xml version="1.0" encoding="UTF-8"?>
> <cdoServer>
> <acceptor type="tcp" listenAddr="0.0.0.0" port="2036">
> <!-- negotiator type="challenge" description="/temp/users.db"/ -->
> </acceptor>
> <repository name="repo1">
> <property name="overrideUUID"
> value="1ff5d226-b1f0-40fb-aba2-0c31b38c764f"/>
> <property name="supportingAudits" value="false"/>
> <property name="verifyingRevisions" value="false"/>
> <property name="currentLRUCapacity" value="10000"/>
> <property name="revisedLRUCapacity" value="100"/>

> <store type="mem"/>
> </repository>
> </cdoServer>

> Will the below code be equivalent to running the CDO server application
> with the above config file?

I think it is good... in a OSGI context. If you are not... it will not
work.

You can find example here:
http://wiki.eclipse.org/User_Contributed_CDO_Documentation#S nippets

> IMEMStore store = MEMStoreUtil.createMEMStore();
> Map<String, String> props = new HashMap<String, String>();
> props.put(Props.SUPPORTING_AUDITS, "false");
> props.put(Props.VERIFYING_REVISIONS, "false");
> props.put(Props.CURRENT_LRU_CAPACITY, "10000");
> props.put(Props.REVISED_LRU_CAPACITY, "100");
> repository = CDOServerUtil.createRepository("repo1", store, props);
> serverContainer = IPluginContainer.INSTANCE;
> LifecycleUtil.activate(serverContainer);
> CDOServerUtil.addRepository(serverContainer, repository);
> acceptor = TCPUtil.getAcceptor(serverContainer, "0.0.0.0:2036");

> ( I did not include the 'overrideUUID'. Is it needed and if so why? )

No it is not needed. If you do not provide one, a UUID will be generated
for you. (If I remember correctly)

In the future we are planning to remove it.



> ---
> Anders
Re: [CDO] Starting a CDO server programatically [message #429325 is a reply to message #429307] Mon, 20 April 2009 01:33 Go to previous messageGo to next message
Matthew Watson is currently offline Matthew WatsonFriend
Messages: 24
Registered: July 2009
Junior Member
Hi,

I also am trying to start a server outside of eclipse and OSGI.


>> IMEMStore store = MEMStoreUtil.createMEMStore();
>> Map<String, String> props = new HashMap<String, String>();
>> props.put(Props.SUPPORTING_AUDITS, "false");
>> props.put(Props.VERIFYING_REVISIONS, "false");
>> props.put(Props.CURRENT_LRU_CAPACITY, "10000");
>> props.put(Props.REVISED_LRU_CAPACITY, "100");
>> repository = CDOServerUtil.createRepository("repo1", store, props);
>> serverContainer = IPluginContainer.INSTANCE;
>> LifecycleUtil.activate(serverContainer);
>> CDOServerUtil.addRepository(serverContainer, repository);
>> acceptor = TCPUtil.getAcceptor(serverContainer, "0.0.0.0:2036");

Well, thanks to your example, I was able to get an example that would run.
I'm using 3.5.M6, EMF 2.5.0, CDO/NET4J 2.0.0. This is my running server:
Now I need to figure out how to turn logging on so I can see what it's
doing...

Both the memstore and derby store work - I'm playing with getting
teneo/hibernate to work also.

public static void main(String[] args) throws InterruptedException,
IOException
{
// IMappingStrategy mappingStratgey =
CDODBUtil.createHorizontalMappingStrategy();
// IDBAdapter dbAdapter = new EmbeddedDerbyAdapter();
//
// EmbeddedDataSource dataSource = new EmbeddedDataSource();
// dataSource.setUser("sa");
// dataSource.setDatabaseName("/tmp/cdodb1");
// dataSource.setCreateDatabase("create");
//
// IDBConnectionProvider dbConnectionProvider =
DBUtil.createConnectionProvider(dataSource);
//
// IJDBCDelegateProvider delegateProvider = new
PreparedStatementJDBCDelegateProvider();
// IStore store = CDODBUtil.createStore(mappingStratgey, dbAdapter,
dbConnectionProvider, delegateProvider );

// IHibernateMappingProvider hibMappingProvider =
HibernateUtil.getInstance().createFileMappingProvider("model/ddd.xml ");
// IStore store2 = CDOHibernateUtil.createStore(hibMappingProvider);

IMEMStore store3 = MEMStoreUtil.createMEMStore();

Map<String,String> props = new HashMap<String,String>();
props.put(IRepository.Props.CURRENT_LRU_CAPACITY, "100000");

IRepository repository = CDOServerUtil.createRepository("repo1",
store3, props);

IManagedContainer container = ContainerUtil.createContainer();
Net4jUtil.prepareContainer(container);
TCPUtil.prepareContainer(container);
LifecycleUtil.activate(container);
CDOServerUtil.prepareContainer(container);
CDOServerUtil.addRepository(container, repository);

IAcceptor acceptor = TCPUtil.getAcceptor(container,
"0.0.0.0:2036");

System.out.println("Press any key to shut down (port:" +
acceptor.toString() + ")");

while (System.in.read() == -1)
{
Thread.sleep(200);
}
container.deactivate();
}
Re: [CDO] Starting a CDO server programatically [message #429326 is a reply to message #429325] Mon, 20 April 2009 04:04 Go to previous messageGo to next message
Simon Mc Duff is currently offline Simon Mc DuffFriend
Messages: 596
Registered: July 2009
Senior Member
Hi Matthew,

I`m glad that you manage it!

For the logging you can look at the following:
http://wiki.eclipse.org/FAQ_for_CDO_and_Net4j#How_can_I_enab le_tracing.3F

Simon

Matthew Watson wrote:

> Hi,

> I also am trying to start a server outside of eclipse and OSGI.


>>> IMEMStore store = MEMStoreUtil.createMEMStore();
>>> Map<String, String> props = new HashMap<String, String>();
>>> props.put(Props.SUPPORTING_AUDITS, "false");
>>> props.put(Props.VERIFYING_REVISIONS, "false");
>>> props.put(Props.CURRENT_LRU_CAPACITY, "10000");
>>> props.put(Props.REVISED_LRU_CAPACITY, "100");
>>> repository = CDOServerUtil.createRepository("repo1", store, props);
>>> serverContainer = IPluginContainer.INSTANCE;
>>> LifecycleUtil.activate(serverContainer);
>>> CDOServerUtil.addRepository(serverContainer, repository);
>>> acceptor = TCPUtil.getAcceptor(serverContainer, "0.0.0.0:2036");

> Well, thanks to your example, I was able to get an example that would run.
> I'm using 3.5.M6, EMF 2.5.0, CDO/NET4J 2.0.0. This is my running server:
> Now I need to figure out how to turn logging on so I can see what it's
> doing...

> Both the memstore and derby store work - I'm playing with getting
> teneo/hibernate to work also.

> public static void main(String[] args) throws InterruptedException,
> IOException
> {
> // IMappingStrategy mappingStratgey =
> CDODBUtil.createHorizontalMappingStrategy();
> // IDBAdapter dbAdapter = new EmbeddedDerbyAdapter();
> //
> // EmbeddedDataSource dataSource = new EmbeddedDataSource();
> // dataSource.setUser("sa");
> // dataSource.setDatabaseName("/tmp/cdodb1");
> // dataSource.setCreateDatabase("create");
> //
> // IDBConnectionProvider dbConnectionProvider =
> DBUtil.createConnectionProvider(dataSource);
> //
> // IJDBCDelegateProvider delegateProvider = new
> PreparedStatementJDBCDelegateProvider();
> // IStore store = CDODBUtil.createStore(mappingStratgey, dbAdapter,
> dbConnectionProvider, delegateProvider );

> // IHibernateMappingProvider hibMappingProvider =
> HibernateUtil.getInstance().createFileMappingProvider("model/ddd.xml ");
> // IStore store2 = CDOHibernateUtil.createStore(hibMappingProvider);

> IMEMStore store3 = MEMStoreUtil.createMEMStore();

> Map<String,String> props = new HashMap<String,String>();
> props.put(IRepository.Props.CURRENT_LRU_CAPACITY, "100000");

> IRepository repository = CDOServerUtil.createRepository("repo1",
> store3, props);

> IManagedContainer container = ContainerUtil.createContainer();
> Net4jUtil.prepareContainer(container);
> TCPUtil.prepareContainer(container);
> LifecycleUtil.activate(container);
> CDOServerUtil.prepareContainer(container);
> CDOServerUtil.addRepository(container, repository);

> IAcceptor acceptor = TCPUtil.getAcceptor(container,
> "0.0.0.0:2036");

> System.out.println("Press any key to shut down (port:" +
> acceptor.toString() + ")");

> while (System.in.read() == -1)
> {
> Thread.sleep(200);
> }
> container.deactivate();
> }
Re: [CDO] Starting a CDO server programatically [message #429332 is a reply to message #429302] Mon, 20 April 2009 06:14 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Anders,

Comments below...



Anders Forsell schrieb:
> I want to start and configure a CDO server inside my application.
> The cdo-config.xml I was using with the CDO server application looked
> like this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <cdoServer>
> <acceptor type="tcp" listenAddr="0.0.0.0" port="2036">
> <!-- negotiator type="challenge" description="/temp/users.db"/ -->
> </acceptor>
> <repository name="repo1">
> <property name="overrideUUID"
> value="1ff5d226-b1f0-40fb-aba2-0c31b38c764f"/>
> <property name="supportingAudits" value="false"/>
> <property name="verifyingRevisions" value="false"/>
> <property name="currentLRUCapacity" value="10000"/>
> <property name="revisedLRUCapacity" value="100"/>
>
> <store type="mem"/>
> </repository>
> </cdoServer>
>
> Will the below code be equivalent to running the CDO server
> application with the above config file?
Looks good ;-)
>
> IMEMStore store = MEMStoreUtil.createMEMStore();
> Map<String, String> props = new HashMap<String, String>();
> props.put(Props.SUPPORTING_AUDITS, "false");
> props.put(Props.VERIFYING_REVISIONS, "false");
> props.put(Props.CURRENT_LRU_CAPACITY, "10000");
> props.put(Props.REVISED_LRU_CAPACITY, "100");
> repository = CDOServerUtil.createRepository("repo1", store, props);
> serverContainer = IPluginContainer.INSTANCE;
> LifecycleUtil.activate(serverContainer);
The IPluginContainer is an IManagedContainer with the factories and
element processors populated from the extension registry. It should
automatically be activated, so no need to do it manually. Only if
running standalone, you need to prepare the container yourself and
activate it subsequently before filling it with elements.

> CDOServerUtil.addRepository(serverContainer, repository);
> acceptor = TCPUtil.getAcceptor(serverContainer, "0.0.0.0:2036");
>
> ( I did not include the 'overrideUUID'. Is it needed and if so why? )
It's not needed. As Simon said, it's generated at first startup of the
repository then. For test purposes it can be desirable to have a
predictable UUID,or you may want to have something shorter than a
regular UUID...

Cheers
/Eike

----
http://thegordian.blogspot.com


Previous Topic:[CDO] How to "convert" an XMI resource to a CDO resource
Next Topic:[CDO] Standalone Server Example?
Goto Forum:
  


Current Time: Fri Apr 26 15:20:33 GMT 2024

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

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

Back to the top