Chapter 15: Distributed Communication Sockets Remote Procedure - - PowerPoint PPT Presentation

chapter 15 distributed communication
SMART_READER_LITE
LIVE PREVIEW

Chapter 15: Distributed Communication Sockets Remote Procedure - - PowerPoint PPT Presentation

Chapter 15: Distributed Communication Sockets Remote Procedure Calls (RPCs) Remote Method Invocation (RMI) CORBA Object Registration Silberschatz, Galvin, and Gagne 1999 Applied Operating System Concepts Sockets


slide-1
SLIDE 1

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

Chapter 15: Distributed Communication

  • Sockets
  • Remote Procedure Calls (RPCs)
  • Remote Method Invocation (RMI)
  • CORBA
  • Object Registration
slide-2
SLIDE 2

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

Sockets

  • Defined as an “endpoint for communcation”
  • Concatenation of IP Address + Port
  • All Ports < 1024 are Considered “well-known”
  • TELNET uses port 23
  • FTP uses port 21
  • HTTP server uses port 80
slide-3
SLIDE 3

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

Communication Using Sockets

socket (146.86.5.2/1625) host X (146.86.5.20) socket (161.25.19.8/80) web server (161.25.19.8)

slide-4
SLIDE 4

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

Java Sockets

  • Java Provides:
  • Connection-Oriented (TCP) Sockets
  • Connection-less (UDP) Sockets
  • Multicast Connection-less Socket
slide-5
SLIDE 5

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

Time-Of-Day Server/Client

  • Server uses

s = new ServerSocket(5155) To Create the Socket on Port 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 s = new Socket(“127.0.0.1”,5155); Using the IP Address of the Server.

slide-6
SLIDE 6

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

Remote Procedure Calls (RPC)

  • 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.

slide-7
SLIDE 7

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

Remote Method Invocation (RMI)

  • Java’s Version of RPCs
  • A Thread May Invoke a Method on a Remote Object
  • An Object is Considered “remote” if it Resides in a Separate Java

Virtual Machine.

slide-8
SLIDE 8

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

Remote Method Invocation (BMI)

slide-9
SLIDE 9

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

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
slide-10
SLIDE 10

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

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.

slide-11
SLIDE 11

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

Marshalling Parameters

slide-12
SLIDE 12

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

Parameters

  • Local (Non-Remote) Objects are Passed by Copy using Object

Serialization

  • Remote Objects are Passed by Reference
slide-13
SLIDE 13

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

Remote Objects

  • Remote Objects are Declared by Specifying an interface that

extends java.rmi.Remote

  • Every Method Must Throw java.rmi.RemoteException
slide-14
SLIDE 14

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

MessageQueue interface

public interface MessageQueue extends java.rmi.Remote { public void send(Object item) throws java.rmi.RemoteException; public Object receive() throws java.rmi.RemoteException; }

slide-15
SLIDE 15

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

MessageQueue implementation

public class MessageQueueIMPL extends java.rmi.server.UnicastRemoteObject implements MessageQueue { public void send(Object item) throws java.rmi.RemoteException { /* implementation */ } public Object receive() throws java.rmi.RemoteException { /* implementation */ } }

slide-16
SLIDE 16

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

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”)

slide-17
SLIDE 17

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

Running the Producer-Consumer Using RMI

  • Compile All Source Files
  • Generate Stub and Skeleton

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

slide-18
SLIDE 18

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

Policy File

  • New with Java 2

grant { permission java.net.SocketPermission "*:1024-65535","connect,accept"; };

slide-19
SLIDE 19

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

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.

slide-20
SLIDE 20

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

Cobra Model

slide-21
SLIDE 21

Applied Operating System Concepts Silberschatz, Galvin, and Gagne 1999

Registration Services

  • Registration Service Allows Remote Objects to “register” Their

Services.

  • RMI, CORBA Require Registration Services