Difference between revisions of "CDO/Legacy Mode"

From Eclipsepedia

< CDO
Jump to: navigation, search
(Advantages)
(Switch me on)
 
(20 intermediate revisions by 2 users not shown)
Line 4: Line 4:
 
= Drawbacks =  
 
= Drawbacks =  
  
The disadvantage of the legacy mode lies in its nature. It is just a bridge between EMF and the CDO framework. Thus it inherits the limited scalability of “normal” EMF implementations. It is also a bit slower than the native CDO approach. See the chapter about performance for more information.
+
The disadvantage of the legacy mode lies in its nature, it is just a minimal bridge between EMF and the CDO framework. Thus it inherits the limited scalability of "normal" EMF implementations. This means that legacy support does not support lazy loading or unloading. It is also a bit slower than the native CDO approach. See the [[CDO_Legacy_Mode#Performance|chapter]] about performance for more information.
  
 
= Switch me on =  
 
= Switch me on =  
  
We decided to make the legacy mode switchable. This has two reasons. First, native mode is always recommended. Use legacy objects only if you have not other chance. But then you should be aware of the disadvantaged.
+
'''Important note: As of CDO 4.2 (M6) the legacy mode is always on and cannot be turned off!''' The following section only applies to older CDO versions:
The second reason is the automatically attaching EObject to CDO could be harder to debug. Guess a user forgot to convert it’s model by accident and than receives an error which is related to legacy. This fact might not be show in the behaior of the error or even the stack trace of the exception. With a switchable legacy mode we can assure the user who are using legacy know what they do and that they are aware of using legacy.
+
  
To switch legacy support on or off you can refer to new static methods in CDOUtil. This will influence the default setting for newly created CDOViews.
+
The legacy mode is configurable per view and '''turned off''' by default. To switch legacy support on or off you can refer to static methods in CDOUtil. This will influence the setting for newly created CDOViews. Note that these methods are only setting the default behavior for the current thread. So you must ensure that yout set the flag for the right thread.
Note that these method are only setting the default behavior for the current thread. So you must ensure that yout set the flag for the right thread.
+
  
 
<source lang="java">
 
<source lang="java">
Line 19: Line 17:
 
</source>
 
</source>
  
The snippet below shows how legacy can be enabled or disabled.
+
The snippet below shows how legacy support can be enabled or disabled.
  
 
<source lang="java">
 
<source lang="java">
Line 33: Line 31:
 
</source>
 
</source>
  
Additionally you can ask your view whether legacy is enabled for it by using the following method.
+
Additionally you can ask your view whether legacy mode is enabled for it by using the following method.
 
<source lang="java">
 
<source lang="java">
 
CDOView view = ...;
 
CDOView view = ...;
 
boolean isLegacy = view.isLegacyModeEnabled();
 
boolean isLegacy = view.isLegacyModeEnabled();
 
</source>
 
</source>
 +
 +
Note, that you are not limited to use either native or legacy models. If you like you can combine both. It does not matter whether you reference from native to legacy or vice versa.
  
 
=DynamicEObjects=
 
=DynamicEObjects=
While it was forbidden and punished with an exception to use DynamicEObjects on CDO this is now possible. You can create the dynamic objects as you are used to and store them in CDO. But remember that this is not the recommended way. Because dynamic EObjects can easily be converted to CDO you are encouraged to use CDOUtil.prepareDynamicEPackage(dynamicMapEPackage) whenever possible to convert your dynamic model to a CDO native one. For this reason the tracer, when activated, gives a warning if you have not done so.
+
Now it's possible to use DynamicEObjects on CDO. You can create the dynamic objects as you are used to and store them in CDO. But remember that this is not the recommended way. Since dynamic EObjects can easily be converted to CDO you are encouraged to use CDOUtil.prepareDynamicEPackage(dynamicMapEPackage) whenever possible to convert your dynamic model to a CDO native one.
 
+
= Mixed Mode =
+
 
+
You are not limited to use either native or legacy models. If you like you can combine both. This is then called the mixed mode. It does not matter whether you reference from native to legacy or vice versa.
+
  
 
= Performance =  
 
= Performance =  
  
Due to its nature legacy mode is slower than the native approach. But have in mind that the loss of performance only applies to the client site. For the communication and the server side legacy is transparent. The graph below shows some simple performance measurements between native and legacy. If you are interested in the details of the test see org.eclipse.emf.cdo.tests.PerformanceTest. You can see that the difference between native and legacy it not that big.  
+
Due to its nature legacy mode is slower than the native approach. But have in mind that the loss of performance only applies to the client site. For the communication and the server side legacy is transparent. The graph below shows some simple performance measurements between native and legacy. If you are interested in the details of the test see [[http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org.eclipse.emf.cdo/tests/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PerformanceTest.java?root=Modeling_Project&view=markup|org.eclipse.emf.cdo.tests.PerformanceTest]]. You can see that the difference between native and legacy it not that big.  
  
The tests were executed on a E6600 with ~3 GB RAM running on Windows XP SP2. MemStore and JVM were used for blaninking out the communication and the server side as much as possible.  
+
The tests had been executed on a E6600 with ~3 GB RAM running on Windows XP SP2. MEMStore and JVM are used for redrucing the impact of the communication and the server leyer as much as possible.  
  
 
[[Image:CDO_legacy_native_performance.PNG|800px|center|]]
 
[[Image:CDO_legacy_native_performance.PNG|800px|center|]]
  
Surprisingly there is one case where legacy performs even better than the CDO native models. But this only applies if you are working with the objects before they are added to a resource. In this case CDO native objects (even generate) behave similar to dynamic objects. Compared to the generated EObjects this is certainly not that fast. But this advantage is lost when the objects are attached to a CDO resource.
+
Surprisingly there is one case where legacy performs even better than the CDO native models. But this only applies if you are working with the objects before they are attached to a CDOResource.

Latest revision as of 13:03, 19 March 2013

Contents

[edit] Advantages

The most obvious advantage of the legacy mode is that you don't not need to convert your model and to regenerate your classes. This is very useful if you e.g. cannot change the source because you only own the binaries. In this case legacy mode is the best choice.

[edit] Drawbacks

The disadvantage of the legacy mode lies in its nature, it is just a minimal bridge between EMF and the CDO framework. Thus it inherits the limited scalability of "normal" EMF implementations. This means that legacy support does not support lazy loading or unloading. It is also a bit slower than the native CDO approach. See the chapter about performance for more information.

[edit] Switch me on

Important note: As of CDO 4.2 (M6) the legacy mode is always on and cannot be turned off! The following section only applies to older CDO versions:

The legacy mode is configurable per view and turned off by default. To switch legacy support on or off you can refer to static methods in CDOUtil. This will influence the setting for newly created CDOViews. Note that these methods are only setting the default behavior for the current thread. So you must ensure that yout set the flag for the right thread.

boolean CDOUtil.isLegacyModeDefault()
void CDOUtil.setLegacyModeDefault(boolean on)

The snippet below shows how legacy support can be enabled or disabled.

CDOSession session = ...;
CDOTransaction transaction1 = session.openTransaction();    //this transaction is opened with no legacy support which is the default
 
CDOUtil.setLegacyModeDefault(true);
CDOTransaction transaction2 = session.openTransaction();    //this transaction is opened with legacy support
 
CDOUtil.setLegacyModeDefault(false);
CDOTransaction transaction3 = session.openTransaction();    //this transaction is opened with no legacy support again

Additionally you can ask your view whether legacy mode is enabled for it by using the following method.

CDOView view = ...;
boolean isLegacy = view.isLegacyModeEnabled();

Note, that you are not limited to use either native or legacy models. If you like you can combine both. It does not matter whether you reference from native to legacy or vice versa.

[edit] DynamicEObjects

Now it's possible to use DynamicEObjects on CDO. You can create the dynamic objects as you are used to and store them in CDO. But remember that this is not the recommended way. Since dynamic EObjects can easily be converted to CDO you are encouraged to use CDOUtil.prepareDynamicEPackage(dynamicMapEPackage) whenever possible to convert your dynamic model to a CDO native one.

[edit] Performance

Due to its nature legacy mode is slower than the native approach. But have in mind that the loss of performance only applies to the client site. For the communication and the server side legacy is transparent. The graph below shows some simple performance measurements between native and legacy. If you are interested in the details of the test see [[1]]. You can see that the difference between native and legacy it not that big.

The tests had been executed on a E6600 with ~3 GB RAM running on Windows XP SP2. MEMStore and JVM are used for redrucing the impact of the communication and the server leyer as much as possible.

CDO legacy native performance.PNG

Surprisingly there is one case where legacy performs even better than the CDO native models. But this only applies if you are working with the objects before they are attached to a CDOResource.