Middleware Labs: Java RMI

Similar documents
Middleware Labs: Java RMI

JAVA RMI. Remote Method Invocation

JAVA RMI Java, summer semester

Remote Method Invocation

Generic architecture

RMI Example RMI. CmpE 473 Internet Programming RMI

CSci Introduction to Distributed Systems. Communication: RPC In Practice

Remote Procedure Call

5.4. Events and notifications

RMI. (Remote Method Invocation)

Written by: Dave Matuszek

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

Distributed Applications Programming. Lab 4

RMI. Remote Method Invocation. 16-Dec-16

CS 5523 Operating Systems: Remote Objects and RMI

Last Class: Network Overview. Today: Distributed Systems

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

Remote Objects and RMI

RMI Case Study. A Typical RMI Application

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

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

Introduction & RMI Basics. CS3524 Distributed Systems Lecture 01

CS193k, Stanford Handout #12. Threads 4 / RMI

Distributed Systems. 5. Remote Method Invocation

Distributed Systems COMP 212. Lecture 10 Othon Michail

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

Distributed Information Systems

Lecture VI: Distributed Objects. Remote Method Invocation

Remote Method Invocation

IJESRT. http: //

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

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

Distributed Objects SPL/ SPL 201 / 0 1

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

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

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

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

Verteilte Systeme (Distributed Systems)

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

IBD Intergiciels et Bases de Données

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

DISTRIBUTED COMPUTING

Ibis RMI User s Guide

Distributed Programming in Java. Distribution (2)

Lab #1: A Quick Introduction to the Eclipse IDE

presentation DAD Distributed Applications Development Cristian Toma

Remote Method Invocation

Distributed Computing

Distributed Applications Programming. Lab 7

Activation of remote objects

Kickstart Intro to Java Part I

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

Reflection/RMI 4/28/2009

Distributed Systems. 6. Remote Method Invocation. Werner Nutt

Java WebStart, Applets & RMI

COMP 6231 Distributed Systems Design. Tutorial 2 by Alexandre Hudon January 21 st, 2013

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

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

A Typical RMI Application

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

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

Web. Remote Method Invocation. core. programming. Training Courses: Java, JSP, Servlets, Struts, & JSF:

Concurrent Programming (RIO) Lesson 9. Ch 8 [BenA 06] Messages Channels Rendezvous RPC and RMI. X=f(..); send X to B. OS kernel.

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

ASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists

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

Remote Method Invocation in Java

Remote Method Invocation Benoît Garbinato

Remote Method Invocation. Benoît Garbinato

Course Snapshot. The Next Few Classes

Chapter 4: Processes. Process Concept. Process State

Chapter 4 Remote Procedure Calls and Distributed Transactions

Communication and Distributed Processing

Lab 2 : Java RMI. request sayhello() Hello interface remote object. local object. response "Hello world"

Introduction to Java

Lecture 4: Introduction to Java and your Development Environment

EAST WEST UNIVERSITY

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

Activation of remote objects

Address book. Presenting the Java assignment about an Address Book v

CHAPTER - 4 REMOTE COMMUNICATION

Concurrency Control in Distributed Environment

DISTRIBUTED OBJECTS AND REMOTE INVOCATION

ASSIGNMENT 5 Objects, Files, and a Music Player

ASSIGNMENT 5 Objects, Files, and More Garage Management

Index. Course Outline. Grading Policy. Lab Time Distribution. Important Instructions

Network. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark

SUMMARY INTRODUCTION REMOTE METHOD INVOCATION

CC755: Distributed and Parallel Systems

Distributed Systems Project 4 Assigned: Friday March 20 Due: Friday April 3, 11:59pm

PROJECT INFRASTRUCTURE AND BASH INTRODUCTION MARKUS PILMAN<

Remote Method Invocation Java RMI & Web-Services

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to

Bharati Vidyapeeth s Institute of Computer Applications and Management A-4, Paschim Vihar, New Delhi-63.

RPC and RMI. 2501ICT Nathan

Object Oriented Concepts and Programming (CSC244) By Dr. Tabbasum Naz

3. Remote Procedure Call

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

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

Transcription:

Middleware Labs: Java RMI Petr Tůma Vojtěch Horký Antonín Steinhauser Vladimír Matěna March 6, 2018

General Information Labs Web Every other week 5 labs total, 5 middleware technologies Tuesday, 17.20 (SU1) See calendar on the web http://d3s.mff.cuni.cz/teaching/middleware/ (also at http://d3s.mff.cuni.cz/mwy) Mailing list mwy@d3s.mff.cuni.cz https://d3s.mff.cuni.cz/mailman/listinfo/mwy

Requirements for Getting the Credits Details on the web page At least 7 points for the semester Standard tasks Hello World in various technologies ;-) Alternative tasks Less boring than the Hello World stuff ;-)

Standard Tasks 2 points for solving the task correctly and in time 1 point for incorrect submission in time Fixed submission presented at next labs 1 point for missed deadline (max before next labs) Must show at the labs 5 tasks together, each for 2 points

Alternative Tasks Only after previous consultation Contact Petr Tůma for details (task, points, deadlines) Preferred way to get credit 2 to 6 points (depending on the difficulty) Deadline: end of summer examination period Later only in special cases Topics Benchmark (2), set of benchmarks (4 6) Your very own topic (?)

