<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>The Code Spot</title>
	
	<link>http://www.codespot.net/blog</link>
	<description>Alex Snaps' weblog</description>
	<lastBuildDate>Thu, 05 Jan 2012 21:54:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/codespot/ILKn" /><feedburner:info uri="codespot/ilkn" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Measuring Java Object Sizes</title>
		<link>http://feedproxy.google.com/~r/codespot/ILKn/~3/frHJ6cnjxCA/</link>
		<comments>http://www.codespot.net/blog/2012/01/measuring-java-object-sizes/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 16:35:55 +0000</pubDate>
		<dc:creator>Alex Snaps</dc:creator>
				<category><![CDATA[Ehcache]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Terracotta]]></category>

		<guid isPermaLink="false">http://www.codespot.net/blog/?p=303</guid>
		<description><![CDATA[Probably pure coincidence, but I stumbled upon this Estimating Java Object Sizes with Instrumentation blog. Given we just had released Ehcache 2.5 with Automatic Resource Control, aka ARC, I had to read through this. We do, amongst other, use an instance of java.lang.instrument.Instrumentation to  [...]]]></description>
			<content:encoded><![CDATA[<p>Probably pure coincidence, but I stumbled upon this <a href="http://marxsoftware.blogspot.com/2011/12/estimating-java-object-sizes-with.html" target="_blank">Estimating Java Object Sizes with Instrumentation</a> blog. Given we just had released Ehcache 2.5 with Automatic Resource Control, aka ARC, I had to read through this. We do, amongst other, use an instance of <code>java.lang.instrument.Instrumentation</code> to measure object sizes ourselves. Yet, we found some shortcomings to that approach:</p>
<h5>Getting a reference to a Instrumentation instance !</h5>
<p>As the blog mentions, you need an agent to get to that instance. Yet it felt like imposing every Ehcache users wanting to use ARC to add a <code>-javaagent:</code> just wasn&#8217;t a great idea. Trying to work around this, it turns out Java 6 introduced the <a href="http://docs.oracle.com/javase/6/docs/jdk/api/attach/spec/index.html" target="_blank">Attach API</a>. Now we can <em>try</em> to attach to the VM while it&#8217;s running and load the agent.<br />
And when I say try, I do mean <em>try</em>! As this could fail&#8230; For all kind of reasons: we&#8217;re running JDK5, so no Attach API for us to use; or the attaching to the VM itself fails, this could be for different reasons again. One particularly weird one being due to a bug on OS X, when the java.io.tmpdir system property is set! And even if we get to attach and load the agent, we still need the Ehcache code to get a reference to that <code>Instrumentation</code> instance. The agent classes are being loaded by the system class loader, but the Ehcache classes aren&#8217;t necessarily and we might not get access to the system class loader directly. We don&#8217;t necessarily need to, but we try to avoid accessing another agent class instance, loaded by some other class loader. This would be generally not possible, as we <i>hide</i> the java agent jar within the Ehcache-core jar, so the classes it contains can&#8217;t be present multiple times&#8230;</p>
<h5>What if we can&#8217;t access an Instrumentation instance ?</h5>
<p>Ehcache&#8217;s sizeOf engine, as we named it, falls back to other mechanisms to size POJO. We&#8217;ve added two other methods, to which we fallback shouldn&#8217;t we be able to access the <code>Instrumentation</code> instance: The Unsafe and, finally, the Reflection based one.<br />
The UnsafeSizeOf will try to get a reference to the <code>sun.misc.Unsafe#theUnsafe</code>. Using that reference, we can now query for an Object&#8217;s <i>last non-static</i> field offset in memory using <code>Unsafe.objectFieldOffset</code> and do some math to calculate the object&#8217;s size in memory. I&#8217;ll come back later to the <em>some math</em> part&#8230;<br />
And finally, shouldn&#8217;t we be able to gain access to <em>theUnsafe</em>, we use reflection based sizing. This will measure all primitives and references within an object and sum the size these use in memory. Dr. Heinz Kabutz published more details on that approach in his <a href="http://www.javaspecialists.eu/archive/Issue078.html" target="_blank">Java Specialists Newsletter #78: MemoryCounter for Java 1.4</a> back in 2003.</p>
<h5>Now that&#8217;s all very simple, isn&#8217;t it ?</h5>
<p>Well&#8230; Sadly it isn&#8217;t. But luckily, we&#8217;ve mostly sorted it all out for you! We just were done with the agent based implementation (which didn&#8217;t auto attach yet), and started the testing. Obviously, since this calls into the <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/jvmti/" target="_blank">VM&#8217;s internal</a>, it would all magically figure it out and all. Well, no. <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/vm/cms-6.html" target="_blank">CMS</a> wasn&#8217;t properly accounted for. CMS needs a certain minimal amount of memory to store information when an object is garbage collected and it&#8217;s memory allocation is &#8220;freed&#8221;. That affects the minimal size an object will use on heap. And that was Hotspot only&#8230; We then moved on to test on JRockit that required some finer adjustments, but I won&#8217;t start with these here now.<br />
CMS, <a href="https://wikis.oracle.com/display/HotSpotInternals/CompressedOops" target="_blank">Compressed OOPS</a>, minimum object size were just some of the things that we needed to account for in the <em>some math</em> to in the other implementations: pointer sizes (32 vs. 64 bit VMs), object alignment, field offset adjustment (on JRockit) and &#8220;object header&#8221; size. All these required us to gather all that information about the VM the sizing was happening in order to properly measure object sizes, even using the <code>Instrumentation</code> instance to measure. </p>
<h5>Know what to measure !</h5>
<p>As you could read in Heinz&#8217;s newsletter there is some objects you probably don&#8217;t want to account for. Especially while measuring the size a cached entries are using on heap. There are all the obvious static, classes and other &#8220;Flyweight type objects&#8221;. These can all automatically be discarded by the sizing engine. But some other times, you also don&#8217;t want every cached entry to account for a particular part of an object graph. Simply because every, for instance, every cached entry will reference that particular bit. Hibernate&#8217;s 2nd level cache is good example of that. For that particular example, we&#8217;ve added a &#8220;resource&#8221; file that describes fields and types to be discarded when measuring a cache entry&#8217;s size on heap. For application types though (ones not going into the cache through Hibernate, but applications using the Ehcache API directly), we&#8217;ve added the <a href="http://ehcache.org/apidocs/net/sf/ehcache/pool/sizeof/annotations/IgnoreSizeOf.html" target="_blank"><code>@IgnoreSizeOf</code> annotation</a>. Annotating a Field, a Type or even an entire package with it, will result in the sizing engine skipping that part of the graph (those types or the types in those packages respectively) while doing the sizing.</p>
<h5><a href="http://ehcache.org/downloads/catalog" target="_blank" onclick="_gaq.push(['_trackPageview', '/out/ehcache.org']);">Try it now !</a></h5>
<p><a href="http://ehcache.org" target="_blank" onclick="_gaq.push(['_trackPageview', '/out/ehcache.org']);">Ehcache 2.5</a> is out now and available for direct download or through maven central. It enables you to size your caches simply using values in bytes using Ehcache ARC, you can read more about cache sizing on the <a href="http://ehcache.org/documentation/configuration/cache-size" target="_blank" onclick="_gaq.push(['_trackPageview', '/out/ehcache.org']);">ehcache.org</a> website.</p>
<img src="http://feeds.feedburner.com/~r/codespot/ILKn/~4/frHJ6cnjxCA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codespot.net/blog/2012/01/measuring-java-object-sizes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codespot.net/blog/2012/01/measuring-java-object-sizes/</feedburner:origLink></item>
		<item>
		<title>Asynchronous Job Execution in the Cloud @ JavaOne</title>
		<link>http://feedproxy.google.com/~r/codespot/ILKn/~3/nAxMdLBuwYU/</link>
		<comments>http://www.codespot.net/blog/2011/10/asynchronous-job-execution-in-the-cloud-javaone/#comments</comments>
		<pubDate>Mon, 03 Oct 2011 01:00:50 +0000</pubDate>
		<dc:creator>Alex Snaps</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Quartz]]></category>
		<category><![CDATA[Scaling]]></category>
		<category><![CDATA[Terracotta]]></category>

		<guid isPermaLink="false">http://www.codespot.net/blog/?p=295</guid>
		<description><![CDATA[I&#8217;ll be presenting &#8220;Asynchronous Job Execution in the Cloud&#8221; ( Session ID: 24301) later this week at JavaOne in San Francisco. The session will be held in the Hotel Nikko (Carmel I/II) on Wednesday Oct. 5, at 1pm.
I will cover how deployment topologies requires us to rethink how we go about job  [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll be presenting &#8220;Asynchronous Job Execution in the Cloud&#8221; ( Session ID: 24301) later this week at JavaOne in San Francisco. The session will be held in the Hotel Nikko (Carmel I/II) on Wednesday Oct. 5, at 1pm.<br />
I will cover how deployment topologies requires us to rethink how we go about job execution. As we moved from one machine to multiple and now even to ever changing environment, we need better tools to express the requirement of our job so that we can leverage IT infrastructures optimally and keep the throughput of our applications as high as possible.<br />
I plan on covering this generally and then illustrate how <a href="http://www.quartz-scheduler.org" onclick="_gaq.push(['_trackPageview', '/out/quartz-scheduler.org']);">Quartz</a> achieves those goals when clustered using <a href="http://www.terracotta.org"onclick="_gaq.push(['_trackPageview', '/out/terracotta.org']);">Terracotta</a>. Looking forward to the session and discussions it might trigger. Also feel free to drop by one of our booth in either the Hilton Hotel (Continental Ballroom / JavaOne exhibitor hall / booth #5201) or in the Moscone Center&#8217;s South Hall (booth #640), where I also will be hanging around! </p>
<img src="http://feeds.feedburner.com/~r/codespot/ILKn/~4/nAxMdLBuwYU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codespot.net/blog/2011/10/asynchronous-job-execution-in-the-cloud-javaone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codespot.net/blog/2011/10/asynchronous-job-execution-in-the-cloud-javaone/</feedburner:origLink></item>
		<item>
		<title>Quartz Where Screencast</title>
		<link>http://feedproxy.google.com/~r/codespot/ILKn/~3/KpvTiXoQZZo/</link>
		<comments>http://www.codespot.net/blog/2011/03/quartz-where-screencast/#comments</comments>
		<pubDate>Tue, 29 Mar 2011 17:05:39 +0000</pubDate>
		<dc:creator>Alex Snaps</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Quartz]]></category>
		<category><![CDATA[Scaling]]></category>
		<category><![CDATA[Terracotta]]></category>

		<guid isPermaLink="false">http://www.codespot.net/blog/?p=257</guid>
		<description><![CDATA[Here is a small introduction to the new Quartz Where feature that was just released as part of the Terracotta 3.5 Enterprise Edition.


I&#8217;ll be posting another screencast with some demo application benefiting from the feature, including the couple of steps required to migrate the application to use  [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a small introduction to the new Quartz Where feature that was just released as part of the <a href="http://www.terracotta.org">Terracotta 3.5 Enterprise Edition</a>.<br />
<iframe src="http://player.vimeo.com/video/21156519" width="400" height="300" frameborder="0" style="margin: 0 auto;"></iframe>
<p>
I&#8217;ll be posting another screencast with some demo application benefiting from the feature, including the couple of steps required to migrate the application to use Where&#8230;</p>
<img src="http://feeds.feedburner.com/~r/codespot/ILKn/~4/KpvTiXoQZZo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codespot.net/blog/2011/03/quartz-where-screencast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codespot.net/blog/2011/03/quartz-where-screencast/</feedburner:origLink></item>
		<item>
		<title>Ehcache BeJUG session</title>
		<link>http://feedproxy.google.com/~r/codespot/ILKn/~3/7drxBqP5Q1o/</link>
		<comments>http://www.codespot.net/blog/2011/03/ehcache-bejug-session/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 10:03:15 +0000</pubDate>
		<dc:creator>Alex Snaps</dc:creator>
				<category><![CDATA[Ehcache]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Terracotta]]></category>

		<guid isPermaLink="false">http://www.codespot.net/blog/?p=282</guid>
		<description><![CDATA[The presentation I gave at the BeJUG a couple of weeks back is now available on parleys.com.Here is part 1:


You can also find the code to the Raffle application I used to demo a couple features on github.com. 
For more information, downloads and full documentation on ehcache please visit  [...]]]></description>
			<content:encoded><![CDATA[<p>The presentation I gave at the <a href="http://www.bejug.org" target="_blank">BeJUG</a> a couple of weeks back is now available on <a href="http://parleys.com/c/562" target="_blank">parleys.com</a>.<br/>Here is part 1:<br />
<object width="474" height="443"><param name="movie" value="http://www.parleys.com/share/parleysshare2.swf?pageId=2326"></param><param name="allowFullScreen" value="true"></param><param name="pageId" value="2326"></param><embed src="http://www.parleys.com/share/parleysshare2.swf?pageId=2326" type="application/x-shockwave-flash" allowfullscreen="true" width="474" height="443"></embed></object>
</p>
<p>You can also find the code to the Raffle application I used to demo a couple features on <a href="https://github.com/alexsnaps/Ehcache-Raffle" target="_blank">github.com</a>. <br />
For more information, downloads and full documentation on ehcache please visit <a href="http://www.ehcache.org" target="_blank">ehcache.org</a></p>
<img src="http://feeds.feedburner.com/~r/codespot/ILKn/~4/7drxBqP5Q1o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codespot.net/blog/2011/03/ehcache-bejug-session/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codespot.net/blog/2011/03/ehcache-bejug-session/</feedburner:origLink></item>
		<item>
		<title>Ehcache’s Writer API Screencast</title>
		<link>http://feedproxy.google.com/~r/codespot/ILKn/~3/095n7lxHGfA/</link>
		<comments>http://www.codespot.net/blog/2011/03/ehcache-writers/#comments</comments>
		<pubDate>Fri, 18 Mar 2011 12:41:55 +0000</pubDate>
		<dc:creator>Alex Snaps</dc:creator>
				<category><![CDATA[Ehcache]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Scaling]]></category>
		<category><![CDATA[Terracotta]]></category>

		<guid isPermaLink="false">http://www.codespot.net/blog/?p=269</guid>
		<description><![CDATA[A  common pattern to offloading the database is to use a cache in front of it. Yet, generally, it&#8217;s still application code that goes to the underlying system of records for writes. It also then becomes responsible for invalidating or updating cached entries. 
Using cache writers can not only  [...]]]></description>
			<content:encoded><![CDATA[<p>A  common pattern to offloading the database is to use a cache in front of it. Yet, generally, it&#8217;s still application code that goes to the underlying system of records for writes. It also then becomes responsible for invalidating or updating cached entries. </p>
<p>Using cache writers can not only automate that aspect, but also enables you to scale your writes. This 5 minute screencast explains how to use <a href="http://ehcache.org/documentation/write_through_caching.html" target="_blank">Ehcache Writer API</a> to achieve this and what it means to your application code: especially in distributed environments when clustering your caches with <a href="http://www.terracotta.org/ehcache/" target="_blank">Terracotta</a>, the contract becomes looser than the usual &#8220;happens once and only once&#8221;. Indeed, updates to the database will happen at least once. In case of failure entries could get updated more than once&#8230;</p>
<p><iframe src="http://player.vimeo.com/video/21193026" width="400" height="300" frameborder="0"></iframe></p>
<p>You can also download the Ehcache Raffle application, that demonstrates Cache Writers and Cache Loaders, from <a href="http://github.com/alexsnaps/Ehcache-Raffle" target="_blank">github.com</a>.</p>
<img src="http://feeds.feedburner.com/~r/codespot/ILKn/~4/095n7lxHGfA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codespot.net/blog/2011/03/ehcache-writers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.codespot.net/blog/2011/03/ehcache-writers/</feedburner:origLink></item>
		<item>
		<title>To be relational or not to be relational, that’s not the question</title>
		<link>http://feedproxy.google.com/~r/codespot/ILKn/~3/iWwwS2ZVgA4/</link>
		<comments>http://www.codespot.net/blog/2011/03/relational-or-not/#comments</comments>
		<pubDate>Wed, 09 Mar 2011 08:04:12 +0000</pubDate>
		<dc:creator>Alex Snaps</dc:creator>
				<category><![CDATA[Scaling]]></category>

		<guid isPermaLink="false">http://www.codespot.net/blog/?p=251</guid>
		<description><![CDATA[Sergio Bossa and myself gave this presentation at jFokus (Stockholm, Sweden) and Codemotion (Rome, Italy). Here&#8217;s the slidedeck
   
 For more information:

 www.ehcache.org
 www.terracotta.org
 code.google.com/p/terrastore/

]]></description>
			<content:encoded><![CDATA[<p>Sergio Bossa and myself gave this presentation at jFokus (Stockholm, Sweden) and Codemotion (Rome, Italy). Here&#8217;s the slidedeck</p>
<div style="width:425px" id="__ss_7178881"> <object id="__sse7178881" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=relationnotrelationalcodemotion2011-110307110053-phpapp01&#038;stripped_title=to-be-relational-or-not-to-be-relational-thats-not-the-question&#038;userName=sbtourist" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed name="__sse7178881" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=relationnotrelationalcodemotion2011-110307110053-phpapp01&#038;stripped_title=to-be-relational-or-not-to-be-relational-thats-not-the-question&#038;userName=sbtourist" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>  </div>
<p> For more information:</p>
<ul>
<li> <a href="http://www.ehcache.org">www.ehcache.org</a></li>
<li> <a href="http://www.terracotta.org">www.terracotta.org</a></li>
<li> <a href="http://code.google.com/p/terrastore/">code.google.com/p/terrastore/</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/codespot/ILKn/~4/iWwwS2ZVgA4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codespot.net/blog/2011/03/relational-or-not/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codespot.net/blog/2011/03/relational-or-not/</feedburner:origLink></item>
		<item>
		<title>Quartz Where!</title>
		<link>http://feedproxy.google.com/~r/codespot/ILKn/~3/J92qSJfetwQ/</link>
		<comments>http://www.codespot.net/blog/2010/12/quartz-where/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 18:40:18 +0000</pubDate>
		<dc:creator>Alex Snaps</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Quartz]]></category>
		<category><![CDATA[Terracotta]]></category>

		<guid isPermaLink="false">http://www.codespot.net/blog/?p=187</guid>
		<description><![CDATA[Amongst many new features part of our Terracotta Enterprise Suite Fremantle beta release comes <em>Quartz Where</em>: an easy for developers to control on what node a job will be executed. ]]></description>
			<content:encoded><![CDATA[<p>One week ago we released the first beta of our Fremantle release, which includes <a href="http://ehcache.org" onclick="_gaq.push(['_trackPageview', '/out/ehcache.org']);">Ehcache 2.4</a>, <a href="http://www.terracotta.org" onclick="_gaq.push(['_trackPageview', '/out/terracotta.org']);">Terracotta Enterprise Suite 3.5</a> and at last but not least <a href="http://www.quartz-scheduler.org/" onclick="_gaq.push(['_trackPageview', '/out/quartz-scheduler.org']);">Quartz 2.0</a>. You have been able to cluster your Quartz Scheduler instances using Terracotta for a while already. Yet, as with a JDBC backed storage, you had no control over what node your job would be executed on. The only guarantee was that your job would be executed once within the cluster. <em>Quartz Where</em> aims at addressing exactly that, and is one of the many new features that are part of this new major release of our product line.</p>
<p>A popular demand from clustered Quartz Scheduler users was to be able to specify where a Job would be executed: because data for the job is known to be present on some machine (like using NFS-like file sharing) or because the Job requires much processing and memory. Controlling the locality of execution is now feasible. We have tried to make this a seamless addition to Quartz: you can configure jobs to be dispatched to <strong>node groups</strong> using a simple configuration file; or programmatically schedule <code>LocalityJob</code> or <code>LocalityTrigger</code> instances. Let&#8217;s first cover the configuration based approach, which doesn&#8217;t require any code changes to an existing Quartz 2.0 application.</p>
<h2>Configuration based locality of execution</h2>
<p>Before getting started with this new feature, you will have to configure your Quartz scheduler to use the Terracotta Enterprise Store by setting the property <code>org.quartz.jobStore.class</code> to <code>org.terracotta.quartz.EnterpriseTerracottaJobStore</code>. If you were not using Terracotta to cluster Quartz, you will also have to set the <code>org.quartz.jobStore.tcConfigUrl</code> property to point to the Terracotta server. Here is a small example of a quartz.properties</p>

<div class="wp_syntax"><div class="code"><pre class="properties" style="font-family:monospace;"><span style="color: #000080; font-weight:bold;">org.quartz.scheduler.instanceName</span> <span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;"> QuartzWhereScheduler</span>
&nbsp;
<span style="color: #000080; font-weight:bold;">org.quartz.scheduler.instanceId</span> <span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;"> AUTO</span>
<span style="color: #000080; font-weight:bold;">org.quartz.scheduler.instanceIdGenerator.class</span> <span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;"> org.terracotta.quartz.demo.locality.SystemPropertyIdGenerator</span>
&nbsp;
<span style="color: #000080; font-weight:bold;">org.quartz.threadPool.class</span> <span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;"> org.quartz.simpl.SimpleThreadPool</span>
<span style="color: #000080; font-weight:bold;">org.quartz.threadPool.threadCount</span> <span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;"> 10</span>
<span style="color: #000080; font-weight:bold;">org.quartz.threadPool.threadPriority</span> <span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;"> 5</span>
<span style="color: #000080; font-weight:bold;">org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread</span> <span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;"> true</span>
&nbsp;
<span style="color: #000080; font-weight:bold;">org.quartz.jobStore.class</span> <span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;"> org.terracotta.quartz.EnterpriseTerracottaJobStore</span>
<span style="color: #000080; font-weight:bold;">org.quartz.jobStore.tcConfigUrl</span> <span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;"> localhost:9510</span></pre></div></div>

<p>Using the <code>quartzLocality.properties</code> configuration file, you can define node groups. A node group is composed of one or more Quartz Scheduler instance nodes (generally one per machine within your cluster). You define them as such:</p>

<div class="wp_syntax"><div class="code"><pre class="properties" style="font-family:monospace;"><span style="color: #000080; font-weight:bold;">org.quartz.locality.nodeGroup.slowNodes</span> <span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;"> tortoise, snail</span>
<span style="color: #000080; font-weight:bold;">org.quartz.locality.nodeGroup.fastNodes</span> <span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;"> hare, leopard</span>
<span style="color: #000080; font-weight:bold;">org.quartz.locality.nodeGroup.linuxNodes</span> <span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;"> tortoise</span></pre></div></div>

<p>We have now defined three groups: the slowNodes, fastNodes and linuxNodes. We can now use the node groups to have jobs or triggers being executed by them, depending on their <code>group</code>. Quartz Jobs and Triggers were and still are uniquely identified by a name and group pair. We can now have all jobs (or triggers) of a certain group only get executed on a node of a given group through the same configuration file:</p>

<div class="wp_syntax"><div class="code"><pre class="properties" style="font-family:monospace;"><span style="color: #000080; font-weight:bold;">org.quartz.locality.nodeGroup.fastNodes.triggerGroups</span> <span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;"> bigJobGroup</span>
<span style="color: #000080; font-weight:bold;">org.quartz.locality.nodeGroup.linuxNodes.triggerGroups</span> <span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;"> reporting</span></pre></div></div>

<p>Now all triggers from the group <code>bigJobGroup</code> will be executed by a Scheduler from the group <code>fastNodes</code>, either the <code>hare</code> or <code>leopard</code> scheduler. These scheduler nodes receive unique ids as before by providing an <code>org.quartz.spi.InstanceIdGenerator</code> implementation to the scheduler at configuration time (don&#8217;t mix this with the instanceName, which needs to be the same for all nodes from them to be a single clustered Scheduler). Triggers from the group <code>reporting</code> will always be executed on tortoise, as this is the only scheduler in the <code>linuxNodes</code> group.</p>
<h2>Programmatic locality of execution</h2>
<p>Using the new locality API for Quartz that is part of our Terracotta Enterprise Suite 3.5 you can achieve even finer grained control and express more complex constraints about where a job should be executed. The example below uses the new <a href="http://dsoguy.blogspot.com/2010/11/quartz-scheduler-20-beta-1-welcomes-new.html">DSL like builder API</a> introduced with Quartz 2.0. Let’s see how that looks:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="java5" style="font-family:monospace;">LocalityJobDetail jobDetail =
    localJob<span style="color: #009900;">&#40;</span>
        newJob<span style="color: #009900;">&#40;</span>ImportantJob.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span>
            .<span style="color: #006633;">withIdentity</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;importantJob&quot;</span><span style="color: #009900;">&#41;</span>
            .<span style="color: #006633;">build</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        .<span style="color: #006633;">where</span><span style="color: #009900;">&#40;</span>
            node<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #006633;">is</span><span style="color: #009900;">&#40;</span>partOfNodeGroup<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;fastNodes&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        .<span style="color: #006633;">build</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>On line 3, we create a new <code>JobDetail</code> for the <code>Job</code> implementation <code>ImportantJob</code>. We then wrap it on line 2 as a localJob that needs to be executed on a node that is part of the group <code>fastNodes</code>. You might have noticed that creating the <code>JobDetail</code> is pretty straight forward with the new API. Adding the locality information isn&#8217;t much more work neither. You can be much more precise on where the job should be executed though. Let&#8217;s have a look at this example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="java5" style="font-family:monospace;">scheduler.<span style="color: #006633;">scheduleJob</span><span style="color: #009900;">&#40;</span>
    localTrigger<span style="color: #009900;">&#40;</span>
        newTrigger<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
            .<span style="color: #006633;">forJob</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;importantJob&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        .<span style="color: #006633;">where</span><span style="color: #009900;">&#40;</span>node<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
            .<span style="color: #006633;">has</span><span style="color: #009900;">&#40;</span>atLeastAvailable<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">512</span>, MemoryConstraint.<span style="color: #006633;">Unit</span>.<span style="color: #006633;">MB</span><span style="color: #009900;">&#41;</span>
            .<span style="color: #006633;">is</span><span style="color: #009900;">&#40;</span>OsConstraint.<span style="color: #006633;">LINUX</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        .<span style="color: #006633;">build</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Here we schedule an immediate trigger for the <code>importantJob</code> we&#8217;ve registered in the previous example. Line 2 is creating the locality aware trigger, defining it to require a node that is running Linux and has at least 512 MB of heap available. Using these constraints, here memory and OS, you can be much more explicit about what the characteristics of the node executing the Job should be.</p>
<h2>Locality constraints</h2>
<p>The new Terracotta clustered JobStore we&#8217;ve introduced will evaluate the constraint expressed on a Trigger and/or a Job to decide where to dispatch the Job for execution. We plan on providing implementation for expressing constraints on the CPU, Memory and Operating System characteristics of the node. I am still heavily working on these, but what is being shipped as part of this first beta should give you a good feel for where we are headed. To test it yourself today, go fetch the Fremantle beta 1 from the <a href="http://terracotta.org/beta" onclick="_gaq.push(['_trackPageview', '/out/terracotta.org']);">Terracotta website</a> now! </p>
<img src="http://feeds.feedburner.com/~r/codespot/ILKn/~4/J92qSJfetwQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codespot.net/blog/2010/12/quartz-where/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.codespot.net/blog/2010/12/quartz-where/</feedburner:origLink></item>
		<item>
		<title>Not quite dead yet…</title>
		<link>http://feedproxy.google.com/~r/codespot/ILKn/~3/QpXjj8Aa6xc/</link>
		<comments>http://www.codespot.net/blog/2010/04/not-quite-dead-yet/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 08:33:30 +0000</pubDate>
		<dc:creator>Alex Snaps</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Terracotta]]></category>

		<guid isPermaLink="false">http://www.codespot.net/blog/2010/04/28/not-quite-dead-yet/</guid>
		<description><![CDATA[Despite not having posted here for almost two years now, I&#8217;m not dead yet&#8230;It&#8217;s been a year now, I joined Terracotta to work on their Hibernate second level cache implementation. A lot as happened since: Terracotta acquired Ehcache and Quartz, which gave the transparency team I joined some work&#8230;

My  [...]]]></description>
			<content:encoded><![CDATA[<p>Despite not having posted here for almost two years now, I&#8217;m not dead yet&#8230;<br />It&#8217;s been a year now, I joined <a href="http://www.terracotta.org/" target="_blank">Terracotta</a> to work on their Hibernate second level cache implementation. A lot as happened since: Terracotta acquired <a href="http://ehcache.org" target="_blank">Ehcache</a> and <a href="http://www.quartz-scheduler.org/" target="_blank">Quartz</a>, which gave the transparency team I joined some work&#8230;</p>
<p><object height="344" width="425"><param value="http://www.youtube.com/v/grbSQ6O6kbs&amp;hl=en_US&amp;fs=1&amp;" name="movie"></param><param value="true" name="allowFullScreen"></param><param value="always" name="allowscriptaccess"></param><embed src="http://www.youtube.com/v/grbSQ6O6kbs&amp;hl=en_US&amp;fs=1&amp;" height="344" width="425" allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash"></embed></object>
<p>My latest work there has been on Ehcache and its JTA support. <a href="http://www.terracotta.org/dl/ehcache-oss-download-catalog" target="_blank">Ehcache 2.1.0 beta</a> has just been released with a whole bunch of new features. I&#8217;m planning on putting a post together on using JTA (and the coherent methods added to this release) with Ehcache in some very near future&#8230;</p>
<img src="http://feeds.feedburner.com/~r/codespot/ILKn/~4/QpXjj8Aa6xc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codespot.net/blog/2010/04/not-quite-dead-yet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codespot.net/blog/2010/04/not-quite-dead-yet/</feedburner:origLink></item>
		<item>
		<title>Jazoon Presentation on Distributed Client/Server Persistence</title>
		<link>http://feedproxy.google.com/~r/codespot/ILKn/~3/HeKROt_6n3o/</link>
		<comments>http://www.codespot.net/blog/2008/06/jazoon-presentation-on-distributed-clientserver-persistence/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 09:38:05 +0000</pubDate>
		<dc:creator>Alex Snaps</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.codespot.net/blog/2008/06/26/jazoon-presentation-on-distributed-clientserver-persistence/</guid>
		<description><![CDATA[
	I&#8217;ve presented at this year&#8217;s Jazoon conference on H&#246;lchoko, a framework for distributing the persistence of your JPA domain models to multiple clients. While the project itself is not where I would have expected it to be by now, I&#8217;ve finished enough of the demos to show what the idea is all  [...]]]></description>
			<content:encoded><![CDATA[<p>
	I&#8217;ve presented at this year&#8217;s <a href="http://www.jazoon.com" target="_blank">Jazoon conference</a> on <a href="http://www.holchoko.org" target="_blank">H&ouml;lchoko</a>, a framework for distributing the persistence of your JPA domain models to multiple clients. While the project itself is not where I would have expected it to be by now, I&#8217;ve finished enough of the demos to show what the idea is all about. <br />
	I&#8217;ve uploaded the presentation <a href="http://www.codespot.net/sessions/jazoon/2008.html" target="_blank">here</a>. I know the demo still has the encumbrance of <a href="http://www.jetbrains.com/idea" target="_blank">IntelliJ Idea</a> forms for parts of the UI. I hope to get enough time to remove these very soon.
</p>
<p>
	I plan on closing the remain tickets and release version 0.9.1 somewhere next week. I know the type system abstraction still requires quite some work. Finishing the remote filter for sending entities back to the server is just a matter of back porting from the in production systems and developing the dynamic proxy I show in the <a href="http://www.codespot.net/sessions/jazoon/2008.html" target="_blank">presentation</a>. Code cleanup is still an issue and so is JavaDoc! HMVC is pretty there already&#8230;</p>
<img src="http://feeds.feedburner.com/~r/codespot/ILKn/~4/HeKROt_6n3o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codespot.net/blog/2008/06/jazoon-presentation-on-distributed-clientserver-persistence/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.codespot.net/blog/2008/06/jazoon-presentation-on-distributed-clientserver-persistence/</feedburner:origLink></item>
		<item>
		<title>Hudson continuous build full screen monitoring</title>
		<link>http://feedproxy.google.com/~r/codespot/ILKn/~3/HvV6RCFfasA/</link>
		<comments>http://www.codespot.net/blog/2008/06/hudson-continuous-build-full-screen-monitoring/#comments</comments>
		<pubDate>Sun, 01 Jun 2008 06:51:31 +0000</pubDate>
		<dc:creator>Alex Snaps</dc:creator>
				<category><![CDATA[CI]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.codespot.net/blog/2008/06/01/hudson-continuous-build-full-screen-monitoring/</guid>
		<description><![CDATA[I&#8217;ve just quickly hacked a fullscreen monitor for our continuous integration server at work. As for my personal projects, we use Hudson, which has a nice restful xml API.This small utility asks for the url of your Hudson server and retrieves all the jobs and their status. You can also provide the  [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just quickly hacked a fullscreen monitor for our continuous integration server at work. As for my personal projects, we use <a href="https://hudson.dev.java.net">Hudson</a>, which has a nice restful xml API.This small utility asks for the url of your Hudson server and retrieves all the jobs and their status. You can also provide the url to a view, would you want to only partially monitor your jobs (such as only the continuous integration builds, ignoring nightly builds, or the other way around).
<p style="text-align: center"><a href="http://www.codespot.net/blog/wp-content/uploads/2008/06/hudsonmonitor_main.png" title="HudsonMonitor Main screen"><img src="http://www.codespot.net/blog/wp-content/uploads/2008/06/hudsonmonitor_main.thumbnail.png" alt="HudsonMonitor Main screen" /></a></p>
<p><a href="http://www.codespot.net/blog/wp-content/uploads/2008/06/hudsonmonitor_main.png" title="HudsonMonitor Main screen"></a>When in full screen mode, the tool will poll the server every 15 seconds for job updates and render a fully red, yellow or blue (and yes, I kept the blue!) screen displaying the worse status of your currently monitored jobs. Should the screen not be blue (all monitored builds stable), it will also display the list of unstable or broken builds.
<p style="text-align: center"><a href="http://www.codespot.net/blog/wp-content/uploads/2008/06/hudsonmonitor_fullscreen.png" title="HudsonMonitor - Full screen mode"><img src="http://www.codespot.net/blog/wp-content/uploads/2008/06/hudsonmonitor_fullscreen.thumbnail.png" alt="HudsonMonitor - Full screen mode" /></a></p>
<p><a href="http://www.codespot.net/blog/wp-content/uploads/2008/06/hudsonmonitor_fullscreen.png" title="HudsonMonitor - Full screen mode"></a>Everything is pretty much hacked together, with way too many inner classes (lazy me!). This is what I call a &#8220;one movie hack&#8221;, as I quickly wrote this with the computer on my lap next to my wife while we were watching a movie&#8230; or at least she was! Besides, it uses the IntelliJ Idea&#8217;s layout manager for the main screen. I&#8217;ll try to clean this all up. In the meantime the code is available through a:
<pre>svn co http://www.codespot.net/svn/repos/HudsonMonitor/trunk HudsonMonitor</pre>
<p>and the executable jar is available <a href="http://www.codespot.net/stuff/HudsonMonitor.jar">here</a>.</p>
<img src="http://feeds.feedburner.com/~r/codespot/ILKn/~4/HvV6RCFfasA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codespot.net/blog/2008/06/hudson-continuous-build-full-screen-monitoring/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.codespot.net/blog/2008/06/hudson-continuous-build-full-screen-monitoring/</feedburner:origLink></item>
	</channel>
</rss>

