June 17, 2009

Ultimate Derailed

I had grand aspirations to play ultimate five consecutive days last week. Monday, Wednesday, and Friday were to be regularly scheduled Burlington lunchtime pickup, and Tuesday, Thursday evenings were to be BUDA summer league games. That plan was derailed when I suffered a quadriceps contusion during Tuesday night's game from an in-game collision. I played the remainder of the game with some discomfort, but once I stopped, things tightened up very quickly. I could barely walk on Wednesday morning and was sidelined for two days.

Wouldn't you know it, though, I was back on the field for Friday's lunchtime game and have already played Monday and Wednesday this week. There are still some lingering effects, and my nagging hamstring problem (on the other leg) is still in the background, but for the most part I'm back in business. I've got five consecutive days of ultimate scheduled again for next week so we'll see how it goes.

Ultimate Statistics (since January 2008):
Total Games Played: 193
Total Hours Played: 225

June 10, 2009

Hello Project Darkstar! in Netbeans and Eclipse

With Project Darkstar'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 "TMTOWTDI" (There's More Than One Way To Do It). This is true but not necessarily very helpful. In the hopes of eliminating some pain I'm here to offer a way to setup a project in these IDE's (but this should by no means be considered the way).

First, here is a quick description of the project and the tools that I will be using:
  • This will be a purely server side project that will print "Hello Project Darkstar!" when the server is booted.
  • I will be using Maven as the build tool for the project.
  • The project will leverage the Project Darkstar Maven Plugin to aid in deploying, booting, and shutting down the server according to the new distribution format for the official Project Darkstar server package.
  • 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).
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:
package my.pkg.hello;

import java.io.Serializable;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.sun.sgs.app.AppListener;
import com.sun.sgs.app.ClientSession;
import com.sun.sgs.app.ClientSessionListener;

public class HelloProjectDarkstar implements AppListener, Serializable {
  private static final long serialVersionUID = 1L;
  private static final Logger logger = 
      Logger.getLogger(HelloProjectDarkstar.class.getName());

  public void initialize(Properties props) {
    logger.info("Hello Project Darkstar!");
  }

  public ClientSessionListener loggedIn(ClientSession session) {
    return null;
  }
}

Second, it is strongly recommended for a Project Darkstar application that you include an app.properties file in the META-INF 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'll include just two required properties, the name of the server and the listener class:

com.sun.sgs.app.name=HelloProjectDarkstar
com.sun.sgs.app.listener=my.pkg.hello.HelloProjectDarkstar

Third, you need a Maven POM file.  If you're unaware of how Maven works, you can read up on it at the Maven website.  Essentially, the POM file is used to declaratively describe your project'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:

  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                      http://maven.apache.org/maven-v4_0_0.xsd">
  4.0.0

  my.package.hello
  hello-projectdarkstar
  0.1-SNAPSHOT
  Hello Project Darkstar
  jar

  
    
      com.projectdarkstar.server
      sgs-server-api
      ${sgs-server.version}
    
  

  
    
      
      
 org.apache.maven.plugins
 maven-compiler-plugin
 
   1.6
   1.6
 
      
    
  

  
    0.9.9
  

  
    
      java.net
      java.net Maven2 Repository
      http://download.java.net/maven/2/
      default

These three files should be organized in a directory structure that looks something like this:
- hello-projectdarkstar
  - pom.xml
  - src
    - main
      - java
        - my
          - pkg
            - hello
              - HelloProjectDarkstar.java
    - resources
      - META-INF
        - app.properties

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:
  • From outside an IDE using the command mvn package
  • From within Netbeans (ensure that you have the Maven plugin installed, then try "Open Project" and Netbeans should automatically detect that the root folder is a Maven project)
  • Or from within Eclipse (ensure that you have the Maven plugin installed, then choose "Import" from the File menu and import as a "Maven project").
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'd rather be able to do this using one command (or one click from the IDE). Enter the Project Darkstar Maven plugin. 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:
  
      run-server
      
 
          
            com.projectdarkstar.maven.plugin
            sgs-maven-plugin
            1.0-alpha-3
            
              
                sgs-run
                pre-integration-test
                
                  install
                  configure
                  deploy
                  boot
                
              
            
            
              ${sgs-server.version}
              
                ${project.build.directory}/sgs-server-dist-${sgs-server.version}
              
              ${basedir}/conf/hello.boot
              ${basedir}/conf/hello.properties
              
                ${project.artifact.file}

