Chapter 2
Overview of Distributed Computing
Distributed System
A collection of (probably heterogeneous) networked computers which communicate and coordinate their actions by passing messages.
Infrastructure for service-oriented computing.
Components (servers, processors, applications) are autonomous; no central control.
Sharing of resources is the main motivation.
Components are typically heterogeneous; different programming languages, operating systems, hardware platforms.
Distribution is transparent to users; system appears as a single integrated facility.
Applications are executed concurrently; components fail
independently. 2
Heterogeneity Issue
3
Networks
Different networks have an implementation of the common Internet protocols.
Hardware architecture
Two alternatives for byte ordering of integers Operating systems
Different APIs for exchange-message call in UNIX and NT Programming languages
Different presentations for characters and data structures such as arrays and records.
Implementations by different developers
Need to use common standards (e.g. network communication, representation of primitive data items and data structures in messages).
A B C D 32-bit a
3 2 1 0 byte hex A B
C D 16-bit a
a+1 big endian
C D A B little endian a a+1
row major vs. column major arrays
Marshaling and Unmarshaling
4
External data representation - An agreed standard for the representation of data structures and primitive values.
Marshaling– The process of transforms structured data items and primitive values into a stream of bytes of an agreed standard form for transmission.
Unmarshaling– The process of reconstructs equivalent data structures and primitive values from the external data
representation at the receiving end.
5
Serialization – Flattening objects into a serial form that is suitable for (storing on disk or) transmitting in a message.
Deserialization – Storing the state of objects from their serialized form.
All objects that an object to be serialized references to will be serialized as well.
References are serialized as handles.
Example: Java Object Serialization
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
h0
java.lang.String place:
h1
Explanation class name, version number number, type and name of
instance variables values of instance variables public class Person implements Serializable {
private String name;
private String place;
private int year;
//followed by methods }
Middleware
A distributed software layer above operating system.
Masks applications from complexity and heterogeneity of underlying distributed environment including marshaling and unmarshaling.
Implemented over Internet protocols.
Provides programming abstraction in a simple integrated distributed environment.
Shields software developers from low-level and error-prone platform details such as socket-level programming.
Allows applications to locate other applications or services across network.
Provides services such as reliability, availability, security for applications.
6 Application
Middleware OS
Computer and network hardware
Java Remote Interfaces for Distributed Whiteboard (Java RMI)
import java.rmi.*;
import java.util.Vector;
...
public interface ShapeList extends Remote {
Shape newShape(GraphicalObject g) throws RemoteException;
Vector allShapes() throws RemoteException;
int getVersion() throws RemoteException;
}
Server Program in Java RMI (1)
Class ShapeListServant implements interface ShapeList.
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
import java.util.Vector;
public class ShapeListServant extends UnicastRemoteObject implements ShapeList { private Vector theList; // contains the list of Shapes
private int version;
public ShapeListServant() throws RemoteException{...}
public Shape newShape(GraphicalObject g) throws RemoteException { version++;
Shape s = new ShapeServant( g, version);
theList.addElement(s);
return s;
}
public Vector allShapes()throws RemoteException{...}
public int getVersion() throws RemoteException { ... }
Server Program in Java RMI (2)
Class ShapeListServer with main method
9
import java.rmi.*;
public class ShapeListServer{
public static void main(String args[]){
System.setSecurityManager(new RMISecurityManager());
try{
ShapeList aShapeList = new ShapeListServant();
Naming.rebind("ShapeList", aShapeList );
System.out.println("ShapeList server ready");
}catch(Exception e) {
System.out.println("ShapeList server main " + e.getMessage());}
} }
Client Program in Java RMI
Class ShapeListClient with main method
10
import java.rmi.*;
import java.rmi.server.*;
import java.util.Vector;
public class ShapeListClient{
public static void main(String args[]){
System.setSecurityManager(new RMISecurityManager());
ShapeList aShapeList = null;
try{
aShapeList = (ShapeList) Naming.lookup("//bruno.ShapeList");
Vector sList = aShapeList.allShapes();
} catch(RemoteException e) {System.out.println(e.getMessage());
}catch(Exception e) {System.out.println("Client: " + e.getMessage());}
} }
Basic modes of communication: Synchronous messaging
Sender and receiver must be ready to communicate with each other at all time.
11
Consumer Service 1 Service 2
block ->
unblock ->
block ->
unblock ->
Synchronous forms of middleware
Uses remote procedure call (RPC) or remote method invocation (RMI), e.g. CORBA, Java RMI, DCOM, Active X, Sun RPC, JAX-RPC, SOAP v.1.0-1.1.
A request looks like a local call.
Client stub is a local proxy for server which mimics the interface of remote object but performs request marshalling, sends request using RPC runtime library, and wait to unmarshal reply.
Server stub unmarshals request, calls service procedure, marshals reply, and sends reply using RPC runtime library.
12
RPC communication
13
RPC point-to-point integration
RPC style leads to tight coupling.
Each application needs to know details of interface of every other application (i.e. number of methods and method signature).
Success of one RPC call depends on success of all downstream RPC calls that are part of the same request/response (i.e. whole or nothing).
Works well for smaller simple applications; Does not scale well for enterprise-wide applications where high performance and high reliability are needed.
14
Basic modes of communication: Asynchronous messaging
Sender and receiver do not have to be active at the same time; usually implemented by queuing mechanism.
Consumer Service 1 Service 2
Asynchronous forms of middleware
Uses store and forward or publish/subscribe messaging.
Application does not need to know intimate details of how to interface with others, but only that it can send a message to a messaging system.
Store and forward messaging (1)
A message is placed in a message queue by a sending application and retrieved by a receiving application; typically, many-to-one.
Physical location of the queue is not known to applications and physical details of the host platform are not known either.
It is required that the application is in some way registered to the message queue subsystem.
Delivery guarantee to final destination: exactly once, at most once, at least once.
Message acknowledgement is used to monitor progress and manage delivery guarantee.
17
Store and forward messaging (2)
18
Publish/subscribe messaging (1)
An application publishes a message on a topic to a message server, and applications that need this info subscribe to it and receive the message when it is published.
Message is generated with no particular destination intended.
Message server delivers (pushes) messages to subscribers;
if not acknowledged, the messages are kept until their expiration time for subscribers to become active and accept delivery.
Subscribers have a message event listener that takes the message from the topic and delivers to the messaging client application.
19
Publish/subscribe messaging (2)
20
Request/reply messaging
Synchronous
Requestor blocks and waits for synchronous response.
Asynchronous
Requestor expects the reply to arrive at a later time and continues its work unaffected.
Request message contains reference to the receiver’s endpoint and correlation identifier to correlate request with response.
Requestor polls a reply channel for the reply message.
21
Message-oriented middleware (MOM)
Mainly supports asynchronous messaging via queues.
Includes services for translating data, message prioritization, security, error recovery, reliable delivery, load balancing etc.
E.g. IBM WebSphereMQ, Microsoft MQ, Oracle AQ etc.
Each product uses a proprietary communication protocol and API; an application used with one product cannot be used with others.
Java Message Service (JMS) is a framework that provides vendor- agnostic API by which Java applications can access different MOM software.
But two communicating applications must use the same MOM products.
22