Slide 1Middleware layersMarshalling and External Data RepresentationExternal Data Representation and MarshallingSlide 5Three Important ApproachesSlide 7Slide 8Let’s Examine Three Approaches to external data representationCORBA Common Data Representation (CDR) for constructed typesCORBA CDR messageCORBAJava SerializationSlide 14Java Serialized FormWeb Service use of XMLBut what about passing pointers?Representation of a Remote Object ReferenceA Request Reply ProtocolUDP Style Request-Reply CommunicationUDP Based Request-Reply ProtocolFailure Model of UDP Request Reply ProtocolFailure Model Handling Duplicates (Appropriate for UDP but not TCP)Request-Reply Message StructureRPC Exchange Protocols Identified by Spector[1982]A QuizHTTP Request MessageHTTP SOAP MessageTraditional HTTP Reply MessageHTTP Web Services SOAP Reply MessageA Working Toy ExampleCoolClassServer.javaMyCoolClass_Servant.javaMyCool_Skeleton.java (1)MyCoolSkeleton.java (2)MyCoolClass.javaCoolClient.javaCoolClass_Stub.java (1)CoolClass_Stub.java (2)DiscussionLab Exercise95-702 Distributed Systems Information System Management 195-702 Distributed Systems Chapter 4: Inter-process Communications95-702 Distributed Systems Information System Management 2Middleware layersApplications, servicesMiddlewarelayersrequest-reply protocolmarshalling and external data representationUDP and TCPThischapterRMI and RPC95-702 Distributed Systems Information System Management 3Marshalling and External Data Representation Messages consist of sequences of bytes.Interoperability ProblemsBig-endian, little-endian byte ordering Floating point representation Character encodings (ASCII, UTF-8, Unicode, EBCDIC)So, we must either:Have both sides agree on an external representation or transmit in the sender’s format along with an indication of the format used. The receiver converts to its form.95-702 Distributed Systems Information System Management 4External Data Representation and MarshallingExternal data representation – an agreed standard for the representation of data structures and primitive values Marshalling – the process of taking a collection of data itemsand assembling them into a form suitable for transmission in a messageUnmarshalling – is the process of disassembling them on arrival into an equivalent representation at the destinationThe marshalling and unmarshalling are intended to be carriedout by the middleware layer95-702 Distributed Systems Information System Management 5External Data Representation and MarshallingQuiz: Suppose we write a Java TCP client and server. And suppose we we pass java objects rather than simple characters, would the server interoperate with a .NET client?95-702 Distributed Systems Information System Management 6Three Important ApproachesTo External Data Representation and Marshalling: CORBA’s CDR binary data may be used by different programming languages Java and .Net Remoting Object Serialization are both platform specific (that is, Java on both sides or .Net on both sides) and binary. XML is a textual format, verbose when compared to binary but more interoperable.95-702 Distributed Systems Information System Management 7InteroperabilityConsider int j = 3;What does it look like in memory?00000000000000000000000000000011How could we write it to the wire?Little-Endian approach Big-Endian ApproachWrite 00000011 Write 0000000Then 00000000 Then 0000000Then 00000000 Then 0000000Then 00000000 Then 0000011The receiver had better knowwhich one we are using!95-702 Distributed Systems Information System Management 8Binary vs. UnicodeConsider int j = 3;j holds a binary representation 00…011We could also write it in Unicode.The character ‘3’ is coded as 0000000000110011Binary is better for arithmetic.The character ‘Ω’ is coded as 0000001110101001The number 43 can be written as a 32 bit binaryinteger or as two 16 bit Unicode charactersThe receiver had better knowwhich one we are using!Let’s Examine Three Approaches to external data representation•CORBA’s Common Data Representation•Java’s serialization •Web Service use of XML95-702 Distributed Systems Information System Management 995-702 Distributed Systems Information System Management 10CORBA Common Data Representation (CDR) for constructed typesType Representationsequence length (unsigned long) followed by elements in orderstring length (unsigned long) followed by characters in order (can alsocan have wide characters)array array elements in order (no length specified because it is fixed)struct in the order of declaration of the componentsenumerated unsigned long (the values are specified by the order declared)union type tag followed by the selected member• Can be used by a variety of programming languages.• The data is represented in binary form.• Values are transmitted in sender’s byte ordering which is specified in each message.• May be used for arguments or return values in RMI.95-702 Distributed Systems Information System Management 11CORBA CDR message struct with value: {‘Smith’, ‘London’, 1934}0–34–78–1112–1516–1920-2324–275"Smit""h___" 6"Lond""on__"1934index in sequence of bytes 4 bytesnotes on representationlength of string‘Smith’length of string‘London’unsigned longIn CORBA, it is assumed that the sender and receiver have common knowledge of the order and types of the data items to be transmittedin a message.95-702 Distributed Systems Information System Management 12CORBACORBA Interface Definition Language (IDL)struct Person { string name; string place; long year;};CORBA Interface CompilerAppropriate marshallingand unmarshalling operationsgenerates95-702 Distributed Systems Information System Management 13Java Serializationpublic class Person implements Serializable { private String name; private String place; private int year; public Person(String nm, place, year) { nm = name; this.place = place; this.year = year; } // more methods}95-702 Distributed Systems Information System Management 14Java Serialization Serialization refers to the activity of flattening an object or even a connected set of objects- May be used to store an object to disk- May be used to transmit an object as an argument or return value in Java RMI- The serialized object holds Class information as well as object instance data - There is enough class information passed to allow Java to load the appropriate class at
View Full Document