<?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</title>
	<atom:link href="https://blackbeanbag.net/wp/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>Adventures with Spring XD and ZooKeeper</title>
		<link>https://blackbeanbag.net/wp/2014/05/22/adventures-with-spring-xd-and-zookeeper/</link>
		<comments>https://blackbeanbag.net/wp/2014/05/22/adventures-with-spring-xd-and-zookeeper/#comments</comments>
		<pubDate>Thu, 22 May 2014 18:55:26 +0000</pubDate>
		<dc:creator><![CDATA[Patrick Peralta]]></dc:creator>
				<category><![CDATA[Spring XD]]></category>

		<guid isPermaLink="false">http://blackbeanbag.net/wp/?p=542</guid>
		<description><![CDATA[Back in January I announced my departure from Oracle and my arrival to Pivotal. One of my first goals was to help build a robust distributed runtime platform for Spring XD. Most (if not all) Java developers are familiar with the Spring framework, but Spring XD is not as well known. Spring XD is a [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-544" src="http://blackbeanbag.net/wp/wp-content/uploads/2014/05/trees.jpg" alt="trees" width="278" height="196" /></p>
<p>Back in January I <a href="https://twitter.com/patrickperalta/status/422741438984880128">announced my departure from Oracle and my arrival to Pivotal</a>. One of my first goals was to help build a robust distributed runtime platform for Spring XD. Most (if not all) Java developers are familiar with the Spring framework, but Spring XD is not as well known.</p>
<p><a href="http://projects.spring.io/spring-xd/">Spring XD</a> is a system used for defining streams and/or batch processing of data. Although developers may introduce their own modules into the system, writing code is not a prerequisite for use. This by itself makes Spring XD different from Spring framework. Spring XD is a standalone distributed application. Streams and jobs are created via an <a href="http://docs.spring.io/spring-xd/docs/1.0.0.M6/reference/html/#_start_the_runtime_and_the_xd_shell">interactive shell</a>.</p>
<p>What is a stream? The best way to demonstrate is via an example using the UNIX shell. Consider the following:<br />
<code><br />
tail -f /tmp/log.txt | grep ERROR<br />
</code><br />
The tail command will continuously display the file. The | will pipe the output of tail to grep, which will filter out all lines that don’t include the string ERROR.</p>
<p>This command can be translated to the Spring XD shell:<br />
<code><br />
stream create --name error-filter --definition "tail --name=/tmp/log.txt | filter --expression=payload.contains('ERROR') | log" --deploy<br />
</code></p>
<p>Why is this useful? For this example Spring XD is not very practical. However, imagine building a system to grep for errors in a 1000 node farm of servers. Perhaps these messages should be persisted in HDFS for further analysis in a Hadoop cluster. The creation and management of these types of distributed streams is where Spring XD shines. In addition to streams, Spring XD can handle the scheduling and execution of jobs across a cluster.</p>
<p>As in any distributed system, it is desirable to scale the system up or down to meet demand. Single points of failure should be eliminated to the extent possible. In order to meet these challenges, Spring XD has adopted ZooKeeper as the basis for distributed runtime configuration and coordination.</p>
<p><a href="http://zookeeper.apache.org/">Apache ZooKeeper</a> is a &#8220;centralized service for maintaining configuration information, naming, providing distributed synchronization&#8230;[for] distributed applications.&#8221; It is used by many projects, including <a href="http://kafka.apache.org/documentation.html#zk">Kafka</a>, <a href="http://storm.incubator.apache.org/documentation/Fault-tolerance.html">Storm</a> and <a href="https://hbase.apache.org/book/quickstart.html">HBase</a>. One of the bits of core functionality that ZooKeeper provides is the ability to emit notifications when data is updated. Spring XD relies on this functionality for stream and job deployments. Much of this functionality, in addition to ZooKeeper data caching, is made much easier via the use of <a href="http://curator.apache.org/">Apache Curator</a>.</p>
<p>A <a href="http://docs.spring.io/spring-xd/docs/1.0.0.M6/reference/html/#running-distributed-mode">container process</a> in Spring XD has the ability to host modules for streams or jobs. An <a href="http://docs.spring.io/spring-xd/docs/1.0.0.M6/reference/html/#running-distributed-mode">admin process</a> can accept HTTP requests to manage streams and jobs. It is also responsible for deployment coordination. Multiple admin processes may exist in a Spring XD cluster. One of these processes is designated with the &#8220;supervisor&#8221; role. <a href="http://curator.apache.org/curator-recipes/leader-election.html">Curator&#8217;s leader election recipe</a> is used to select which admin process is the supervisor. This process is the one responsible for deploying stream and job modules to containers.</p>
<p>Commands entered into the shell are sent to an admin server via HTTP/REST. Most commands will consist of the creation and deployment of streams and jobs. Stream and job definitions are stored in ZooKeeper by the admin server. When streams and jobs are deployed, a node is written in ZooKeeper by the admin process that received the REST request for deployment. The node triggers the admin supervisor (which may or may not be the same admin process that received the initial REST request) to start the deployment process. This process consists of selecting which containers will host the various modules that comprise the stream/job and writing to ZooKeeper a request for module deployment. The respective containers will deploy the modules, thus establishing the stream/job.</p>
<p>When a container joins or leaves the cluster, the supervisor will determine if any action is required in terms of stream/job module deployment. In most cases, if a departing container was hosting a module, the supervisor will select another container to host that module. Should the system be without a supervisor for a period of time, the new supervisor will query the state of the system upon startup and take any actions required.</p>
<p>See the reference documentation for more details on how <a href="http://docs.spring.io/spring-xd/docs/1.0.0.M6/reference/html/#_zookeeper_overview">Spring XD uses ZooKeeper</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://blackbeanbag.net/wp/2014/05/22/adventures-with-spring-xd-and-zookeeper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>The Live Object Pattern &#8211; Coming to a SIG Near You</title>
		<link>https://blackbeanbag.net/wp/2011/10/20/the-live-object-pattern-coming-to-a-sig-near-you/</link>
		<comments>https://blackbeanbag.net/wp/2011/10/20/the-live-object-pattern-coming-to-a-sig-near-you/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 02:27:25 +0000</pubDate>
		<dc:creator><![CDATA[Patrick Peralta]]></dc:creator>
				<category><![CDATA[Coherence]]></category>

		<guid isPermaLink="false">http://blackbeanbag.net/wp/?p=519</guid>
		<description><![CDATA[In spite of this blog being dormant for over a year, things have been busier than ever over in Coherence land! We just released version 3.7.1 which is packed with new features. Some of the highlights: REST support in the proxy. In addition to Java, C# and C++, now you can access the grid with [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-521" style="margin-left: 5px; margin-right: 5px;" title="Live Objects" src="http://blackbeanbag.net/wp/wp-content/uploads/2011/10/liveobject.jpg" alt="" width="199" height="132" />In spite of this blog being dormant for over a year, things have been busier than ever over in Coherence land! We just released version 3.7.1 which is packed with new features. Some of the highlights:</p>
<ul>
<li>REST support in the proxy. In addition to Java, C# and C++, now you can access the grid with any language that has a REST API.</li>
<li>POF enhancements, including annotations and the ability to eliminate Java key classes (for pure C# and C++ applications)</li>
<li>Query Explain Plan. If you&#8217;ve ever had a problem with a production application missing indexes (because you won&#8217;t notice it in development and you may not notice it during testing) you&#8217;ll be interested in this feature. It analyzes queries (filter based or CohQL) and indicates where indexes are used (and not used.)</li>
</ul>
<p>We&#8217;ve been adding screencasts to the <a href="http://www.youtube.com/user/OracleCoherence">Coherence YouTube channel</a> going over these features &#8211; in most cases the screencasts are delivered by the architect/developer responsible for the feature.</p>
<p>We also just wrapped up JavaOne and Oracle Open World a few weeks ago. I had the privilege of co-presenting the Live Object Pattern with <a href="http://brianoliver.wordpress.com/">Brian Oliver</a>. The <a href="https://oracleus.wingateweb.com/scheduler/modifySession.do?SESSION_ID=25144">description</a> and <a href="https://oracleus.wingateweb.com/published/oracleus2011/sessions/25144/25144_Cho2550380.pdf">PDF</a> can be downloaded from the JavaOne site.</p>
<p>If you didn&#8217;t get to see the talk, you&#8217;re in luck if you&#8217;re in New York or London. Noah Arliss, who worked with Brian on the Live Objects concept and the abstract of the JavaOne talk, will be presenting on this topic at the <a href="http://coherence.oracle.com/display/CSIG/28+Oct+2011+-+New+York%2C+NY">New York SIG</a> on October 28th and the <a href="http://coherence.oracle.com/display/CSIG/4+November+2011+-+London%2C+UK">London SIG</a> on November 4th.</p>
<p>All of the SIGs this fall (including the <a href="http://coherence.oracle.com/display/CSIG/3+Nov+2011+-+Redwood+Shores%2C+CA">Bay Area SIG</a> on November 3rd) will cover the new features in Coherence 3.7.1. Come out and join us!</p>
]]></content:encoded>
			<wfw:commentRss>https://blackbeanbag.net/wp/2011/10/20/the-live-object-pattern-coming-to-a-sig-near-you/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>Partitions, Backing Maps, and Services&#8230;Oh My!</title>
		<link>https://blackbeanbag.net/wp/2010/07/01/partitions-backing-maps-and-services-oh-my/</link>
		<comments>https://blackbeanbag.net/wp/2010/07/01/partitions-backing-maps-and-services-oh-my/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 20:12:58 +0000</pubDate>
		<dc:creator><![CDATA[Patrick Peralta]]></dc:creator>
				<category><![CDATA[Coherence]]></category>

		<guid isPermaLink="false">http://blackbeanbag.net/wp/?p=454</guid>
		<description><![CDATA[Recently I was asked the following question: What is the relationship between a partition, cache, and a backing map?  To answer this, first we should go through some definitions: Cache: An object that maps keys to values. In Coherence, caches are referred to by name (thus the interface NamedCache.) Caches are also typically clustered, i.e. [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/rockinfree/2814780379/"><img src="http://blackbeanbag.net/wp/wp-content/uploads/2010/07/road.jpg" alt="Yellow Brick Road (Credit: _rockinfree)" title="Yellow Brick Road (Credit: _rockinfree)" width="134" height="129" style="border-style: initial; border-color: initial; border-width: 0px;" class="alignright size-full wp-image-470" style="margin:15px 15px"/></a><br />
Recently I was asked the following question:</p>
<blockquote><p>What is the relationship between a partition, cache, and a backing map? </p></blockquote>
<p>To answer this, first we should go through some definitions:</p>
<p><strong>Cache:</strong> An object that maps keys to values.  In Coherence, caches are referred to by name (thus the interface NamedCache.)  Caches are also typically clustered, i.e. they can be accessed and modified from any member of a Coherence cluster.</p>
<p><strong>Partition:</strong> A unit of transfer for a partitioned/distributed cache.  (In Coherence terminology, partitioned and distributed are used interchangeably, with preference towards the former.)  </p>
<p><strong>Backing Map:</strong> Data structure used by a storage node to hold contents of a cache.  For partitioned caches, this data is in binary (serialized) form.</p>
<p>I&#8217;ll add one more term for completeness: </p>
<p><strong>Service:</strong> Set of threads dedicated to handling requests; a cache service handles requests such as put, get, etc.  The DistributedCache service is present on all members of the cluster that read/write/store cache data, even if the node is storage disabled.</p>
<p>Now let&#8217;s put these concepts together to see how a clustered partitioned cache works.</p>
<p>First we&#8217;ll start with a backing map.  It is a straight forward data structure, usually an instance of <a href="http://download.oracle.com/otn_hosted_doc/coherence/353/com/tangosol/net/cache/LocalCache.html">LocalCache</a>:</p>
<p><a href="http://blackbeanbag.net/wp/wp-content/uploads/2010/07/SimpleBackingMap.png"><img src="http://blackbeanbag.net/wp/wp-content/uploads/2010/07/SimpleBackingMap.png" alt="" title="SimpleBackingMap" width="99" height="151" class="aligncenter size-full wp-image-457" /></a></p>
<p>The contents of this map are managed by a partitioned cache service.  In a typical thread dump, this would be the &#8220;DistributedCache&#8221; thread:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="none" style="font-family:monospace;">&quot;DistributedCache&quot; daemon prio=5 tid=101a91800 nid=0x118445000 in Object.wait() [118444000]</pre></td></tr></table></div>

<p>A single cache service can manage multiple backing maps.  This is the default behavior if multiple services are not specified in the cache configuration file.  (Multiple partitioned cache services are beyond the scope of this post; this topic will be addressed in a future posting.)</p>
<p><a href="http://blackbeanbag.net/wp/wp-content/uploads/2010/07/PCBM.png"><img src="http://blackbeanbag.net/wp/wp-content/uploads/2010/07/PCBM.png" alt="" title="PCBM" width="365" height="272" class="aligncenter size-full wp-image-461" /></a></p>
<p>So how do partitions come into play?  Each backing map is logically split into partitions:</p>
<p><a href="http://blackbeanbag.net/wp/wp-content/uploads/2010/07/PCBM-partitioned.png"><img src="http://blackbeanbag.net/wp/wp-content/uploads/2010/07/PCBM-partitioned.png" alt="" title="PCBM-partitioned" width="365" height="306" class="aligncenter size-full wp-image-463" /></a></p>
<p>This splitting is used for transferring data between storage enabled members.  Here are log file snippets of data transfer between two nodes:</p>
<p><strong>Member 1:</strong></p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="none" style="font-family:monospace;">(thread=DistributedCache, member=1): 3&gt; Transferring 128 out of 257 primary partitions to member 2 requesting 128</pre></td></tr></table></div>

<p><strong>Member 2:</strong></p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="none" style="font-family:monospace;">(thread=DistributedCache, member=2): Asking member 1 for 128 primary partitions</pre></td></tr></table></div>

<p>As members are added to the cluster, the partitions are split up amongst the members.  Note that this includes backup copies of each partition.</p>
<p><a href="http://blackbeanbag.net/wp/wp-content/uploads/2010/07/Distribution.png"><img src="http://blackbeanbag.net/wp/wp-content/uploads/2010/07/Distribution.png" alt="" title="Distribution" width="424" height="307" class="aligncenter size-full wp-image-466" /></a></p>
<p>As of Coherence 3.5, it is possible to configure backing maps to <a href="http://coherence.oracle.com/display/COH35UG/Storage+and+Backing+Map">physically split partitions into their own respective backing maps</a>.  This configuration may be desirable for backing maps that are stored off heap (i.e. NIO direct memory or disk) as it will make data transfer more efficient.</p>
<p><a href="http://blackbeanbag.net/wp/wp-content/uploads/2010/07/SplitBackingMap.png"><img src="http://blackbeanbag.net/wp/wp-content/uploads/2010/07/SplitBackingMap.png" alt="" title="SplitBackingMap" width="365" height="369" class="aligncenter size-full wp-image-468" /></a></p>
]]></content:encoded>
			<wfw:commentRss>https://blackbeanbag.net/wp/2010/07/01/partitions-backing-maps-and-services-oh-my/feed/</wfw:commentRss>
		<slash:comments>9</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>Springtime for Coherence</title>
		<link>https://blackbeanbag.net/wp/2010/04/18/springtime-for-coherence/</link>
		<comments>https://blackbeanbag.net/wp/2010/04/18/springtime-for-coherence/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 09:50:12 +0000</pubDate>
		<dc:creator><![CDATA[Patrick Peralta]]></dc:creator>
				<category><![CDATA[Coherence]]></category>

		<guid isPermaLink="false">http://blackbeanbag.net/wp/?p=401</guid>
		<description><![CDATA[As I type this I am 35,000 feet over Alaska (no I can’t see Putin’s backyard from here) en route to QCon Tokyo. Brian was scheduled to talk but was unable to make it so I’m stepping in to present a talk on spanning multiple data grids across disparate data centers. (You can see Brian [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>As I type this I am 35,000 feet over Alaska (no I can’t see Putin’s backyard from here) en route to <a href="http://qcontokyo.com/">QCon Tokyo</a>.  Brian was scheduled to talk but was unable to make it so I’m stepping in to present a talk on <a href="http://qcontokyo.com/speaker_PatrickPeralta.html">spanning multiple data grids across disparate data centers</a>.  (You can see Brian describing this talk at QCon SF <a href="http://www.youtube.com/watch?v=hHURxMmsAJ8">here</a>.)  In addition to this presentation, I’m looking forward to sampling the food and culture in Japan.  As a big city guy I’ve always wanted to visit Tokyo so I’m quite fortunate to have the chance.</p>
<p>As they say, when it rains it pours.  I just came back from the <a href="http://coherence.oracle.com/display/CSIG/15+Apr+2010+-+New+York%2C+NY">New York SIG</a> where I talked about real world challenges in customer deployments and passed along lessons that we learned in solving these problems.  After leaving Tokyo, I will be joining Cameron and Noah in Toronto for the <a href="http://coherence.oracle.com/display/CSIG/23+Apr+2010+-+Mississauga%2C+ON">inaugural SIG</a> where I will deliver the same presentation I gave in NY.  Cameron will talk about the past and future of Coherence, and Noah will give an update on the latest innovations in the Coherence Incubator project.</p>
<p>Has everyone received their copy of the <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">Coherence book</a> yet?  One of my favorite parts of the book is the very beginning where Aleks describes what it takes to build scalable applications.  In fact a good portion of the first chapter doesn’t even mention Coherence; it just talks about aspects of scalability that developers and architects of high scale systems should be familiar with.  A copy of this book was raffled at the NY SIG, and more copies will be given away at the Bay SIG and Toronto SIG.</p>
]]></content:encoded>
			<wfw:commentRss>https://blackbeanbag.net/wp/2010/04/18/springtime-for-coherence/feed/</wfw:commentRss>
		<slash:comments>0</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>
	</channel>
</rss>
