Anotações
Apresentação de slides
Estrutura de tópicos
1
Modulo I
Introdução aos Sistemas Distribuídos
  • Prof. Ismael H F Santos


2
Bibliografia
  • Sistemas Distribuídos
    •   Santos,F., H., Ismael; Notas de Aula, 2005
  • Sistemas Operacionais e Programação Concorrente
    •  Toscani e outros, Editora sagra-luzzatto
  • Fundamentos de Sistemas Operacionais
    •   Silberschatz, Abraham, Galvin, Peter, Gagne, G., LTC


  • Sistemas Distribuídos
    •   Andrew S. Tanenbaun; Prentice Hall
  • Operating System Concepts: Internals and Design Principles
    •   Williiam Stallings, Prentice Hall
3
Ementa
  • Distributed Systems
  • Hardware for Distibuted Systems
  • Client Server Paradigm
  • Networking
  • Client Server Communication


4
SOA
5
Motivation
  • Distributed system is collection of loosely coupled processors interconnected by a communications network
  • Processors called nodes, computers, machines, hosts
    • Site is location of the processor
  • Reasons for distributed systems
    • Resource sharing
      • sharing and printing files at remote sites
      • processing information in a distributed database
      • using remote specialized hardware devices
    • Computation speedup – load sharing
    • Reliability – detect and recover from site failure, function transfer, reintegrate failed site
    • Communication – message passing
6
A Distributed System
7
Definition of a Distributed System (2)
8
Transparency in a Distributed System
9
Multitiered Architectures (1)
  • Alternative client-server organizations (a) – (e).
10
Multitiered Architectures (2)
  • An example of a server acting as a client.
11
Scalability Problems
12
Scaling Techniques (1)
13
Scaling Techniques (2)
14
Types of Distributed Operating Systems
  • Network Operating Systems
  • Distributed Operating Systems


15
Network-Operating Systems
  • Users are aware of multiplicity of machines.  Access to resources of various machines is done explicitly by:
    • Remote logging into the appropriate remote machine (telnet, ssh)
    • Transferring data from remote machines to local machines, via the File Transfer Protocol (FTP) mechanism
16
Distributed-Operating Systems
  • Users not aware of multiplicity of machines
    •   Access to remote resources similar to access to local resources
  • Data Migration – transfer data by transferring entire file, or transferring only those portions of the file necessary for the immediate task
  • Computation Migration – transfer the computation, rather than the data, across the system
17
Distributed-Operating Systems (Cont.)
  • Process Migration – execute an entire process, or parts of it, at different sites
    • Load balancing – distribute processes across network to even the workload
    • Computation speedup – subprocesses can run concurrently on different sites
    • Hardware preference – process execution may require specialized processor
    • Software preference – required software may be available at only a particular site
    • Data access – run process remotely, rather than transfer all data locally
18
Network Structure
  • Local-Area Network (LAN) – designed to cover small geographical area.
    • Multiaccess bus, ring, or star network
    • Speed » 10 megabits/second, or higher
    • Broadcast is fast and cheap
    • Nodes:
      • usually workstations and/or personal computers
      • a few (usually one or two) mainframes
19
 Depiction of typical LAN
20
Network Types (Cont.)
  • Wide-Area Network (WAN) – links geographically separated sites
    • Point-to-point connections over long-haul lines (often leased from a phone company)
    • Speed » 100 kilobits/second
    • Broadcast usually requires multiple messages
    • Nodes:
      • usually a high percentage of mainframes
21
Communication Processors in a Wide-Area Network
22
SOA
23
Hardware Concepts
24
Multiprocessors (1)
25
Software Concepts
  • DOS  (Distributed Operating Systems)
  • NOS (Network Operating Systems)
  • Middleware
26
Uniprocessor Operating Systems
  • Separating applications from operating system code through
  •  a microkernel.
27
Multicomputer Operating Systems (1)
  • General structure of a distributed system as middleware.
28
Multicomputer Operating Systems (2)
  • Alternatives for blocking and buffering in message passing.
