<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Ike&#039;s Biased Objectivity</title>
	<atom:link href="http://theikester.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://theikester.wordpress.com</link>
	<description>Just my bijective point of view on tech and media.</description>
	<lastBuildDate>Sat, 08 May 2010 15:11:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='theikester.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Ike&#039;s Biased Objectivity</title>
		<link>http://theikester.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://theikester.wordpress.com/osd.xml" title="Ike&#039;s Biased Objectivity" />
	<atom:link rel='hub' href='http://theikester.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Can The Play Framework Play Nice With Others?</title>
		<link>http://theikester.wordpress.com/2010/05/07/can-the-play-framework-play-nice-with-others/</link>
		<comments>http://theikester.wordpress.com/2010/05/07/can-the-play-framework-play-nice-with-others/#comments</comments>
		<pubDate>Fri, 07 May 2010 21:14:25 +0000</pubDate>
		<dc:creator>theikester</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[play]]></category>
		<category><![CDATA[scala]]></category>
		<category><![CDATA[servlet]]></category>
		<category><![CDATA[webapp]]></category>

		<guid isPermaLink="false">http://theikester.wordpress.com/?p=66</guid>
		<description><![CDATA[So you still can&#8217;t get over how fast and simple it is to develop web apps with the Play framework and you want to use it for all your future web development. In fact, you like it so much that you even want to jam it into an existing servlet-based app with thousands of lines of code, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=theikester.wordpress.com&amp;blog=8816305&amp;post=66&amp;subd=theikester&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So you still can&#8217;t get over how fast and simple it is to develop web apps with the <a title="Play framework site" href="http://www.playframework.org/">Play framework</a> and you want to use it for all your future web development. In fact, you like it so much that you even want to jam it into an existing servlet-based app with thousands of lines of code, Spring configuration files, etc. But wait, the Play framework doesn&#8217;t use the Servlet API! Can you still do it?</p>
<p>The short answer is YES, but first, let&#8217;s take a quick look at how Play works because there are some important limitations to this <a title="Definition of Chimera" href="http://en.wikipedia.org/wiki/Chimera_(mythology)">chimera</a>, and understanding the constraints will help you decide when and where to do this kind of integration. In a future post I&#8217;ll show how to make this work in a couple of different ways.</p>
<h3>Look Ma, No Servlets!</h3>
<p>The Play framework has conceptual differences and similarities with other Java webapp frameworks but it differs greatly from all others in one thing: it doesn&#8217;t use the Java Servlet API and therefore doesn&#8217;t run in a Servlet container. Guillaume Bort (Play&#8217;s creator and lead developer) <a title="Why there is no Servlets in Play" href="http://iam.guillaume.bort.fr/post/558830013/why-there-is-no-servlets-in-play">explains his reasons for dumping Servlets here</a>. It basically boils down to Development Speed and Scalability.</p>
<p>On one hand, by dropping the whole Java Servlet apparatus he was able to create an environment that detects code changes, dynamically (re)compiles source files and hot-swaps the new bytecode into the running JVM, to the point where it feels like developing in a dynamic language like Ruby or Python, while maintaining all the goodness of a compiled, type-safe language like Java or Scala. You can literally edit your code, hit reload on your browser and see the change. Compare that to the typical edit-build-deploy-restart cycle with traditional Java-based frameworks. If you don&#8217;t think that makes a difference for development you haven&#8217;t really tried it yet. To deploy it in production Play pre-compiles all the files and runs the app in an optimized, non-reloadable mode.</p>
<p>On the other hand, the Play framework generates stateless applications that can be easily deployed in load-balanced clusters. You can start as many Play app instances as you need and just do simple load balancing between them; no need for layer 7 juggling, server affinity, session failover, or any of that fun stuff. Web app scalability is a complex subject and I&#8217;m not suggesting that Play addresses all its challenges, but it helps you design your web tier so that it doesn&#8217;t become the bottleneck. To accomplish this it requires a mental adjustment as some concepts clash with paradigms we take for granted in a Servlet environment (i.e. storing state in the session scope). But having developed and scaled massively large web apps for the past 10 years I believe Play discourages just the right anti-patterns and pushes the correct share-nothing constructs to the dev cycle.</p>
<p>There is a lot more that Play does for you behind the scenes but I won&#8217;t cover all its features here. You can watch the <a title="Play framework site" href="http://www.playframework.org">intro video on the Play site</a> for a quick teaser. There is no such thing as a perfect development framework but if you create web applications you should take a serious look at Play.</p>
<h3>Play-Servlet Chimera</h3>
<p>The scenario I described at the beginning echoes one in which I recently found myself. We have a large web application built with some plain old Servlets, some Spring MVC, JSPs, Velocity templates, a service layer, data access code, caching, etc. all glued together with a Spring application context. When we recently needed to add a new feature I really wanted to do it in Play, but I wasn&#8217;t sure if I could integrate it in a seamless way or at all.</p>
<p>How can you reconcile these two different and seemingly incompatible runtime environments in a single web application? The answer is, you don&#8217;t! It&#8217;s not necessary because they can both live under the same webapp without overlapping and here&#8217;s why.</p>
<p>Play manages the complete HTTP request-response cycle through its default Mina-based implementation (Netty and Grizzly can be installed as modules). Not only is a container not required, it is not recommended.</p>
<p>However, Lee Breisacher wrote a Servlet wrapper that basically encapsulates a full Play application in a standard Servlet. To try it, you can export the Play application with a single command (play war &lt;playapp_dir&gt; -o &lt;war_dir&gt;). You lose all the dynamic recompilation features of the framework this way, but it is a viable alternative for people with limited deployment options. The resulting file layout conforms to the Servlet WAR standard. All the framework files end up inside the WEB-INF directory and a standard web.xml file is generated with the minimum necessary definitions to manage the full URL space (/*). With this in mind, it was relatively straightforward to take it to the next level: complete integration.</p>
<p>The result is more akin to Frankenstein&#8217;s monster than I would have liked, but it works and provides a migration path for new feature development on an old application. It requires splicing the exported Play app with the existing webapp by merging the contents of their respective WEB-INF directories. In a future post I will illustrate how to do this in an automated way.</p>
<h3>Obstacles Ahead</h3>
<p>Although getting both apps to run together in one Servlet context is relatively easy, getting them to behave like a single, seamless application is much more challenging. The Play app doesn&#8217;t naturally have access to any of the data structures of the webapp. You&#8217;ll find you need to create a communication channel between the two camps if you want the user to be able to navigate back and forth between different sections of the app without disruption.</p>
<p>For a completely stateless app this is no big deal. You may need to duplicate some HTML templates and maybe find a way to share some caches to avoid having redundant, possibly inconsistent data. For stateful apps it&#8217;s a different story. You may find that traditionally simple things like sharing the logged-in user state across requests can take some developer brain power. But these are not insurmountable and once you solve them once you won&#8217;t need to solve them again.</p>
<p>One obvious candidate for the traffic cop role is a shared Spring application context. There&#8217;s even a Spring module for Play, but I haven&#8217;t used it yet so I can&#8217;t recommend a solution at this point.</p>
<h3>Promising Future</h3>
<p>So far, I&#8217;m loving the productivity I get with Play. It is still a relatively new player in the space and I&#8217;m sure I&#8217;ll encounter some bumps along the way, but the community is wonderful and the developers are very responsive. Although I initially hoped it would be easier to plug it into old code I&#8217;ve come to embrace its approach and happily accept the limitations.</p>
<p>I used to think that Grails was the holy grail (pun intended) of JVM-based web frameworks. It has a large, active community, tons of modules and Springsource/VMWare behind it. But after using Play I can hardly justify writing all my code in Groovy. With Play&#8217;s bytecode gymnastics even Java code in Play looks more compact than Grails&#8217; equivalent. And I haven&#8217;t even mentioned <a title="Guillaume's thoughts on Scala" href="http://iam.guillaume.bort.fr/post/541145173/my-thoughts-on-scala">Play&#8217;s future with the Scala module</a>&#8230;it&#8217;s just cool. But that&#8217;s a subject for another post.</p>
<br />Filed under: <a href='http://theikester.wordpress.com/category/software-development/'>Software Development</a> Tagged: <a href='http://theikester.wordpress.com/tag/framework/'>framework</a>, <a href='http://theikester.wordpress.com/tag/howto/'>howto</a>, <a href='http://theikester.wordpress.com/tag/java/'>java</a>, <a href='http://theikester.wordpress.com/tag/play/'>play</a>, <a href='http://theikester.wordpress.com/tag/scala/'>scala</a>, <a href='http://theikester.wordpress.com/tag/servlet/'>servlet</a>, <a href='http://theikester.wordpress.com/tag/webapp/'>webapp</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/theikester.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/theikester.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/theikester.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/theikester.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/theikester.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/theikester.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/theikester.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/theikester.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/theikester.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/theikester.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/theikester.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/theikester.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/theikester.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/theikester.wordpress.com/66/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=theikester.wordpress.com&amp;blog=8816305&amp;post=66&amp;subd=theikester&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://theikester.wordpress.com/2010/05/07/can-the-play-framework-play-nice-with-others/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/34366beb64ceb0c4a375d479af60d5c2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">theikester</media:title>
		</media:content>
	</item>
		<item>
		<title>Access Cassandra From Scala – Cascal</title>
		<link>http://theikester.wordpress.com/2010/04/23/access-cassandra-from-scala-cascal/</link>
		<comments>http://theikester.wordpress.com/2010/04/23/access-cassandra-from-scala-cascal/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 17:24:24 +0000</pubDate>
		<dc:creator>theikester</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[cassandra]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[nosql]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://theikester.wordpress.com/?p=43</guid>
		<description><![CDATA[I recently wrote about my experience using Hector (a Java-Cassandra client library) from Scala. Although I found it to be workable, I was looking for something even simpler and more in the spirit of Scala. Chris Shorrock wrote a compact, pure Scala client library for Cassandra called Cascal. You can download a precompiled binary from [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=theikester.wordpress.com&amp;blog=8816305&amp;post=43&amp;subd=theikester&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I <a title="Access Cassandra From Scala - Hector" href="http://theikester.wordpress.com/2010/04/07/access-cassandra-from-scala-hector/">recently wrote</a> about my experience using <a title="Hector" href="http://github.com/rantav/hector">Hector</a> (a Java-Cassandra client library) from Scala. Although I found it to be workable, I was looking for something even simpler and more in the spirit of Scala.</p>
<p>Chris Shorrock wrote a compact, pure Scala client library for Cassandra called <a title="Cascal" href="http://github.com/shorrockin/cascal">Cascal</a>. You can download a <a title="Cascal Binaries" href="http://github.com/shorrockin/cascal/downloads">precompiled binary</a> from GitHub but I chose to build the latest version myself. If you have <a title="Git Home" href="http://git-scm.com/">Git</a> and <a title="Maven Home" href="http://maven.apache.org/">Maven</a> already set up on your system you can just do:</p>
<pre class="brush: scala; light: true; wrap-lines: false;">
$ git clone git://github.com/shorrockin/cascal.git
...
$ cd cascal
$ mvn package
</pre>
<p>After Maven is done building you&#8217;ll have a <code>target</code> directory. Add the main jar file (I got cascal-1.2-SNAPSHOT.jar) to the Build Path in Eclipse and make sure you have other Cassandra dependencies configured (thrift, commons-pool, slf4j, log4j, etc.) I then wrote a simple test object to perform the same functions as before and I think the resulting data access code is very clean and readable:</p>
<pre class="brush: scala; wrap-lines: false;">
import com.shorrockin.cascal.utils.Conversions._
import com.shorrockin.cascal.session._

object CassandraCascalTester {
  def main(args : Array[String]) : Unit = {
    // Set up session pool
    val hosts  = Host(&quot;localhost&quot;, 9160, 250) :: Nil
    val params = new PoolParams(10, ExhaustionPolicy.Fail, 500L, 6, 2)
    val pool   = new SessionPool(hosts, params, Consistency.One)

    pool.borrow { session =&gt;

      // Define column path
      val colPath = &quot;Keyspace1&quot; \ &quot;Standard1&quot; \ &quot;key&quot; \ &quot;column-name&quot;

      // insert
      session.insert(colPath \ &quot;value&quot;)

      // read
      val col = session.get(colPath)
      System.out.println(&quot;Stored value: &quot; + string(col.get.value))
    }
  }
}
</pre>
<p>As you can see, we don&#8217;t need to explicitly handle a try/catch block and Scala&#8217;s implicit type conversions take care of transforming strings to byte arrays and the directory-like column path syntax, all in a type-safe manner enforced by the compiler. For example, <code>colPath</code> will automatically become</p>
<pre class="brush: scala; light: true;">
Keyspace(value = Keyspace1) \ StandardColumnFamily(value = Standard1) \ StandardKey(value = key) \ Column(name = [B@6910fe28, value = null, time = 1272046381878)
</pre>
<p>and <code>col</code> will become</p>
<pre class="brush: scala; light: true;">
Some(Keyspace(value = Keyspace1) \ StandardColumnFamily(value = Standard1) \ StandardKey(value = key) \ Column(name = [B@30ec4a87, value = [B@6910fe28, time = 1272041137177))
</pre>
<p>Note that we do need to explicitly convert the retrieved value to a String because the basic <code>get</code> has no way of knowing what is stored in there. But Cascal has a solution for that too. Starting with version 1.1 Cascal includes a simple object mapping framework that can do the heavy lifting of populating objects from <code>get</code> and <code>list</code> results. I&#8217;ll explore this capability and its constraints in a future post.</p>
<br />Filed under: <a href='http://theikester.wordpress.com/category/software-development/'>Software Development</a> Tagged: <a href='http://theikester.wordpress.com/tag/cassandra/'>cassandra</a>, <a href='http://theikester.wordpress.com/tag/java/'>java</a>, <a href='http://theikester.wordpress.com/tag/nosql/'>nosql</a>, <a href='http://theikester.wordpress.com/tag/scala/'>scala</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/theikester.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/theikester.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/theikester.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/theikester.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/theikester.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/theikester.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/theikester.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/theikester.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/theikester.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/theikester.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/theikester.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/theikester.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/theikester.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/theikester.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=theikester.wordpress.com&amp;blog=8816305&amp;post=43&amp;subd=theikester&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://theikester.wordpress.com/2010/04/23/access-cassandra-from-scala-cascal/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/34366beb64ceb0c4a375d479af60d5c2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">theikester</media:title>
		</media:content>
	</item>
		<item>
		<title>Access Cassandra From Scala &#8211; Hector</title>
		<link>http://theikester.wordpress.com/2010/04/07/access-cassandra-from-scala-hector/</link>
		<comments>http://theikester.wordpress.com/2010/04/07/access-cassandra-from-scala-hector/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 05:37:04 +0000</pubDate>
		<dc:creator>theikester</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[cassandra]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[nosql]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://theikester.wordpress.com/?p=3</guid>
		<description><![CDATA[I was looking for a convenient way to access Cassandra from Scala for a new version of our app that is currently in development. After a long and tedious afternoon I finally got something working that feels solid, so I thought I&#8217;d share my experience here. The first time I checked the Client Options wiki page there were [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=theikester.wordpress.com&amp;blog=8816305&amp;post=3&amp;subd=theikester&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was looking for a convenient way to access <a title="Cassandra" href="http://cassandra.apache.org/">Cassandra</a> from <a title="Scala" href="http://www.scala-lang.org/">Scala</a> for a new version of our app that is currently in development. After a long and tedious afternoon I finally got something working that feels solid, so I thought I&#8217;d share my experience here.</p>
<p>The first time I checked the <a title="Cassandra Client Options" href="http://wiki.apache.org/cassandra/ClientOptions">Client Options</a> wiki page there were a couple of projects listed for the Scala language. I wasn&#8217;t convinced by any of the alternatives I looked at. Given that Cassandra is such a fast-moving target, I felt that the client library needs to have at least one committed developer (and some community momentum) behind it.</p>
<p>I took a quick look at <a title="Scromium" href="http://github.com/cliffmoon/scromium">scromium</a> but I wasn&#8217;t convinced with the choice of different token separators. I then looked more deeply into <a title="Scalandra" href="http://github.com/nodeta/scalandra">scalandra</a> but just couldn&#8217;t make it work with Cassandra 0.6-rc1. I was initially interested in the Akka option since I was already looking at Akka for it’s distributed actors but I was disappointed by its current implementation.</p>
<p>You can use Akka to access Cassandra via the Pluggable Persistence module. According to the <a title="Akka Documentation" href="http://doc.akkasource.org/persistence">documentation</a> you can bypass the Akka STM and use it as a library; they call it the Cassandra Session API. After a lot of tinkering, building Thrift on MacOS X, installing MacPorts to get the missing pieces, etc. I still couldn’t get a simple test to run against Cassandra 0.6-rc1. I later noticed that even Akka developers were <a title="Akka switch to Hector" href="http://groups.google.com/group/akka-user/browse_thread/thread/4055344e4924574e/d6cee0a2f5bf7637?lnk=gst&amp;q=cassandra#">considering a shift</a> to <a title="Hector - Cassandra Java Client" href="http://github.com/rantav/hector">Hector</a>, a Java-based library. Given this endorsement I decided to try it myself.</p>
<p>Hector is a thin wrapper over the Cassandra Thrift API. It basically makes it a bit more object-oriented and easy to use from Java.</p>
<p>It turns out that talking to Cassandra from Scala using Hector is very simple, albeit not very Scala-ish. I set up a basic Scala project in Eclipse and added the Hector libraries to the classpath. Then I modified <a title="ExampleClient.java" href="http://github.com/rantav/hector/blob/master/src/main/java/me/prettyprint/cassandra/service/ExampleClient.java">ExampleClient.java</a> and with Cassandra running on the default port it worked like a charm:</p>
<pre class="brush: scala; wrap-lines: false;">
import me.prettyprint.cassandra.service.CassandraClientPoolFactory
import me.prettyprint.cassandra.utils.StringUtils._

import org.apache.cassandra.thrift.{Column, ColumnPath}

object CassandraScalaHectorTest {
  def main(args : Array[String]) : Unit = {
    val pool = CassandraClientPoolFactory.INSTANCE.get()
    // var client = pool.borrowClient(Array(&quot;cas1:9160&quot;, &quot;cas2:9160&quot;)
    var client = pool.borrowClient(Array(&quot;localhost:9160&quot;))

    try {
      val keyspace = client.getKeyspace(&quot;Keyspace1&quot;)
      val columnPath = new ColumnPath(&quot;Standard1&quot;).setColumn(bytes(&quot;column-name&quot;))

      // insert
      keyspace.insert(&quot;key&quot;, columnPath, bytes(&quot;value&quot;))

      // read
      val col = keyspace.getColumn(&quot;key&quot;, columnPath)
      System.out.println(&quot;Stored value: &quot; + string(col.getValue()))

      // This line makes sure that even if the client had
      // failures and recovered, a correct
      // releaseClient is called, on the up to date client.
      client = keyspace.getClient()

    } finally {
      // return client to pool. do it in a finally block to
      // make sure it's executed
      pool.releaseClient(client)
    }
  }
}
</pre>
<p>As you can see this was only slightly modified so it compiles in Scala. It&#8217;s a little cleaner and less verbose than the Java version, mostly because of Scala&#8217;s type inference, which reduces the need to declare all types.</p>
<p>One of the things I don&#8217;t like is the explicit conversions to and from byte arrays. This is exactly the kind of boilerplate that can be done for you by using Scala&#8217;s implicit conversions and, overall, it&#8217;s just not very idiomatic Scala. Although I&#8217;m not a purist and I could live with this solution, I would prefer a cleaner approach. I still haven&#8217;t ruled out the possibility of wrapping Hector in Scala and providing a couple of conversions to make it work as expected.</p>
<p>Since I started working on this test the Cassandra Client Options wiki page was updated with a new Scala library called <a title="Cascal" href="http://github.com/shorrockin/cascal">cascal</a>. I haven&#8217;t had a chance to try it yet but it looks promising so I will evaluate that next.</p>
<p>Perhaps there&#8217;s a silver bullet I haven&#8217;t even heard off yet. I&#8217;m curious to know how many people are fronting Cassandra with a Scala app.</p>
<br />Filed under: <a href='http://theikester.wordpress.com/category/software-development/'>Software Development</a> Tagged: <a href='http://theikester.wordpress.com/tag/cassandra/'>cassandra</a>, <a href='http://theikester.wordpress.com/tag/java/'>java</a>, <a href='http://theikester.wordpress.com/tag/nosql/'>nosql</a>, <a href='http://theikester.wordpress.com/tag/scala/'>scala</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/theikester.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/theikester.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/theikester.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/theikester.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/theikester.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/theikester.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/theikester.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/theikester.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/theikester.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/theikester.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/theikester.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/theikester.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/theikester.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/theikester.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=theikester.wordpress.com&amp;blog=8816305&amp;post=3&amp;subd=theikester&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://theikester.wordpress.com/2010/04/07/access-cassandra-from-scala-hector/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/34366beb64ceb0c4a375d479af60d5c2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">theikester</media:title>
		</media:content>
	</item>
	</channel>
</rss>
