Software Engineering Recitation 7 Suhit Gupta. Review Anything from last time???

Slides:



Advertisements
Similar presentations
What is RMI? Remote Method Invocation –A true distributed computing application interface for Java, written to provide easy access to objects existing.
Advertisements

15-May-15 RMI Remote Method Invocation. 2 “The network is the computer” Consider the following program organization: If the network is the computer, we.
Remote Method Invocation in Java Bennie Lewis EEL 6897.
Advanced Programming Rabie A. Ramadan Lecture 4. A Simple Use of Java Remote Method Invocation (RMI) 2.
Java Remote Method Invocation (RMI) In Java we implement object systems: O1O2 O3 thread 1thread 2 execution scheme JVM 1JVM 2 distribution scheme.
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
Remote Method Invocation
Remote Object Invocation Tran, Van Hoai Department of Systems & Networking Faculty of Computer Science & Engineering HCMC University of Technology.
Company LOGO Remote Method Invocation Georgi Cholakov, Emil Doychev, University of Plovdiv “Paisii.
Understanding Makefiles COMP 2400, Fall 2008 Prof. Chris GauthierDickey.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
Sockets  Defined as an “endpoint for communication.”  Concatenation of IP address + port.  Used for server-client communication.  Server waits for.
EEC-681/781 Distributed Computing Systems Lecture 5 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
CSE331: Introduction to Networks and Security Lecture 11 Fall 2002.
Introduction to Remote Method Invocation (RMI)
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
Practical Issues of RPCCS-4513, D-Term Remote Procedure Call Practical Issues CS-4513 Distributed Computing Systems (Slides include materials from.
Java RMI RMI = Remote Method Invocation. Allows Java programs to invoke methods of remote objects. Only between Java programs. Several versions (JDK-1.1,
1 Java Programming II Java Network II (Distributed Objects in Java)
CS 584 Lecture 18 l Assignment » Glenda assignment extended to the Java RMI Deadline » No Java RMI Assignment l Test » Friday, Saturday, Monday.
+ A Short Java RMI Tutorial Usman Saleem
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
15 - RMI. Java RMI Architecture Example Deployment RMI is a part of J2SE (standard edition), but is used by J2EE) A J2EE server is not nessesary for using.
Java RMI: Remote Method Invocation January 2000 Nancy McCracken Syracuse University.
1 Java RMI G53ACC Chris Greenhalgh. 2 Contents l Java RMI overview l A Java RMI example –Overview –Walk-through l Implementation notes –Argument passing.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
Silberschatz, Galvin, and Gagne  1999 Applied Operating System Concepts Chapter 15: Distributed Communication Sockets Remote Procedure Calls (RPCs) Remote.
Java Remote Method Invocation RMI. Idea If objects communicate with each other on one JVM why not do the same on several JVM’s? If objects communicate.
Remote Method Invocation onlineTraining/rmi/RMI.html.
RMI Continued IS Outline  Review of RMI  Programming example.
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
RMI Remote Method Invocation Distributed Object-based System and RPC Together 2-Jun-16.
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 43 Remote Method Invocation.
Fall 2007cs4251 Distributed Computing Umar Kalim Dept. of Communication Systems Engineering 17/10/2007.
Li Tak Sing COMPS311F. RMI callbacks In previous example, only the client can initiate a communication with the server. The server can only response to.
Data Display Debugger (DDD)
Java Remote Method Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
1 Java Remote Method Invocation java.rmi.* java.rmi.registry.* java.rmi.server.*
Remote Method Invocation by James Hunt, Joel Dominic, and Adam Mcculloch.
 Java RMI Distributed Systems IT332. Outline  Introduction to RMI  RMI Architecture  RMI Programming and a Sample Example:  Server-Side RMI programming.
Florida State UniversityCOP Advanced Unix Programming Remote Method Invocation /rmi/index.html.
Remote Method Invocation A Client Server Approach.
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
Java RMI. RMI Any object whose methods can be invoked from another Java VM is called a remote object.
Java Distributed Object Model A remote object is one whose methods can be invoked from another JVM on a different host. It implements one or more remote.
1 Lecture 15 Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
Distributed programming in Java Faculty:Nguyen Ngoc Tu Session 5 - RMI.
Using RMI The Example of A Remote Calculator 1. Parts of A Working RMI System A working RMI system is composed of several parts. –Interface definitions.
RMI1 Remote Method Invocation Adapted from “Core Java 2” by Cay Horstmann.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 29 Remote Method.
Java Remote Method Invocation (RMI)
Broker in practice: Middleware
Remote Method Invocation
What is RMI? Remote Method Invocation
Remote Method Invocation
Makefile Tutorial CIS5027 Prof: Dr. Shu-Ching Chen
Network and Distributed Programming in Java
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
Chapter 40 Remote Method Invocation
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
Remote method invocation (RMI)
Overview of RMI Architecture
Chapter 46 Remote Method Invocation
Chapter 46 Remote Method Invocation
GNU Make.
Java Remote Method Invocation
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Software Engineering Recitation 7 Suhit Gupta

Review Anything from last time???

Today Threads/pthreads Bit operators in Java The GNU make utility Javadocs RMI/Siena

Threads/pThreads We have already done threads (therefore we are going to skip) pThreads used in C. (POSIX Threads) pThreads is the name of a machine- independent library of functions that are generally used to facilitate the multiprocessing of programs on shared memory machines. pThreads is used to synchronize threads.

Bit Operators Bit operators treat Number types as a 32 bit value, change bits according to the operator and then converts the value back to Number when done. The operators are bitwise NOT (~), AND (&), OR (|), XOR (^), left shift ( >), unsigned right shift (>>>).

Bit operators in Java Bitwise operations are not to be confused with logical operations (&&, ||...) & - and | - or << - shift left >> - shift right ^ - XOR ~ - compliment/not

Bitwise operators Bitwise operators (AND, OR) can be used in place of logical operators (&&,||), but they are less efficient, because logical operators are designed to reduce the number of comparisons made, in an expression, to the optimum: as soon as the truth or falsity of an expression is known, a logical comparison operator quits. A bitwise operator would continue operating to the last before the final result were known. Bitwise operators are basically arithmetic operation. Now, bitwise are not really inefficient because they are truly put on the chip… The first point is more or less in C. In Java they are fairly different operations.

Eg | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | = Shift operators move whole bit patterns left or right by shunting them between boxes. The syntax of this operation is: 1 << 1 would have the value 2, because the bit pattern would have been moved one place the the left: | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | = Similarly: 1 << 4 has the value 16 because the original bit pattern is moved by four places: | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | = And: 6 << 2 == | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | = Shift left 2 places: | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | =

The GNU make utility /html_node/make_toc.html /html_node/make_toc.html The make utility automatically determines which pieces of a large program need to be recompiled, and issues commands to recompile them. You have to have a Makefile Run make to start rules in the Makefile file.

Example of a Makefile edit : main.o kbd.o command.o display.o \ insert.o search.o files.o utils.o cc -o edit main.o kbd.o command.o display.o \ insert.o search.o files.o utils.o main.o : main.c defs.h cc -c main.c kbd.o : kbd.c defs.h command.h cc -c kbd.c command.o : command.c defs.h command.h cc -c command.c display.o : display.c defs.h buffer.h cc -c display.c insert.o : insert.c defs.h buffer.h cc -c insert.c search.o : search.c defs.h buffer.h cc -c search.c files.o : files.c defs.h buffer.h command.h cc -c files.c utils.o : utils.c defs.h cc -c utils.c clean : rm edit main.o kbd.o command.o display.o \ insert.o search.o files.o utils.o

From the example To use this makefile to create the executable file called ‘edit’, type: make make clean

Javadocs Javadoc provides a way to integrate code comments with program documentation. –Enter comments with a series of flags to indicate the type of comment/documentation –Run javadoc to parse the flags and the comments to create an html file documentation of the code

Example If you miss recitation then you will miss the demonstration You can run – javadoc somefile.java

RMI/Siena We have done Siena (therefore we will skip) Remote Method Invocation (RMI) enables the programmer to create distributed JavaTM technology-based to Java technology-based applications, in which the methods of remote Java objects can be invoked from other Java virtual machines, possibly on different hosts.

More on RMI Remote Method Invocation (RMI) is the object equivalent of Remote Procedure Calls (RPC). While RPC allows you to call procedures over a network, RMI invokes an object's methods over a network. In the RMI model, the server defines objects that the client can use remotely. The clients can now invoke methods of this remote object as if it were a local object running in the same virtual machine as the client.

More RMI… RMI hides the underlying mechanism of transporting method arguments and return values across the network. In Java-RMI, an argument or return value can be of any primitive Java type or any other Serializable Java object. Java-RMI is a Java-specific middleware spec that allows client Java programs to invoke server Java objects as if they were local. Java-RMI is tightly coupled with the Java language. Hence there are no separate IDL mappings that are required to invoke remote object methods. This is different from DCOM or CORBA where IDL mappings have to be created to invoke remote methods. IDL==Interface Definition Language

RMI contd… Because of this, parameters passed during method calls between machines can be true Java Objects. This is impossible in DCOM or CORBA at present. If a process in an RMI system receives an object of a class that it has never seen before, it can request that its class information be sent over the network. Over and above all this, Java-RMI supports Distributed Garbage Collection that ties into the local Garbage Collectors in each JVM. Since both the client and the server may reside on different machines/processes, there needs to be a mechanism that can establish a relationship between the two. Java-RMI uses a network-based registry program called RMIRegistry to keep track of the distributed objects. (Note: The RMI Registry is an RMI server itself!!!)

RMI/Remote Interface package SimpleStocks; import java.util.*; import java.rmi.*; public interface StockMarket extends java.rmi.Remote { float get_price( String symbol ) throws RemoteException; }

RMI/server package SimpleStocks; import java.rmi.*; import java.rmi.server.UnicastRemoteObject; public class StockMarketImpl extends UnicastRemoteObject implements StockMarket { public StockMarketImpl( String name ) throws RemoteException { try { Naming.rebind( name, this ); } catch( Exception e ) { System.out.println( e ); } } public float get_price( String symbol ) { float price = 0; for( int i = 0; i < symbol.length(); i++ ) { price += (int) symbol.charAt( i ); } price /= 5; return price; } }

RMI/server-deploy import java.rmi.*; import java.rmi.server.UnicastRemoteObject; import SimpleStocks.*; public class StockMarketServer { public static void main(String[] args) throws Exception { if(System.getSecurityManager() == null) { System.setSecurityManager( new RMISecurityManager() ); } StockMarketImpl myObject = new StockMarketImpl( "NASDAQ" ); System.out.println( "RMI StockMarketServer ready..." ); } }

RMI/policy.all grant { permission java.security.AllPermission "", ""; };

RMI/server start Compile the Files, generate the stubs & skeletons, startup the RMIRegistry and Run the Server E:\MyProjects\StockRMI\SimpleStocks> E:\MyProjects\StockRMI\SimpleStocks>javac *.java E:\MyProjects\StockRMI\SimpleStocks>cd.. E:\MyProjects\StockRMI>rmic SimpleStocks.StockMarketImpl E:\MyProjects\StockRMI>javac *.java E:\MyProjects\StockRMI>start rmiregistry E:\MyProjects\StockRMI>java -Djava.security.policy=policy.all StockMarketServer RMI StockMarketServer ready...

RMI/client import java.rmi.*; import java.rmi.registry.*; import SimpleStocks.*; public class StockMarketClient { public static void main(String[] args) { try { if(System.getSecurityManager() == null) { System.setSecurityManager( new RMISecurityManager() ); } StockMarket market = (StockMarket)Naming.lookup("rmi://localhost/NASDAQ"); System.out.println( "The price of MY COMPANY is " + market.get_price("MY_COMPANY") ); } catch( Exception e ) { System.out.println( e ); } } }

RMI/policy.all grant { permission java.security.AllPermission "", ""; };

RMI/run the client Compile the files and run the client E:\MyProjects\StockRMI> E:\MyProjects\StockRMI>javac *.java E:\MyProjects\StockRMI>java - Djava.security.policy=policy.all StockMarketClient The price of MY COMPANY is E:\MyProjects\StockRMI>

Conclusion We covered quite a few concepts. Any questions???