Name:

SE550 final exam: Autumn 2003-2004

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 the difference between remote method invocation and remote procedure call?

d) What is a naming service?

Question 1 continued

Question 2 (25 points)

For each of the following programs, say whether the messages "A", "B" and "C" are printed on the server or on the client. In each case, draw an interaction diagram for each answer.

a)

class Client {
    public static void main (String[] args) throws Exception {
        String server = args[0];
        Broker broker = (Broker)(Naming.lookup ("//" + server + "/broker"));
        Factory factory = broker.buildFactory ();
        Task task = factory.buildTask ();
        task.run ();
    }
}
class Server {
    public static void main (String[] args) throws Exception {
        Naming.rebind ("broker", new BrokerImpl ());
    }
}
interface Broker extends Remote {
    public Factory buildFactory () throws RemoteException;
}
class BrokerImpl extends UnicastRemoteObject implements Broker {
    BrokerImpl () throws RemoteException { super (); }
    public Factory buildFactory () throws RemoteException {
        System.out.println ("A");
        return new FactoryImpl ();
    }
}
interface Factory extends Remote {
    public Task buildTask () throws RemoteException;
}
class FactoryImpl extends UnicastRemoteObject implements Factory {
    FactoryImpl () throws RemoteException { super (); }
    public Task buildTask () throws RemoteException {
        System.out.println ("B");
        return new TaskImpl ();
    }
}
interface Task extends Remote {
    public void run () throws RemoteException;
}
class TaskImpl extends UnicastRemoteObject implements Task {
    TaskImpl () throws RemoteException { super (); }
    public void run () {
        System.out.println ("C");
    }
}

Question 2 continued

b)

class Client {
    public static void main (String[] args) throws Exception {
        String server = args[0];
        Broker broker = (Broker)(Naming.lookup ("//" + server + "/broker"));
        Factory factory = broker.buildFactory ();
        Task task = factory.buildTask ();
        task.run ();
    }
}
class Server {
    public static void main (String[] args) throws Exception {
        Naming.rebind ("broker", new BrokerImpl ());
    }
}
interface Broker extends Remote {
    public Factory buildFactory () throws RemoteException;
}
class BrokerImpl extends UnicastRemoteObject implements Broker {
    BrokerImpl () throws RemoteException { super (); }
    public Factory buildFactory () throws RemoteException {
        System.out.println ("A");
        return new FactoryImpl ();
    }
}
interface Factory extends Serializable {
    public Task buildTask () throws RemoteException;
}
class FactoryImpl implements Factory {
    FactoryImpl () throws RemoteException { super (); }
    public Task buildTask () throws RemoteException {
        System.out.println ("B");
        return new TaskImpl ();
    }
}
interface Task extends Remote {
    public void run () throws RemoteException;
}
class TaskImpl extends UnicastRemoteObject implements Task {
    TaskImpl () throws RemoteException { super (); }
    public void run () {
        System.out.println ("C");
    }
}

Question 2 continued

c)

class Client {
    public static void main (String[] args) throws Exception {
        String server = args[0];
        Broker broker = (Broker)(Naming.lookup ("//" + server + "/broker"));
        Factory factory = broker.buildFactory ();
        Task task = factory.buildTask ();
        task.run ();
    }
}
class Server {
    public static void main (String[] args) throws Exception {
        Naming.rebind ("broker", new BrokerImpl ());
    }
}
interface Broker extends Remote {
    public Factory buildFactory () throws RemoteException;
}
class BrokerImpl extends UnicastRemoteObject implements Broker {
    BrokerImpl () throws RemoteException { super (); }
    public Factory buildFactory () throws RemoteException {
        System.out.println ("A");
        return new FactoryImpl ();
    }
}
interface Factory extends Serializable {
    public Task buildTask () throws RemoteException;
}
class FactoryImpl implements Factory {
    FactoryImpl () throws RemoteException { super (); }
    public Task buildTask () throws RemoteException {
        System.out.println ("B");
        return new TaskImpl ();
    }
}
interface Task extends Serializable {
    public void run () throws RemoteException;
}
class TaskImpl implements Task {
    TaskImpl () throws RemoteException { super (); }
    public void run () {
        System.out.println ("C");
    }
}

Question 2 continued

d)

class Client {
    public static void main (String[] args) throws Exception {
        String server = args[0];
        Broker broker = (Broker)(Naming.lookup ("//" + server + "/broker"));
        Factory factory = broker.buildFactory ();
        Task task = factory.buildTask ();
        task.run ();
    }
}
class Server {
    public static void main (String[] args) throws Exception {
        Naming.rebind ("broker", new BrokerImpl ());
    }
}
interface Broker extends Remote {
    public Factory buildFactory () throws RemoteException;
}
class BrokerImpl extends UnicastRemoteObject implements Broker {
    BrokerImpl () throws RemoteException { super (); }
    public Factory buildFactory () throws RemoteException {
        System.out.println ("A");
        return new FactoryImpl ();
    }
}
interface Factory extends Serializable {
    public Task buildTask () throws RemoteException;
}
class FactoryImpl implements Factory {
    FactoryImpl () throws RemoteException { super (); }
    public Task buildTask () throws RemoteException {
        System.out.println ("B");
        return new TaskImpl ();
    }
}
interface Task extends Serializable {
    public void run () throws RemoteException;
}
class TaskImpl implements Task {
    TaskImpl () throws RemoteException { super (); }
    public void run () {
        System.out.println ("C");
    }
}

Question 3 (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 world to be printed at the client, what XML is sent between the client and the server?

  interface Foo extends Remote { Bar swap (Bar x) throws RemoteException; }
  class Bar extends Serializable { String contents = "hello"; }
  Foo foo = (Foo)(Naming.singleton.lookup ("//server/foo"));
  Bar bar = foo.swap (new Bar ());
  System.out.println (bar.contents);

Question 3 continued

Question 4 (20 points)

Draw an interaction diagram showing the messages sent during a remote method call from host C to host S. The method should be on an object named "foo", calling method "m" with argument "bar" and result "baz". Your diagram should include:

a) A client object on host C, with a pointer to a stub object.

b) A stub object on host C, with a pointer to an executor object.

c) An executor object on host C, with a pointer to a socket object.

d) A lookup table on host C, mapping result object ids to result objects.

e) A socket connecting the two hosts.

f) An executor object on host S, with a pointer to a socket object.

g) A remote object on host S.

h) A lookup table on host S, mapping remote object ids to remote objects.

You may include other objects, which are created during the execution of the remote method call.

Question 4 continued

Question 5 (20 points)

a) What is object persistence?

b) What is orthogonal persistence?

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

d) Describe the begin/commit/abort protocol provided by a transaction model.

Question 5 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.