Telecooperation Technische Universität Darmstadt Copyrighted material; for TUD student use only 1 Exercise TK3 Assigment 2: RMC & WorldView FG Telekooperation.

Slides:



Advertisements
Similar presentations
Network II.5 simulator ..
Advertisements

Three types of remote process invocation
Telecooperation/RBG Technische Universität Darmstadt Copyrighted material; for TUD student use only Introduction to Computer Science I Topic 14: Stepwise.
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
COS 461 Fall 1997 Network Objects u first good implementation: DEC SRC Network Objects for Modula-3 u recent implementation: Java RMI (Remote Method Invocation)
Telecooperation/RBG Technische Universität Darmstadt Copyrighted material; for TUD student use only Introduction to Computer Science I Topic 16: Exception.
RPC Robert Grimm New York University Remote Procedure Calls.
A1.1 Assignment 1 “Deploying a Simple Web Service”
Copyright © 2001 Qusay H. Mahmoud RMI – Remote Method Invocation Introduction What is RMI? RMI System Architecture How does RMI work? Distributed Garbage.
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.
C# and Windows Programming Application Domains and Remoting.
Remote Method Invocation
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 42 Web Services.
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.
Java RMI. What is RMI? RMI is an RPC system for an object based language. Objects provide a natural granularity for the binding of functions. –RMI allows.
How Does Remote Method Invocation Work? –Systems that use RMI for communication typically are divided into two categories: clients and servers. A server.
Integration case study Week 8 – Lecture 1. Enrolment request (Workstation) Application server Database server Database New University Student Record System.
Remote Procedure Calls. 2 Client/Server Paradigm Common model for structuring distributed computations A server is a program (or collection of programs)
Telecooperation Technische Universität Darmstadt Copyrighted material; for TUD student use only 1 Exercise TK3 Assigment 3: Application Scenario FG Telekooperation.
JavaScript & jQuery the missing manual Chapter 11
Beyond DHTML So far we have seen and used: CGI programs (using Perl ) and SSI on server side Java Script, VB Script, CSS and DOM on client side. For some.
© Keren Kalif Intro to Android Development Written by Keren Kalif, Edited by Liron Blecher Contains slides from Google I/O presentation.
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
Designing For Testability. Incorporate design features that facilitate testing Include features to: –Support test automation at all levels (unit, integration,
1 HRS2422 Web Services JAX-WS and SOAP Introduction  Web service – A software component stored on one computer that can be accessed via method.
Guidelines for Homework 6. Getting Started Homework 6 requires that you complete Homework 5. –All of HW5 must run on the GridFarm. –HW6 may run elsewhere.
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
CSCI 6962: Server-side Design and Programming Web Services.
+ A Short Java RMI Tutorial Usman Saleem
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
LAB 1CSIS04021 Briefing on Assignment One & RMI Programming February 13, 2007.
Chapter 6 Server-side Programming: Java Servlets
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
Distributed Programming CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
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.
RMI Remote Method Invocation Distributed Object-based System and RPC Together 2-Jun-16.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
Homework Assignment #1 J. H. Wang Oct. 13, Homework #1 Chap.1: 1.24 Chap.2: 2.13 Chap.3: 3.5, 3.13* (or 3.14*) Chap.4: 4.6, 4.12* –(*: optional.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 43 Remote Method Invocation.
Update on CORBA Support for Babel RMI Nanbor Wang and Roopa Pundaleeka Tech-X Corporation Boulder, CO Funded by DOE OASCR SBIR.
CS-2851 Dr. Mark L. Hornick 1 Generic Java Classes Implementing your own generic classes.
Chapter 5: Distributed objects and remote invocation Introduction Remote procedure call Events and notifications.
IBM TSpaces Lab 2 Customizing tuples and fields. Summary Blocking commands Tuple Expiration Extending Tuples (The SubclassableTuple) Reading/writing user.
Remote Method Invocation with Java-RMI
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
.NET Mobile Application Development XML Web Services.
Java Object-Relational Layer Sharon Diskin GUS 3.0 Workshop June 18-21, 2002.
Distributed Computing & Embedded Systems Chapter 4: Remote Method Invocation Dr. Umair Ali Khan.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 29 Remote Method.
Topic 4: Distributed Objects Dr. Ayman Srour Faculty of Applied Engineering and Urban Planning University of Palestine.
Distributed Web Systems Distributed Objects and Remote Method Invocation Lecturer Department University.
Apache Axis2 XML Based Client API.
Java Distributed Computing
Principles of Software Development
Chapter 5 Remote Procedure Call
Google Web Toolkit Tutorial
Data Transport for Online & Offline Processing
Java Distributed Computing
Remote Method Invocation
Remote Method Invocation
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
Chapter 46 Remote Method Invocation
Remote Procedure Call Hank Levy 1.
Chapter 46 Remote Method Invocation
Chapter 42 Web Services.
Remote Procedure Call Hank Levy 1.
Remote Procedure Call Hank Levy 1.
Presentation transcript:

Telecooperation Technische Universität Darmstadt Copyrighted material; for TUD student use only 1 Exercise TK3 Assigment 2: RMC & WorldView FG Telekooperation Prof. Dr. Max Mühlhäuser Daniel Schreiber

Prof. Dr. M. Mühlhäuser Telekooperation © Exercise Groups 2

Prof. Dr. M. Mühlhäuser Telekooperation © 3 RMC RMC with MundoCore –MCC precompiler WorldView Outline

Prof. Dr. M. Mühlhäuser Telekooperation © Pub/Sub with MundoCore //sending a message: public void run() { //… TypedMap map = new TypedMap(); map.putString("ln", ln); publisher.send(new Message(map)); //… } //receiving a message public void received(Message msg, MessageContext ctx) { System.out.println(msg.getMap().getString("ln")); } 4

Prof. Dr. M. Mühlhäuser Telekooperation © 5 Publish Subscribe Chat Disadvantage: Messages have to be created and parsed “by hand” (new Message() …)

Prof. Dr. M. Mühlhäuser Telekooperation © A More Complex Example 6 public void foo(int a) { } public void bar(String b) { } //parsing the message and dispatching to methods public void received(Message msg, MessageContext ctx) { String method = msg.getMap().getString(“call")); if (“foo”.equals(method)) { foo(msg.getMap().getInt(“p0")); } if (“bar”.equals(method)) { foo(msg.getMap().getString(“p0")); }

Prof. Dr. M. Mühlhäuser Telekooperation © RMC Message dispatch Parameter marshalling RMC means: This is done by the middleware you just implement foo and bar and the middleware takes care of dispatching and marshalling 7 String method = msg.getMap().getString(“call")); if (“foo”.equals(method)) { … } if (“bar”.equals(method)) { … } foo(msg.getMap().getString(“p0"));

