Assignment No. 5 PTT 2011

(C) 2011 — Software Languages Team, University of Koblenz-Landau

Navigation

The PTT course

Check-in deadline

June 3, 2011 (End Of Day, Koblenz timezone)

Preamble

According to the schedule, there should be an assignment on AOP, but the lecture was canceled due to insufficient student participation. Hence, the subject cannot be reasonably covered by the lab. Thus, the subject is also skipped in this assignment. Students are advised to study AOP for the exam though, as it will certainly play a role in the exam indeed.

Resources

  • 101implementation javaRmi (Wiki with SVN checkout URI)
  • Extra RMI samples (SVN checkout URI)

Variation 1

Title

Distributed banking services

Instructions

Consider the following topology of sites involved in a banking scenario of interest:

  • There is a client site, say an ATM.
  • There is a server site Base which is the primary service provider for the client site.
  • There are also extra server sites—-one for "each" bank.

The sites are involved in an RMI-based scenario of interest as follows:

  • On the ATM site, the balance for a given account is to be determined.
  • The account is specified through the account number (8 digits) and a bank code (8 digits, too).
  • The ATM software delegates the "getBalance" request to the Base.
  • The Base maintains a mapping from bank codes to bank servers.
  • Hence, it further delegates the "getBalance" request to the appropriate bank server.

(Just a query for the balance must be implemented—no other services such as deposit or withdrawal.)

The scenario is to be implemented and demonstrated through a JUnit test case or a main method:

  • There should be at least two banks with two accounts each.
  • The functionality should be robust under incorrect input data such as nonexistent account numbers or bank codes.
  • Manual steps (such as starting servers from the command line) are to be expected and hence acceptable.
  • For ease of testing, all sites must be located on "local host".

(Please note that the requirement for "local host" both simplifies and complicates the problem.)

Variation 2

Title

Distributed data-parallel programming

Instructions

Consider the following code:

/*
 * Compute the length of an array of words
 */
public class SumWordLength {

    // Sequential computation of the sum of the lengths of some given words
    private static int sumWordLength(String[] words) {
        int sum = 0;
        for (String w : words) {
            sum += w.length();
        }        
        return sum;
    }

    // Test input
    final static String[] words = {"let", "us", "sum", "up", "the", "length", "of", "all", "these", "words"};

    @Test
    public void testSumWordLength() {
        assertEquals(sumWordLength(words), 34);
      }
}

Now suppose the following:

  • The computation of the length of a word is computationally very expensive.
  • You would like to leverage parallelism based on distribution (RMI) to speed up the overall computation.
  • You have available an array of compute servers for the service of computing the length of a word.
  • You distribute work to the various servers by iterating over them essentially.

(There may be more words than servers, and hence, you may need to iterate over the servers several times.)

The problem is to be implemented and demonstrated through a JUnit test case or a main method:

  • There should be at least two compute servers.
  • Manual steps (such as starting servers from the command line) are to be expected and hence acceptable.
  • For ease of testing, all sites must be located on "local host".

(Please note that the requirement for "local host" both simplifies and complicates the problem.)