<?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>owenkellett.com &#187; Project Darkstar</title>
	<atom:link href="http://owenkellett.com/category/project-darkstar/feed/" rel="self" type="application/rss+xml" />
	<link>http://owenkellett.com</link>
	<description></description>
	<lastBuildDate>Sun, 13 May 2012 15:22:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>RedDwarf</title>
		<link>http://owenkellett.com/2010/02/04/reddwarf/</link>
		<comments>http://owenkellett.com/2010/02/04/reddwarf/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 16:55:34 +0000</pubDate>
		<dc:creator>Owen</dc:creator>
				<category><![CDATA[Project Darkstar]]></category>
		<category><![CDATA[RedDwarf]]></category>

		<guid isPermaLink="false">http://owenkellett.com/?p=584</guid>
		<description><![CDATA[As I mentioned previously, I do intend to continue working on Project Darkstar part-time at least while I search for new employment opportunities. Not only will it allow me and whoever else is interested push along the original goals of the project, but it will also give me a perfect place to keep my skills [...]]]></description>
			<content:encoded><![CDATA[<p>As I mentioned previously, I do intend to continue working on <a href="http://www.projectdarkstar.com">Project Darkstar</a> part-time at least while I search for new employment opportunities.  Not only will it allow me and whoever else is interested push along the original goals of the project, but it will also give me a perfect place to keep my skills sharp while I&#8217;m out of work.  Selfless and selfish reasons, molded into one.  However, it does not seem appropriate to continue working using what are now Oracle&#8217;s resources and contributing code to Oracle&#8217;s official repository.  Not only are there questions about outside contributions, but there are also no guarantees about how long Oracle&#8217;s official repository will remain active.  So I am going with an equally reasonable and open-source-y alternative.</p>
<p>I have established what I hope will become an official community fork of Project Darkstar.  This fork will go by the name <a href="http://reddwarf.sourceforge.net">RedDwarf</a> and is hosted as a <a href="https://sourceforge.net/projects/reddwarf/">sourceforge project</a>.  I cannot take credit for the new name, as it was dreamt up by the original instigator of Project Darkstar at Sun Labs (Jeff Kesselman), but I do hope that it will become an even more well known name than Project Darkstar ever was in the games industry.  So without further adieu, here are the new community guidelines:</p>
<ul>
<li>The sourceforge project is used to host what were once three separate projects on java.net.  The reddwarf-server, reddwarf-shared, and reddwarf-java-client all live in the same subversion repository, but under completely separate sub-trees, each with their own trunk, branches, and tags.</li>
<li>The development process should remain largely unchanged from Project Darkstar.  All commits to any trunk repository must undergo a thorough review by at least one other committer, and commit privileges are earned.  Review requests should be sent to the mailing list: reddwarf-develop on sourceforge.</li>
<li>All design, support, and informational documents should go in the <a href="https://sourceforge.net/apps/trac/reddwarf/">Trac instance</a> hosted at sourceforge.</li>
<li>All issues and bugs should be filed as a ticket in Trac.</li>
<li><a href="https://sourceforge.net/projects/reddwarf/forums">Forum discussions</a> should continue as usual on the sourceforge hosted forums.</li>
<li>Releases will be done periodically as appropriate.  All releases will be published to the central Maven repository rather than the java.net Maven repositories.  (This is <a href="https://sourceforge.net/apps/trac/reddwarf/ticket/2">my first task</a> and may take some time).  They will also be published as files for download on the sourceforge site.</li>
</ul>
<p>Progress will be much slower than before, but I think it&#8217;s very important to maintain the structure and code quality standards that we had established as a fully funded project.  Will anything come of this effort?  I&#8217;m not sure.  But I think it&#8217;s the best chance for coordinated progress to continue with Project Darkstar.</p>
]]></content:encoded>
			<wfw:commentRss>http://owenkellett.com/2010/02/04/reddwarf/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Shocking News</title>
		<link>http://owenkellett.com/2010/02/03/shocking-news/</link>
		<comments>http://owenkellett.com/2010/02/03/shocking-news/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 15:28:29 +0000</pubDate>
		<dc:creator>Owen</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Project Darkstar]]></category>

		<guid isPermaLink="false">http://owenkellett.com/?p=580</guid>
		<description><![CDATA[It&#8217;s been a while since I posted anything on this blog, and I wish my return was the result of better circumstances but no such luck: my position at Sun Microsystems has been eliminated, and as a result I have been let go. It is ironic that the European Union&#8217;s lengthy delay in approving the [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since I posted anything on this blog, and I wish my return was the result of better circumstances but no such luck: my position at Sun Microsystems has been eliminated, and as a result I have been let go.  It is ironic that the European Union&#8217;s lengthy delay in approving the Oracle-Sun acquisition gave the <a href="http://www.projectdarkstar.com">Project Darkstar</a> team and community such a long, uninterrupted stretch of time to make some unbelievable progress towards our goals.  However, once the deal did finally close, the decision had already been made that Oracle will discontinue investing resources in the project, and so here I am: newly unemployed.</p>
<p>I must say that the shock and disbelief of learning that you&#8217;ve been laid off is a predictably emotional time.  Of course I didn&#8217;t think it would happen to me, but it did: proof that job security is all but an illusion.  They say losing your job is like dealing with any other type of loss, which is absolutely true.  Knowing this doesn&#8217;t make it any easier though.  Despite this difficult situation, however, I have received nothing but support from my family, friends, colleagues and even people who were previously just casual acquaintances.  Thank you to everyone who has been there so far; I know for a fact I&#8217;ll come out the other side of this a strong person.</p>
<p>As for my future, and the future of Project Darkstar?  Well both are uncertain.  I have already started ramping up and preparing for a full scale job search in the hope that I will find something even better than the best job I&#8217;ve ever had.  In terms of Project Darkstar, a core group of former members of the team have already started exploring alternative ways to keep the project going.  This includes both potential for-profit and volunteer efforts to carry out the original mission objectives laid out years ago.  At the very least, after getting myself organized, I personally intend to continue working on the project on a part-time basis during my job search and hopefully beyond.  More details to come&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://owenkellett.com/2010/02/03/shocking-news/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Rule 1 of Programming: It&#8217;s Always Your Fault (Almost)</title>
		<link>http://owenkellett.com/2009/11/12/rule-1-of-programming-its-always-your-fault-almost/</link>
		<comments>http://owenkellett.com/2009/11/12/rule-1-of-programming-its-always-your-fault-almost/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 16:21:25 +0000</pubDate>
		<dc:creator>Owen</dc:creator>
				<category><![CDATA[Project Darkstar]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://owenkellett.com/?p=551</guid>
		<description><![CDATA[Over the past week or so, I&#8217;ve been working on putting together some micro benchmarks for Project Darkstar. There has been a significant uptick in forum activity lately relating to stress testing and performance issues. In particular, we&#8217;ve seen many questions along the lines: &#8220;I can only connect X users to my darkstar server, what&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Over the past week or so, I&#8217;ve been working on putting together some micro benchmarks for <a href="http://www.projectdarkstar.com">Project Darkstar</a>.  There has been a significant uptick in <a href="http://www.projectdarkstar.com/forum/">forum activity</a> lately relating to stress testing and performance issues.  In particular, we&#8217;ve seen many questions along the lines: &#8220;I can only connect X users to my darkstar server, what&#8217;s wrong?&#8221;  First of all, this is great news.  It means that people are making significant progress with their darkstar based games/applications and are working to push the limits of the technology.  However, I also think that this is the completely wrong question to ask.  As <a href="http://owenkellett.com/2009/05/12/capacity-testing/">I&#8217;ve demonstrated before</a>, Project Darkstar has a pretty high ceiling for raw capacity in terms of number of users.  A properly tuned app with a light load can easily handle tens of thousands of users per node.  However, connecting mostly idle users to a mostly idle server is not very interesting.  These capacity numbers naturally decrease as the number of messages between the clients and server and the amount of processing per message increases.  This seems obvious, but people still ask the capacity question as though all games developed with darkstar are going to have identical limitations.  This is simply not the case.</p>
<p>With this said, though, we can still strive to identify upper bounds on Project Darkstar&#8217;s performance at a more fine-grained level.  Project Darkstar is an event driven transactional system, so all operations are not without cost.  With these micro benchmarks, I&#8217;m hoping that I can establish a relative cost to each of the operations using the DataManager, the ChannelManager, and the TaskManager.  For example, how expensive is it to retrieve an object using DataManager.getBinding() vs ManagedReference.get().  How much overhead is involved with each transaction?  How expensive is it to create a Channel or send a message on a Channel?  With more or less users?  While the cost of retrieving data from Darkstar&#8217;s data store should be an order of magnitude faster than using J2EE and a RDBMS, it is also likely an order of magnitude <em>slower</em> than retrieving data from a data structure that is already in memory and using no synchronization.  This is information that users really need to be aware of and be able to take into perspective when designing their game, structuring their tasks, and establishing their own expectations of what the performance should be like.</p>
<p>So over the past couple of days, I&#8217;ve been debugging a problem in these benchmarks.  In one particular test, I was attempting to measure the raw execution time per call to DataManager.getBinding() from the Project Darkstar API.  The test was pretty simple, I just set a large number of bindings in a single set of setup transactions.  Then I would time the execution of another set of transactions that would make some subset of calls to getBinding() on the names that I had just setup.  Taking into account previously measured transaction overhead I could then come up with a reasonable estimate of the cost per operation.  Seems easy right?  Well it turns out that I hit a snag.  In running this test, I was repeatedly getting a situation where a seemingly random name binding was not being set properly during setup.  Most of the calls to getBinding() would work fine, but a couple were throwing NameNotBoundException.  What?  This didn&#8217;t make much sense.  I went back and looked over my code many times, I tried a myriad of variations, logging output, and print lines, but still no luck.  I was still getting NameNotBoundException for what seemed like a random name in the sequence.  Hmmph.</p>
<p>At this point, I went through a whole series of exercises, all centered around one assumption, that my code was right.  I tested the native edition vs. the Java edition of BDB, suspecting maybe there was a weird bug in one of them: same result.  I tried longer transactions, more operations, larger serialized data objects: same result.  I tried running my benchmarks in different orders: same result.  I even started writing test cases for DataManager.setBinding() that simulated transaction rollback and retry, large numbers of consecutive calls to setBinding() and binding and rebinding of the same name.  I thought I was going to uncover some weird corner case bug.  But those tests were passing!  I was at a loss.  After probably two days of sporadic attempts at debugging this, I finally went back and looked really hard at my own test code.  And&#8230; I found a bug (doh!).  It turns out that I was being too cute with my setup transactions, and was modifying a non-local counter variable inside of my anonymous nested transaction class.  In random situations, this class would abort and retry (a normal darkstar operation), but since it was modifying a variable that lived outside of the task itself, this value was not being rolled back.  The result was that a name binding would be skipped periodically (exactly the behavior that I was seeing).</p>
<p>So here&#8217;s my question.  Why did I assume that code that I wrote in less than a day was more likely to be correct than Berkeley DB itself, a project that&#8217;s been developed and tested for a couple of decades?  Why did I assume that code that I wrote in less than a day was more likely to be correct than Project Darkstar&#8217;s Data Service code which has been developed and tested for years?  I mean, I knew better than to think that Tim&#8217;s code is the likely culprit, but I still started writing test cases thinking I was going to heroically find some obscure bug.  This, my friends, is a violation of the number 1 rule of programming: If you&#8217;re having problems, It&#8217;s Always Your Fault (almost).  I mean, don&#8217;t get me wrong, I&#8217;ve found (and reported) bugs in well established open source projects before, but those situations are actually few and far between.  I also don&#8217;t mean to suggest that Project Darkstar is bug free.  I do think, though, that sometimes it&#8217;s too tempting to conclude that there&#8217;s a bug in that library you&#8217;re using, or there&#8217;s a performance limitation in that technology that is fundamentally impossible to overcome.  Maybe that&#8217;s true, but 99% of the time, it&#8217;s your fault.</p>
<p>And with regard to those micro benchmarks, I&#8217;m hoping to publish some results soon (assuming I don&#8217;t get hung up with any more boneheaded mistakes!)</p>
]]></content:encoded>
			<wfw:commentRss>http://owenkellett.com/2009/11/12/rule-1-of-programming-its-always-your-fault-almost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Austin GDC 2009</title>
		<link>http://owenkellett.com/2009/09/25/austin-gdc-2009/</link>
		<comments>http://owenkellett.com/2009/09/25/austin-gdc-2009/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 19:49:55 +0000</pubDate>
		<dc:creator>Owen</dc:creator>
				<category><![CDATA[Project Darkstar]]></category>

		<guid isPermaLink="false">http://owenkellett.com/?p=482</guid>
		<description><![CDATA[Last week, a number of us from the Project Darkstar team were in Austin for the Austin Game Developer&#8217;s Conference. Like last year, we had a large booth on the expo floor. However, while last year we were largely focused on demonstrating Project Darkstar&#8217;s capabilities to scale and distribute load across multiple cores and processors [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://owenkellett.com/blog/wp-content/uploads/2009/09/agdc.jpg" alt="agdc" title="agdc" width="233" height="164" class="alignleft size-full wp-image-481" />Last week, a number of us from the <a href="http://www.projectdarkstar.com">Project Darkstar</a> team were in Austin for the <a href="http://www.gdcaustin.com/">Austin Game Developer&#8217;s Conference</a>.  Like last year, we had a large booth on the expo floor.  However, while last year we were largely focused on demonstrating Project Darkstar&#8217;s capabilities to scale and distribute load across multiple cores and processors on a <em>single</em> node, this year our focus was on showcasing the team&#8217;s progress on <em>multi-node</em> capabilities.  Here&#8217;s a recap of the week&#8217;s events:</p>
<p>If you&#8217;ve been following along with Project Darkstar&#8217;s progress over the years, you know that transparent multi-node scaling capabilities are one of its main attractions as a platform.  On the other hand, you should also know that with Project Darkstar being a still maturing research project in <a href="http://research.sun.com/">Sun Labs</a>, these features are not yet done.  In fact, we have still not proven if what we are attempting can even <em>be</em> done.  Our fearless lead architect, <a href="http://research.sun.com/people/mybio.php?c=444">Jim Waldo</a>, has put together an excellent series of posts on <a href="http://blogs.sun.com/scalinggames/">his blog</a> outlining why and how we hope to achieve this multi-node scaling.  He calls it the &#8220;Four Miracles.&#8221;</p>
<p>Our goal for Austin was to put together some measure of a compelling visual demonstration of our current progress towards achieving these &#8220;Four Miracles.&#8221;  Specifically, we hoped to show how <a href="http://blogs.sun.com/scalinggames/entry/miracle_4">Ann&#8217;s miracle</a> of transparently moving clients from one node to another in a cluster worked in tandem with <a href="http://blogs.sun.com/scalinggames/entry/miracle_3">Keith&#8217;s miracle</a> of monitoring a node&#8217;s health and intelligently making decisions about which clients to relocate and when.  Also, while <a href="http://blogs.sun.com/scalinggames/entry/miracle_2">Jane&#8217;s miracle</a> of detecting and organizing clients into groups of affinity groups based on social networking algorithms is not complete, we also hoped to portray how it should work by rigging up an app that formed affinity groups based on a players location in the game (specifically which chat room it was in).</p>
<p>In the weeks leading up to the conference, Keith and I came up with two demos that for the most part seemed to hit the mark.  Using the JMX facilities already built into Darkstar, I hacked up a monitoring GUI that tapped into a running Darkstar cluster and displayed each of the nodes as a vertical bar.  The height of the bar represented the total number of clients connected to that node, and the color optionally represented either the node health, or fragments of colors represented the affinity group of each connected client.  For the first demo, we had <a href="https://project-snowman.dev.java.net">Project Snowman</a> running in a multi-node cluster and showed how the new node health monitoring features of darkstar caused client traffic to spill over and be intelligently distributed between the nodes.  Here&#8217;s a quick video of Keith talking through it on expo floor in Austin:</p>
<div align="center"><object width="533" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=6644938&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=6644938&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="533" height="300"></embed></object>
<p><a href="http://vimeo.com/6644938">Project Darkstar Node Health Demo</a> from <a href="http://vimeo.com/darkstar">Project Darkstar</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
</div>
<p>The second demo had <a href="http://project-darkchat.dev.java.net">Darkchat</a> running on a multi-node cluster and was designed to show how clients would relocate between nodes depending on which rooms they were connected to in the application.  Here&#8217;s another quick video given by yours truly on the floor at Austin:</p>
<div align="center"><object width="533" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=6661259&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=6661259&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="533" height="300"></embed></object>
<p><a href="http://vimeo.com/6661259">Project Darkstar Affinity Grouping Demo</a> from <a href="http://vimeo.com/darkstar">Project Darkstar</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
</div>
<p>Both of these demos we had running throughout the week on the floor and the response from people who came by was generally positive.  I think one of the main differences that I noticed between this year and last year was the amount of <em>quality</em> traffic that we had come through the booth.  I talked to a lot of people at Austin last year, but a large percentage of them had never heard of Project Darkstar or were just vaguely familiar with it.  This year many people came by who were already committed to a project using Darkstar, or were very interested in our progress, or were familiar with the technology and had a strong desire to learn more.  I think the best piece of anecdotal evidence was one person from the Intel booth who came by and said &#8220;Oh, so this is for real now?&#8221;  Referring, of course, to the significant headway that we are finally making and showing on the multi-node scaling capabilities of the Project Darkstar platform.</p>
<p>In a tough year for everyone in just about every industry, I think going to this conference and putting together these demos have injected some energy into both the Project Darkstar community and the team.  A few more personal observations:</p>
<ul>
<li>
The expo floor seemed smaller this year and overall attendance appeared to be down.  Not too surprising but hopefully a sign of things past and not things to come.</p>
</li>
<li>
A little tidbit on some of the pains of getting the demos setup.  Leading up to the conference, we had everything running just fine in Burlington and the demos packaged up and ready to go.  After a few hours of pulling cables, moving pods around, and booting up systems, we fired up the node health demo on Tuesday, the day before the expo floor opened.  Except, it didn&#8217;t work.  At least not like it did in Burlington.  When simulating an overloaded node, instead of offloading clients onto the other node right away, there was some seemingly random and arbitrary delay of 20 &#8211; 30 seconds before any clients would be moved.  Huh?</p>
<p>After some hours of debugging, and pulling Seth into the mix for help, we finally tracked it down.  The (still unfinished) node health code offloads identities from a node when it gets overloaded.  However, it doesn&#8217;t just move client identities, it also moves identities of robots and other NPC&#8217;s in the system.  Since each snowman game has a number of robots, it was choosing to move the robot identities before moving the client identities.  The question, of course, is why didn&#8217;t we ever see this behavior in Burlington?  Well it turns out that the order in which identities are chosen to be moved is deterministic and seemingly alphabetical.  While in Burlington, our client simulated players were generating identity names according to the hostname of the client machine (dstar1, dstar2, dstarX, &#8230;).  The hostnames of the machines used in Austin? x2250-1, x2250-2, etc.  So in our Burlington deployment, the client identities were always getting chosen <em>before</em> the robot identities since they started with a <em>d</em>; in our Austin deployment, the client identities were always getting chosen <em>after</em> the robot identities since they started with an <em>x</em>.  Unbelievable.
</li>
<li>
Keith gave a talk during a one hour session which was awesome.  He went through a number of obstacles and challenges he faced when building Darkchat for JavaOne and I think it came across as very real and genuine.</p>
</li>
<li>
One final note, it appears as though Chuck Norris <em>still</em> doesn&#8217;t need scalable server technology.  All of his CPU&#8217;s run faster to get away from him.  Also, any code that he writes cannot be optimized.  For anyone else, though, Project Darkstar could be a solution.</p>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://owenkellett.com/2009/09/25/austin-gdc-2009/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JavaOne Podcast</title>
		<link>http://owenkellett.com/2009/07/07/javaone-podcast/</link>
		<comments>http://owenkellett.com/2009/07/07/javaone-podcast/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 13:31:55 +0000</pubDate>
		<dc:creator>Owen</dc:creator>
				<category><![CDATA[Project Darkstar]]></category>

		<guid isPermaLink="false">http://owenkellett.com/?p=466</guid>
		<description><![CDATA[About a month ago I spent a week in San Francisco for JavaOne 2009. One of the activities that I participated in there was the java.net Community Corner where I recorded a podcast on Project Darkstar. Well, the podcast is now up on the java.net site for download and it turned out really nice! It&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://owenkellett.com/blog/wp-content/uploads/2009/07/communitycorner.jpg" alt="communitycorner" title="communitycorner" width="111" height="91" class="alignleft size-full wp-image-467" />About a month ago I spent a week in San Francisco for <a href="http://java.sun.com/javaone">JavaOne 2009</a>.  One of the activities that I participated in there was the <a href="http://wiki.java.net/bin/view/Javaone/CommunityCorner">java.net Community Corner</a> where I recorded a podcast on <a href="http://www.projectdarkstar.com">Project Darkstar</a>.  Well, the podcast is now up on the java.net site for download and it turned out really nice!  It&#8217;s available for download <a href="http://today.java.net/pub/a/today/2009/07/06/J1-2009-ProjectDarkstar.html">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://owenkellett.com/2009/07/07/javaone-podcast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello Project Darkstar! in Netbeans and Eclipse</title>
		<link>http://owenkellett.com/2009/06/10/hello-project-darkstar-in-netbeans-and-eclipse/</link>
		<comments>http://owenkellett.com/2009/06/10/hello-project-darkstar-in-netbeans-and-eclipse/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 14:40:24 +0000</pubDate>
		<dc:creator>Owen</dc:creator>
				<category><![CDATA[Project Darkstar]]></category>

		<guid isPermaLink="false">http://owenkellett.com/?p=435</guid>
		<description><![CDATA[With Project Darkstar&#8216;s new distribution structure (introduced in version 0.9.8 and explained here), people ask from time to time what the best way is to setup a project in Netbeans or Eclipse. I think the typical answer that you see the most fits the acronym &#8220;TMTOWTDI&#8221; (There&#8217;s More Than One Way To Do It). This [...]]]></description>
			<content:encoded><![CDATA[<p>With <a href="http://www.projectdarkstar.com">Project Darkstar</a>&#8216;s new distribution structure (introduced in version 0.9.8 and <a href="http://owenkellett.com/2009/01/06/project-darkstar-098/">explained here</a>), people ask from time to time what the best way is to setup a project in Netbeans or Eclipse.  I think the typical answer that you see the most fits the acronym &#8220;TMTOWTDI&#8221; (There&#8217;s More Than One Way To Do It).  This is true but not necessarily very helpful.  In the hopes of eliminating some pain I&#8217;m here to offer <strong><em>a way</em></strong> to setup a project in these IDE&#8217;s (but this should by no means be considered <strong><em>the way</em></strong>).</p>
<p>First, here is a quick description of the project and the tools that I will be using:</p>
<ul>
<li>This will be a purely server side project that will print &#8220;Hello Project Darkstar!&#8221; when the server is booted.</li>
<li>I will be using <a href="http://maven.apache.org">Maven</a> as the build tool for the project.</li>
<li>The project will leverage the <a href="https://sgs-maven-plugin.dev.java.net">Project Darkstar Maven Plugin</a> to aid in deploying, booting, and shutting down the server according to the new distribution format for the official Project Darkstar server package.</li>
<li>It should be possible to build, run, and test the raw project outside of an IDE, within Netbeans, and also within Eclipse (with a few tweaks for each respective IDE).</li>
</ul>
<p>There are three source files that are of interest in this project.  The first is the actual Java source file that represents the main class for the server.  This class should look something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">my.pkg.hello</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.Serializable</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Properties</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.logging.Level</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.logging.Logger</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.sun.sgs.app.AppListener</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.sun.sgs.app.ClientSession</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.sun.sgs.app.ClientSessionListener</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HelloProjectDarkstar <span style="color: #000000; font-weight: bold;">implements</span> AppListener, <span style="color: #003399;">Serializable</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">long</span> serialVersionUID <span style="color: #339933;">=</span> 1L<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> Logger logger <span style="color: #339933;">=</span> 
      Logger.<span style="color: #006633;">getLogger</span><span style="color: #009900;">&#40;</span>HelloProjectDarkstar.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> initialize<span style="color: #009900;">&#40;</span><span style="color: #003399;">Properties</span> props<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    logger.<span style="color: #006633;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Hello Project Darkstar!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> ClientSessionListener loggedIn<span style="color: #009900;">&#40;</span>ClientSession session<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;">null</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Second, it is strongly recommended for a Project Darkstar application that you include an <em>app.properties</em> file in the <em>META-INF</em> directory of your resulting JAR file.  This file will be used as the base set of configuration properties for the server and is a good place to include default values for application specific configuration properties.  In our simple example, we&#8217;ll include just two required properties, the name of the server and the listener class:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">com.sun.sgs.app.name=HelloProjectDarkstar
com.sun.sgs.app.listener=my.pkg.hello.HelloProjectDarkstar</pre></div></div>

<p>Third, you need a Maven POM file.  If you&#8217;re unaware of how Maven works, you can read up on it at the <a href="http://maven.apache.org">Maven website</a>.  Essentially, the POM file is used to declaratively describe your project&#8217;s resources and dependencies.  Maven then uses this information to correctly build it.  Our project has only one dependency (the sgs-server-api) so our POM file should look something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://maven.apache.org/POM/4.0.0&quot;</span></span>
<span style="color: #009900;">  <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">  <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://maven.apache.org/POM/4.0.0</span>
<span style="color: #009900;">                      http://maven.apache.org/maven-v4_0_0.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;modelVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>4.0.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/modelVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>my.package.hello<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>hello-projectdarkstar<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0.1-SNAPSHOT<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Hello Project Darkstar<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;packaging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jar<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/packaging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.projectdarkstar.server<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>sgs-server-api<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${sgs-server.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #808080; font-style: italic;">&lt;!-- Use 1.6 for source and target during compile --&gt;</span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-compiler-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.6<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.6<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sgs-server.version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0.9.9<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sgs-server.version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;repositories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;repository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>java.net<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>java.net Maven2 Repository<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://download.java.net/maven/2/<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;layout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>default<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/layout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/repository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/repositories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>These three files should be organized in a directory structure that looks something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">- hello-projectdarkstar
  - pom.xml
  - src
    - main
      - java
        - my
          - pkg
            - hello
              - HelloProjectDarkstar.java
    - resources
      - META-INF
        - app.properties</pre></div></div>

<p>At this point you should be able to build a JAR file that is deployable in a Project Darkstar server.  Since this is a Maven project, this should be possible:</p>
<ul>
<li>From outside an IDE using the command <code>mvn package</code></li>
<li>From within Netbeans (ensure that you have the Maven plugin installed, then try &#8220;Open Project&#8221; and Netbeans should automatically detect that the root folder is a Maven project)</li>
<li>Or from within Eclipse (ensure that you have the <a href="http://m2eclipse.codehaus.org/">Maven plugin</a> installed, then choose &#8220;Import&#8221; from the File menu and import as a &#8220;Maven project&#8221;).</li>
</ul>
<p>This is all a good first step, but in order to boot up our server, we still need to manually take the JAR file that is built by Maven, deploy it into a Project Darkstar server, and then fire up the server.  This is tedious, and we&#8217;d rather be able to do this using one command (or one click from the IDE).  Enter the <a href="https://sgs-maven-plugin.dev.java.net">Project Darkstar Maven plugin</a>.  The plugin is pretty well documented on its website, but essentially what it does is automate the process of taking your built JAR file, deploying it into a Project Darkstar container, configuring the container with the appropriate configuration files, and then booting up the server.  It also includes the capability to shutdown a running server.  Using this, therefore, we can automate the process of running our Project Darkstar application by simply adding a configuration entry for this plugin into our POM in a separate Maven profile:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;profiles<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;profile<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>run-server<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.projectdarkstar.maven.plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>sgs-maven-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0-alpha-3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
              <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>sgs-run<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>pre-integration-test<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>install<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>configure<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>deploy<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>boot<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
              <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
              <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${sgs-server.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
              <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sgsHome<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                ${project.build.directory}/sgs-server-dist-${sgs-server.version}
              <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sgsHome<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
              <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sgsBoot<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${basedir}/conf/hello.boot<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sgsBoot<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
              <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sgsServer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${basedir}/conf/hello.properties<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sgsServer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
              <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;files<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${project.artifact.file}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
              <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/files<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/profile<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/profiles<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>This configuration combines the <strong>install</strong>, <strong>configure</strong>, <strong>deploy</strong>, and <strong>boot</strong> goals of the <strong>sgs-maven-plugin</strong> into one.  Also notice that there are two additional configuration files that are included in your source tree under the <em>conf</em> directory, <em>hello.boot</em> and <em>hello.properties</em>.  These files are respectively used to replace the sgs-boot.properties and sgs-server.properties configuration files in the main Project Darkstar distribution.  We can keep these files simple for now, but any set of valid configuration properties can be included:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># hello.boot
# =======
JAVA_OPTS = -server -Xmx768M
&nbsp;
# hello.properties
# =======
com.sun.sgs.app.root=data</pre></div></div>

<p>So we now have a complete project that looks something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">- hello-projectdarkstar
  - conf
    - hello.boot
    - hello.properties
  - pom.xml
  - src
    - main
      - java
        - my
          - pkg
            - hello
              - HelloProjectDarkstar.java
    - resources
      - META-INF
        - app.properties</pre></div></div>

<p>The project can be built inside or outside of Netbeans or Eclipse using the same mechanisms as described above.  However, with this additional configuration, we can also automatically build, deploy, and boot the application in a Project Darkstar container by simply activating the <em>run-server</em> Maven profile.  When this is done, Maven will build the project JAR file, download and install the Project Darkstar distribution into the project&#8217;s <em>target</em> directory, deploy the built JAR file into the Project Darkstar installation, copy the hello.boot and hello.properties configuration files into the Project Darkstar installation conf directory, and then boot up the server using the sgs-boot.jar from the Project Darkstar installation.  This is completely automated and requires doing just the following for each of our respective environments:</p>
<ul>
<li>From <strong>outside any IDE</strong>: just run the command <code>mvn verify -Prun-server</code>.  Shutting down the server requires simply a Ctrl-C.  Also, in order to clean out the Project Darkstar datastore in between executions, it is necessary to run <code>mvn clean</code>.</li>
<li>From <strong>Netbeans</strong>: You should configure the properties of the project by right clicking the project and selecting the &#8220;Properties&#8221; option.  Configure a new Action (or one of the existing actions like the &#8220;Run&#8221; action) to run the <code>verify</code> goal with the <code>run-server</code> profile activated.  Then you should be able to boot up the server by executing that specific action for your project (Right click the project and choose &#8220;Run&#8221; or whatever action you created under the &#8220;Custom&#8221; menu).  In order to shutdown the server, you should also configure an additional action (i.e. Stop) that runs the <code>sgs:stop</code> goal with the <code>run-server</code> profile activated.  Prefer using this action to shutdown the server rather than just killing the process (since multiple JVMs are started when Project Darkstar boots).</li>
<li>From <strong>Eclipse</strong>: Similar to Netbeans, you need to configure two &#8220;Run Configurations&#8221;, one that runs the <code>verify</code> goal with the <code>run-server</code> profile activated, and one that runs the <code>sgs:stop</code> goal with the <code>run-server</code> profile activated.  These two configurations should be respectively used to bootup and shutdown the server.</li>
</ul>
<p>There are a lot more sophisticated ways that you can setup your project with the Project Darkstar Maven plugin that allows you to customize the runtime environment from the command line.  You can also tweak it to support booting multi-node configurations by modifying the boot configuration file, or use filterable properties to customize these values at runtime.  I won&#8217;t get into these here, but I would suggest looking at <a href="http://fisheye4.atlassian.com/browse/project-snowman/trunk/snowman-server/pom.xml?r=709">Project Snowman&#8217;s server POM</a> for some ideas.  Hopefully, though, this post should give you enough to get the ball rolling in setting up your development environment for a Project Darkstar application.</p>
]]></content:encoded>
			<wfw:commentRss>http://owenkellett.com/2009/06/10/hello-project-darkstar-in-netbeans-and-eclipse/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>JavaOne: Signing Off</title>
		<link>http://owenkellett.com/2009/06/05/javaone-signing-off/</link>
		<comments>http://owenkellett.com/2009/06/05/javaone-signing-off/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 22:05:31 +0000</pubDate>
		<dc:creator>Owen</dc:creator>
				<category><![CDATA[JavaOne]]></category>
		<category><![CDATA[Project Darkstar]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://owenkellett.com/?p=428</guid>
		<description><![CDATA[I just went to two more sessions here on the last day at JavaOne and they were actually both quite good. The first was given by William Pugh who is one of the creators of the FindBugs static analysis tool. We use FindBugs extensively in our build process with Project Darkstar and it has proven [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://owenkellett.com/blog/wp-content/uploads/2009/06/javaone.png" alt="javaone" title="javaone" width="150" height="56" class="alignleft size-full wp-image-429" />I just went to two more sessions here on the last day at <a href="http://java.sun.com/javaone">JavaOne</a> and they were actually both quite good.  The first was given by <a href="http://en.wikipedia.org/wiki/William_Pugh">William Pugh</a> who is one of the creators of the <a href="http://findbugs.sourceforge.net/">FindBugs</a> static analysis tool.  We use FindBugs extensively in our build process with Project Darkstar and it has proven to be quite useful.  It was interesting to see that a few of the bug examples given during this session actually had some overlap with Josh Bloch&#8217;s <em>Effective Java</em> talk that I attended earlier in the conference.  In addition to the FindBugs talk I also went to a talk on the ins and outs of the Java Virtual Machine.  I am certainly no JVM expert so this was an interesting talk for me to see some examples of how the JVM does speculative optimization, garbage collection, and some other neat tricks to speed up your code.</p>
<p>I have one more session on my schedule for today but this will likely be my final blog post on this year&#8217;s JavaOne conference.  A few closing thoughts:</p>
<ul>
<li>On the subject of <a href="http://www.projectdarkstar.com">Project Darkstar</a>, I would say it was a generally positive event.  Darkstar is a technology that clearly many have heard of, are interested in, and have a sincere desire to apply it for their own needs.  With DarkChat, the CommunityOne and JavaOne sessions, and the hands-on lab, this conference seemed to do a decent job of generating some additional buzz.</li>
<li>On a more general note, there&#8217;s obviously a bit of uncertainty surrounding the future of Java, JavaOne, and how <a href="http://www.oracle.com">Oracle</a> will handle its future direction.  I think that showed a bit at this conference, as there was no clear air of excitement and energy around anything in particular.  There weren&#8217;t really any groundbreaking announcements, no killer apps, no prototypes that can truly be considered game changers.  I did see many examples of fine engineering and innovation but nothing worthy of eliciting that &#8220;Wow&#8221; factor from a general audience.</li>
<li>Finally, on a personal note, I enjoyed coming to this conference and felt like I was able to connect a little more to the community than at the two GDC conferences I&#8217;ve been to this year.  While Project Darkstar is a technology targeted specifically at games, I wouldn&#8217;t say I consider myself a &#8220;game developer&#8221; at all.  I&#8217;m a Java developer, and more generally a software developer, and while it was a long and exhausting week, I was glad I got the opportunity to be here and expand my horizons a bit.</li>
</ul>
<p>So that&#8217;s it for my week at JavaOne 2009.  I hope you enjoyed following along.  Next week I&#8217;ll be back to my regularly scheduled Ultimate-playing ways.</p>
]]></content:encoded>
			<wfw:commentRss>http://owenkellett.com/2009/06/05/javaone-signing-off/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaOne: Days 3 and 4</title>
		<link>http://owenkellett.com/2009/06/05/javaone-days-3-and-4/</link>
		<comments>http://owenkellett.com/2009/06/05/javaone-days-3-and-4/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 18:19:35 +0000</pubDate>
		<dc:creator>Owen</dc:creator>
				<category><![CDATA[JavaOne]]></category>
		<category><![CDATA[Project Darkstar]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://owenkellett.com/?p=418</guid>
		<description><![CDATA[I&#8217;m here at the final day of the JavaOne conference and things are starting to wind down. The pavilion floor is closed, there are only a few sessions left on the schedule, and people are starting to wrap things up. Karl and Keith actually caught flights home this morning but this being my first JavaOne [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://owenkellett.com/blog/wp-content/uploads/2009/06/javanet_logo.png" alt="javanet_logo" title="javanet_logo" width="168" height="60" class="alignright size-full wp-image-417" />I&#8217;m here at the final day of the <a href="http://java.sun.com/javaone">JavaOne</a> conference and things are starting to wind down.  The pavilion floor is closed, there are only a few sessions left on the schedule, and people are starting to wrap things up.  Karl and Keith actually caught flights home this morning but this being my first JavaOne (and last?), I wanted to stay for the whole thing.  What JavaOne will look like next year is anyone&#8217;s guess.</p>
<p>In any case, yesterday was a light day for me at the conference.  I attended a session which was essentially a survey of a grab-bag of small test tools and gizmos.  An interesting takeaway from that session was that testing Java code is not always best done using Java.  Often times certain necessary and useful features of the language (like private methods and security features) make things difficult to test.  Technologies like <a href="http://groovy.codehaus.org/">Groovy</a> and <a href="http://jruby.codehaus.org/">JRuby</a>, though, contain hooks that allow you to circumvent some of these features for the purposes of testing, without making your test code ugly, brittle, and difficult to maintain.  I think the case that was made was good in the case of some tools, but others just traded one piece of complicated (but recognizable) syntax, to another piece of complicated (and unrecognizable) syntax instead.  There were some things worth investigating though.</p>
<p>After that session, as mentioned I also recorded a quick podcast on <a href="http://www.projectdarkstar.com">Project Darkstar</a> at the <a href="http://wiki.java.net/bin/view/Javaone/CommunityCorner">java.net CommunityCorner</a>.  The podcast was in the form of a conversational type interview with one of the editors at java.net and he told me that he&#8217;ll be posting it and a blog of the event somewhere on <a href="http://www.java.net">java.net</a> within the next couple of weeks.  Stay tuned for that.</p>
<p>I didn&#8217;t do a lot Thursday afternoon.  I wandered the pavilion floor, talked with a few people, and handed out the rest of the hundred or so Project Darkstar pens that I brought with me to the conference.  I then met up with Keith, Karl, and Mike.  Mike and his wife offered their generous hospitality with a low-key, very nice get together at their house in Oakland Hills.</p>
<p>I attended James Gosling&#8217;s general session &#8220;Toy Show&#8221; this morning and there were some neat things showcased.  One of the cool innovations that was demoed was the mashup of a Wii remote, a <a href="http://www.sun.com/software/javafx/">JavaFX</a> application being projected onto a piece of transparent, frosted glass, and a glove with infrared sensors on the finger tips.  The result was a makeshift touch screen that gave a user interface similar to what they compared to as something out of the movie Minority Report.  Pretty slick.  There was also a more sobering presentation on how one company is using Java to do image recognition and analysis to identify images, including sharpening the ability to more quickly, easily, and accurately diagnose and identify cancer from biopsy images.  Other highlights included a Java powered, energy efficient, hybrid Lincoln Continental, and an Audi capable of driving itself.</p>
<p>I&#8217;m getting ready to attend a few more sessions before the conference draws to a close, and I&#8217;ll have some closing thoughts a little later.</p>
]]></content:encoded>
			<wfw:commentRss>http://owenkellett.com/2009/06/05/javaone-days-3-and-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaOne: CommunityCorner</title>
		<link>http://owenkellett.com/2009/06/04/javaone-communitycorner/</link>
		<comments>http://owenkellett.com/2009/06/04/javaone-communitycorner/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 16:00:59 +0000</pubDate>
		<dc:creator>Owen</dc:creator>
				<category><![CDATA[JavaOne]]></category>
		<category><![CDATA[Project Darkstar]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://owenkellett.com/?p=409</guid>
		<description><![CDATA[I&#8217;m writing this post from one of the hundreds of Sun Ray stations scattered throughout the Moscone Center at JavaOne. If you don&#8217;t know what a Sun Ray is, it&#8217;s essentially a stateless thin client that, when I stick my JavaOne badge into, will pull up a virtual desktop associated with my JavaOne id from [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://owenkellett.com/blog/wp-content/uploads/2009/06/sunray.png" alt="sunray" title="sunray" width="250" height="250" class="alignleft size-full wp-image-412" />I&#8217;m writing this post from one of the hundreds of Sun Ray stations scattered throughout the Moscone Center at <a href="http://java.sun.com/javaone">JavaOne</a>.  If you don&#8217;t know what a Sun Ray is, it&#8217;s essentially a stateless thin client that, when I stick my JavaOne badge into, will pull up a virtual desktop associated with my JavaOne id from a centralized server.  In the case of these SunRays, JavaOne attendees have the option of using an <a href="http://www.ubuntu.com">Ubuntu</a>, <a href="http://www.opensolaris.org">OpenSolaris</a>, or <a href="http://www.microsoft.com">Windows Vista</a> desktop.  When I pull out my card, the desktop will be saved in its exact state, and I can pull it back up again from any other Sun Ray at the conference.  In my opinion, Sun Rays are only useful in a limited number of use cases, but a conference like this definitely qualifies as one of those use cases.  Instead of cracking open my laptop and trying to hook into wifi and not drain too much battery, I can just pop into one of these stations to check my email, register for sessions, or write a blog post!</p>
<p>Today at 11:30AM I&#8217;m going to be at the java.net <a href="http://wiki.java.net/bin/view/Javaone/CommunityCorner">CommunityCorner</a> located at booth 101 in the Pavilion.  A few other members of the Project Darkstar team should be joining me as well, and I&#8217;ll be doing a brief podcast on Project Darkstar.  If you&#8217;re here at the conference, please stop by to chat (and take a free pen!).</p>
]]></content:encoded>
			<wfw:commentRss>http://owenkellett.com/2009/06/04/javaone-communitycorner/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JavaOne: Day 2</title>
		<link>http://owenkellett.com/2009/06/03/javaone-day-2/</link>
		<comments>http://owenkellett.com/2009/06/03/javaone-day-2/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 15:29:52 +0000</pubDate>
		<dc:creator>Owen</dc:creator>
				<category><![CDATA[JavaOne]]></category>
		<category><![CDATA[Project Darkstar]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://owenkellett.com/?p=403</guid>
		<description><![CDATA[I&#8217;m back for another recap, this time of day two at JavaOne. I managed to get up early again this morning and attend the morning keynote. To be honest, it was a bit of a yawn today. It was basically a marketing pitch for Sony Ericsson&#8217;s platform and how they are making it easier to [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://owenkellett.com/blog/wp-content/uploads/2009/06/darkstar_logo.png" alt="darkstar_logo" title="darkstar_logo" width="288" height="60" class="alignright size-full wp-image-404" />I&#8217;m back for another recap, this time of day two at <a href="http://java.sun.com">JavaOne</a>.  I managed to get up early again this morning and attend the morning <strong>keynote</strong>.  To be honest, it was a bit of a yawn today.  It was basically a marketing pitch for Sony Ericsson&#8217;s platform and how they are making it easier to bring Java applications to their mobile platform.  I could tell it was a marketing pitch because Christopher David, who drove the session said at least four or five times during the hour: &#8220;&#8230; and this is not just a marketing pitch&#8221;.  It is true that mobile apps are just going to grow, though, so it is a good market to move into.  The session didn&#8217;t do it for me though.</p>
<p>After the keynote, I sat in on <a href="http://weblogs.java.net/blog/kohsuke/">Kohsuke Kawaguchi&#8217;s</a> session on bringing continuous integration in <a href="https://hudson.dev.java.net">Hudson</a> to the cloud.  This seemed intriguing and relevant since I maintain a Hudson instance internally for Project Darkstar builds and am looking for ways for us to expand its usefulness.  I was also interested to see what exactly he meant by using &#8220;the cloud&#8221;.  The term &#8220;cloud computing&#8221; is such an overloaded term these days and in fact I would suggest that a very small percentage of things that are named &#8220;cloud computing&#8221; actually qualify as such.  What Kohsuke has done for this session though, is one of those things.  Essentially, he&#8217;s built a Hudson plugin that will automatically provision, configure and use an <a href="http://aws.amazon.com/ec2/">Amazon EC2</a> instance as a Hudson build slave dynamically and <strong>on demand</strong> based on load.  So, if you have a Hudson build cluster, and your build machines are getting swamped with work, Hudson will spin up a new virtual build slave automatically and use it to help handle the additional demand.  When the build queue dies down, after a period of time the EC2 instances will shut themselves down and disappear.  Really slick.</p>
<p>After taking a break for lunch, as I mentioned yesterday I wanted to make sure I went to Josh Bloch&#8217;s session on <a href="http://java.sun.com/docs/books/effective/"><em>Effective Java</em></a>.  He talked about several topics including Java generics, enums, varargs, and serialization tricks.  It was all really useful stuff and it turns out that I clearly have never <em>really</em> learned how to properly use wildcards with Java generics.  In other words when to use <code>List&lt;? extends MyType&gt;</code>, <code>List&lt;? super MyType&gt;</code>, or just <code>List&lt;MyType&gt;</code>.  This &#8220;PECS&#8221; rule, as Josh called it, is so simple that it&#8217;s seems almost embarrassing that I didn&#8217;t know it.  Further incentive for me to read the rest of his book and overall a very worthwhile session.</p>
<p>In the late afternoon, I gave my newly tweaked <a href="http://www.projectdarkstar.com">Project Darkstar</a> talk.  I was actually really encouraged by this talk as we had I would say around 100 attendees in the room.  Additionally, after the talk (which seemed to go pretty well), there were quite a few good honest questions and several people came by afterwards who were genuinely interested in learning more and doing more with the technology.  In fact, there were more questions asked at the end of this talk then any other talk that I&#8217;ve attended so far at both CommunityOne and JavaOne this week.  It&#8217;s interesting too, that even though Project Darkstar is a technology specifically designed for games and game developers, I feel like it has had a much greater presence and interest at JavaOne, a <em>Java</em> developers conference, then at GDC, a <em>game</em> developers conference.  That could also simply be because of the quantity and prominence of the sessions and events going on that are related to it though (including DarkChat).</p>
<p>Overall, it was a good day but also pretty busy and exhausting.  I met up with Karl, Keith, Mike, and John for a good dinner and am now pretty much ready to crash.</p>
]]></content:encoded>
			<wfw:commentRss>http://owenkellett.com/2009/06/03/javaone-day-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