Prof. Dr. M. Mühlhäuser Telekooperation © 8 Remote Method Call Chat RMC builds upon Publish/Subscribe Same syntax for local and remote method calls Service provides methods via interface: Service subscribes for service requests Service publishes service results Marshalling/Demarshalling of parameters needed MarshallingDemarshalling Service

Prof. Dr. M. Mühlhäuser Telekooperation © RMC with MundoCore Java 9 o2: MyService MyService void foo(int a) o1: MyClient MyClient MyService do do = o2 o2.foo(5); MundoCore Node A MundoCore Node B

Prof. Dr. M. Mühlhäuser Telekooperation © RMC with MundoCore Java 10 o2: MyService MyService void foo(int a) o1: MyClient MyClient MyService do do = o2 o2.foo(5); MundoCore Node A MundoCore Node B This does not work! 1.class MyService must be declared in Node A 2.o2 has no address in Node A 3.implementation of MyService (Node B) should work without manual dispatch

Prof. Dr. M. Mühlhäuser Telekooperation © RMC with MundoCore Java 11 o2: MyService MyService void foo(int a) o1: MyClient MyClient DoMyService do do = o2 MundoCore Node A MundoCore Node B DoMyService void foo(int a) o2: DoMyService SrvMyService s: SrvMyService MyService o o = o2 o2.foo(5);

Prof. Dr. M. Mühlhäuser Telekooperation © What do the helper classes do? SrvMyService contains a generic dispatch method –look at message –decide which method to call –parse parameters –call method of associated object –create a message with results –send via MundoCore pub/sub DoMyService contains a generic MundoCore wrapper –create a message with method name and parameters –send via MundoCore pub/sub –[wait for result] –[return result to caller] 12