This configuration combines the install, configure, deploy, and boot goals of the sgs-maven-plugin into one. Also notice that there are two additional configuration files that are included in your source tree under the conf directory, hello.boot and hello.properties. 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:

# hello.boot
# =======
JAVA_OPTS = -server -Xmx768M

# hello.properties
# =======
com.sun.sgs.app.root=data

So we now have a complete project that looks something like this:
- hello-projectdarkstar
  - conf
    - hello.boot
    - hello.properties
  - pom.xml
  - src
    - main
      - java
        - my
          - pkg
            - hello
              - HelloProjectDarkstar.java
    - resources
      - META-INF
        - app.properties
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 run-server Maven profile. When this is done, Maven will build the project JAR file, download and install the Project Darkstar distribution into the project's target 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:
  • From outside any IDE: just run the command mvn verify -Prun-server. 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 mvn clean.
  • From Netbeans: You should configure the properties of the project by right clicking the project and selecting the "Properties" option. Configure a new Action (or one of the existing actions like the "Run" action) to run the verify goal with the run-server 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 "Run" or whatever action you created under the "Custom" menu). In order to shutdown the server, you should also configure an additional action (i.e. Stop) that runs the sgs:stop goal with the run-server 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).
  • From Eclipse: Similar to Netbeans, you need to configure two "Run Configurations", one that runs the verify goal with the run-server profile activated, and one that runs the sgs:stop goal with the run-server profile activated. These two configurations should be respectively used to bootup and shutdown the server.
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't get into these here, but I would suggest looking at Project Snowman's server POM 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.

June 5, 2009

JavaOne: Signing Off

javaoneI 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 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's Effective Java 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.
I have one more session on my schedule for today but this will likely be my final blog post on this year's JavaOne conference. A few closing thoughts:
  • On the subject of Project Darkstar, 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.
  • On a more general note, there's obviously a bit of uncertainty surrounding the future of Java, JavaOne, and how Oracle 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'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 "Wow" factor from a general audience.
  • 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've been to this year. While Project Darkstar is a technology targeted specifically at games, I wouldn't say I consider myself a "game developer" at all. I'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.
So that's it for my week at JavaOne 2009. I hope you enjoyed following along. Next week I'll be back to my regularly scheduled Ultimate-playing ways.

JavaOne: Days 3 and 4

javanet_logoI'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 (and last?), I wanted to stay for the whole thing. What JavaOne will look like next year is anyone's guess.

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 Groovy and JRuby, 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.

After that session, as mentioned I also recorded a quick podcast on Project Darkstar at the java.net CommunityCorner. 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'll be posting it and a blog of the event somewhere on java.net within the next couple of weeks. Stay tuned for that.

I didn'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.

I attended James Gosling's general session "Toy Show" 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 JavaFX 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.
I'm getting ready to attend a few more sessions before the conference draws to a close, and I'll have some closing thoughts a little later.

June 4, 2009

JavaOne: CommunityCorner

sunrayI'm writing this post from one of the hundreds of Sun Ray stations scattered throughout the Moscone Center at JavaOne. If you don't know what a Sun Ray is, it'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 Ubuntu, OpenSolaris, or Windows Vista 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!

Today at 11:30AM I'm going to be at the java.net CommunityCorner located at booth 101 in the Pavilion. A few other members of the Project Darkstar team should be joining me as well, and I'll be doing a brief podcast on Project Darkstar. If you're here at the conference, please stop by to chat (and take a free pen!).

