DISTRIBUTED SYSTEMS Practical Lab Lab 03 - Schedule 2 Discussion - - PowerPoint PPT Presentation

distributed systems
SMART_READER_LITE
LIVE PREVIEW

DISTRIBUTED SYSTEMS Practical Lab Lab 03 - Schedule 2 Discussion - - PowerPoint PPT Presentation

1 DISTRIBUTED SYSTEMS Practical Lab Lab 03 - Schedule 2 Discussion of Homework 03 Part A Discussion of open issues regarding HW 03 Part B Introduction to RMI General overview Small example Overview on Homework 04


slide-1
SLIDE 1

DISTRIBUTED SYSTEMS

Practical Lab

1

slide-2
SLIDE 2

Lab 03 - Schedule

 Discussion of Homework 03 – Part A  Discussion of open issues regarding HW 03 – Part B  Introduction to RMI

 General overview  Small example

 Overview on Homework 04

2

slide-3
SLIDE 3

A pragmatic Introduction

Remote Method Invocation

3

slide-4
SLIDE 4

 Simple idea:

 In an OO-program objects communicate via methods  For remote communication – why not allow an object to

invoke a method of an object within another JVM

 => Remote Method Invocation (RMI)

RMI - Overview

4

JVM - B Java Objects RMI UDP / TCP / ? Java Objects RMI JVM - A

Middelware

slide-5
SLIDE 5

B‘ B‘‘

Detailed Structure & Terminology

5

RMI Transport Layer UDP/TCP/IP A B Stub Skeleton

marshalling/ unmarshalling

X Y W Z Client JVM Server JVM Objects

slide-6
SLIDE 6

Creating an RMI application

6

 Step 1) Define Remote Interface

 Has to extend java.rmi.Remote (marker interface)  Every method has to throw a RemoteException  Only those methods are available remotely  Parameter can be:

 Serializeable objects => will be serialized and transferred  Remote objects => remote reference / stub will be transferred

public interface Service extends Remote { public int increment(int value) throws RemoteException; }

slide-7
SLIDE 7

Creating an RMI Server

7

 Step 2) Implement the Remote Interface

 Any class may implement the interface – no restrictions

 Step 3) Export the remote object

 Initializes the RMI Environment / Transport Layer  Application will not terminate while an object is exported  e.g. using UnicastRemoteObject.exportObject(…)

 Step 4) publish the remote object within a registry

 Optional step, depending on the use case  => see source code example

slide-8
SLIDE 8

The RMI Registry

8

 Problem: how to obtain references for remote objects?

 A) from remote services via RMI (most frequent case)  B) very first reference: RMI registry

 RMI Registry - simple, centralized naming service

 Essentially a map between names (strings) and stubs  Can be accessed using RMI (lookup, bind, …)  A remote reference to access a registry can be constructed using a

hostname and a port number

 Can be an independent process (rmiregistry) or embedded within a

Java application (see example)

 The RMI Registry is handled using the LocateRegistry utility class

slide-9
SLIDE 9

Creating an RMI Client

9

 Step 1) Obtain a remote object reference

 e.g. by using an RMI registry, LDAP

, …

 Step 2) Use the remote object within your application

 Invoke methods on the remote object just like for local

  • bjects (stub implements the remote interface)

 Remote object references may be maintained within data

structures (sets, lists, maps, …)

 References can be forwarded to other services via

arguments

 References can also be stored within a file (they are

serializeable)

slide-10
SLIDE 10

RMI Applications

10

 Not limited to a Client/Server architecture  Every peer might provide and use remote services

 Remote references can be exchanged between peers  e.g. references may be used within routing tables

 RMI only supports synchronous method invocations

 Simply because Java is only supporting those  Usual means to circumvent this limitation may be

applied

slide-11
SLIDE 11

Advanced Topics

11

 Distributed Garbage Collection

 Unused remote objects are detected and removed  Based on Leases with a long lease time

 Dynamic Class Loading

 Load code from a remote location on demand (e.g. for arguments)

 Remote Object Activation

 Create objects on client demand (no need to run them all the time)

 Transport Layer and interaction with alternative middleware

 Encryption using SSL, firwalls, proxies, …  Interaction with CORBA

slide-12
SLIDE 12

Further References

12

 For a more extensive description see

 The Java RMI tutorial:

 http://download.oracle.com/javase/tutorial/rmi/

 Java ist auch eine Insel – Chapter 19 (German)

 http://openbook.galileocomputing.de/javainsel8/javainsel_

19_001.htm

 RMI Specification

 http://download.oracle.com/javase/6/docs/platform/rmi/s

pec/rmiTOC.html