Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
Distributed Systems
COMP90015
Tutorial 05
Today’s agenda
- Discussion / Q & A about Assignment 1
- Inter Process Communication (IPC) data formats
- Code Demonstration : JSON format
- Glance at a research paper
Assignment 1 Q & A
External Data Representation and Marshalling
• Data structures in programs are flattened to a sequence of bytes before
transmission
• Different computers have different data representations- e.g., number of
bytes for an integer, floating point representation, ASCII vs Unicode. Two
ways to enable computers to interpret data in different formats:
• Data is converted to an agreed external format before transmission and
converted to the local form on receipt
• Values transmitted in the senders format, with an indication of the
format used
• Marshalling: Process of converting the data to the form suitable for
transmission
• Unmarshalling: Process of disassembling the data at the receiver
• External data representation: Agreed standard for representing data
structures and primitive data
Extensible Markup Language (XML)
A markup language is a textual encoding representing data and the details of
the structure (or appearance)
XML is:
• a markup language defined by World Wide Web Consortium (W3C)
• tags describe the logical structure of the data
• is extensible - additional tags can be defined
• tags are generic - unlike HTML where tags give display instructions
• self describing - tags describe the data
• tags together with namespaces allow the tags to be meaningful
• since data is textual, it can be read by humans and platform independent
• since data is textual the messages are large causing longer processing and
transmission times and more space to store
XML Elements and Attributes
Element
• consists of data surrounded by tags - e.g.
Smith
• elements can be enclosed within elements -
e.g. elements with the tag “name” is enclosed
within the elements with tag “person”. This
allows hierarchical representation.
Attributes
• a start tag may optionally contain attributes
(names and values) - e.g. id="12345678"
JavaScript Object Notation (JSON)
JSON is a lightweight>JSON is a syntax for storing and exchanging data.
JSON is an easier-to-use alternative for XML
It is based on the subset of JavaScript Programming Language
It is text based and completely language independent
• JSON is lightweight thus simple to
read and write.
• JSON supports array data
structure.
• JSON files are more human
readable.
• JSON has no display capabilities .
• Provides scalar data types and the
ability to express structured data
through arrays and objects.
• Native object support. Similarities
between JSON
• XML is less simple than JSON.
• XML doesn't support array data structure.
• XML files are less human readable.
• XML provides the capability to display data
because it is a markup language.
• Does not provide any notion of data types.
One must rely on XML Schema for adding
type information.
• Objects have to be expressed by
conventions, often through a mixed use of
attributes and elements.
IPC Data formats– JSON vs XML
IPC Data formats– JSON vs XML
JSON:
{"employees":[
{ "firstName":"John", "lastName":"Doe" },
{ "firstName":"Anna", "lastName":"Smith" },
{ "firstName":"Peter", "lastName":"Jones" }