cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Cayenne Documentation > Configuring Caching Behavior
Date Thu, 13 May 2010 20:26:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/1/_/styles/combined.css?spaceKey=CAYDOC&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="http://cwiki.apache.org/confluence/display/CAYDOC/Configuring+Caching+Behavior">Configuring
Caching Behavior</a></h2>
    <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~apl">Andrew
Lindesay</a>
    </h4>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >The conclusion is that using JMS is
probably most appropriate when deploying within J2EE containers that already support this
service, while JavaGroups can be used in almost any environment. <br> <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words">h3<span
class="diff-added-chars"style="background-color: #dfd;">.</span></span> Example
JMS Change Notification Configuration <br></td></tr>
            <tr><td class="diff-unchanged" > <br>This example shows how
the JMS change notification configuration looks for a Cayenne servlet running in the [Jetty|http://www.eclipse.org/jetty]
servlet container.  The example uses the [Apache ActiveMQ|http://activemq.apache.org/] messaging
broker. <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
        </table>
</div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="ConfiguringCachingBehavior-CacheMemoryManagement"></a>Cache
Memory Management</h2>

<p>"Cache Configuration" panel allows to configure a max number of objects in the shared
LRU cache. By default it is set to 10000, which is appropriate for most applications. It is
up to the user whether to change this parameter, however we advise to set it to a value to
be higher than an estimated max. number of objects committed in a single transaction.</p>

<p><span class="image-wrap" style=""><img src="/confluence/download/attachments/10637/cache-size.png?version=1&amp;modificationDate=1183886870000"
style="border: 0px solid black" /></span></p>

<h2><a name="ConfiguringCachingBehavior-CacheSharing"></a>Cache Sharing</h2>

<p>Cayenne supports local and distributed caching of fetched data. When a new DataDomain
is created, it uses default caching settings - data is cached within JVM, but no remote synchronization
is performed. User can change these settings depending on the target application deployment
strategy.</p>

<h3><a name="ConfiguringCachingBehavior-NoCacheSharingConfiguration"></a>No
Cache Sharing Configuration</h3>

<p>This type of configuration may result in somewhat faster commit operations, but is
likely to lead to stale data when multiple users modify data in the same application. To disable
any cache sharing uncheck "Use Shared Cache" checkbox. </p>

<h3><a name="ConfiguringCachingBehavior-LocalVMCacheSharingConfiguration"></a>Local
VM Cache Sharing Configuration</h3>


<p>Default configuration for the new DataDomains. Ideal for applications that do not
care about data being modified outside of the application. This configuration is acceptable
for a lot of client-server and web applications.</p>

<h3><a name="ConfiguringCachingBehavior-CrossVMCacheSharingConfiguration"></a>Cross-VM
Cache Sharing Configuration</h3>

<p>Configuration that allows to notify other applications about changes made by an application
and to listen for such changes made by others. This type of configuration incurs the most
overhead, because it will constantly send and receive synchronization messages, but it is
also the most powerful configuration. Cayenne currently supports the use of JMS and JavaGroups
frameworks for synchronization, and also allows users to create their own transport mechanism.
</p>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/warning.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td>Cayenne distribution does not
include JavaGroups or JMS libraries. Those must be downloaded and installed separately. However
until deployment phase, Cayenne does not require those libraries to be installed.</td></tr></table></div>

<p>To configure distributed cache sharing, check "Remote Change Notifications" checkbox,
and click "Configure" button to select and configure the type of transport to use.</p>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/warning.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td>Synchronization is only done between
remote DataDomains with the same name. Note that for JavaGroups configuration, a combination
of multicast address and port must be unique for each DataDomain name.</td></tr></table></div>

<h3><a name="ConfiguringCachingBehavior-ChoosingJavaGroupsoverJMS"></a>Choosing
JavaGroups over JMS</h3>

<p>JavaGroups is the most portable and flexible mechanism. At the minimum, JMS setup
requires a JMS server running, and subjects for each of the DataDomains to be configured.
JavaGroups is peer-to-peer library that is embedded into applications. Default configuration
provided by CayenneModeler will work out of the box, provided that IP multicast is enabled
on the network. </p>

<p>The conclusion is that using JMS is probably most appropriate when deploying within
J2EE containers that already support this service, while JavaGroups can be used in almost
any environment.</p>

<h3><a name="ConfiguringCachingBehavior-ExampleJMSChangeNotificationConfiguration"></a>Example
JMS Change Notification Configuration</h3>

<p>This example shows how the JMS change notification configuration looks for a Cayenne
servlet running in the <a href="http://www.eclipse.org/jetty" class="external-link" rel="nofollow">Jetty</a>
servlet container.  The example uses the <a href="http://activemq.apache.org/" class="external-link"
rel="nofollow">Apache ActiveMQ</a> messaging broker.</p>

<p>It is assumed that the Jetty deployment has been configured to "look in" <tt>$JETTYHOME/lib/ext</tt>.
 Also assumed is that the Jetty deployment is configured to support JNDI.  Both of these configurations
can be achieved by editing the following line in the <tt>start.ini</tt> to have
the <tt>ext</tt> and <tt>plus</tt> values;</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
OPTIONS=Server,jmx,resources,websocket,ext,plus
</pre>
</div></div>

<p>The use of ActiveMQ assumes that the necessary client ActiveMQ "driver jar files"
from the ActiveMQ distribution have been installed into the <tt>$JETTYHOME/lib/ext</tt>
directory in the Jetty deployment.</p>

<p>In this example, the ficticious Cayenne "Data Domain Name" is called "foo".  In the
Cayenne modeller, the "Remote Change Notifications" is checked and the "Connection Factory
Name" is set to <tt>jms/footopicconnectionfactory</tt>.</p>

<p>The following would appear in the <tt>$JETTYHOME/etc/jetty.xml</tt> file;</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;New class=<span class="code-quote">"org.eclipse.jetty.plus.jndi.Resource"</span>&gt;
&lt;Arg&gt;&lt;/Arg&gt;
&lt;Arg&gt;jms/footopicconnectionfactory&lt;/Arg&gt;
&lt;Arg&gt;
 &lt;New class=<span class="code-quote">"org.apache.activemq.ActiveMQConnectionFactory"</span>&gt;
  &lt;Arg&gt;tcp:<span class="code-comment">//msg01.foo.co.nz:61616&lt;/Arg&gt;
</span> &lt;/New&gt;
&lt;/Arg&gt;
&lt;/New&gt;

&lt;New class=<span class="code-quote">"org.eclipse.jetty.plus.jndi.Resource"</span>&gt;
&lt;Arg&gt;org_apache_cayenne_access_DataRowStore_foo&lt;/Arg&gt;
&lt;Arg&gt;
  &lt;New class=<span class="code-quote">"org.apache.activemq.command.ActiveMQTopic"</span>&gt;
   &lt;Arg&gt;foochangenotificationtopic&lt;/Arg&gt;
  &lt;/New&gt;
&lt;/Arg&gt;
&lt;/New&gt;
</pre>
</div></div>

<p>That following would appear in the servlet's <tt>web.xml</tt> deployment
descriptor file;</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;resource-ref&gt; 
&lt;res-ref-name&gt;jms/footopicconnectionfactory&lt;/res-ref-name&gt; 
&lt;res-type&gt;javax.jms.TopicConnectionFactory&lt;/res-type&gt; 
&lt;res-auth&gt;Container&lt;/res-auth&gt; 
&lt;/resource-ref&gt;

&lt;resource-env-ref&gt; 
&lt;resource-env-ref-name&gt;org_apache_cayenne_access_DataRowStore_foo&lt;/resource-env-ref-name&gt;

&lt;resource-env-ref-type&gt;javax.jms.Topic&lt;/resource-env-ref-type&gt;
&lt;/resource-env-ref&gt;
</pre>
</div></div>

<p>This configuration should enable change notification to function.</p>

<h2><a name="ConfiguringCachingBehavior-Moreaboutcaching"></a>More about
caching</h2>

<p>Read more about <a href="/confluence/display/CAYDOC/Caching+and+Fresh+Data" title="Caching
and Fresh Data">caching options here. </a></p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="http://cwiki.apache.org/confluence/display/CAYDOC/Configuring+Caching+Behavior">View
Online</a>
        |
        <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=10637&revisedVersion=8&originalVersion=7">View
Changes</a>
                |
        <a href="http://cwiki.apache.org/confluence/display/CAYDOC/Configuring+Caching+Behavior?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message