Elastic X10 is a new feature introduced in the X10 2.5.0 release. Elastic X10 allows places to be added to a computation while it is running. The new places join existing ones, and your program will see the new places via calls to Place.numPlaces() and Place.places() once the new place joins. Elastic X10 is currently only supported in Managed X10, when using the default JavaSockets transport.

Writing your program to make use of Elastic X10 is similar to Resilient X10. Keep in mind that the number of live places may change. When places die under Resilient X10, the number of places does not change, but some places are marked as dead. With Elastic X10, the number of places increases with each newly added place.

In order for a new place to join, it needs to know the hostname and port number of any other place that is already up and running. Since X10 runs on hosts you specify, but will use dynamic port numbers by default, it's not immediately obvious what those port numbers are. If you are running on Linux, you can use the netstat utility to query which ports are open by each process. But an easier way is to tell X10 to use specific port numbers via the X10_FORCEPORTS environment variable, so that you know what they are.

With the hostname and port number of some existing place in hand, start up your new place with the argument “-DX10_JOIN_EXISTING=hostname:port”, replacing hostname:port with your own hostname and port number. The new place will join the existing ones, and it will be assigned the next available place ID.

Example usage

To see how Elastic X10 works in practice, let's launch the HelloWholeWorldLoop program, available under the samples/resiliency folder of the X10 2.5.0 distribution.

First, compile the program:

$ x10c HelloWholeWorldLoop.x10

Next, launch the program normally. We're going to start with 3 places, and specify ports 7000-7002 on localhost, but you can use any values you want.

$ X10_NPLACES=3 X10_FORCEPORTS=7000 x10 HelloWholeWorldLoop greetings 100 

The console output should look like this:

Place(0) sees 3 places
Place(0) says hello and greetings 0
Place(1) says hello and greetings 0
Place(2) says hello and greetings 0
Place(0) sees 3 places
Place(0) says hello and greetings 1
Place(1) says hello and greetings 1
Place(2) says hello and greetings 1
Place(0) sees 3 places
Place(0) says hello and greetings 2
Place(1) says hello and greetings 2
Place(2) says hello and greetings 2
….

While that program is running, we'll open up a new window, and launch place #4:

$ x10 -DX10_JOIN_EXISTING=localhost:7000 HelloWholeWorldLoop

Your original console will now show “Place(0) sees 4 places”, and you'll see “Place(3) says hello and greetings “ messages in the new window, which matches the counter for the original window.

Because we used the X10 launcher to launch places 0-2, the launcher forwards their output to that console, but not the output from the new place. This is because the new place was started in an independent console, and so has independent output.