The scenario

POV-Ray is a graphical application to transform images using a technique, known as ray tracing, so to produce a high degree of visual realism but it is computationally expensive.

The main goal of this coursework is to transform the code in code.tgz (a variant of the model answer of CW1) so that the image elaboration is done remotely according to the requirements specified in each question. More precisely, the goal is to develop services for elaborating and merging the images and test them with simple clients.

Warning To answer the questions below, you can introduce any classes you need (this depends on your design). However, in all your answers, you have to respect the following naming conventions

  • names of objects/class/variables in this worksheet or in the code provided must not be changed
  • the file name of any class you introduce must end with Class before the .java suffix (eg., FooClass.java)
  • the file name of any interface you introduce must end with Interface before the .java suffix (eg., BarInterface.java)
  • the name of a class implementing some interfaces, say BarInterface and FooInterface, must be BarFooClass

Question 1

After inspecting this code, design a possible solution for the distributed scenario above such that

  • there is a remote service called ElaborationService for elaborating the image; ElaborationService is an object of the class ElaborationClass supposed to slice an image and produce elaborated tasks
  • there is a remote service called MergingService for merging tasks; MergingService is an object of the class MergingClass supposed to merge the tasks elaborated by ElaborationService
  • a typical client is given in input the path to a .pov file, the number of threads n_of_threads, and width and height of the image; the client invokes the ElaborationService providing
    • an array of bytes corresponding to a .pov file,
    • n_of_threads, width, and height

Write all the interfaces necessary to implement objects servers and clients assuming that elaborated images are stored on the machine of MergingService.

Hint. The code for transforming files to arrays of bytes and viceversa (necessary only in Question 2 and Question 3) is given in the class FileHandling.java. Such class is not part of the assessment, namely you do not have to decide whether the objects of FileHandling.java is local or remote: you just have to duplicate and use FileHandling.java in each client and server of your solution.

Hint. As usual, there are many possible solutions and you may need to add extra classes to those mentioned above or in the model answer. Also, interface depends on your design. Indeed, to work out the solution of the questions of this coursework, it is strongly recommended to sketch a design of the application using the notation adopted in this module (see notes) and casting into a Java implementation.

Such design is not part of the assessment and should not be submitted.

Question 2

Under the hypothesis of Question 1, write

  • the class ElaborationClass
  • the class MergingClass
  • all the main classes for your application.

It is not required to return the final file obtained generated MergingService to the client.

To test your solution, deploy it on a single physical machine and use this java.policy:

grant { permission java.net.SocketPermission "*:1024-65535", "connect,accept"; permission java.net.SocketPermission "*:80", "connect"; };

The following idiosyncrasies of Java must be taken into account to test you code:

  • use lowercase strings made only of letters for package names
  • valid codebase attributes must have a trailing '/' symbol

Hint. To answer this question you can use and modify the classes in code.tgz. Depending on your design, the actual changes are minimal and should not affect the business logic of the code using POV-Ray.

Warning When organising the files in the folder question2/ you must have a subdirectory for one client (only) and one for each server of your solution; such subdirectories contain on turn two further directories named public_html and home. The subdirectory public_html plays the role of public_html on the slides explaining the deployment of RMI applications, while the subdirectory home is meant to represent the home directory of the programmer of each part of the application. An example of a typical structure is See image.

Question 3

For each server myServer of your solution, create a directory structure as the one below See image.

and organise your files so that

  • the subdirectory home contains the Java package myServer any file you developed necessary for for compiling myServer
  • the subdirectory public_html contains all the .class files necessary for the remote invocation
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.