Introduction & RMI Basics. CS3524 Distributed Systems Lecture 01

Similar documents
JAVA RMI. Remote Method Invocation

Object Interaction. Object Interaction. Introduction. Object Interaction vs. RPCs (2)

DISTRIBUTED OBJECTS AND REMOTE INVOCATION

Distributed Systems. 5. Remote Method Invocation

RMI (Remote Method Invocation) Over the year, there have been 3 different approaches to application development:

The UNIVERSITY of EDINBURGH. SCHOOL of INFORMATICS. CS4/MSc. Distributed Systems. Björn Franke. Room 2414

Last Class: Network Overview. Today: Distributed Systems

Distributed Computing

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

Contents. Java RMI. Java RMI. Java RMI system elements. Example application processes/machines Client machine Process/Application A

Remote Method Invocation

5.4. Events and notifications

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

Outline. EEC-681/781 Distributed Computing Systems. The OSI Network Architecture. Inter-Process Communications (IPC) Lecture 4

RMI. (Remote Method Invocation)

presentation DAD Distributed Applications Development Cristian Toma

Distributed Objects SPL/ SPL 201 / 0 1

Distributed Systems. 6. Remote Method Invocation. Werner Nutt

Distributed Systems. Distributed Object Systems 2 Java RMI. Java RMI. Example. Applet continued. Applet. slides2.pdf Sep 9,

Generic architecture

Chapter 15: Distributed Communication. Sockets Remote Procedure Calls (RPCs) Remote Method Invocation (RMI) CORBA Object Registration

Questions and Answers. A. RMI allows us to invoke a method of java object that executes on another machine.

IBD Intergiciels et Bases de Données

Distributed object component middleware I - Java RMI

Distributed object component middleware I - Java RMI

JAC444 - Lecture 11. Remote Method Invocation Segment 2 - Develop RMI Application. Jordan Anastasiade Java Programming Language Course

RMI. Remote Method Invocation. 16-Dec-16

Remote Method Invocation

Distributed Systems. 02r. Java RMI Programming Tutorial. Paul Krzyzanowski TA: Long Zhao Rutgers University Fall 2017

Chapter 4 Remote Procedure Calls and Distributed Transactions

RMI Case Study. A Typical RMI Application

Communication and Distributed Processing

Message Passing vs. Distributed Objects. 5/15/2009 Distributed Computing, M. L. Liu 1

Written by: Dave Matuszek

Remote Procedure Call

Communication and Distributed Processing

5 Distributed Objects: The Java Approach

Remote Objects and RMI

SUMMARY INTRODUCTION REMOTE METHOD INVOCATION

Course Snapshot. The Next Few Classes

Distributed Information Processing

A Typical RMI Application

Verteilte Systeme (Distributed Systems)

How are classes loaded into the Java Virtual Machine (JVM)? from the local file system (CLASSPATH). by an instance of ClassLoader

A Typical RMI Application. Case Study

Course Snapshot. The Next Few Classes. Parallel versus Distributed Systems. Distributed Systems. We have covered all the fundamental OS components:

CS 5523 Operating Systems: Remote Objects and RMI

Applications. RMI, RPC and events. Request reply protocol External data representation. Operating System

Communication Basics, RPC & RMI. CS403/534 Distributed Systems Erkay Savas Sabanci University

Agent and Object Technology Lab Dipartimento di Ingegneria dell Informazione Università degli Studi di Parma. Distributed and Agent Systems RMI

03 Remote invocation. Request-reply RPC. Coulouris 5 Birrel_Nelson_84.pdf RMI

Distributed Systems COMP 212. Lecture 10 Othon Michail

JAVA RMI Java, summer semester

RPC and RMI. 2501ICT Nathan

Outline. Chapter 4 Remote Procedure Calls and Distributed Transactions. Remote Procedure Call. Distributed Transaction Processing.

Distributed Software Systems

BEA WebLogic. Server. Programming WebLogic RMI

Component-Based Software Engineering

Chapter 5: Distributed objects and remote invocation

