Skip to main content

Hudson port-allocator plugin

Posted by kohsuke on November 8, 2007 at 6:12 PM PST

As I discussed some time ago, we run a lot of tests of Metro on Hudson with GlassFish, but there's one common problem we had. Namely, often test jobs abort in the middle, leaving an application server running behind. This causes problems to later builds and other jobs since those run-away processes occupy memory and TCP ports.

Another related problem is that as the number of test jobs grow, we don't want to keep track of what jobs are using what ports. Moreover, some tests that predate automation age is hard-coded against certain port, making the scheduling harder.

So Rama and I wrote a Hudson plugin called "port allocator" to fix this problem. This plugin lets me allocate unique TCP ports (so that I don't have to manually keep track), reserve fixed ports (for example if a job requires port 8080), and terminate those daemon processes after the build if they are not shut-down.

To implement the last feature, we wrote multiple "port type" implementations that know how to talk to the TCP port to shut it down. For example, GlassFish can be shut down by talking to its JMX port, so in the job configuration you'd tell Hudson that this port is going to be used as the GlassFish JMX port, so that Hudson knows which port to talk to.

The port type is extensible, so more can be added either in this plugin or in other plugins. I'm hoping that JBoss guys that are using Hudson would chime in and show us how to shut down JBoss remotely.

Finally a couple of screen-shots below. This is the one showing the shut-down feature:

... and this is the one showing the port allocation feature:

Related Topics >>