






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







] Questions on Laboratory 2 ] Continue Corba from last lecture ] Java object serialization ] Callbacks ] Design issues for remote calls and invocation ] RPCs ] Invocation semantics
] flattens object(s) into compact form for disk storage or message transmission ] process doing deserialization has no knowledge of the object structure
Serialization allows you to save objects to disk and read them back it. Serialization allows you to send objects over a socket or other communication stream and be able to reconstitute a copy on the other end.
public class Person implements Serializable { private String name; private String place; private int year; public Person (String aName, String aPlace, int aYear) { name = aName; place = aPlace; year = aYear; } // methods } What do you have to do to serialize this? Ans: Nothing!
Instructor’s Guide for Coulouris, Dollimore and Kindberg© Addison-Wesley Publishers 2000 Distributed Systems: Concepts and Design Edn. 3
Figure 4. Indication of Java serialized form
The true serialized form contains additional type markers; h0 and h1 are handles
Serialized values Person 3 1934
8-byte version number int year 5 Smith
java.lang.String name: 6 London
h java.lang.String place: h
Explanation class name, version number number, type and name of instance variables values of instance variables
] Field descriptors: 1-byte type code: (B = byte, C = char, D = double, … [ = array) 2-byte length of field name field name class name (if field is an object) 2-byte count of data field descriptors data field descriptors 78 (end marker) superclass type or 70 if none ] If the same class is used again in the file: 71 4-byte serial number
] Array representation 75 class descriptor 4-byte number of entries entries
] Other data: 00 data value
] Representation of unicode values uses Universal Transfer Format (UTF)
Simply implement: private void writeObject(java.io.ObjectOutputStream out) throws IOException;
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException;
] Reflection is the ability to determine the properties of a class dynamically ] The Java package java.lang.reflect contains tools for analyzing classes. ] Remote object references may be passed as input arguments or returned as output arguments.
] May leave server with inconsistent state if client crashes or exits without notifying the server ] Requires the server to make a series of synchronous RMI’s
Leasing can overcome the first problem. Event notification to address the second problem.
] What are invocation semantics? (Local calls are invoked exactly once. Under what circumstances can this fail to happened for remote calls?) ] Transparency (Local calls are made to in environment of the calling process. How is the choice of environment handled for remote calls?)
] Exactly once semantics – every method is executed exactly once
] Maybe semantics – caller can not determine whether or not the remote method has been executed
] At-least-once semantics – caller either receives a result (in which case the user knows the method was executed at least once) or an exception
] At-most-once semantics - caller either receives a result (in which case the user knows the method was executed at exactly once) or an exception
Instructor’s Guide for Coulouris, Dollimore and Kindberg© Addison-Wesley Publishers 2000 Distributed Systems: Concepts and Design Edn. 3
Figure 5. Invocation semantics
Fault tolerance measures Invocationsemantics
Retransmit request message
Duplicate filtering
Re-execute procedure or retransmit reply No Yes Yes
Not applicable No Yes
Not applicable Re-execute procedure Retransmit reply At-most-once
At-least-once
Maybe
] A server provides a set of procedures available to client ] These procedures are specified by a service interface ] Input and output parameters are specified ] Use: \ When the remote procedure is invoked, the values of arguments corresponding to the input parameters are converted to a standard external representation and copied into a packet (marshaling). \ The client sends the marshaled packet to the server. \ The server demarshals the packet, performs the procedure, marshals the return packet, and sends the marshaled return packet to the client. \ Client demarshals the return. \ The entire procedure is concealed in the call.
Instructor’s Guide for Coulouris, Dollimore and Kindberg© Addison-Wesley Publishers 2000 Distributed Systems: Concepts and Design Edn. 3
Figure 4. RPC exchange protocols
Name (^) Messages sent by Client (^) Server Client R (^) Request RR (^) Request Reply RRA (^) Request Reply Acknowledge reply
RPC can be based on TCP or UDP – what are the design issues with respect to invocation semantics?
Instructor’s Guide for Coulouris, Dollimore and Kindberg© Addison-Wesley Publishers 2000 Distributed Systems: Concepts and Design Edn. 3
Figure 5. Files interface in Sun XDR
const MAX = 1000; typedef int FileIdentifier; typedef int FilePointer; typedef int Length; struct Data { int length; char buffer[MAX]; }; struct writeargs { FileIdentifier f; FilePointer position; Data data; };
struct readargs { FileIdentifier f; FilePointer position; Length length; }; program FILEREADWRITE { version VERSION { void WRITE(writeargs)=1; 1 Data READ(readargs)=2; 2 }=2; } = 9999;