Prof. Dr. M. Mühlhäuser Telekooperation © Advantages / Disadvantages of RMC + code is much more readable + MundoCore handling is isolated in one place - client must have interface description from server - need to write lots of boilerplate code This can be avoided by using a precompiler!! Mundo contains the mcc precompiler Have a look in the ant build file –files in prep directory are created by mcc –caveat: Eclipse does not know when to invoke mcc! 13

Prof. Dr. M. Mühlhäuser Telekooperation © 14 Creating Distributed Objects Creating the boilerplate code for distributed objects: MundoCore (Pre-)Compiler –creates client- and server-stubs –creates code for serializer and deserializer Rerun mcc whenever the interface changes! MyService.java DoMyService.java SrvMyService.java mcc Client-Stub, „Distributed Object“ Server-Stub Must be available at the client!!

Prof. Dr. M. Mühlhäuser Telekooperation © Generating Do… from interface only Normally mcc does not have access to server implementation MyService –e.g. service provider only publishes WSDL DoMyService must be created from interface The following class must be generated by mcc from WSDL mcc –I 15 import org.mundo.service.wmstore.WMStoreService; import org.mundo.service.wmstore.DoWMStoreService;

Prof. Dr. M. Mühlhäuser Telekooperation © 16 How to make methods RMC-able? Serviceclasses have to be marked Remote available methods have to be marked mcc creates the required stubs class ChatService extends Service { public void chatMessage(String msg) { System.out.println(msg); }

Prof. Dr. M. Mühlhäuser Telekooperation © 17 Connecting RMC Server & Client Server: public boolean init() { … Signal.connect(getSession().subscribe("lan", "chat_rmc"), this); … } Client DoMyService stub = new DoMyService(); Signal.connect(stub,getSession().publish("lan", "chat_rmc")); –If you invoke a method on the stub object, it will be called on all objects of class MyService listening to „chat_rmc“ –For invoking the method only on one distributed objects, you need to store the reference to this object and invoke the method directly on it.

Prof. Dr. M. Mühlhäuser Telekooperation © 18 Method invocations Synchron: Client is blocked until result is returned One-way („fire and forget“): Client invokes method, but does not wait for the answer Asynchron: Client invokes method, but retrieves answer later or specifies callback method that is called as soon as the result is available

Prof. Dr. M. Mühlhäuser Telekooperation © 19 Method invocations II All methods that are available via RMC are extended by an additional parameter that specifies the type of method invocation: –Synchron: stub.chatMessage(„hallo“); –One-way („fire and forget“) stub.chatMessage(„hallo“, DoChatService.ONEWAY); –Asynchron to retrieve returnvalue later: AsyncCall callObject = stub.add(1, 2, DoCalculator.ASYNC); … int result = ((Integer)callObject.getObj()).intValue(); or to specify a callback method: AsyncCall callObject = stub.add(1, 2, DoCalculator.CREATEONLY); callObject.setResultListener(new AsyncCall.IResultListener() { public void resultReceived(AsyncCall callObject) { int rslt = ((Integer)callObject.getObj()).intValue(); } }); callObject.invoke();

Prof. Dr. M. Mühlhäuser Telekooperation © 20 De/Marshalling To use an object as parameter / returnvalue classes need to be serializable Primitive datatypes, references on distributed objects (Do…) are serializable Serializing own classes: –mcc can build serializing metadata for own classes. For that purpose these classes have to be marked All public fields need to be serializable The class has to specify a public nullary constructor –Resulting classes start with Meta… –Mapping from classname to metaclass is configured in file metaclasses.xml  needs to be in the path! –Eclipse may cause problems  What is the path?

Prof. Dr. M. Mühlhäuser Telekooperation © 21 De/Marshalling Example: „name“ can be transmitted by-value To transmit „address“ by-value needs to be serialized: KeyTypeValue “name”String“Max Mühlhäuser” “address”Address Street=… City=… KeyTypeValue “address”Address KeyTypeValue „Street“StringHochschulstr. “City”StringDarmstadt

Prof. Dr. M. Mühlhäuser Telekooperation © 22 De/Marshalling To transmit „address“ by-reference: Each distributed object has a unique ID that corresponds to the channelname they are subscribed to. The object that invokes the method adds its ID to the message to receive results KeyTypeValue “address”DoAddressID: AB456

Prof. Dr. M. Mühlhäuser Telekooperation © DeMarshalling 23 KeyTypeValue “address”Address KeyTypeValue „Street“StringHochschulstr. “City”StringDarmstadt public class MetaAddress { void activate(Object o, TypedMap m) { Address t=(Address)o; Address.street = m.getString(„Street“); … } } Address Object Metaclass

Prof. Dr. M. Mühlhäuser Telekooperation © WorldView UbiComp applications often involve real world data Entering and leaving the room to test your ContextAwareLightSwitch is impractical Idea: Simulate the sensor data for testing purposes Mundo provides the WorldView Tool for this WorldView allows to –view, edit and create world models –simulate sensor data by moving the model elements –update model elements based on sensor data 24

Prof. Dr. M. Mühlhäuser Telekooperation © WorldView II 25 simulated world, simulated sensors „WorldView“ real world via sensors application automatic updates MundoCore events Testing of application, testing of real world sensors

Prof. Dr. M. Mühlhäuser Telekooperation © 26 Assignment 2 Download, compile & run WorldView Create a WorldModel and save it Implement a MundoCore service LightSwitch Implement a ContextAwareLightSwitch service Implement your own Lamp service

Prof. Dr. M. Mühlhäuser Telekooperation © WorldView Download at: run with java –jar worldview.jar 27

Prof. Dr. M. Mühlhäuser Telekooperation © Adding Items Room: Tool -> Rectangle –add pickable classes „region“ –give the rectangle a name Light: Tool -> Building Automation -> Lamp –set the channel the lamp listens on Location Tracking: Tool -> Mundo IRIS -> Badge & Camera 28

Prof. Dr. M. Mühlhäuser Telekooperation © Simulating Sensor Data set a channel for IRIS Camera start IRIS Cient: File -> Iris Client check the „simulate“ box have a look at the events generated by moving the IRIS Badge around in Inspect 29

Prof. Dr. M. Mühlhäuser Telekooperation © Saving the new World Start the „worldmodelstore“ –wmstore.zip from homepage –java –jar wmstore-app.jar File -> Upload –The World is now available for all other services in the WorldModel store –This needs to be done after creating or loading a new world in WorldView File -> Save As… –save as a file, so you can load it later 30

Prof. Dr. M. Mühlhäuser Telekooperation © Accessing the WorldModel wmstore stores WorldModel in wmstore-db.xml To access the worldmodel clients can use an API via RMC example: wmstore-querytest mcc needs to know the interface of WMStore to generate DoWMStore (see slide 15) interfaces in interfaces.zip Look at the ant file in wmstore-querytest.zip 31

Prof. Dr. M. Mühlhäuser Telekooperation © Service LightSwitch skeleton provided in lamp.zip on the homepage should start with java –cp /…/mundocore.jar LightSwitch Reads from the command-line –‚1‘ turns the light on –‚0‘ turns the light off –‚?‘ outputs the current state of the light Use RMC –use mcc to create the stub DoLamp from org.mundo.bas.Ilamp –Ilamp is defined in interfaces.zip –mcc -09 –x –Oprep –I../interfaces src/*.java –will generate stubs in dir prep –connecting to the lamp in WorldView see the example on slide 16 32

Prof. Dr. M. Mühlhäuser Telekooperation © Your LampServer Imagine you want to provide a real implementation of the LightService, e.g. a LED controlled via RS232 Write a MundoCore Service –that implements the ILamp interface –can be used by your LightSwitch via MundoCore RMC –controls a real LED… or outputs „on“ / „off“ on the console –You need to connect an instance of your service to a MundoCore channel like shown on slide 16 33

Prof. Dr. M. Mühlhäuser Telekooperation © Service ContextAwareLightSwitch connect to the IRIS event Channel –IRIS events contain serialized IRISSpaceCoordTable object –IRIS classes are contained in interfaces.zip –see example in iris-receiver.zip whenever you receive an event, compute whether a user is in a „room“ If user is in room  turn light on, else turn light off You need to query the WorldModel to compare user coordinates with room coordinates –Look at the example in wmstore-querytest.zip –we will test your service with our own worldmodels You can also get channel information, lamps… from worldmodel 34

Prof. Dr. M. Mühlhäuser Telekooperation © Grading Hand in a zip file containing: A screenshot of your world in WorldView 5% the corresponding wmstore-db.xml from wmstore 5% The sourcecode and build instructions (or ant files) for your services –LightSwitch 25% –ContextAwareLightSwitch 30% –LightService implementation 25% a video / screencast showing how the ContextAwareLightSwitch is working 10% Deadline: Sunday :00 35