June 3, 2009

JavaOne: Day 2

darkstar_logoI'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'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: "... and this is not just a marketing pitch". It is true that mobile apps are just going to grow, though, so it is a good market to move into. The session didn't do it for me though.

After the keynote, I sat in on Kohsuke Kawaguchi's session on bringing continuous integration in Hudson 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 "the cloud". The term "cloud computing" is such an overloaded term these days and in fact I would suggest that a very small percentage of things that are named "cloud computing" actually qualify as such. What Kohsuke has done for this session though, is one of those things. Essentially, he's built a Hudson plugin that will automatically provision, configure and use an Amazon EC2 instance as a Hudson build slave dynamically and on demand 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.

After taking a break for lunch, as I mentioned yesterday I wanted to make sure I went to Josh Bloch's session on Effective Java. 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 really learned how to properly use wildcards with Java generics. In other words when to use List<? extends MyType>, List<? super MyType>, or just List<MyType>. This "PECS" rule, as Josh called it, is so simple that it's seems almost embarrassing that I didn't know it. Further incentive for me to read the rest of his book and overall a very worthwhile session.

In the late afternoon, I gave my newly tweaked Project Darkstar 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've attended so far at both CommunityOne and JavaOne this week. It'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 Java developers conference, then at GDC, a game 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).
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.

June 2, 2009

JavaOne: Day 1

snowmanlabWhew. Technically it's still only day one of the JavaOne conference and I already feel like I've put in a week's worth of energy. I just returned from running the Project Snowman hands-on lab this afternoon. It was moderately successful with a few painful and time consuming hiccups - more on that in a minute. First though, another quick rundown of my day:

The keynote was great. Chris, of course, kicked off the event and introduced the DarkChat application that will be running throughout the conference. It's basically a simple social networking tool that shows off JavaFX. The other thing about it, though, is that the backend is built on Project Darkstar, and Keith is the one who had been spending a lot of his time recently getting that put together. Chris also snuck in a plug for the Project Darkstar sessions during that intro (the Project Snowman lab was completely full this afternoon).

After that, obviously, he yielded to CEO Jonathan Schwartz who ran most of the show. There were several announcements, including preview releases of JDK 7 and J2EE 6 and updates to JavaFX. Perhaps the most interesting, though, is the launch of the Java Store beta program. The Java Store is essentially a distribution mechanism that taps into the huge install base of Java to deliver Java applications to consumers in a consistent manner. Think iPhone's app store except replace iPhone users with Java users. Now, the concept behind the Java Store is not a new idea, but packaging and distributing Java applications has always been sort of a funny animal. I actually think this is a great initiative and hope it takes off.

After the keynote, I attended two sessions. The first was on using Java on game handhelds. This session caught my eye because the description claims that they were able to connect a Sony PSP to a Nintendo DSi using a Project Darkstar server as the game backend. Wow that sounds cool right? Well, it is cool, but not quite as cool as you think. What they actually did is hack the PSP and DSi and put their own firmware on the devices which supports JavaME. They then wrote a game client using the JavaME darkstar client and hooked them both up to the same darkstar server. After some finagling they did eventually get a PSP and two DSi clients logged into the same game, but they were not using anything native to the two devices. A ways off from what we'd like to see but still pretty neat.

