Name:

SE550 final exam: Winter 2002-2003

This is a closed-book, closed-note exam.

Answer all questions.

Time allowed: 2 hours

Total number of points: 100

Question 1 (20 points)

a) What is a remote pointer?

b) What is a remote method invocation?

c) What is a stub?

d) What is marshalling?

e) How does remote method invocation make use of stubs and marshalling?

Question 1 continued

Question 2 (15 points)

For each of the following programs, say whether the messages "hello" and "world" are printed on the server or on the client. In each case, give a short (one or two sentence) explaination for your answer. Hint: draw an interaction diagram for each answer.

a)

class Client {
    public static void main (String[] args) throws Exception {
        String server = args[0];
        Message msg = (Message)(Naming.lookup ("//" + server + "/msg"));
        Printer p = new PrinterImpl ();
        p.print (msg);
    }
}
class Server {
    public static void main (String[] args) throws Exception {
        Naming.rebind ("msg", new MessageImpl ());
    }
}
interface Message extends Remote {
    public String get () throws RemoteException;
}
class MessageImpl extends UnicastRemoteObject implements Message {
    public String get () throws RemoteException {
        System.out.println ("hello"); return "world";
    }
    HelloWorldImpl () throws RemoteException { super (); }
}
interface Printer extends Serializable {
    public void println (Message msg);
}
class PrinterImpl implements Printer {
    public void println (Message msg) {
        System.out.println (msg.get ());
    }
}

Question 2 continued

b)

class Client {
    public static void main (String[] args) throws Exception {
        String server = args[0];
        Message msg = new MsgImpl ();
        Printer p = (Printer)(Naming.lookup ("//" + server + "/p");
        p.print (msg);
    }
}
class Server {
    public static void main (String[] args) throws Exception {
        Naming.rebind ("p", new PrinterImpl ());
    }
}
interface Message extends Remote {
    public String get () throws RemoteException;
}
class MessageImpl extends UnicastRemoteObject implements Message {
    public String get () throws RemoteException {
        System.out.println ("hello"); return "world";
    }
    HelloWorldImpl () throws RemoteException { super (); }
}
interface Printer extends Serializable, Remote {
    public void println (Message msg) throws RemoteException;
}
class PrinterImpl extends UnicastRemoteObject implements Printer {
    public void println (Message msg) throws RemoteException {
        System.out.println (msg.get ());
    }
}

Question 2 continued

c)

class Client {
    public static void main (String[] args) throws Exception {
        String server = args[0];
        Message msg = (Message)(Naming.lookup ("//" + server + "/msg"));
        Printer p = (Printer)(Naming.lookup ("//" + server + "/p");
        p.print (msg);
    }
}
class Server {
    public static void main (String[] args) throws Exception {
        Naming.rebind ("p", new PrinterImpl ());
        Naming.rebind ("msg", new MessageImpl ());
    }
}
interface Message extends Remote {
    public String get () throws RemoteException;
}
class MessageImpl extends UnicastRemoteObject implements Message {
    public String get () throws RemoteException {
        System.out.println ("hello"); return "world";
    }
    HelloWorldImpl () throws RemoteException { super (); }
}
interface Printer extends Serializable, Remote {
    public void println (Message msg) throws RemoteException;
}
class PrinterImpl extends UnicastRemoteObject implements Printer {
    public void println (Message msg) throws RemoteException {
        System.out.println (msg.get ());
    }
}

Question 3 (20 points)

a) What is distributed garbage collection?

b) What is reference counting?

c) Explain how Java uses reference counting in its implementation of distributed garbage collection.

d) What is object leasing?

e) Explain how Java uses object leasing in its implementation of distributed garbage collection.

Question 3 continued

Question 4 (15 points)

One possible data representation for an RMI implementation is XML. For example, the following code fragment:

  Object bar = Naming.singleton.lookup ("//server/bar");
  bar.set ("hello");

would generate the following XML (ignoring method overloading and object handles) being sent from the client to the server:

  <Object class="Call">
    <String value="bar"/>
    <String value="set"/>
    <Array class="Object" length="1">
      <String value="hello"/>      
    </Array>
    <String value="result1">
  </Object>

and the following response from the server (assuming it returned null):

  <Object class="Return">
    <String value="result1">
    <Null/>
  </Object>

If the following code fragment causes hello to be printed at the client, what XML is sent between the client and the server?

  Object foo = Naming.singleton.lookup ("//server/baz");
  System.out.println (baz.set ("hello", "world"));

Question 4 continued

Question 5 (15 points)

What are the ACID properties of a relational database? Give a short (one or two sentence) description of each property.

Question 5 continued

Question 6 (15 points)

a) What does it mean for an SQL statement to be atomic?

b) Are JDBC statements atomic?

c) Give an example of why transactions are sometimes necessary.

d) Give a one- or two-sentence description of commit and rollback operations on a transaction.

Question 6 continued

Worksheet

You can use this sheet as scrap paper.

Worksheet

You can use this sheet as scrap paper.

Worksheet

You can use this sheet as scrap paper.

Worksheet

You can use this sheet as scrap paper.