Archives for owenkellett.com

Adieu Reading Rainbow

I caught a glimpse of this headline the other day: Reading Rainbow Reaches Its Final Chapter. Wow! I had no idea that show was still airing. Not only that, but LeVar Burton was still the host! I remember watching Reading Rainbow when I was in first grade and getting a huge kick out of it because “the guy who plays Geordi La Forge” was the host of the show (and look! he’s not wearing a VISOR!). My favorite episode, of course, was the one where they went behind the scenes on the set of Star Trek: TNG.

I’m not sure what’s weirder, the fact that I remember this, or the fact that I was a Star Trek geek in the first grade…

Bolt

Is there any sprinter with a better name than Usain Bolt? If you haven’t seen it, watch this video of yesterday’s men’s 100 meter final at the world track and field championships in Berlin. It won’t take long. (Sorry the audio is in Italian but it’s a good quality video from Italian TV. There are no guarantees how long any of NBC’s coverage may stay up on YouTube if at all).

When I watched the semifinals of this event and saw Bolt jog his way down the track to a tune of 9.85 seconds, I had a feeling he might break his own world record again in the final like he did last year in the Beijing Olympics. Not only did he break it, he annihilated it, lowering his 9.69 world record to a 9.58. Since the start of fully automatic electronic timing, that’s the largest drop in the 100 meter world record ever. And with a long career ahead of him, who knows how low Bolt will take it.

Also, probably the most amazing thing about this race is Tyson Gay’s performance (lane 5). He ran just about a perfect race, from start to finish, setting an American record 9.71. His time was 0.02 seconds off of the previous world record; but he still got destroyed by Bolt. Unbelievable.

Ultimate Summer

It’s taken until August, but we seem to be in a mostly consistent summer weather pattern now. It’s been busy over the past several weeks but not too busy for ultimate. BUDA club tournament coming up this weekend.

Ultimate Statistics (since January 2008):
Total Games Played: 218
Total Hours Played: 254

Ultimate Catchup

In my last ultimate post, I mentioned something about shutting things down to give my body a rest. Well, that didn’t happen. In the last 11 days, I’ve played ultimate in 8 of them. I’m pretty sore but it’s been a lot of fun. Finally getting a long stretch of nice weather has been a big help. And speaking of the weather, all of this rain that we’ve had over the last several months has accelerated the process of destroying my cleats. Not only was it almost impossible to dry them out with less than 24 hours between games at times, but my aggressive style has caused me to bust several holes in them. This pair barely lasted 6 months…

Ultimate Statistics (since January 2008):
Total Games Played: 209
Total Hours Played: 243

JavaOne Podcast

communitycornerAbout 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’s available for download here.

Ultimate Status

My left hamstring is becoming a pain in the ass (quite literally). My body is not holding up well to the five consecutive days per week schedule. In the past two weeks I’ve missed two BUDA games due to my ailing hamstring, as well as a couple Burlington pickup games. I still managed to average one game every two days though (go figure).

At some point I may need to shut things down for a few weeks. We’ll see…

Ultimate Statistics (since January 2008):
Total Games Played: 201
Total Hours Played: 232

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

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:

<project xmlns="http://maven.apache.org/POM/4.0.0"
  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">
  <modelVersion>4.0.0</modelVersion>
 
  <groupId>my.package.hello</groupId>
  <artifactId>hello-projectdarkstar</artifactId>
  <version>0.1-SNAPSHOT</version>
  <name>Hello Project Darkstar</name>
  <packaging>jar</packaging>
 
  <dependencies>
    <dependency>
      <groupId>com.projectdarkstar.server</groupId>
      <artifactId>sgs-server-api</artifactId>
      <version>${sgs-server.version}</version>
    </dependency>
  </dependencies>
 
  <build>
    <plugins>
      <!-- Use 1.6 for source and target during compile -->
      <plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-compiler-plugin</artifactId>
	<configuration>
	  <source>1.6</source>
	  <target>1.6</target>
	</configuration>
      </plugin>
    </plugins>
  </build>
 
  <properties>
    <sgs-server.version>0.9.9</sgs-server.version>
  </properties>
 
  <repositories>
    <repository>
      <id>java.net</id>
      <name>java.net Maven2 Repository</name>
      <url>http://download.java.net/maven/2/</url>
      <layout>default</layout>
    </repository>
  </repositories>
</project>

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:

  <profiles>
    <profile>
      <id>run-server</id>
      <build>
	<plugins>
          <plugin>
            <groupId>com.projectdarkstar.maven.plugin</groupId>
            <artifactId>sgs-maven-plugin</artifactId>
            <version>1.0-alpha-3</version>
            <executions>
              <execution>
                <id>sgs-run</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>install</goal>
                  <goal>configure</goal>
                  <goal>deploy</goal>
                  <goal>boot</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <version>${sgs-server.version}</version>
              <sgsHome>
                ${project.build.directory}/sgs-server-dist-${sgs-server.version}
              </sgsHome>
              <sgsBoot>${basedir}/conf/hello.boot</sgsBoot>
              <sgsServer>${basedir}/conf/hello.properties</sgsServer>
              <files>
                <file>${project.artifact.file}</file>
              </files>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

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.

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.