The second session that I went to caught my attention because Josh Bloch was one of the presenters. For a while now, I've been meaning to get my hands on and read all the way through his book Effective Java. This session further solidified that desire. During the session, he and Neal Gafter analyzed five or six Java code snippets that look correct but actually have tricky and subtle bugs. Not only was the content interesting, but the back and forth banter style presentation format was entertaining and engaging. I plan to attend another of Josh's talks scheduled for tomorrow.
After a break, as I mentioned above, I proctored and ran the Project Snowman hands-on lab in the late afternoon (with the help of Dan, Keith, and a few other proctors as well). Overall, I would say it ran ok. There was one large and unfortunate problem at the beginning of the lab that reeked havoc throughout the remainder of the session. Essentially, one of the first steps in the lab is to install and configure the Maven plugin for Netbeans. Unfortunately, when all 100 people in the room tried to do that, we overwhelmed something on the network (whether it was the outgoing pipe in the room, the Netbeans server, or what who knows). Getting Maven up and configured for everyone took a while, and once it was up, network connectivity issues continued to plague the attendees as Maven would occasionally search for artifacts on the network causing it to pause or hang during builds. The result is that running the session was not very smooth as I and the other proctors (special thanks to them btw) spent most of the time running around the room debugging these annoying Maven issues rather than Project Darkstar issues. Regardless, though, I think many people did enjoy it and they were given all of the materials that they need to try to complete it on their own.

So that was my day. There's another session tonight on the Java Collections Framework that I'm currently signed up to attend. But first, dinner.

June 1, 2009

CommunityOne

communityone_logoGetting to JavaOne early to test out the snowman lab actually gave me a chance to attend some of the sessions and events going on today at CommunityOne. This is a free conference that is geared towards users and developers of open source technologies and software. Here's a rundown of what I did/saw:
  • The keynote this morning had two main focuses: cloud computing and OpenSolaris. There was some good stuff in there; Solaris has long had a bad reputation for being very unfriendly, making many oblivious to its core quality. Solaris is consistently the best performer in many of the Project Darkstar benchmarks that we've run, for example. I think OpenSolaris is slowly, but surely, making Solaris more accessible to the masses.
  • I attended two morning talks, one on the features in the latest Subversion release and one on a Hudson use case. Most of the material I was already aware of but looking at some of the things they were doing with Hudson, I think we should really investigate expanding our Hudson deployment. Currently we have a Hudson server doing continuous integration builds on each commit to the Project Darkstar trunk. However, it's only deployed on a single Solaris machine so our continuous test platform is limited to that. In the presentation, these guys were using Hudson to fire up multiple virtual machines representing various platforms on demand to do cross-platform testing of Netbeans. This could also be an option for us.
  • In the afternoon, I went to Chris Melissinos's talk on Project Darkstar. Chris is actually the Master of Ceremonies for the entire JavaOne conference and is one of the original promoters of the Project Darkstar project. If you've ever met him, you know that he's one of the most dynamic and outspoken people there is. Which makes this next fact even more surprising in that I actually ended up giving part of Chris's talk. About five minutes before the session was about to start, I bumped into Chris and chatted with him for a few minutes. Then he said something like "Oh good I'm glad you're here, do you mind coming up and sitting on stage to answer any technical questions people might have?" Um, sure? The next thing I know some guy is putting a microphone on me and I'm sitting in front of these blinding lights. Then, about halfway through the talk, Chris stumbles across some technical slides and says "Owen do you want to give this part of the presentation? Better you then me butchering it." Ummmm, ok? I spent the next fifteen minutes or so ad-libbing a sequence of presentation slides, having no idea what was coming next. Thanks Chris! The truth is, the presentation actually did turn out pretty well. Chris was his usual dynamic and entertaining self and I managed to bring just enough technical depth to the show. Karl suggested I stay away from Chris before he gives the JavaOne keynote tomorrow morning though!
  • During the keynote this morning I briefly heard them mention something about the OpenSolaris Juicer. The Juicer is a service which allows anyone to submit a piece of software for OpenSolaris for test and review to be included in the official "contrib" repository of OpenSolaris packages. Software packaging and distribution is interesting to me so I took a peak at their late afternoon session on the Juicer. It's good to see that OpenSolaris is finally approaching something close to the apt system that has been around for years on Debian and now Ubuntu.
That's about it for my day. I met up with a few others for dinner and am now getting ready to go to sleep. Big day tomorrow with the Project Snowman lab scheduled in the afternoon.