Be Original No Cheating! This is not a mandatory subject Go cheat somewhere else You do not want to learn how to modify someone else s code You want to learn middleware technologies If the tasks seems boring to you...... settle for an alternative.

Submission (generic notes) Working implementation Answer all the questions from the assignment By e-mail Deadline is on the web Make sure it works in the lab downstairs

Submission (generic notes) II Documentation README with key decisions overview Notes on compiling/running The submission shall be easy to start No need for Maven or Ant script No need for packages etc. Updated versions of the run-* scripts Do not send stubs, compiled files or Eclipse.projects

Java RMI

Task: Distance Between Graph Nodes public interface Searcher { public int getdistance ( Node from, Node to ); } public interface Node { Set < Node > getneighbors (); void addneighbor ( Node neighbor ); }

Local Implementation Java version java -version java-config -s oracle-jdk-bin-1.7 java-config -s oracle-jdk-bin-1.8 (rmic deprecation) java-config -s sun-jdk-1.6 (shall work as well) Eclipse All the eye-candy Correct set-up of the run configuration

Local Implementation (cont.) Interfaces Node and Searcher Classes NodeImpl and NodeSearcher Java main() is in the Main class Measures the speed on a random graph Your implementation must be easy to start Use the provided implementation Do not add package etc. Make sure it works in the labs downstairs

Implementation Notes Extend single project, do not create 4 separate ones. Interface hides different implementations Even Remote interface can be used locally Just catch exceptions that would never occur E.g. remote graph is just another array Node[] Easy to have the same (logically) local and remote one Similarly with Searcher Measure everything in one run to ease comparison Just add measuring and a column to results in searchbenchmark()

Launching Use launchers from the Hello World Important parameters Simple Run as... /Application in Eclipse is not enough! Read these slides But can be set-up to work as well Avoid common problems Report problems Well before submission Use solely mailing list for questions The same problem might affect more people

Launching (cont.) rmiregistry application run in background Port in use? use different port number (> 1024) Edit path in calls to [re]bind() and lookup() localhost becomes localhost:1234 For simplicity it has the same CLASSPATH We want to avoid setting permissions for codebase etc. Starting the server see run-server script Starting the client see run-client script

Building the make Script javac (with Eclipse unnecessary) rmic Deprecated in Java 8 Creates stubs for remote objects Parameters are class names implementing the remote objects keep does not remove the generated stub sources Sometimes unnecessary Client can access the classes (yes in our task) Classes inherit from UnicastRemoteObject Subtle differences for generated stubs and proxies equals()

Remote Searcher Extend Searcher interface (see Example) Interface java.rmi.remote Exception of type java.rmi.remoteexception Remotely accessible object (see ExampleImpl) Must be exported 2 ways Derive from java.rmi.server.unicastremoteobject Export ensured by parent constructor Call UnicastRemoteObject.exportObject(obj) manually Does not handle semantics of hashcode(), equals(), tostring() not a problem with Searcher (just one instance)

Remote Searcher (cont.) Executable server (see ExampleServer) Create instance (and export) of the remote object Register with java.rmi.naming.[re]bind() Extend Main with RMI (see ExampleClient) Get reference to a remote Searcher java.rmi.naming.lookup(path) Add call to remote Searcher.getDistance() with local objects NodeImpl in searchbenchmark() method How the server access the neighbors of the passed nodes?

Remote Node Objects Extend interface Node with RMI (like Searcher) Class inherits from UnicastRemoteObject and implements Node To allow for hashcode(), equals(), tostring() Copy/paste + edit is enough We want that local Nodes from previous task still behaved locally

Remote Node Objects (cont.) How to create and return instances for client requests? Implement NodeFactory with method createnode() Similar to remote Searcher interface with RMI, implementing class, create and call Naming.bind() inside the existing server Do not create a standalone server, we want just one for the 4 th variant Client gets the reference with lookup() and creates also the remote Node objects together with the local graph How does the local Searcher access the remote Nodes? What exactly returns NodeFactory to the client?

Remote Searcher on Remote Nodes Everything is ready, just add this variant to searchbenchmark() and compare the speed How does the Searcher on server access the Node objects on (the same) server?

Impact Of the Network So far, client and server were running on the same machine Overhead of RMI communication, but no network latency Run on more machines Server on the machine next to you, client on yours Change paths in [re]bind() and lookup() Remote machine name instead of localhost Modify to use args[0] Run rmiregistry and Server in SSH session on the remote machine Run the client locally Beware of CLASSPATH

Passing by Value vs. Passing by Reference Previous tasks solves extreme cases How about combining both approaches? Idea: batch transfer of bigger parts of the graph gettransitiveneighbors(int distance) Returns all neighbors up to some distance Use the getdistancetransitive method of the Searcher interface In each step, requests neighbors up to the specified distance Try different values for the distance parameter Compare measured times with previous variants

Submission Working implementation Documentation Answer all the questions from the assignment Describe measurement results By e-mail (deadline is on the web) Make sure it works in the lab downstairs The submission shall be easy to start No need for Maven or Ant script No need for packages etc. Updated versions of the run-server scripts