Assignment 1: A compute server
In this assignment, you are to work in pairs.
Purpose
The purpose of this programming assignment is to:
- Give you experience working with Java RMI
- Begin building a Java-centric cluster computing infrastructure.
Specification
Build a simple compute server:
- Tasks are sent to it;
- It performs the computational task, and returns a result object.
The basic scheme
- Define a Task<T> interface with 1 method, execute, that takes no arguments, and returns an object of type <T>.
- Define a remote interface, Computer, with 1 method, execute, that takes 1 argument, a Task object, and returns the return value of the Task object's execute method.
- Define a ComputerImpl class that implements Computer.
Define classes that implement Task
- MandelbrotSetTask
- This task helps produce a visualization of the some part of the Mandelbrot set.
- The constructor takes the following inputs:
- 2 doubles that represent the lower left corner of a square in the complex plane.
- a double that represents the edge length of a square in the complex plane, whose sides are parallel to the axes.
- an int , n, such that the square region of the complex plane is subdivided into n X n squares, each of which is visualized by 1 pixel.
- an int which is the iteration limit: It defines when the representative point of a region is considered to be in the Mandelbrot set.
- The execute method returns an int[n][n] count array, where count[i][j] = k, where |zk| > 2 or k is the iteration limit (whichever is smaller), where
- z0 = c, where c is the representative point in region[i][j] (typically the lower left point defining the region)
- zk = (zk-1)2 + c.
- Your client should be able to map each element of the count
array (i.e., elements in the set {0, 1, 2, ..., iterationLimit }) to a
Color object, and should display the n X n array of colors, 1 pixel per Color.
- EuclideanTspTask
- This task solves a Traveling Salesman Problem (TSP), where the cities are points in the 2D Euclidean plane.
- The constructor takes a double[][] cities that codes the x and y coordinates of city[i]: cities[i][0] is the x-coordinate of city[i] and cities[i][1] is the y-coordinate of city[i].
- The distance between cities is the Euclidean distance.
- The execute method returns an int[] tour that lists the order of the cities of a minimal distance tour. Its method of finding this tour does not have to be clever: For example, your program can iterate over all permutations of the cities, and return a permutation of least cost (which need not be unique).
Exercise each task class
Define a client that:- gets, as a command-line argument, the domain name or IP address of a machine that is running a Computer;
- obtains a remote reference to a Computer;
- constructs an instance of each of the Task classes
specified
above;
- for each instance:
- invokes the Computer's remote execute method, passing the Task object as an argument;
- For the MandelbrotSetTask use the parameter values:
- -2.0, -2.0
- 4.0
- 256
- 64
- For the EuclideanTspTask, use the following list of cities as a problem instance:
Each line that follows has the x and y coordinates of a city, starting with city 0 and ending with city 9:
6 3
2 2
5 8
1 5
1 6
2 7
2 8
6 5
1 3
6 6
If you plot these cities, a minimal tour is obvious: 0, 1, 8, 3, 4, 5, 6, 2, 9, 7.
- suitably display the arguments and return value.
Experiment
- Start a Computer.
- Start your client.
- Do the following 5 times: For each task, record the elapsed time.
- Record the average Task elapsed time for each problem.
Deploy your client such that the ComputerImp class cannot be loaded by the client's classloader: ComputerImpl is not in the client's classpath. Similarly, make sure that the Computer does not have the client's Task classes in its class path: The client provides a codebase.
Deployment requirement: The Computer works with tasks whose Task class has been implemented after the Computer was deployed, without having to restart the Computer. This is not the same as the Computer reloading classes which have changed, which is not a goal.
Paper Summary
Submit a 1-page summary, using entirely your own words, of the paper titled, "A Note on Distributed Computing."
Deliverable
Mail <cappello@cs.ucsb.edu> a jar file, named <name>.jar, where <name> is the CS computer account username of 1 member of the pair. When mailing this attachment to me, cc yourself. We will download and open your jar file during the weekly meeting. The jar file includes the following directories & files:
Directories
- documents: has index.html file that contains [links to]:
- readme.html: Instructions to compile and run your client and compute server.
- javadoc: a directory that documents your
- api
- Task classes: constructor parameters and execute method return values.
- Experimental results: Present the elapsed run times for each task type, and its average elapsed time.
- Your paper summary.
- source: a directory containing the following subdirectories, reflecting the package structure:
- tasks, which contains your Task classes (each Task subtype may be in a subpackage, if you prefer)
- client, which contains your client class[es]
- computer, which contains your implementation of the Computer interface.
- api, which contains your Task and Computer interfaces.
- test: Java unit test source files. Each test class is in the same package as the class it tests.
- library: has executables, typically jar files, that are not written by your team, but are needed to compile your work.
Files
If you are installing Ant, set the ANT_HOME environment variable. Set the JAVA_HOME environment variable to /usr/java/latest before using Ant.
- build.xml file with targets to:
- runComputer: starts a Computer whose classpath does not include the client's Task classes.
- runClient: starts a client whose classpath does not include the Computer implementation.

