Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » CDO starter guide
CDO starter guide [message #54249] Thu, 28 September 2006 20:16 Go to next message
Gunay Arslan is currently offline Gunay ArslanFriend
Messages: 16
Registered: July 2009
Junior Member
Hi,

I am using EMF for in house developed modelling software, and need a
database persistence of my models. From the CDO web demo, seems like the
CDO can solve my problem, but could not find a basic starter
guide/tutorial. Is there a documentation that shows how to persists a
model, starting from creating the .ecore ?

Thank you in advance.
Gunay
Re: CDO starter guide [message #54392 is a reply to message #54249] Fri, 29 September 2006 07:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stepper.sympedia.de

This is a multi-part message in MIME format.
--------------020009080503060308040109
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Gunay,

I will provide a starter tutorial ASAP, maybe backed by another web demo
for developing a CDO'ished application. Basically it's not very
complicated, so here are the steps in short:

1. Install the CDO SDK (requires the Net4j SDK, possibly OCL)
2. Design your model (.ecore file) like you always did it (if you never
did it before please refer to the EMF docs or ask the EMF newsgroup)



3. Create a Genmodel like you always did it



4. Generate your model (important only if you'll be using the CDO
Migrator, it expects a plugin.xml)



4. Migrate the Ecore model to CDO (right-click the .ecore file -> CDO ->
Migrate Ecore to CDO)



5. Migrate the plugin.xml to CDO (right-click the .ecore file -> CDO ->
Add Mappings to plugin.xml)

<plugin>

<extension point="org.eclipse.emf.ecore.generated_package">
<package
uri = "http://example"
class = "example.ExamplePackage"
genModel = "model/example.genmodel" />
</extension>

<extension point="org.eclipse.emf.cdo.client.mappings">
<mapping
map="META-INF/example.mapping"
uri="http://example"/>
</extension>

</plugin>

6. Migrate the Genmodel to CDO (right-click the .genmodel file -> CDO ->
Migrate Genmodel to CDO)



7. Generate your model *and the edit plugin*

9. Fix the MANIFEST.MF of the model plugin (if you open a Bugzilla I can
try to automate this)



10. Fix the MANIFEST.MF of the edit plugin (if you open a Bugzilla I can
try to automate this)



That's it!
Now you can proceed as shown in the web demo (start Net4j server, start
client, ...)
The default RDBMS is Derby and the database is created in the working
directoy of the Net4j server (by default)

If you have further questions don't hesitate to contact me ;-)

Cheers
/Eike


Gunay Arslan schrieb:
> Hi,
>
> I am using EMF for in house developed modelling software, and need a
> database persistence of my models. From the CDO web demo, seems like
> the CDO can solve my problem, but could not find a basic starter
> guide/tutorial. Is there a documentation that shows how to persists a
> model, starting from creating the .ecore ?
>
> Thank you in advance.
> Gunay
>
>

--------------020009080503060308040109
Content-Type: multipart/related;
boundary="------------030600020209000201050205"


--------------030600020209000201050205
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Gunay,<br>
<br>
I will provide a starter tutorial ASAP, maybe backed by another web
demo for developing a CDO'ished application. Basically it's not very
complicated, so here are the steps in short:<br>
<br>
1. Install the CDO SDK (requires the Net4j SDK, possibly OCL)<br>
2. Design your model (.ecore file) like you always did it (if you never
did it before please refer to the EMF docs or ask the EMF newsgroup)<br>
<br>
<img src="cid:part1.02010302.01050800@sympedia.de" alt=""><br>
<br>
3. Create a Genmodel like you always did it<br>
<br>
<img src="cid:part2.03040008.03010402@sympedia.de" alt=""><br>
<br>
4. Generate your model (important only if you'll be using the CDO
Migrator, it expects a plugin.xml)<br>
<br>
<img src="cid:part3.07020906.04030300@sympedia.de" alt=""><br>
<br>
4. Migrate the Ecore model to CDO (right-click the .ecore file -&gt;
CDO -&gt; Migrate Ecore to CDO)<br>
<br>
<img src="cid:part4.01050501.07000704@sympedia.de" alt=""><br>
<br>
5. Migrate the plugin.xml to CDO (right-click the .ecore file -&gt; CDO
-&gt; Add Mappings to plugin.xml)<br>
<br>
&lt;plugin&gt;<br>
<br>
Re: CDO starter guide [message #54555 is a reply to message #54392] Fri, 29 September 2006 14:41 Go to previous messageGo to next message
Gunay Arslan is currently offline Gunay ArslanFriend
Messages: 16
Registered: July 2009
Junior Member
HI Eike,

Thank you very much for the help. Now I can create the resource over CDO.
I entered a future request for the CDO plugin update, when migrating
ecore files. https://bugs.eclipse.org/bugs/show_bug.cgi?id=159290

Eike, from .genmodel we can generate ....test plugin and there are codes
for quickly test the generated models, without starting a new runtime
eclipse workbench. Is is possible to do the same with CDO ? I mean the
ability to test the CDO client apart from the eclipse environment.

For the server,how it should be run ? headless run of the server ?

Thank you in advance.
Gunay
Re: CDO starter guide [message #54635 is a reply to message #54555] Fri, 29 September 2006 15:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stepper.sympedia.de

Gunay,

See comments inline...


Gunay Arslan schrieb:
> HI Eike,
>
> Thank you very much for the help. Now I can create the resource over
> CDO. I entered a future request for the CDO plugin update, when
> migrating ecore files.
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=159290
Got it ;-)

> Eike, from .genmodel we can generate ....test plugin and there are
> codes for quickly test the generated models, without starting a new
> runtime eclipse workbench. Is is possible to do the same with CDO ? I
> mean the ability to test the CDO client apart from the eclipse
> environment.
I'm not sure but I don't believe it.
CDO, like Net4j, will not work in non-Eclipse environments.
But basically your model code, although prepared for CDO, should be able
to be used with other resource implementations like XM(L/I)Resource or
even without be attached to a resource at all. I have not tried it so
far but I can imagine that I'll be able to fix bugs that you report on
this topic.

For tests I use the feature of embedding a CDO/Net4j server into the
client, so that I don't have to use separate VMs for client and server.
Even socket transport could be routed through a single VM but with
embedded transport you can easily avoid the problem of socket binding
problems. Of course you need a minimum (headless) Eclipse environment
for this setup, too. I'd suggest that you have a look at the automated
tests that come with CDO (separate download). There you can see how to
setup such an environment.

> For the server,how it should be run ? headless run of the server ?
I'd say headless is enough. You can also start UI bundles, but headless
is the more common choice for the server.

Cheers
/Eike
Re: CDO starter guide [message #54688 is a reply to message #54555] Fri, 29 September 2006 19:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stepper.sympedia.de

Gunay Arslan schrieb:
> HI Eike,
>
> Thank you very much for the help. Now I can create the resource over
> CDO. I entered a future request for the CDO plugin update, when
> migrating ecore files.
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=159290
I've committed the migrator changes to CVS.
It will be included in the 0.7.1 maintenance build when has retired from
Callisto flooding ;-)

Cheers
/Eike
Re: CDO starter guide [message #55000 is a reply to message #54635] Fri, 29 September 2006 21:50 Go to previous messageGo to next message
Gunay Arslan is currently offline Gunay ArslanFriend
Messages: 16
Registered: July 2009
Junior Member
Hi Eike

at the beggining I was assuming that I had to run a single server, the CDO
server, and all my workstations had to connect to this server. Now I see
that every workstation will need to run an embedded CDO server, and all of
them had to connect to the database. The share point is the database not
the CDO server as I was assuming, Am I right ?

and also for a client, with pure EMF we have something like
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource =esourceSet.createResource(URI.createURI(".."));
resource.getContents().add(...);

now we can add our eobject to the resource. How is this with the CDO ?

Thanks,
Gunay
Re: CDO starter guide [message #55080 is a reply to message #55000] Sat, 30 September 2006 05:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stepper.sympedia.de

Gunay Arslan schrieb:
> Hi Eike
>
> at the beggining I was assuming that I had to run a single server, the
> CDO server, and all my workstations had to connect to this server. Now
> I see that every workstation will need to run an embedded CDO server,
> and all of them had to connect to the database. The share point is the
> database not the CDO server as I was assuming, Am I right ?
No, exactly the opposite is true ;-)
Hibernate, JDO and thelike do the mapping at client-side (share point: DBMS)
CDO uses server-side mapping. This is due to better performance but
mainly to be able to distribute asynchronous invalidation notifications.
This is the normal way to setup a CDO topology.

The embedded topology is mainly for testing but also for other
applications on top of Net4j, or people who simply like to embed the
mapper (+/- database) into their app.

>
> and also for a client, with pure EMF we have something like
> ResourceSet resourceSet = new ResourceSetImpl();
> Resource resource =esourceSet.createResource(URI.createURI(".."));
> resource.getContents().add(...);
>
> now we can add our eobject to the resource. How is this with the CDO ?
The only thing that changes is that you have to prepare your ResourceSet
for the usage with CDO.
You can use an aritrary ResourceSet but you must associate it with a CDO
ResourceManager that can handle model distribution.
Please have a look at
org.eclipse.emf.cdo.examples.ui.internal.editors.CDOEditor:

public void createModel()
{
CDOEditorInput editorInput = (CDOEditorInput)getEditorInput();
String uri = editorInput.getResourceURI();

try
{
// @ADDED
resourceManager =
ExampleClientPlugin.createResourceManager(editingDomain.getR esourceSet());
resourceManager.addInvalidationListener(this);

// Load the resource through the editing domain.
editingDomain.loadResource(uri);
}
catch (Exception exception)
{
ExampleUIActivator.INSTANCE.log(exception);
}
}

and org.eclipse.emf.cdo.examples.client.internal.ExampleClientPl ugin:

public static ResourceManager createResourceManager(ResourceSet
resourceSet)
{
ResourceManager resourceManager = (ResourceManager)
getClientContainer().getBean(
"resourceManager");
resourceManager.setResourceSet(resourceSet);

try
{
resourceManager.start();
}
catch (Exception ex)
{
getDefault().error("Problem while starting ResourceManager " +
resourceManager, ex);
}

return resourceManager;
}

One more thing to mention:
CDO uses transactions at the ResourceSet level, not for single Resources!
The usual way to commit a CDO transaction is

resourceManager.commit();

Mostly because (EMF generated) editors don't know the ResourceManager
out-of-the-box there is a convenience delegation in
org.eclipse.emf.cdo.client.impl.CDOResourceImpl:

public void save(Map options)
{
try
{
resourceManager.commit();
}
catch (OptimisticControlException ex)
{
throw ex;
}
catch (RuntimeException ex)
{
logger.error("Error while committing", ex);
throw ex;
}
catch (Throwable t)
{
logger.error("Error while committing", t);
throw new RuntimeException(t);
}
}

that is, resource.save(Collection.EMPTY_MAP) will commit *all* CDOResources!

I hope this removes the confusion ;-)

Cheers
/Eike
Re: CDO starter guide [message #55131 is a reply to message #55080] Sat, 30 September 2006 12:11 Go to previous messageGo to next message
Gunay Arslan is currently offline Gunay ArslanFriend
Messages: 16
Registered: July 2009
Junior Member
HI Eike,

it is bad that answering the message over web does not include the
original message, maybe a improvement request can be created for this.

With CDO Server issue, I am bit confused.I understand the reason behind
using the CDO Server as a share point, but could not figure out what is
the best practice running the CDO Server. Assuming that I will need to run
the CDO server on server machine (Linux) without a graphical interface,
which plugins should I had to get ? Is there a detail documentation about
this ? I remember that in the past I could create a script for running the
help system of the Eclipse in Linux environment without GUI, most probably
the CDO server will be something like, only I had to figure which plugins
are must, right ??

Another issue is new models. Assume that I have a running CDO Server on my
network. Now I created another model (.ecore, .genmodel ... ) can I use
the new models/clients with already running server ?? Does server need to
have model plugins for proper operation ?? Do I have to stop and add the
new model plugin to the server plugins directory ??

In Multiuser environment security is another issue, does server have hooks
for checking connected clients ?.

In my current application we are using several model files (using XML
persistence of the EMF) and every model is ~1M, total eobject are in terms
of thousand, I want to replace it with CDO. the number of objects will
increase and in the future we are planning to use cross model references.
If I am going to migrate to CDO, does it going to work ?

Eike thank you very much for being so helpful.

Best Regards,
Gunay Arslan
Re: CDO starter guide [message #55241 is a reply to message #55131] Sat, 30 September 2006 17:07 Go to previous message
Eclipse UserFriend
Originally posted by: stepper.sympedia.de

Gunay Arslan schrieb:
> HI Eike,
>
> it is bad that answering the message over web does not include the
> original message, maybe a improvement request can be created for this.
It took me a while what you mean here because I always use the
Thunderbird for my news.
That said, you *can* include the quoted original message as shown below:


If you think that the "Quote" button at the bottom of the reply form is
not at the place where people would expect it to be, I can only agree ;-)
Why don't you file a Bugzilla? I'd try it here:
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Phoenix& amp;bug_severity=enhancement

>
> With CDO Server issue, I am bit confused.I understand the reason
> behind using the CDO Server as a share point, but could not figure out
> what is the best practice running the CDO Server.
Yes, that's often the case with open frameworks ;-)
When I finally come to tutorials I'll remember this fact and provide
several example.
If you want to, you can also use the wiki for that purpose and share
your experience.

> Assuming that I will need to run the CDO server on server machine
> (Linux) without a graphical interface, which plugins should I had to
> get ?
With Einstein I'd say: Get as few as possible but no fewer ;-)
But without joking, the web demo shows how to determine the needed
plugins. Please keep in mind that Net4j and CDO are *frameworks* not
applications. You can use them to form applications at your taste. This
is the reason why I decided to put all the UI stuff that you can see in
the web demo into the Examples feature. It's just one (generic) example
application. But I think it's a typical application setup and you could
choose to build upon that or copy and modify it.

The pattern is the following: CDO/Net4j provide the framework
components. You have to decide which of them to use and how to wire
them. This depends on your requirements and design decisions:
- Which DBMS do you want to use? Which JDBC drivers do you have for it?
- Do you need authentication? Where/how are the credentials stored?
- Are there other application protocols than CDO to be supported (see
Net4j provisioning example)? Shall all protocols share the same connection?
- ...

When you have answered all these questions you can start to develop a
plugin (or severals) to reflect the chosen architecture. CDO/Net4j uses
Spring Framework application contexts for creating and wiring the
framework components you need. Please have a look into the META-INF
folders of the example plugins. Some contain additional XML files that,
at runtime, are accessed through the BundleActivator (Plugin class) of
that plugin. I've already posted you an example of this pattern:
Obtaining a ResourceManager for use with an EMF ResourceSet.

Since there are so many possibilities I expect that you'll have further
questions. That's ok ;-)

> Is there a detail documentation about this ?
Sorry, there's even no undetailed documentatin about these issues, yet ;-(

> I remember that in the past I could create a script for running the
> help system of the Eclipse in Linux environment without GUI, most
> probably the CDO server will be something like, only I had to figure
> which plugins are must, right ??
Exactly, it's actually quite simple.
An example application that can be run in headless mode is provided in
org.eclipse.net4j.examples.server:

public class ExampleServerApplication implements IPlatformRunnable
{
public Object run(Object args) throws Exception
{
ExampleServerPlugin.getDefault().startServer();
System.out.println("HIT ENTER FOR SHUTDOWN!!!");

while (System.in.available() == 0)
{
DeadlockDetector.sleep(100);
}

ExampleServerPlugin.getDefault().stopServer();
return null;
}
}

You should start your analysis from here. This example application also
provides a basic Spring application context in
/org.eclipse.net4j.examples.server/META-INF/net4j.xml where all the
communications details are configured (socket transport, ...,
negotiation/authentication could also go here). It further provides an
extension-point to let you contribute additional server functionality.
Look at the examples in org.eclipse.net4j.examples.prov.server and
org.eclipse.emf.cdo.examples.server.

>
> Another issue is new models. Assume that I have a running CDO Server
> on my network. Now I created another model (.ecore, .genmodel ... )
> can I use the new models/clients with already running server ??
Yes, simply deploy the models to the clients and go.

> Does server need to have model plugins for proper operation ??
No, the original version of CDO required you to deploy the models to the
server. The first major redesign (the effort which led to the current
version) introduced a completely different approach: A CDO server is
basically not aware of EMF (at least with respect to your models). Your
model information is transfered to the server when needed and stored in
the database. Note that the format does not allow to recreate either the
original Ecore model or even the model code. Anyway the process should
be completely transparent for you.

Btw. it's interesting that you mention this concern, because I plan for
the next version of CDO to return to the original way of having the
model plugins deployed to both the server and the clients. The reason is
that I want to be able to have OCL constraints checked at server-side as
part of committing a transaction. This would only be feasible if the
server can access your instances through a regular Ecore API. BUT:
Deploying the models to the server does fortunately not imply that
you'll have to restart the server (originally this was one of the main
reasons to use OSGi at server-side)! You can use several means to
install and start the model plugins in a running server. For example
just add -console to the command used to start the headless OSGi
framework and use OSGI console commands ("install", "start").

> Do I have to stop and add the new model plugin to the server plugins
> directory ??
See above.

>
> In Multiuser environment security is another issue, does server have
> hooks for checking connected clients ?.
Net4j contains framework components to do configurable authentication on
a Connector (connection) basis. Basically you'll have to inject a
Negotiator into the Connector you are using. Net4j provides
org.eclipse.net4j.core.impl.ServerChallengeNegotiatorImpl and
org.eclipse.net4j.core.impl.SimpleClientChallengeNegotiatorI mpl as
default implementations. At server-side the Negotiator can be wired with
an AuthenticationManager. At client-side you will want to provide your
own implementation of ClientChallengeNegotiator that provides login
dialogs and password caching. It's all up to you.

>
> In my current application we are using several model files (using XML
> persistence of the EMF) and every model is ~1M, total eobject are in
> terms of thousand, I want to replace it with CDO. the number of
> objects will increase and in the future we are planning to use cross
> model references. If I am going to migrate to CDO, does it going to
> work ?
Certainly ;-)
Inter resource references are explicitely and transparently supported by
CDO. Further CDO is from ground up designed to scale well. I hope that
I've done a good job ;-) I know of at least one user running a really
HUGE repository for several years in production. He's come along with me
since the earliest version of CDO that was published outside of
Eclipse.org. Of course, issues arise from time to time, but hey, this is
open source software and usually I'm able to fix issues or provide
requested functionality in acceptable time ;-)
>
> Eike thank you very much for being so helpful.
You're welcome!

Cheers
/Eike
Re: CDO starter guide [message #592665 is a reply to message #54249] Fri, 29 September 2006 07:17 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6690
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020009080503060308040109
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Gunay,

I will provide a starter tutorial ASAP, maybe backed by another web demo
for developing a CDO'ished application. Basically it's not very
complicated, so here are the steps in short:

1. Install the CDO SDK (requires the Net4j SDK, possibly OCL)
2. Design your model (.ecore file) like you always did it (if you never
did it before please refer to the EMF docs or ask the EMF newsgroup)



3. Create a Genmodel like you always did it



4. Generate your model (important only if you'll be using the CDO
Migrator, it expects a plugin.xml)



4. Migrate the Ecore model to CDO (right-click the .ecore file -> CDO ->
Migrate Ecore to CDO)



5. Migrate the plugin.xml to CDO (right-click the .ecore file -> CDO ->
Add Mappings to plugin.xml)

<plugin>

<extension point="org.eclipse.emf.ecore.generated_package">
<package
uri = "http://example"
class = "example.ExamplePackage"
genModel = "model/example.genmodel" />
</extension>

<extension point="org.eclipse.emf.cdo.client.mappings">
<mapping
map="META-INF/example.mapping"
uri="http://example"/>
</extension>

</plugin>

6. Migrate the Genmodel to CDO (right-click the .genmodel file -> CDO ->
Migrate Genmodel to CDO)



7. Generate your model *and the edit plugin*

9. Fix the MANIFEST.MF of the model plugin (if you open a Bugzilla I can
try to automate this)



10. Fix the MANIFEST.MF of the edit plugin (if you open a Bugzilla I can
try to automate this)



That's it!
Now you can proceed as shown in the web demo (start Net4j server, start
client, ...)
The default RDBMS is Derby and the database is created in the working
directoy of the Net4j server (by default)

If you have further questions don't hesitate to contact me ;-)

Cheers
/Eike


Gunay Arslan schrieb:
> Hi,
>
> I am using EMF for in house developed modelling software, and need a
> database persistence of my models. From the CDO web demo, seems like
> the CDO can solve my problem, but could not find a basic starter
> guide/tutorial. Is there a documentation that shows how to persists a
> model, starting from creating the .ecore ?
>
> Thank you in advance.
> Gunay
>
>

--------------020009080503060308040109
Content-Type: multipart/related;
boundary="------------030600020209000201050205"


--------------030600020209000201050205
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Gunay,<br>
<br>
I will provide a starter tutorial ASAP, maybe backed by another web
demo for developing a CDO'ished application. Basically it's not very
complicated, so here are the steps in short:<br>
<br>
1. Install the CDO SDK (requires the Net4j SDK, possibly OCL)<br>
2. Design your model (.ecore file) like you always did it (if you never
did it before please refer to the EMF docs or ask the EMF newsgroup)<br>
<br>
<img src="cid:part1.02010302.01050800@sympedia.de" alt=""><br>
<br>
3. Create a Genmodel like you always did it<br>
<br>
<img src="cid:part2.03040008.03010402@sympedia.de" alt=""><br>
<br>
4. Generate your model (important only if you'll be using the CDO
Migrator, it expects a plugin.xml)<br>
<br>
<img src="cid:part3.07020906.04030300@sympedia.de" alt=""><br>
<br>
4. Migrate the Ecore model to CDO (right-click the .ecore file -&gt;
CDO -&gt; Migrate Ecore to CDO)<br>
<br>
<img src="cid:part4.01050501.07000704@sympedia.de" alt=""><br>
<br>
5. Migrate the plugin.xml to CDO (right-click the .ecore file -&gt; CDO
-&gt; Add Mappings to plugin.xml)<br>
<br>
&lt;plugin&gt;<br>
<br>


Re: CDO starter guide [message #592726 is a reply to message #54392] Fri, 29 September 2006 14:41 Go to previous message
Gunay Arslan is currently offline Gunay ArslanFriend
Messages: 16
Registered: July 2009
Junior Member
HI Eike,

Thank you very much for the help. Now I can create the resource over CDO.
I entered a future request for the CDO plugin update, when migrating
ecore files. https://bugs.eclipse.org/bugs/show_bug.cgi?id=159290

Eike, from .genmodel we can generate ....test plugin and there are codes
for quickly test the generated models, without starting a new runtime
eclipse workbench. Is is possible to do the same with CDO ? I mean the
ability to test the CDO client apart from the eclipse environment.

For the server,how it should be run ? headless run of the server ?

Thank you in advance.
Gunay
Re: CDO starter guide [message #592755 is a reply to message #54555] Fri, 29 September 2006 15:03 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6690
Registered: July 2009
Senior Member
Gunay,

See comments inline...


Gunay Arslan schrieb:
> HI Eike,
>
> Thank you very much for the help. Now I can create the resource over
> CDO. I entered a future request for the CDO plugin update, when
> migrating ecore files.
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=159290
Got it ;-)

> Eike, from .genmodel we can generate ....test plugin and there are
> codes for quickly test the generated models, without starting a new
> runtime eclipse workbench. Is is possible to do the same with CDO ? I
> mean the ability to test the CDO client apart from the eclipse
> environment.
I'm not sure but I don't believe it.
CDO, like Net4j, will not work in non-Eclipse environments.
But basically your model code, although prepared for CDO, should be able
to be used with other resource implementations like XM(L/I)Resource or
even without be attached to a resource at all. I have not tried it so
far but I can imagine that I'll be able to fix bugs that you report on
this topic.

For tests I use the feature of embedding a CDO/Net4j server into the
client, so that I don't have to use separate VMs for client and server.
Even socket transport could be routed through a single VM but with
embedded transport you can easily avoid the problem of socket binding
problems. Of course you need a minimum (headless) Eclipse environment
for this setup, too. I'd suggest that you have a look at the automated
tests that come with CDO (separate download). There you can see how to
setup such an environment.

> For the server,how it should be run ? headless run of the server ?
I'd say headless is enough. You can also start UI bundles, but headless
is the more common choice for the server.

Cheers
/Eike


Re: CDO starter guide [message #592783 is a reply to message #54555] Fri, 29 September 2006 19:02 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6690
Registered: July 2009
Senior Member
Gunay Arslan schrieb:
> HI Eike,
>
> Thank you very much for the help. Now I can create the resource over
> CDO. I entered a future request for the CDO plugin update, when
> migrating ecore files.
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=159290
I've committed the migrator changes to CVS.
It will be included in the 0.7.1 maintenance build when has retired from
Callisto flooding ;-)

Cheers
/Eike


Re: CDO starter guide [message #592937 is a reply to message #54635] Fri, 29 September 2006 21:50 Go to previous message
Gunay Arslan is currently offline Gunay ArslanFriend
Messages: 16
Registered: July 2009
Junior Member
Hi Eike

at the beggining I was assuming that I had to run a single server, the CDO
server, and all my workstations had to connect to this server. Now I see
that every workstation will need to run an embedded CDO server, and all of
them had to connect to the database. The share point is the database not
the CDO server as I was assuming, Am I right ?

and also for a client, with pure EMF we have something like
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource =esourceSet.createResource(URI.createURI(".."));
resource.getContents().add(...);

now we can add our eobject to the resource. How is this with the CDO ?

Thanks,
Gunay
Re: CDO starter guide [message #592971 is a reply to message #55000] Sat, 30 September 2006 05:16 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6690
Registered: July 2009
Senior Member
Gunay Arslan schrieb:
> Hi Eike
>
> at the beggining I was assuming that I had to run a single server, the
> CDO server, and all my workstations had to connect to this server. Now
> I see that every workstation will need to run an embedded CDO server,
> and all of them had to connect to the database. The share point is the
> database not the CDO server as I was assuming, Am I right ?
No, exactly the opposite is true ;-)
Hibernate, JDO and thelike do the mapping at client-side (share point: DBMS)
CDO uses server-side mapping. This is due to better performance but
mainly to be able to distribute asynchronous invalidation notifications.
This is the normal way to setup a CDO topology.

The embedded topology is mainly for testing but also for other
applications on top of Net4j, or people who simply like to embed the
mapper (+/- database) into their app.

>
> and also for a client, with pure EMF we have something like
> ResourceSet resourceSet = new ResourceSetImpl();
> Resource resource =esourceSet.createResource(URI.createURI(".."));
> resource.getContents().add(...);
>
> now we can add our eobject to the resource. How is this with the CDO ?
The only thing that changes is that you have to prepare your ResourceSet
for the usage with CDO.
You can use an aritrary ResourceSet but you must associate it with a CDO
ResourceManager that can handle model distribution.
Please have a look at
org.eclipse.emf.cdo.examples.ui.internal.editors.CDOEditor:

public void createModel()
{
CDOEditorInput editorInput = (CDOEditorInput)getEditorInput();
String uri = editorInput.getResourceURI();

try
{
// @ADDED
resourceManager =
ExampleClientPlugin.createResourceManager(editingDomain.getR esourceSet());
resourceManager.addInvalidationListener(this);

// Load the resource through the editing domain.
editingDomain.loadResource(uri);
}
catch (Exception exception)
{
ExampleUIActivator.INSTANCE.log(exception);
}
}

and org.eclipse.emf.cdo.examples.client.internal.ExampleClientPl ugin:

public static ResourceManager createResourceManager(ResourceSet
resourceSet)
{
ResourceManager resourceManager = (ResourceManager)
getClientContainer().getBean(
"resourceManager");
resourceManager.setResourceSet(resourceSet);

try
{
resourceManager.start();
}
catch (Exception ex)
{
getDefault().error("Problem while starting ResourceManager " +
resourceManager, ex);
}

return resourceManager;
}

One more thing to mention:
CDO uses transactions at the ResourceSet level, not for single Resources!
The usual way to commit a CDO transaction is

resourceManager.commit();

Mostly because (EMF generated) editors don't know the ResourceManager
out-of-the-box there is a convenience delegation in
org.eclipse.emf.cdo.client.impl.CDOResourceImpl:

public void save(Map options)
{
try
{
resourceManager.commit();
}
catch (OptimisticControlException ex)
{
throw ex;
}
catch (RuntimeException ex)
{
logger.error("Error while committing", ex);
throw ex;
}
catch (Throwable t)
{
logger.error("Error while committing", t);
throw new RuntimeException(t);
}
}

that is, resource.save(Collection.EMPTY_MAP) will commit *all* CDOResources!

I hope this removes the confusion ;-)

Cheers
/Eike


Re: CDO starter guide [message #592987 is a reply to message #55080] Sat, 30 September 2006 12:11 Go to previous message
Gunay Arslan is currently offline Gunay ArslanFriend
Messages: 16
Registered: July 2009
Junior Member
HI Eike,

it is bad that answering the message over web does not include the
original message, maybe a improvement request can be created for this.

With CDO Server issue, I am bit confused.I understand the reason behind
using the CDO Server as a share point, but could not figure out what is
the best practice running the CDO Server. Assuming that I will need to run
the CDO server on server machine (Linux) without a graphical interface,
which plugins should I had to get ? Is there a detail documentation about
this ? I remember that in the past I could create a script for running the
help system of the Eclipse in Linux environment without GUI, most probably
the CDO server will be something like, only I had to figure which plugins
are must, right ??

Another issue is new models. Assume that I have a running CDO Server on my
network. Now I created another model (.ecore, .genmodel ... ) can I use
the new models/clients with already running server ?? Does server need to
have model plugins for proper operation ?? Do I have to stop and add the
new model plugin to the server plugins directory ??

In Multiuser environment security is another issue, does server have hooks
for checking connected clients ?.

In my current application we are using several model files (using XML
persistence of the EMF) and every model is ~1M, total eobject are in terms
of thousand, I want to replace it with CDO. the number of objects will
increase and in the future we are planning to use cross model references.
If I am going to migrate to CDO, does it going to work ?

Eike thank you very much for being so helpful.

Best Regards,
Gunay Arslan
Re: CDO starter guide [message #593044 is a reply to message #55131] Sat, 30 September 2006 17:07 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6690
Registered: July 2009
Senior Member
Gunay Arslan schrieb:
> HI Eike,
>
> it is bad that answering the message over web does not include the
> original message, maybe a improvement request can be created for this.
It took me a while what you mean here because I always use the
Thunderbird for my news.
That said, you *can* include the quoted original message as shown below:


If you think that the "Quote" button at the bottom of the reply form is
not at the place where people would expect it to be, I can only agree ;-)
Why don't you file a Bugzilla? I'd try it here:
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Phoenix& amp;bug_severity=enhancement

>
> With CDO Server issue, I am bit confused.I understand the reason
> behind using the CDO Server as a share point, but could not figure out
> what is the best practice running the CDO Server.
Yes, that's often the case with open frameworks ;-)
When I finally come to tutorials I'll remember this fact and provide
several example.
If you want to, you can also use the wiki for that purpose and share
your experience.

> Assuming that I will need to run the CDO server on server machine
> (Linux) without a graphical interface, which plugins should I had to
> get ?
With Einstein I'd say: Get as few as possible but no fewer ;-)
But without joking, the web demo shows how to determine the needed
plugins. Please keep in mind that Net4j and CDO are *frameworks* not
applications. You can use them to form applications at your taste. This
is the reason why I decided to put all the UI stuff that you can see in
the web demo into the Examples feature. It's just one (generic) example
application. But I think it's a typical application setup and you could
choose to build upon that or copy and modify it.

The pattern is the following: CDO/Net4j provide the framework
components. You have to decide which of them to use and how to wire
them. This depends on your requirements and design decisions:
- Which DBMS do you want to use? Which JDBC drivers do you have for it?
- Do you need authentication? Where/how are the credentials stored?
- Are there other application protocols than CDO to be supported (see
Net4j provisioning example)? Shall all protocols share the same connection?
- ...

When you have answered all these questions you can start to develop a
plugin (or severals) to reflect the chosen architecture. CDO/Net4j uses
Spring Framework application contexts for creating and wiring the
framework components you need. Please have a look into the META-INF
folders of the example plugins. Some contain additional XML files that,
at runtime, are accessed through the BundleActivator (Plugin class) of
that plugin. I've already posted you an example of this pattern:
Obtaining a ResourceManager for use with an EMF ResourceSet.

Since there are so many possibilities I expect that you'll have further
questions. That's ok ;-)

> Is there a detail documentation about this ?
Sorry, there's even no undetailed documentatin about these issues, yet ;-(

> I remember that in the past I could create a script for running the
> help system of the Eclipse in Linux environment without GUI, most
> probably the CDO server will be something like, only I had to figure
> which plugins are must, right ??
Exactly, it's actually quite simple.
An example application that can be run in headless mode is provided in
org.eclipse.net4j.examples.server:

public class ExampleServerApplication implements IPlatformRunnable
{
public Object run(Object args) throws Exception
{
ExampleServerPlugin.getDefault().startServer();
System.out.println("HIT ENTER FOR SHUTDOWN!!!");

while (System.in.available() == 0)
{
DeadlockDetector.sleep(100);
}

ExampleServerPlugin.getDefault().stopServer();
return null;
}
}

You should start your analysis from here. This example application also
provides a basic Spring application context in
/org.eclipse.net4j.examples.server/META-INF/net4j.xml where all the
communications details are configured (socket transport, ...,
negotiation/authentication could also go here). It further provides an
extension-point to let you contribute additional server functionality.
Look at the examples in org.eclipse.net4j.examples.prov.server and
org.eclipse.emf.cdo.examples.server.

>
> Another issue is new models. Assume that I have a running CDO Server
> on my network. Now I created another model (.ecore, .genmodel ... )
> can I use the new models/clients with already running server ??
Yes, simply deploy the models to the clients and go.

> Does server need to have model plugins for proper operation ??
No, the original version of CDO required you to deploy the models to the
server. The first major redesign (the effort which led to the current
version) introduced a completely different approach: A CDO server is
basically not aware of EMF (at least with respect to your models). Your
model information is transfered to the server when needed and stored in
the database. Note that the format does not allow to recreate either the
original Ecore model or even the model code. Anyway the process should
be completely transparent for you.

Btw. it's interesting that you mention this concern, because I plan for
the next version of CDO to return to the original way of having the
model plugins deployed to both the server and the clients. The reason is
that I want to be able to have OCL constraints checked at server-side as
part of committing a transaction. This would only be feasible if the
server can access your instances through a regular Ecore API. BUT:
Deploying the models to the server does fortunately not imply that
you'll have to restart the server (originally this was one of the main
reasons to use OSGi at server-side)! You can use several means to
install and start the model plugins in a running server. For example
just add -console to the command used to start the headless OSGi
framework and use OSGI console commands ("install", "start").

> Do I have to stop and add the new model plugin to the server plugins
> directory ??
See above.

>
> In Multiuser environment security is another issue, does server have
> hooks for checking connected clients ?.
Net4j contains framework components to do configurable authentication on
a Connector (connection) basis. Basically you'll have to inject a
Negotiator into the Connector you are using. Net4j provides
org.eclipse.net4j.core.impl.ServerChallengeNegotiatorImpl and
org.eclipse.net4j.core.impl.SimpleClientChallengeNegotiatorI mpl as
default implementations. At server-side the Negotiator can be wired with
an AuthenticationManager. At client-side you will want to provide your
own implementation of ClientChallengeNegotiator that provides login
dialogs and password caching. It's all up to you.

>
> In my current application we are using several model files (using XML
> persistence of the EMF) and every model is ~1M, total eobject are in
> terms of thousand, I want to replace it with CDO. the number of
> objects will increase and in the future we are planning to use cross
> model references. If I am going to migrate to CDO, does it going to
> work ?
Certainly ;-)
Inter resource references are explicitely and transparently supported by
CDO. Further CDO is from ground up designed to scale well. I hope that
I've done a good job ;-) I know of at least one user running a really
HUGE repository for several years in production. He's come along with me
since the earliest version of CDO that was published outside of
Eclipse.org. Of course, issues arise from time to time, but hey, this is
open source software and usually I'm able to fix issues or provide
requested functionality in acceptable time ;-)
>
> Eike thank you very much for being so helpful.
You're welcome!

Cheers
/Eike


Previous Topic:EMF Model Synchrinization with Multipage Editor (Tree based Editor and Text Editor)
Next Topic:Can I add my own class path entries to JETEmitter project
Goto Forum:
  


Current Time: Sun Oct 06 14:19:27 GMT 2024

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

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

Back to the top