29
Multicomputer Operating Systems (3)
  • Relation between blocking, buffering, and reliable communications.
30
Distributed Shared Memory Systems (1)
  • Pages of address space distributed among four machines


  • Situation after CPU 1 references page 10


  • Situation if page 10 is read only and replication is used
31
Distributed Shared Memory Systems (2)
  • False sharing of a page between two independent processes.
32
Network Operating System (1)
  • General structure of a network operating system.
33
Network Operating System (2)
  • Two clients and a server in a network operating system.
34
Network Operating System (3)
  • Different clients may mount the servers in different places.
35
Middleware and Openness
  •     In an open middleware-based distributed system, the protocols used by each middleware layer should be the same, as well as the interfaces they offer to applications.
36
Middleware and Openness
  • In an open middleware-based distributed system, the protocols used by each middleware layer should be the same, as well as the interfaces they offer to applications.


37
Modern Architectures
  • An example of horizontal distribution of a Web service.
38
Comparison between Systems
  • A comparison between multiprocessor operating systems, multicomputer operating systems, network operating systems, and middleware based distributed systems.
39
SOA
40
Software and hardware service layers in distributed systems
41
Clients invoke individual servers
42
A service provided by multiple servers
43
Web proxy server
44
A distributed application based on peer processes
45
Web applets
46
Thin clients and compute servers
47
Spontaneous networking in a hotel
48
Real-time ordering of events
49
Processes and channels
50
SOA
51
Middleware layers
52
Client-Server Communication
  • Sockets
  • Remote Procedure Calls
  • Remote Method Invocation (Java)
  • CORBA
  • Object Registration


53
Middleware layers
54
Sockets
  • A socket is defined as an endpoint for communication
  • Concatenation of IP address and port
  • The socket 161.25.19.8:1625 refers to port 1625 on host 161.25.19.8
  • Communication consists between a pair of sockets
  • All Ports < 1024 are Considered “well-known”
  • - TELNET uses port 23
  • - FTP uses port 21
  • - HTTP server uses port 80
55
Socket Communication
56
Sockets and ports
57
Java Sockets
  • Java Provides:
  • - Connection-Oriented (TCP) Sockets
  • - Connection-less (UDP) Sockets
  • - Multicast Connection-less Socket


58
Time-Of-Day Server/Client
  • Server uses ServerSocket to Create the Socket on Port 5155
  •   ServerSocket s = new ServerSocket(5155);
  • To Accept Connections From Clients:
  • Socket client = s.accept();
  • Connections are Often Serviced in Separate Threads
  • The Client Connects to the Server Using Socket class with the IP Address of the Server.
  • Socket s = new Socket(“127.0.0.1”,5155);


59
Sockets used for streams
60
Client and server with threads
61
TCP client makes connection to server, sends request and receives reply
62
TCP server continued
63
An Example Client and Server (1)
  • The header.h file used by the client and server.
64
An Example Client and Server (2)
  • A sample server.
65
An Example Client and Server (3)
  • A client using the server to copy a file.
66
Alternative server threading architectures
67
State associated with execution environments and threads
68
Java thread constructor and management methods
69
Java thread synchronization calls
70
Sockets used for datagrams
71
UDP client sends a message to the server and gets a reply
72
UDP server repeatedly receives a request and sends it back to the client
73
TCP server makes a connection for each client and then echoes the client’s  request
74
Multicast peer joins a group and sends and receives datagrams
75
Multicast peer continued …
76
Indication of Java serialized form
77
Representation of a remote object reference
78
Remote Procedure Calls
  • Sockets are Considered Low-level.
  • RPCs Offer a higher-level Form of Communication
  • Client Makes Procedure Call to “Remote” Server Using Ordinary Procedure Call Mechanisms.
  • Remote procedure call (RPC) abstracts procedure calls between processes on networked systems.
79
Remote Procedure Calls
  • Remote procedure call, RPC
    • Stubs – client-side proxy for the actual procedure on the server.
    • The client-side stub locates the server and marshalls the parameters.
    • The server-side stub receives this message, unpacks the marshalled parameters, and peforms the procedure on the server.