Distributed Systems Lecture 2 1. External Data Representation and Marshalling (Sec. 4.3) Request reply protocol (failure modes) (Sec. 4.

55:182/22C:182. Distributed Application Frameworks Java RMI, CORBA, Web Services (SOAP)

15-498: Distributed Systems Project #1: Design and Implementation of a RMI Facility for Java

Lecture VI: Distributed Objects. Remote Method Invocation

Info 408 Distributed Applications programming 2 nd semester of Credits: 5 Lecturer: Antoun Yaacoub Ph.D.

RPC flow. 4.3 Remote procedure calls IDL. RPC components. Procedure. Program. sum (j,k) int j,k; {return j+k;} i = sum (3,7); Local procedure call

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications

Chapter 5 Distributed Objects and Remote Invocation

Remote Method Invocation Benoît Garbinato

Remote Method Invocation in Java

Java RMI Middleware Project

Distributed Objects. Chapter Distributing Objects Overview

Grid Computing. Java Remote Method Invocation (RMI) RMI Application. Grid Computing Fall 2006 Paul A. Farrell 9/5/2006

CC755: Distributed and Parallel Systems

Java Programming Language Advance Feature

Remote Method Invocation. Benoît Garbinato

BEA WebLogic Server. Programming WebLogic RMI

Java RMI Activation: A running example We have the following classes: MyRemoteInterface: the remote interface. Client: the client that invokes a

Remote Method Invocation

Reflection/RMI 4/28/2009

CSci Introduction to Distributed Systems. Communication: RPC In Practice

COMP 6231: Distributed System Design

Module 1 - Distributed System Architectures & Models

Distributed Programming in Java. Distribution (2)

COMMUNICATION PROTOCOLS: REMOTE PROCEDURE CALL (RPC)

RMI Example RMI. CmpE 473 Internet Programming RMI

Activation of remote objects

EAST WEST UNIVERSITY

Lecture 5: RMI etc. Servant. Java Remote Method Invocation Invocation Semantics Distributed Events CDK: Chapter 5 TVS: Section 8.3

Middleware. Adapted from Alonso, Casati, Kuno, Machiraju Web Services Springer 2004

Architecture of So-ware Systems RMI and Distributed Components. Mar<n Rehák

Programming with RMI Reminder

Modulo II Socket, RMI e Corba

Distributed Computing

Desarrollo de Aplicaciones en Red RMI. Introduction. Considerations. Considerations. RMI architecture

Structured communication (Remote invocation)

Remote Method Invocation R.M.I.

Distributed Programming with RMI. Overview CORBA DCOM. Prepared By: Shiba R. Tamrakar

Distributed Systems Architecture

Distributed Systems Principles and Paradigms. Distributed Object-Based Systems. Remote distributed objects. Remote distributed objects

DISTRIBUTED COMPUTING

Transcription:

Introduction & RMI Basics CS3524 Distributed Systems Lecture 01

Distributed Information Systems Distributed System: A collection of autonomous computers linked by a network, with software to produce an integrated computing infrastructure Information: Processed data data that is organised, meaningful, and useful. Security: How to prevent unauthorised access to information and services, and how to maintain availability of information and services to authorised users

Learning Outcomes and Assessment Learning outcome Basic concepts of distributed object systems Distributed database systems Concurrency control Security issues and secure programming Assessment A 2.5hr examination (75%) (2 questions from 3, each 25 marks) An in-course assessment on programming distributed object systems (25%), and

Reading Recommended reading: G. Coulouris, J. Dollimore & T. Kindberg. Distributed systems: Concepts and design, Addison-Wesley, 4th Edition, 2005. J. Farley, W. Crawford & D. Flanagan. Java enterprise in a nutshell, O Reilly, 3rd Edition, 2005. Available free on-line through Safari (see information page). Many more books on the subject in the library including: D. Ince. Developing Distributed and E-Commerce Applications, Addison-Wesley, 2nd Edition, 2004. A. S. Tanenbaum & M. van Steen. Distributed Systems: Principles and Paradigms, 2nd Edition, 2007.

Distributed Systems Software systems that consist of components that may reside on different networked hardware We will discuss in detail the Client Server Paradigm A server is a software application that provides access to services for clients A client accesses a particular service provided by a server

Distributed Systems We will discuss technology for implementing client-server systems Interaction / access to services Remote Objects, Remote Method Invocation Socket Communication JDBC database access Concurrency of activities Processes, Threads and Scheduling Serialisation Transactions and Commit Protocols Secure Programming

Distributed Systems We will discuss Security Issues in Distributed Systems Threat analysis: how to counteract attacks of online systems Network security: attack analysis and defence Cryptology Digital Signature Authentication and Access Control

The Use of Java Implementing distributed systems in Java Easy-to-use socket interface for stream & datagram sockets Object-based interaction using Java RMI Database access via java database connectivity (JDBC) We will see some of these technologies

Big Picture: The Online Business

Scenario: The Online Business Infrastructure for Online Business Provides access to databases, e.g. Orders, provides information about stocked goods etc. Dedicated applications for staff to access and manipulate this information (internal) Web servers to allow clients / customers to order products, browse product catalogues etc Integration with external systems of business partners, suppliers etc. Activities within this distributed system Internal: communication via the company intranet, access to database resources External: access to resources via web servers, via gateways Security Issues: Internal/external: different access rights to data Guarantee confidentiality for customer data Save-guard sensitive company data against unauthorised access

Basic Problems Communication Link is unreliable Server X Server Y Servers may become unresponsive CYBER ATTACK!! How can components of a distributed system clients and servers interact reliably? How can we guarantee reliable communication? How can we guarantee that no data is lost? How can we guarantee that the system is save?

Client Server Paradigm Programming Distributed Systems

Client Server Interaction Client applications access services on a server application How to implement such a distributed application: How to establish a communication between a client program and a server program? Identification: how can a client find a particular server? Data exchange: how can data be exchanged between client and server? Client Program Server Program Client Program Client Program Client Program

Programming Distributed Systems We want a programmer to use a very simple way to use services on a server network concepts and distribution should be hidden Simple method invocation remote_print ( server, Hello World ) ; Server handle Client remote_print Hello World Server 192.168.1.2, 9123

History: Client Server Connection Remote Procedure Calls (RPCs) In the 1980s and early 1990s, the procedural programming paradigm was dominant Client Server systems were built using Remote Procedure Calls (RPCs) Such a procedure call on a client takes a reference to a server as an extra argument a so-called server handle

Remote Procedure Calls Remote Procedure Calls are programming means that hide aspects of identifying and finding remote procedures and the data exchange between client and server: Identification IP (Internet Protocol) address, e.g. 192.168.1.2, and ports (the connection endpoint on a computer at which a server is listening for client requests) A server handle hides the server s IP address and port Lookup Data exchange

Remote Procedure Calls Lookup The server address and port are obtained from a wellknown RPC registry server The client asks the registry for the RPC service by name this is a naming service Data exchange marshalling and unmarshalling arguments: The process of serialization of arguments: Argument data has to be transformed into a platform-independent format before it can be sent from a client to a server (or server to client) this is called marshalling / un-marshalling (see serialization in Java) Network communication via the Remote Procedure Call protocol

Remote Method Invocation (RMI) In the mid to late 1990s, with the rise of the object-based paradigm in software development, RPCs are now replaced by RMIs: Remote Method Invocation the principles are the same as with RPCs: A client has to obtain a reference to a remote object from a known registry Calling a method on the remote object reference hides the marshalling of data and communication over the RMI protocol Goal: hide aspects of distribution from a programmer, the programmer should not care whether a local or remote method is called

Advantages of RMI over RPC Apart from simply being a more modern approach, with the usual benefits of object-orientation, such as: encapsulation, inheritance, polymorphism, etc., RMI offers: No servers, only objects Local objects, from where methods on other (remote) objects are called, don t care where these remote objects reside Greater transparency Objects can be moved to other locations of a network, replicated, etc. Local and remote calls can be almost indistinguishable

Advantages of RMI over RPC Finer service granularity Fat monolithic server are broken up into more maintainable, slim-line service-providing objects Highly dynamic, open environment Remote object methods can return references to other remote objects as data values object copies can be shipped as data. Specific objects can terminate when not required, and, due to serialization, reinitiate when next required. Note: Specific services of pre-oo legacy systems can be wrapped as objects and made available on the network

Java RMI How to program with RMI in Java

Java Remote Method Invocation (RMI) lookup register rmiregistry Client Program call Remote Object register Remote Object Server Program Computer A Computer B

Java RMI Registration ( binding of remote objects) A set of remote objects has to be registered with a naming service in case of Java RMI, this is the rmiregistry Obtaining a remote object reference A client can use the naming service to lookup a URL to obtain a remote object reference The application can pass and return remote object references as part of its operation Communication with remote objects RMI enables method invocation between objects that are not situated in the same Java Virtual Machine To the programmer, this looks like standard Java method invocation The client actually has a local proxy to the server, which is generated during the compilation process

Java RMI lookup rmi://../myservice1, rmi://../myservice2 etc. rmiregistry register as rmi://../myservice1, rmi://../myservice2 etc. Client Server Service Registrar call remote methods MyService1 RemoteObject 1 MyService2 RemoteObject 2 RemoteObject n

Using RMI Design and implement the remote services of the distributed application: Define the remote services as rmi.remote interfaces Implement the remote services as Java objects Write a server starter program to deploy the application This will construct and register the remote objects Write a client for the application The client will lookup and invoke the services of the remote objects.

Defining the Remote Service To illustrate the basics of RMI, we will use the simple shout example (download the rmishout example from the practicals web page): To define the remote service, we write a remote interface The interface must extend java.rmi.remote All methods on the interface may throw a java.rmi.remoteexception Such exceptions are thrown during a remote method call if there is a communication failure or protocol error

An Example Remote Interface package cs3517.examples.rmishout; import java.rmi.remote; import java.rmi.remoteexception; public interface ShoutServerInterface extends Remote { public String shout( String s ) throws RemoteException; } This is an interface definition for a remote object (service), called ShoutServer It provides the method shout to clients, which has to be implemented by the actual remote object

Remote Object as an Implementation of a Remote Interface To do: Create the remote object that implements one or more remote interface(s) Define a constructor for the remote object Provide an implementation for each method declared by the remote interface(s) We introduce the following convention: The name of a class implementing an interface consists of a part of the name of the interface + an extra Impl at the end

An Example Implementation package cs3517.examples.rmishout; import java.rmi.server.unicastremoteobject; public class ShoutServerImpl extends UnicastRemoteObject; implements ShoutServerInterface { public ShoutServerImpl() throws RemoteException { } } public String shout( String s ) throws RemoteException { return s.touppercase(); }

The Server Implement a registrar for your remote objects: We call it the Server Mainline Creates and installs a security manager Instantiates remote objects and export them Registers ( exports ) these remote objects using the Naming service (RMI registry) this is called binding Remote object registration with the RMI registry Each remote object is given a unique URL, e.g.: rmi://hawk.csd.abdn.ac.uk:12345/myservice If the port is omitted, it defaults to 1099 (port where rmiregistry is listening) Note that, for security reasons, an application can bind, unbind or rebind remote object references only with a registry running on the same host

Key Server Mainline Code package cs3517.examples.rmishout; import java.rmi.naming; import java.rmi.rmisecuritymanager; public class ShoutServerMainline { public static void main(string args[]) { try { if (System.getSecurityManager() == null) System.setSecurityManager(new SecurityManager()); } ShoutServerImpl service = new ShoutServerImpl(); String url = rmi:// + host + : + port + /Shout ; Naming.rebind(url, service); } // catch & handle exceptions. } // NB: The server mainline will not shut down; why?

Implementing a Client In common with the server, the client must create and install a security manager Look up the remote object with the Naming service by its URL This gives the programmer a reference to the remote object (a stub is generated within the client VM) Finally invoke methods on that remote object

Binding Remote Objects lookup rmi://../myservice1, rmi://../myservice2 etc. rmiregistry register as rmi://../myservice1, rmi://../myservice2 etc. Client Server Service Registrar call remote methods MyService1 RemoteObject 1 MyService2 RemoteObject 2 RemoteObject n

Key Client Code package cs3515.examples.rmishout; import java.rmi.naming; import java.rmi.rmisecuritymanager; public class ShoutClient { public static void main(string args[]) { try { if (System.getSecurityManager() == null) System.setSecurityManager(new SecurityManager()); String url = rmi:// + host + : + port + /Shout ; ShoutServerInterface service = (ShoutServerInterface)Naming.lookup(url); System.out.println(service.shout( "hello" )); } // catch and handle exceptions. } }