<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>~pperalta &#187; Development</title>
	<atom:link href="https://blackbeanbag.net/wp/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>https://blackbeanbag.net/wp</link>
	<description>Thoughts on software development and other stuff</description>
	<lastBuildDate>Thu, 22 May 2014 18:55:26 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=3.9.40</generator>
	<item>
		<title>Coherence Near Cache Best Practices</title>
		<link>https://blackbeanbag.net/wp/2013/02/26/coherence-near-cache-best-practices/</link>
		<comments>https://blackbeanbag.net/wp/2013/02/26/coherence-near-cache-best-practices/#comments</comments>
		<pubDate>Tue, 26 Feb 2013 22:41:10 +0000</pubDate>
		<dc:creator><![CDATA[Patrick Peralta]]></dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://blackbeanbag.net/wp/?p=529</guid>
		<description><![CDATA[New on the Coherence blog is an article on best practices for near caching written by yours truly. This article went through several reviews by PM and engineering (both internal and field engineers) and is a good summary of our experiences with near caching. The key takeaway is to understand the near cache invalidation strategies [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><img src="http://blackbeanbag.net/wp/wp-content/uploads/2013/02/coins-300x199.jpg" title="coins" width="150" height="100" class="alignright size-medium wp-image-531" /></p>
<p>New on the Coherence blog is an article on best practices for near caching written by yours truly. This article went through several reviews by PM and engineering (both internal and field engineers) and is a good summary of our experiences with near caching. The key takeaway is to understand the near cache invalidation strategies and to explicitly configure the one best suited to the application needs.</p>
<p>See the full <a href="https://blogs.oracle.com/OracleCoherence/entry/oracle_coherence_near_cache_best">Near Cache Best Practices article</a> on the official <a href="https://blogs.oracle.com/OracleCoherence/">Oracle Coherence blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://blackbeanbag.net/wp/2013/02/26/coherence-near-cache-best-practices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle Enterprise Pack for Eclipse now supports Coherence</title>
		<link>https://blackbeanbag.net/wp/2010/08/09/oracle-enterprise-pack-for-eclipse-now-supports-coherence/</link>
		<comments>https://blackbeanbag.net/wp/2010/08/09/oracle-enterprise-pack-for-eclipse-now-supports-coherence/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 17:05:39 +0000</pubDate>
		<dc:creator><![CDATA[Patrick Peralta]]></dc:creator>
				<category><![CDATA[Coherence]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://blackbeanbag.net/wp/?p=479</guid>
		<description><![CDATA[The latest release of Oracle Enterprise Pack for Eclipse (OEPE) now includes a Coherence Facet. This makes it convenient to quickly start up a Coherence project and launch nodes right in the IDE. Recently I took it for a test drive and took some notes to help users of Eclipse and Coherence get started. Note [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>The latest release of <a href="http://www.oracle.com/us/products/tools/enterprise-eclipse-pack-161756.html">Oracle Enterprise Pack for Eclipse (OEPE)</a> now includes a Coherence Facet. This makes it convenient to quickly start up a Coherence project and launch nodes right in the IDE. Recently I took it for a test drive and took some notes to help users of Eclipse and Coherence get started.</p>
<p><em>Note that all images below are thumbnails; click on the images to expand.</em></p>
<p>You have the option of downloading <a href="http://www.oracle.com/technetwork/developer-tools/eclipse/downloads/oepe-1116-161753.html">Eclipse with the OEPE plugins pre-installed</a>, but I already had a copy of Eclipse Helios 3.6; therefore I went for the plugin install. The plugin install is straight forward, similar to any other Eclipse plugin. These instructions are lifted <a href="http://download.oracle.com/docs/cd/E15315_06/help/oracle.eclipse.tools.common.doc/html/install.html">straight from the doc</a>:</p>
<ol>
<li>Select Help &gt; Install New Software.</li>
<li>Click Add to add a new update site.</li>
<li>In the Add Repository dialog, enter the location as http://download.oracle.com/otn_software/oepe/helios, and then click OK.</li>
<li>Select Oracle Enterprise Pack for Eclipse, verify that all of the subcomponents are selected, and then click Next.</li>
<li>Confirm information presented in the Install Details, and then click Finish.</li>
</ol>
<p><a href="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/1.png"><img class="alignnone size-medium wp-image-481" style="border-style: initial; border-color: initial; border-width: 0px;" title="1" src="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/1-300x263.png" alt="" width="300" height="263" /></a><br />
Once the install is complete and you&#8217;ve restarted Eclipse, the next step is to install Coherence as a User Library. I&#8217;ve got the latest 3.6 bits from our source code repository, so I&#8217;ll install that as a library. Note that the plugin also supports Coherence 3.5.2.<br />
<a href="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/2.png"><img class="alignnone size-medium wp-image-485" title="2" style="border-style: initial; border-color: initial; border-width: 0px;" src="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/2-300x263.png" alt="" width="300" height="263" /></a><br />
Now, let&#8217;s create a new Java project. As part of the project creation, add Coherence as a project library.<br />
<a href="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/3.png"><img class="alignnone size-medium wp-image-487" title="3" style="border-style: initial; border-color: initial; border-width: 0px;" src="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/3-278x300.png" alt="" width="278" height="300" /></a><br />
After the project is created, we&#8217;ll have to enable Facets to use the Coherence plugin. Bring up the project properties window and search for &#8220;Facets&#8221; in the search field.<br />
<a href="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/4.png"><img class="alignnone size-medium wp-image-488" title="4" style="border-style: initial; border-color: initial; border-width: 0px;" src="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/4-300x214.png" alt="" width="300" height="214" /></a><br />
Once Facets are enabled, select Oracle Coherence.<br />
<a href="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/5.png"><img class="alignnone size-medium wp-image-490" title="5" src="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/5-300x214.png" style="border-style: initial; border-color: initial; border-width: 0px;" alt="" width="300" height="214" /></a><br />
Upon selection, a link indicating that further configuration is required will appear. Click on the link. Select the &#8220;Oracle Coherence 3.6&#8243; library. Note how it provides the option to generate configuration files. Let&#8217;s leave all of the checkboxes selected.<br />
<a href="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/6.png"><img class="alignnone size-medium wp-image-492" title="6" style="border-style: initial; border-color: initial; border-width: 0px;" src="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/6-300x266.png" alt="" width="300" height="266" /></a><br />
Now we are ready to start a cache server. Select File | Run Configurations to bring up the Run Configurations dialog. First select &#8220;Oracle Coherence&#8221; under the list of run configurations. Next, select the &#8220;New&#8221; button on the upper left portion of the dialog to create a new run configuration.<br />
<a href="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/7.png"><img class="alignnone size-medium wp-image-493" title="7" style="border-style: initial; border-color: initial; border-width: 0px;" src="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/7-300x203.png" alt="" width="300" height="203" /></a><br />
Under the &#8220;Main&#8221; tab, enter <tt>com.tangosol.net.DefaultCacheServer</tt> as the main class. Of course you are free to create configurations with your own classes; however this example will focus on starting up a cache server.</p>
<p>Note the presence of a &#8220;Coherence&#8221; tab. This tab allows for operational configuration (items typically found in <tt>tangosol-coherence-override.xml</tt>) such as the cache configuration file name, multicast address configuration, management/JMX, and so on. Here I decided to leave all of the defaults as is.<br />
<a href="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/8.png"><img class="alignnone size-medium wp-image-496" title="8" style="border-style: initial; border-color: initial; border-width: 0px;" src="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/8-300x251.png" alt="" width="300" height="251" /></a><br />
After clicking on &#8220;Run&#8221;, here&#8217;s what I get:<br />
<a href="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/9.png"><img class="alignnone size-medium wp-image-498" title="9" style="border-style: initial; border-color: initial; border-width: 0px;" src="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/9-300x230.png" alt="" width="300" height="230" /></a><br />
We can see that the node started up and formed a cluster, but there are no services listed. This is because the OEPE plugin generated a cache configuration file that defaults to all caches being local. Next, let&#8217;s examine the cache configuration file (located under <tt>src</tt> and add a distributed/partitioned cache to the configuration.<br />
<a href="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/10.png"><img class="alignnone size-medium wp-image-499" title="10" style="border-style: initial; border-color: initial; border-width: 0px;" src="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/10-300x225.png" alt="" width="300" height="225" /></a><br />
One of the nice features the plugin provides is pre-configured auto complete for Coherence configuration files via the DTD.</p>
<p>Here&#8217;s the cache configuration file I used:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!--?xml version=&quot;1.0&quot;?--&gt;</span>
&nbsp;
      *
      partitioned
&nbsp;
      partitioned
&nbsp;
      true</pre></td></tr></table></div>

<p>With the modified cache configuration, we now see the partitioned cache service start up:</p>
<p><a href="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/11.png"><img class="alignnone size-medium wp-image-505" title="11" style="border-style: initial; border-color: initial; border-width: 0px;" src="http://blackbeanbag.net/wp/wp-content/uploads/2010/08/11-300x253.png" alt="" width="300" height="253" /></a></p>
<p>I can see the Coherence plugin for OEPE being quite useful for Coherence developers on Eclipse not only for quickly starting up a Coherence project (since config files are generated) but also for enabling configuration validation out of the box.</p>
]]></content:encoded>
			<wfw:commentRss>https://blackbeanbag.net/wp/2010/08/09/oracle-enterprise-pack-for-eclipse-now-supports-coherence/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Florida JUGs Next Week</title>
		<link>https://blackbeanbag.net/wp/2010/06/16/florida-jugs-next-week/</link>
		<comments>https://blackbeanbag.net/wp/2010/06/16/florida-jugs-next-week/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 18:09:43 +0000</pubDate>
		<dc:creator><![CDATA[Patrick Peralta]]></dc:creator>
				<category><![CDATA[Coherence]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://blackbeanbag.net/wp/?p=447</guid>
		<description><![CDATA[I will be in central Florida next week presenting at the following user groups: An Introduction to Data Grids for Database developers (GatorJUG June 23rd) This talk will introduce the concept of data grids to developers that have experience with Java EE and relational databases such as Oracle. The programming model will be explored (including [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>I will be in central Florida next week presenting at the following user groups:</p>
<p><strong><a href="http://www.codetown.us/events/gatorjug-2">An Introduction to Data Grids for Database developers (GatorJUG June 23rd)</a></strong></p>
<p><em>This talk will introduce the concept of data grids to developers that have experience with Java EE and relational databases such as Oracle. The programming model will be explored (including caching patterns and similarities to NoSQL) as well as the performance &#038; scalability improvements a data grid offers.</em></p>
<p><strong><a href="http://www.codetown.us/events/orlandojug-2">From IDE to Data Center &#8211; What Every Developer Should Know About Deploying Distributed Systems to Production (Orlando JUG June 24th)</a><br />
</strong></p>
<p><em>Taking a distributed system from development into a working production environment is a challenge that many developers take for granted. This talk will explore these challenges, especially scenarios that are not typically seen in a development setting.<br />
</em></p>
<p>I&#8217;m especially excited about the OJUG talk as I think it will cover many topics of interest to Developers and OPS guys.  It is a set of general guidelines that came about from seeing dozens of Coherence applications in production.  We will cover such things as:</p>
<ul>
<li>What to look for when using <tt>vmstat</tt>
<li>Must-have production level JVM settings/flags
<li>Developer Do&#8217;s and Dont&#8217;s
<li>Crash course on thread dumps and heap dumps
</ul>
<p>We will also be giving away a copy of <a href="http://www.amazon.com/gp/product/1847196128/ref=s9_simh_gw_p14_i1?pf_rd_m=ATVPDKIKX0DER&#038;pf_rd_s=center-2&#038;pf_rd_r=0F55S1X7P530YBMX67RX&#038;pf_rd_t=101&#038;pf_rd_p=470938631&#038;pf_rd_i=507846">Oracle Coherence 3.5</a> at each event!  If you are coming please follow the links to the events above and RSVP (you need to be a member of <a href="http://www.codetown.us/">CodeTown</a> to sign up, but registration is free and painless.)</p>
]]></content:encoded>
			<wfw:commentRss>https://blackbeanbag.net/wp/2010/06/16/florida-jugs-next-week/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Coherence Key HOWTO</title>
		<link>https://blackbeanbag.net/wp/2010/06/06/coherence-key-howto/</link>
		<comments>https://blackbeanbag.net/wp/2010/06/06/coherence-key-howto/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 02:28:31 +0000</pubDate>
		<dc:creator><![CDATA[Patrick Peralta]]></dc:creator>
				<category><![CDATA[Coherence]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://blackbeanbag.net/wp/?p=409</guid>
		<description><![CDATA[On occasion I am asked about best practices for creating classes to be used as keys in Coherence. This usually comes about due to unexpected behavior that can be explained by incorrect key implementations. First and foremost, equals and hashCode need to be implemented correctly for any type used as a key. I won&#8217;t describe [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/brenda-starr/3509344100/in/set-72157617806022838"><img src="http://blackbeanbag.net/wp/wp-content/uploads/2010/06/3509344100_ebf565abe7_m.jpg" alt="Image credit: Brenda Starr" title="Image credit: Brenda Starr" width="162" height="109" class="alignright size-full wp-image-425" style="margin:10px 10px" /></a></p>
<p>On occasion I am asked about best practices for creating classes to be used as keys in Coherence.  This usually comes about due to unexpected behavior that can be explained by incorrect key implementations.</p>
<p>First and foremost, <code>equals</code> and <code>hashCode</code> need to be implemented correctly for any type used as a key.  I won&#8217;t describe how to do this &#8211; instead I&#8217;ll defer to Josh Bloch who has written <a href="http://java.sun.com/developer/Books/effectivejava/Chapter3.pdf">the definitive guide on this topic</a>.</p>
<p>There is an additional requirement that needs to be addressed.  <strong>All serializable (non transient) fields in the key class must be used in the <code>equals</code> implementation.</strong>  To understand this requirement, let&#8217;s explore how Coherence works behind the scenes.</p>
<p>First, let&#8217;s try the following experiment:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> <span style="color: #003399;">Key</span>
        <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399;">Serializable</span>
    <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Key</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> id, <span style="color: #003399;">String</span> zip<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
        m_id <span style="color: #339933;">=</span> id<span style="color: #339933;">;</span>
        m_zip <span style="color: #339933;">=</span> zip<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//...</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> equals<span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span> o<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// print stack trace</span>
        <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Throwable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;equals debug&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span> <span style="color: #339933;">==</span> o<span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>o <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">||</span> getClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> o.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #003399;">Key</span> key <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Key</span><span style="color: #009900;">&#41;</span> o<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>m_id <span style="color: #339933;">!=</span> key.<span style="color: #006633;">m_id</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>m_zip <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">?</span> <span style="color: #339933;">!</span>m_zip.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>key.<span style="color: #006633;">m_zip</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> key.<span style="color: #006633;">m_zip</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> hashCode<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// print stack trace</span>
        <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Throwable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;hashCode debug&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>        
        <span style="color: #000066; font-weight: bold;">int</span> result <span style="color: #339933;">=</span> m_id<span style="color: #339933;">;</span>
        result <span style="color: #339933;">=</span> <span style="color: #cc66cc;">31</span> <span style="color: #339933;">*</span> result <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>m_zip <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">?</span> m_zip.<span style="color: #006633;">hashCode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">return</span> result<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> m_id<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> m_zip<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This key prints out stack traces in <code>equals</code> and <code>hashCode</code>.  Now use this key with a HashMap:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> testKey<span style="color: #009900;">&#40;</span><span style="color: #003399;">Map</span> m<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
    <span style="color: #003399;">Key</span> key <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Key</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #0000ff;">&quot;12345&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    m.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>key, <span style="color: #0000ff;">&quot;value&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    m.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>key<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//...</span>
&nbsp;
testKey<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">HashMap</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>Output is as follows:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="none" style="font-family:monospace;">java.lang.Throwable: hashCode debug
	at oracle.coherence.idedc.Key.hashCode(Key.java:60)
	at java.util.HashMap.put(HashMap.java:372)
	at oracle.coherence.idedc.KeyTest.testKey(KeyTest.java:46)
	at oracle.coherence.idedc.KeyTest.testKey(KeyTest.java:52)
	at oracle.coherence.idedc.KeyTest.main(KeyTest.java:18)
java.lang.Throwable: hashCode debug
	at oracle.coherence.idedc.Key.hashCode(Key.java:60)
	at java.util.HashMap.get(HashMap.java:300)
	at oracle.coherence.idedc.KeyTest.testKey(KeyTest.java:47)
	at oracle.coherence.idedc.KeyTest.testKey(KeyTest.java:52)
	at oracle.coherence.idedc.KeyTest.main(KeyTest.java:18)</pre></td></tr></table></div>

<p>Try it again with a partitioned cache this time:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;">testKey<span style="color: #009900;">&#40;</span>CacheFactory.<span style="color: #006633;">getCache</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;dist-test&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Note the absence of stack traces this time.  Does this mean Coherence is not using the key&#8217;s <code>equals</code> and <code>hashCode</code>?  The short answer (for now) is yes.  Here is the flow of events that occur when executing a put with a partitioned cache:</p>
<ol>
<li> Invoke NamedCache.put
<li> Key and value are serialized
<li> Hash is executed on serialized key to determine which partition the key belongs to
<li> Key and value are transferred to the storage node (likely over the network)
<li> Cache entry is placed into backing map in binary form
</ol>
<p><img src="http://blackbeanbag.net/wp/wp-content/uploads/2010/06/keys.png" class="aligncenter size-medium wp-image-423" /></p>
<p>Note that objects are <strong>not</strong> deserialized before placement into the backing map &#8211; objects are stored in their serialized binary format.  As a result, this means that two keys that are equal to each other in object form <strong>must</strong> be equal to each other in binary form so that the keys can be later be used to retrieve entries from the backing map.  The most common way to violate this principle is to exclude non transient fields from <code>equals</code>.  For example:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BrokenKey
        <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399;">Serializable</span>
    <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> BrokenKey<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> id, <span style="color: #003399;">String</span> zip<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
        m_id <span style="color: #339933;">=</span> id<span style="color: #339933;">;</span>
        m_zip <span style="color: #339933;">=</span> zip<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//...</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> equals<span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span> o<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span> <span style="color: #339933;">==</span> o<span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>o <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">||</span> getClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> o.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
        BrokenKey brokenKey <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>BrokenKey<span style="color: #009900;">&#41;</span> o<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>m_id <span style="color: #339933;">!=</span> brokenKey.<span style="color: #006633;">m_id</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> hashCode<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">int</span> result <span style="color: #339933;">=</span> m_id<span style="color: #339933;">;</span>
        result <span style="color: #339933;">=</span> <span style="color: #cc66cc;">31</span> <span style="color: #339933;">*</span> result<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">return</span> result<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Note this key has two fields (id and zip) but it only uses id in the <code>equals</code>/<code>hashCode</code> implementation.  I have the following method to test this key:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> testBrokenKey<span style="color: #009900;">&#40;</span><span style="color: #003399;">Map</span> m<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
    BrokenKey keyPut <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> BrokenKey<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #0000ff;">&quot;11111&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    BrokenKey keyGet <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> BrokenKey<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #0000ff;">&quot;22222&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    m.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>keyPut<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    m.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>keyPut, <span style="color: #0000ff;">&quot;value&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>m.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>keyPut<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>m.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>keyGet<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Output using HashMap:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="none" style="font-family:monospace;">value
value</pre></td></tr></table></div>

<p>Output using partitioned cache:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="none" style="font-family:monospace;">value
null</pre></td></tr></table></div>

<p>This makes sense, since <code>keyPut</code> and <code>keyGet</code> will serialize to different binaries.  However, things get really interesting when combining partitioned cache with a near cache.  Running the example using a near cache gives the following results:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="none" style="font-family:monospace;">value
value</pre></td></tr></table></div>

<p>What happened?  In this case, the first get resulted in a near cache miss, resulting in a read through to the backing partitioned cache.  The second get resulted in a near cache <strong>hit</strong> because the object&#8217;s equals/hashCode was used (since near caches store data in object form.)</p>
<p>In addition to <code>equals</code>/<code>hashCode</code>, keep the following in mind:</p>
<ul>
<li>Keys should be immutable.  Modifying a key while it is in a map generally isn&#8217;t a good idea, and it certainly won&#8217;t work in a distributed/partitioned cache.
<li>Key should be as small as possible.  Many operations performed by Coherence assume that keys are very light weight (such as the key based listeners that are used for near cache invalidation.)
<li>Built in types (String, Integer, Long, etc) fit all of this criteria.  If possible, consider using one of these existing classes.)
</ul>
]]></content:encoded>
			<wfw:commentRss>https://blackbeanbag.net/wp/2010/06/06/coherence-key-howto/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>What I’ve learned during a winter of running</title>
		<link>https://blackbeanbag.net/wp/2010/05/12/what-i%e2%80%99ve-learned-during-a-winter-of-running/</link>
		<comments>https://blackbeanbag.net/wp/2010/05/12/what-i%e2%80%99ve-learned-during-a-winter-of-running/#comments</comments>
		<pubDate>Thu, 13 May 2010 02:45:12 +0000</pubDate>
		<dc:creator><![CDATA[Patrick Peralta]]></dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://blackbeanbag.net/wp/?p=405</guid>
		<description><![CDATA[Motivated (or should I say distributed) by my lack of fitness, I decided to take on running last fall. I had done weights in the past but never running for two reasons: I used to live in Florida where it is uncomfortable to walk outside during most of the year, let alone run. I was [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Motivated (or should I say distributed) by my lack of fitness, I decided to take on running last fall.  I had done weights in the past but never running for two reasons: I used to live in Florida where it is uncomfortable to walk outside during most of the year, let alone run.  I was also bored to tears on the treadmill so that didn’t go anywhere.</p>
<p>In Boston however I found the environment much more conducive to running, given that there are sidewalks and bike paths, not to mention it feels like half of the people here run.  Also, the weather in the fall is very comfortable to run in (which probably explains why the NYC marathon is in November.)</p>
<p>Winter running, on the other hand, came with its own set of challenges.  During those months I learned some lessons that I’m passing along.</p>
<p>At first I tried running with a thick cotton sweater.  This turned out to be a bad idea, because the sweater (being a warm sweater as advertised) prevented heat from escaping my body.  This, paradoxically, causes you to freeze your ass off since you now have a pool of sweat on your skin.  The best practice is to wear material that wicks sweat away, including the top layer.  Even on the coldest of days (my personal low was 15F) I would get comfortable after about a mile.</p>
<p>The biggest challenge for me was not the air temperature (at least after warming up), it was ice.  On icy days my runs were much slower.  On really icy days I would just skip the run.  I know some hard core runners that would throw on spikes or yak tracks, but I didn’t take it to that level.  A related challenge is when it isn’t quite cold enough to freeze deeper pools of water.  I had the distinctly unpleasant experience of stepping into a 1 inch puddle on the bike path after wrongly assuming it was frozen over.  That day my run was definitely shorter than it would have been otherwise.</p>
<p>For the given temperatures, I really was wearing very thin layers of clothing.  This means that I had to keep moving in order to stay warm.  I never slowed down to a walk because that would have been far more unpleasant than dealing with the fatigue.  Running on the road in general has that advantage over the treadmill &#8211; with the treadmill you can quit anytime, whereas on the road you have to make it back home sometime, so you may as well run the distance.</p>
<p>Due to things being really busy lately my mileage has been decreasing.  I’m hoping to turn this around soon, especially since the warm spring weather is bringing out so many runners.</p>
<p>So how has the running affected my fitness?  It used to be that my heart and lungs were ready to break out of my chest after chasing down a bus.  After taking up running, I was not only able to perform this exercise without loosing breath, but I was able to do it while carrying my 40 lbs son!</p>
]]></content:encoded>
			<wfw:commentRss>https://blackbeanbag.net/wp/2010/05/12/what-i%e2%80%99ve-learned-during-a-winter-of-running/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>What&#8217;s happening in the world of Coherence?</title>
		<link>https://blackbeanbag.net/wp/2010/02/19/whats-happening-in-the-world-of-coherence/</link>
		<comments>https://blackbeanbag.net/wp/2010/02/19/whats-happening-in-the-world-of-coherence/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 18:28:23 +0000</pubDate>
		<dc:creator><![CDATA[Patrick Peralta]]></dc:creator>
				<category><![CDATA[Coherence]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://blackbeanbag.net/wp/?p=395</guid>
		<description><![CDATA[It has been a while since I&#8217;ve posted, so I figured it would be a good time to give an update on what is happening in Coherence land. New Coherence Bloggers We have two new bloggers sharing their experiences with Coherence! The first is by Oracle JDBC expert Pas Apicella who recently took on Coherence. [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>It has been a while since I&#8217;ve posted, so I figured it would be a good time to give an update on what is happening in Coherence land.</p>
<h3>New Coherence Bloggers</h3>
<p>We have two new bloggers sharing their experiences with Coherence!</p>
<p>The first is by Oracle JDBC expert Pas Apicella who recently took on Coherence.  Upon his introduction to Coherence he immediately proceeded to create a <a href="http://theblasfrompas.blogspot.com/2009/11/oracle-coherence.html">CacheStore example using PL/SQL</a>, followed by an example of using the <a href="http://www.oracle.com/technology/obe/11gr1_db/appdev/dcn/dcn.htm">Oracle JDBC Data Change Notification</a> mechanism to <a href="http://theblasfrompas.blogspot.com/2010/02/using-database-change-notification-dcn.html">push updates from the database to a cache</a>.</p>
<p>Additionally we have Coherence architect Andy Nguyen debuting with a detailed description of a <a href="http://cohfu.wordpress.com/2010/01/06/bulk-loading-a-coherence-cache-from-an-oracle-database/">sophisticated distributed bulk loading technique</a> he&#8217;s employed on several customer projects.</p>
<h3>Coherence Book in March</h3>
<p>After many months of blood, sweat, and blisters from too much typing, <a href="http://coherence.seovic.com/">Aleksandar Seovic</a> has completed the highly anticipated <a href="http://www.packtpub.com/oracle-coherence-3-5/book">Coherence book</a> published by <a href="http://www.packtpub.com">Packt</a>.  Having worked closely with Aleks on reviews and contributions, I believe this book will be a terrific resource for developers and architects that need to write scalable applications.  Both experienced users of Coherence and new users will find relevant and useful content.  Aleks was recently interviewed by Cameron Purdy about the book which can be downloaded as an <a href="http://streaming.oracle.com/ebn/podcasts/media/8458541_Aleksander_Seovic_020310.mp3">MP3</a>.</p>
<h3>User Group Meetings</h3>
<p>The UK SIG in London is the last Coherence user group meeting for the winter, it is coming up on <a href="http://brianoliver.wordpress.com/2010/02/01/london-coherence-sig-winter-edition-26th-february-2010-2/">February 26th</a>.  The spring events are currently being planned; stay tuned for details!</p>
<p>Also coming up on February 24th is the first <a href="http://www.bostonsug.org/">Boston SUG</a> meeting of the year.  Although the topic won&#8217;t be Coherence this time, it will be of interest for developers and architects interested in scalable systems.  We&#8217;ll be meeting up for drinks and snacks at Bertucci&#8217;s afterwards.  And I&#8217;ll be there if anyone wants to chat about Coherence or any other topic!</p>
]]></content:encoded>
			<wfw:commentRss>https://blackbeanbag.net/wp/2010/02/19/whats-happening-in-the-world-of-coherence/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle Open World: The most Coherence content under one roof!</title>
		<link>https://blackbeanbag.net/wp/2009/09/22/oracle-open-world-the-most-coherence-content-under-one-roof/</link>
		<comments>https://blackbeanbag.net/wp/2009/09/22/oracle-open-world-the-most-coherence-content-under-one-roof/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 21:26:49 +0000</pubDate>
		<dc:creator><![CDATA[Patrick Peralta]]></dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://blackbeanbag.net/wp/?p=391</guid>
		<description><![CDATA[This year I&#8217;ll be at Oracle Open World for the first time. I hear that this conference dwarfs JavaOne in size which is hard to imagine given how large JavaOne is. For those of you attending that are interested in Coherence, we have over two dozen sessions to choose from &#8211; making this the biggest [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>This year I&#8217;ll be at Oracle Open World for the first time.  I hear that this conference dwarfs JavaOne in size which is hard to imagine given how large JavaOne is.  For those of you attending that are interested in Coherence, we have over two dozen sessions to choose from &#8211; making this the biggest Coherence event ever.</p>
<p>The Coherence content is available on <a href="http://www.oracle.com/technology/products/coherence/coherencedatagrid/coherence_openworld_2009.html">OTN</a>.  (There&#8217;s also a <a href="http://www.oracle.com/technology/products/coherence/pdf/focuson_coherence_openworld-2009.pdf">PDF</a> version that is nicer for printing out.)  It includes sessions on future direction, integration with other products in the Oracle lineup, developer workshops, and customer panels describing their use of Coherence.</p>
<p>I&#8217;ll be talking about <a href="http://www.oracle.com/technology/products/coherence/coherencedatagrid/coherence_openworld_2009.html#coherence-persistence">using Coherence to scale out external data stores</a> (including relational databases.)  This is mostly the same content that will be covered during the <a href="http://blackbeanbag.net/wp/2009/09/17/next-ny-coherence-sig-on-october-1st/">NY SIG</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://blackbeanbag.net/wp/2009/09/22/oracle-open-world-the-most-coherence-content-under-one-roof/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Next NY Coherence SIG on October 1st</title>
		<link>https://blackbeanbag.net/wp/2009/09/17/next-ny-coherence-sig-on-october-1st/</link>
		<comments>https://blackbeanbag.net/wp/2009/09/17/next-ny-coherence-sig-on-october-1st/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 12:35:30 +0000</pubDate>
		<dc:creator><![CDATA[Patrick Peralta]]></dc:creator>
				<category><![CDATA[Coherence]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://blackbeanbag.net/wp/?p=383</guid>
		<description><![CDATA[The next NY Coherence SIG is on October 1st (two weeks from today) and it promises to be a great event. For those of you who follow my blog, I previously introduced these two gentlemen a few months ago when they started blogging. The first talk will be by Aleksandar Seovic who has an extensive [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>The next <a href="http://coherence.oracle.com/display/CSIG/1+Oct+2009+-+New+York%2C+NY">NY Coherence SIG</a> is on October 1st (two weeks from today) and it <a href="http://craigblitz.typepad.com/rawpower/2009/09/fall-edition-of-the-new-york-coherence-sig.html">promises to be a great event</a>.  For those of you who follow my blog, I previously <a href="http://blackbeanbag.net/wp/2009/05/27/two-new-coherence-blogs/">introduced these two gentlemen</a> a few months ago when they started blogging.  </p>
<p>The first talk will be by <a href="http://coherence.seovic.com/">Aleksandar Seovic</a> who has an extensive Coherence resume.  In addition to implementing POF in .NET, he is also the author of an upcoming <a href="http://www.packtpub.com/oracle-coherence-3-5/book">book on Coherence</a>.  In his spare time (insert tongue in cheek) he runs <a href="http://www.s4hc.com/">S4HC</a>, a consulting company specializing in Spring, Coherence, and other technologies.  </p>
<p><i>If you&#8217;re in Tampa, you can also check out his <a href="http://www.tampajug.org/wordpress/?p=133">upcoming talk at Tampa JUG</a> on September 29th.</i></p>
<p>We will also have <a href="http://markfalco.wordpress.com/">Mark Falco</a>, one of our rock star engineers who concentrates on our network protocol (TCMP), C++, and other areas.  Mark is usually the first (and last) person I reach out to when I have questions about Coherence networking &#8211; so if you have any questions of your own be sure to bring them.  He will talk to us about TCMP and how to optimize your machines and network for optimum performance.</p>
<p>Finally, yours truly will talk about configuring Coherence to work with an external data source (usually relational databases.)  I&#8217;ll describe in detail how each of the external connectivity features work (including many features you&#8217;ve probably never heard of), best practices, and good old fashioned war stories.  (Shout out to <a href="http://calmerthanur.wordpress.com/">Rob</a> for helping with the Omni Graffle diagrams!)  This is the same talk that I will present in mid October at <a href="http://www.oracle.com/openworld/index.html">Oracle Open World</a> in San Francisco.  I&#8217;ll provide more detail on this later; for now you can check out the <a href="http://www.oracle.com/technology/products/coherence/pdf/focuson_appgrid_openworld_2009.pdf">Application Grid</a> lineup &#8211; which includes WebLogic Server, Coherence, JRockit, Tuxedo and Enterprise Manager.</p>
]]></content:encoded>
			<wfw:commentRss>https://blackbeanbag.net/wp/2009/09/17/next-ny-coherence-sig-on-october-1st/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>NFJS Boston Day 3</title>
		<link>https://blackbeanbag.net/wp/2009/09/16/nfjs-boston-day-3/</link>
		<comments>https://blackbeanbag.net/wp/2009/09/16/nfjs-boston-day-3/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 23:03:26 +0000</pubDate>
		<dc:creator><![CDATA[Patrick Peralta]]></dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://blackbeanbag.net/wp/?p=362</guid>
		<description><![CDATA[Coverage of the last day of No Fluff Just Stuff (albeit a few days late): Spring DM and OSGi Craig Walls provided an extensive overview (and defense) of OSGi. OSGi is a framework for managing library dependencies. It enables the installation, configuration, and updating of modules in a live program without JVM restarts. Multiple versions [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Coverage of the last day of <a href="http://www.nofluffjuststuff.com/conference/boston/2009/09/home">No Fluff Just Stuff</a> (albeit a few days late):</p>
<h3>Spring DM and OSGi</h3>
<p>Craig Walls provided an extensive overview (and defense) of OSGi.  OSGi is a framework for managing library dependencies.  It enables the installation, configuration, and updating of modules in a live program without JVM restarts.  Multiple versions of a class and/or libraries can coexist in a container.  Each module has a defined lifecycle and dependencies between modules can be defined.</p>
<p>Here is a list of OSGi implementations:</p>
<h4>Open Source</h4>
<ul>
<li><a href="http://www.eclipse.org/equinox">Eclipse Equinox</a>
<li><a href="http://felix.apache.org">Apache Felix</a>
<li><a href="http://www.knopﬂerﬁsh.org">Knopﬂerﬁsh</a>
<li><a href="http://concierge.sourceforge.net/">Concierge</a>
</ul>
<h4>Commercial</h4>
<ul>
<li><a href="http://www.makewave.com">Makewave Knopﬂerﬁsh Pro</a>
<li><a href="http://www.prosyst.com">ProSyst mBedded Server</a>
<li>Samsung OSGi R4 Solution
<li>HitachiSoft SuperJ Engine Framework
</ul>
<p>Craig provided a live demonstration of the <a href="http://wiki.ops4j.org/display/ops4j/Pax+Shell">OPS4J Pax shell</a> running under Eclipse Equinox and Apache Felix.  Unfortunately we ran out of time and we didn&#8217;t get to see much of the Spring DM server in action.</p>
<h3>java.next</h3>
<p>Stuart Halloway gave an overview of the latest and greatest languages available for the JVM.  Like some of the other NFJS speakers he has very strong opinions, especially when it comes to the use of Java.  I believe the quote was something along the lines of &#8220;every time you start a greenfield project with Java, God kills a kitten.&#8221;  (Incidentally, Ted Neward believes that using Java arrays instead of collections will lead to the same fate for said kitten.)</p>
<p>Straight from Stuart&#8217;s slides: pros and cons for your consideration:</p>
<h4>Clojure Pros</h4>
<ul>
<li>Functional
<li>Multimethods
<li>Concurrency
<li>Lisp
<li>A la carte
</ul>
<h4>Clojure Cons</h4>
<ul>
<li>Youngest java.next language
</ul>
<h4>Groovy Pros</h4>
<ul>
<li>Easiest to learn
<li>Easiest bi-di interop
<li>More committed to reusing Java libs
</ul>
<h4>Groovy Cons</h4>
<ul>
<li>Worst Java baggage
<li>No concurrency/multicore story
</ul>
<h4>JRuby Pros</h4>
<ul>
<li>Biggest community
<li>Commercial support: EngineYard
<li>Rails
<li>multiple platforms
</ul>
<h4>JRuby Cons</h4>
<ul>
<li>No concurrency/multicore story
</ul>
<h4>Scala Pros</h4>
<ul>
<li>Functional
<li>High performance
<li>Pattern matching
<li>Actor model
<li>Hybrid object/functional (could also be a con)
</ul>
<h4>Scala Cons</h4>
<ul>
<li>Hardest to learn
</ul>
<p>The general theme on these new generation languages is:</p>
<ul>
<li>Dynamic typing (Scala is not as dynamic as the others, but offers more flexibility than Java)
<li>No checked exceptions
<li>Reasonable defaults
<li>Convention over configuration
<li><a href="http://en.wikipedia.org/wiki/YAGNI">YAGNI</a>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://blackbeanbag.net/wp/2009/09/16/nfjs-boston-day-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NFJS Boston Day 2</title>
		<link>https://blackbeanbag.net/wp/2009/09/12/nfjs-boston-day-2/</link>
		<comments>https://blackbeanbag.net/wp/2009/09/12/nfjs-boston-day-2/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 02:25:03 +0000</pubDate>
		<dc:creator><![CDATA[Patrick Peralta]]></dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://blackbeanbag.net/wp/?p=349</guid>
		<description><![CDATA[Here are my highlights of No Fluff Just Stuff Day 2: Garbage Collector Friendly Programming Garbage collection is an interesting topic to me for several reasons, the main reason being that poor GC performance is very harmful in distributed environments. When you have a peer to peer system such as Coherence, any one node can [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Here are my highlights of <a href="http://www.nofluffjuststuff.com/conference/boston/2009/09/home">No Fluff Just Stuff</a> Day 2:</p>
<h3>Garbage Collector Friendly Programming</h3>
<p>Garbage collection is an interesting topic to me for several reasons, the main reason being that poor GC performance is very harmful in distributed environments.  When you have a peer to peer system such as Coherence, any one node can directly communicate with any other node at any point in time to service a request.  If a node that needs to service several requests is in a long GC pause, it isn&#8217;t just that node that is affected.  Every JVM that is waiting for a response from that node also experiences high latency, thus causing a cascading effect.  (More on what to do about this later.)</p>
<p>Brian Goetz described the evolution of GC in Java, starting with the single threaded mark and sweep algorithms up to the modern generational collector.         What they each have in common is the tracking of allocation roots (which include static variables and local variables allocated on thread stacks) and the traversal of object references starting at these roots.  The implementation of the generational collector is (roughly) as follows:</p>
<ul>
<li>New objects are allocated in the young generation space
<li>When a minor GC occurs, objects that have references pointing to them are copied to the survival space.  The remaining objects are removed
<li>Eventually objects that live long enough in the survival space are moved to the old generation.
<li>If a minor collection fails to free up enough space in the young generation  area, a full collection (which is much more expensive) will occur in the old generation space.
</ul>
<p>An implementation detail is that the JVM must track references from the old generation to the young generation in order to know which GC roots to traverse when performing a minor collection.  This means that the more &#8220;old&#8221; objects there are pointing to &#8220;new&#8221; objects, the more work the collector has to do.  In a practical sense, this means that allocating new objects is preferred to reference field updates.</p>
<p>It took a while to wrap my head around that last statement, so let me attempt to demonstrate.  Let&#8217;s say I have a map that contains objects with many fields.  If I wanted to update some of those fields I could do it like this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">Map</span> map <span style="color: #339933;">=</span> ...
<span style="color: #006633;">MyObject</span> o <span style="color: #339933;">=</span> map.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>key<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
o.<span style="color: #006633;">setField1</span><span style="color: #009900;">&#40;</span>f1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
o.<span style="color: #006633;">setField3</span><span style="color: #009900;">&#40;</span>f3<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
o.<span style="color: #006633;">setField5</span><span style="color: #009900;">&#40;</span>f5<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Or I could do it like this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">Map</span> map <span style="color: #339933;">=</span> ...
<span style="color: #006633;">MyObject</span> oOld <span style="color: #339933;">=</span> map.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>key<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
MyObject oNew <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MyObject<span style="color: #009900;">&#40;</span>f1, o.<span style="color: #006633;">getField2</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, f3, o.<span style="color: #006633;">getField4</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, f5<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
map.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>key, oNew<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The first example updates three reference fields (assuming the object in the map is in the old generation), whereas the second is updating one (the reference held by Map.Entry) &#8211; and as an added bonus the second implementation is thread safe (assuming that MyObject is immutable and the Map implementation is also thread safe.)  If anyone has a better (or more correct) example of this concept, I&#8217;d be happy to see it!</p>
<p>Many other concepts were covered including: why you should use <i>finally</i> instead of finalizers to clean up, weak references, soft references, and tracking down memory leaks.  Capturing heap dumps to track memory usage is a technique I recommend to customers (this works much better than speculating/wild guesses about where unexpected memory allocation is coming from) &#8211; I especially recommend configuring the JVM to generate a heap dump when an OutOfMemoryError is thrown.  My favorite tool to read heap dumps is <a href="http://www.eclipse.org/mat/">Eclipse MAT</a>.  Heap histograms are also a nice light weight approach to analyze memory problems.</p>
<p>When customers ask for suggestions on GC tuning, my recommendation is to keep it simple: fixed size 1 GB heaps (on the Sun VM), and don&#8217;t use more than 75% of the heap.  I usually don&#8217;t recommend any specific tuning parameters, as the GC algorithms are constantly improving and any exotic flags that may have worked in older JVMs (assuming they helped in the first place) may not work so well in newer JVMs.  The best advice I can give is to not fill up the heap as this will cause more frequent full collections.</p>
<h3>Inside the Modern JVM</h3>
<p>NFJS tends to cover languages in the JVM other than Java (such as Groovy, Scala, JRuby, etc.)  This is a testament to the strength and viability of the modern JVM.  Brian covered some of the advancements and (quite frankly) rocket science that goes into the JVM, HotSpot in particular.  No matter what happens to Java (which isn&#8217;t going away any time soon), the JVM will be around for a very long time.</p>
<p>In a nutshell: why is Java, a supposedly interpreted language, faster than C++ in many cases?  The answer is that the JVM determines which optimizations to make at run time instead of compile time, which is the opposite approach of C++ and other native languages.  Optimization at runtime is far more effective, since the JVM has hard statistics of real world usage to draw on as opposed to the speculation and guessing that happens when everything has to be compiled to machine code before execution.</p>
<p>The overall theme of this talk (and the previous ones) is to write simple clean code &#8211; the runtime recognizes common usage patterns in Java and is built to optimize these patterns.</p>
<h3>Java Collections</h3>
<p>Ted Neward gave an engaging and entertaining talk on the Java Collections API.  To be honest I was familiar with most of the material, but he is a fun speaker to watch, in spite of the fact that he gave me a good ribbing for showing up to his talk after it had already started!  He is quite biased against arrays and towards collections, which made me think back to a web/remote services API I designed a few years ago.  I exclusively used arrays as the collection type for this API for two reasons:</p>
<ol>
<li>To make SOAP/cross language interoperability much simpler (least common denominator &#8211; every language does arrays)
<li>There were no generics at the time; using arrays instead of generics in the interfaces meant that I could explicitly define the type of the array
</ol>
<p>The second item is not as important anymore now that we have generics, so I&#8217;m inclined to agree that arrays should be used sparingly nowadays.  </p>
<p>Another interesting point is that iteration over collections should be done using a <a href="http://en.wikipedia.org/wiki/Functor">functor</a> instead of a plain iterator.  For example:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;">List<span style="color: #339933;">&lt;</span>Name<span style="color: #339933;">&gt;</span> names <span style="color: #339933;">=</span> ...<span style="color: #339933;">;</span> 
MyListOps.<span style="color: #006633;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> MyApplyFn<span style="color: #339933;">&lt;</span>Name<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> apply<span style="color: #009900;">&#40;</span><span style="color: #003399;">Name</span> n<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #666666; font-style: italic;">// use n </span>
  <span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span>, names<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This allows the possibility of processing the collection in multiple threads.</p>
<h3>What&#8217;s coming in Java 7</h3>
<p>This was Ted Neward&#8217;s next talk which was just as interesting and opinionated.  Here are the highlights:</p>
<ul>
<li>The release is targeted for early 2010
<li>There is no official JSR for Java 7
<li>Most of the information on what is going into Java 7 can be found on the blog of <a href="http://blogs.sun.com/darcy/date/20090828">Joe Darcy of Sun</a>.
<li><a href="http://tech.puredanger.com/java7/">Alex Miller</a> has a <i>huge</i> page on his blog detailing what is in and what is out.  This is information that is is aggregating off the web.
</ul>
<p>One of the most compelling additions to Java 7 is <a href="http://jcp.org/en/jsr/detail?id=292">JSR 292</a>, which introduces the bytecode <i>invokedynamic</i>.  The implications of this addition are narrated by <a href="http://blog.headius.com/2008/09/first-taste-of-invokedynamic.html">Charles Nutter</a> of JRuby.  There are other syntactic conveniences making it in; however it will not include closures (a fairly controversial topic.)</p>
]]></content:encoded>
			<wfw:commentRss>https://blackbeanbag.net/wp/2009/09/12/nfjs-boston-day-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