80
Stubs and Skeletons
  • “Stub” is a Proxy for the Remote Object – Resides on Client.
  • The Stub “Marshalls” the Parameters and Sends Them to the Server.
  • “Skeleton” is on Server Side.
  • Skeleton “Unmarshalls” the Parameters and Delivers Them to the Server.
81
Remote Method Invocation
  • Remote Method Invocation (RMI) is a Java mechanism similar to RPCs.
  • RMI allows a Java program on one machine to invoke a method on a remote object.


82
Remote Method Invocation
  • A Thread May Invoke a Method on a Remote Object
  • An Object is Considered “remote” if it Resides in a Separate Java Virtual Machine.


83
A remote object and its remote interface
84
The role of proxy and skeleton in remote method invocation
85
Marshalling Parameters
86
Role of client and server stub procedures in RPC
87
RPC versus RMI
  • RPC’s Support Procedural Programming Style
  • RMI Supports Object-Oriented Programming Style
  • Parameters to RPCs are Ordinary Data Structures
  • Parameters to RMI are Objects
88
Classes supporting Java RMI
89
Parameters
  • Local (Non-Remote) Objects are Passed by Copy using Object Serialization
  • Remote Objects are Passed by Reference
90
Remote Objects
  • Remote Objects are Declared by Specifying an interface that extends java.rmi.Remote
  • Every Method Must Throw java.rmi.RemoteException
91
MessageQueue interface
  • import java.rmi.*;


  • public interface MessageQueue extends Remote
  • {
  •   public void send(Object item) throws
  •                                 RemoteException;
  •   public Object receive() throws RemoteException;
  • }
92
MessageQueue implementation
  • import java.rmi.*;
  • public class MessageQueueIMPL
  • extends server.UnicastRemoteObject
  • implements MessageQueue
  • {
  • public void send(Object item) throws
  •                                 RemoteException
  • { /* implementation */
  •   }
  • public Object receive() throws RemoteException
  • { /* implementation */
  •   }
  • }
93
The Client
  • The Client Must
  • (1) Install a Security Manager:
  • System.setSecurityManager(
  • new RMISecurityManager());


  • (2) Get a Reference to the Remote Object
  • MessageQueue mb;
  • mb = (MessageQueue)Naming.lookup(
  •              “rmi://127.0.0.1/MessageServer”’);
94
Running the Producer-Consumer Using RMI
  • Compile All Source Files and Generate Stubs
  •   javac *.java; rmic MessageQueueImpl
  • Start the Registry Service
  • rmiregistry
  • Create the Remote Object
  • java –Djava.security.policy=java.policy MessageQueueImpl
  • Start the Client
  • java –Djava.security.policy=java.policy Factory
95
Policy File
  • New with Java 2
  • grant {
  •   permission java.net.SocketPermission "*:1024-65535","connect,accept";
  • };
96
Java Remote interfaces Shape and ShapeList
97
The Naming class of Java RMIregistry
98
Java class ShapeListServer with main method
99
Java class ShapeListServant implements interface ShapeList
100
Java client of ShapeList
101
CORBA
  • RMI is Java-to-Java Technology
  • CORBA is Middleware that Allows Heterogeneous Client and Server Applications to Communicate
  • Interface Definition Language (IDL)  is a Generic Way to Describe an Interface to a Service a Remote Object Provides
  • Object Request Broker (ORB) Allows Client and Server to Communicate through IDL.
  • Internet InterORB Protocol (IIOP) is a Protocol Specifying how the ORBs can Communicate.
102
Corba Model
103
CORBA IDL example
104
Registration Services
  • Registration Service Allows Remote Objects to “register” their services.
  • RMI, CORBA Require Registration Services
105
System layers
106
Core OS functionality
107
Address space
108
Copy-on-write
109
Request-reply communication
110
Operations of the request-reply protocol
111
Request-reply message structure
112
RPC exchange protocols