Distribution Transparency in C# Klaus-Peter Löhr Institut für Informatik Freie Universität Berlin www.inf.fu-berlin.de.

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
Advertisements

Three types of remote process invocation
RMI Varun SainiYing Chen. What is RMI? RMI is the action of invoking a method of a remote interface on a remote object. It is used to develop applications.
.Net Remoting Pooja Panjala 06/17/10. Agenda What is.net Remoting? Explanation of terms Architecture Implementation of Remoting Sample example.net Security.
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.
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.
Remote Method Invocation
1 Advanced Programming Topics - II Objectives:  Background  Remoting  Types of remoting  Marshalling  Farmatters  Channels.
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.
1 HANDOUT 14 Remote Method Invocation (RMI) BY GEORGE KOUTSOGIANNAKIS THIS DOCUMENT CAN NOT BE REPRODUCED OR DISTRIBUTED WITHOUT TH E WRITTEN PERMISSION.
CS490T Advanced Tablet Platform Applications Network Programming Evolution.
EEC-681/781 Distributed Computing Systems Lecture 5 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
Distributed Systems Tutorial 2 -.NET Remoting. 2 What is Remoting?  Remoting allows you to pass objects or values across servers in different domains.
Introduction to Remote Method Invocation (RMI)
OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 5: Distributed Objects.
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.
Java RMI RMI = Remote Method Invocation. Allows Java programs to invoke methods of remote objects. Only between Java programs. Several versions (JDK-1.1,
Lesson 3 Remote Method Invocation (RMI) Mixing RMI and sockets Rethinking out tic-tac-toe game.
Task Bag A Distributed System using the.NET Framework and Remoting Frank McCown Old Dominion University Spring 2005 CS 875 Distributed Systems - Final.
.Net Remoting. 2 Distributed Computing under.Net In.Net, there are three levels of access to distributed computing machinery: In.Net, there are three.
1 Java Programming II Java Network II (Distributed Objects in Java)
Presentation: SOAP in a distributed object framework, Application Servers & AXIS SOAP.
CSCI 6962: Server-side Design and Programming Web Services.
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
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.
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.
Presentation: RMI Continued 2 Using The Registry & Callbacks.
LAB 1CSIS04021 Briefing on Assignment One & RMI Programming February 13, 2007.
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.
Systems Prog. & Script. - Heriot Watt Univ 1 Systems Programming & Scripting Lecture 11: The Distributed Object Model.
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.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
.NET Mobile Application Development XML Web Services.
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.
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.
Presentation 24 Ultra Simple.NET Remoting to CORBA bridge.
CSC 480 Software Engineering Lab 6 – RMI Nov 8, 2002.
Netprog Java RMI1 Remote Method Invocation.
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.
.NET Remoting. Remoting Introduction The process of programs or components interacting across certain boundaries either different processes or machines.
Distributed Web Systems Distributed Objects and Remote Method Invocation Lecturer Department University.
.NET Remoting Priyanka Bharatula.
Broker in practice: Middleware
Remote Method Invocation
Presentation 23 .NET Remoting Introduced
Advanced .NET Programming II 10th Lecture
Remote Method Invocation
Creating a Distributed System with RMI
Creating a Distributed System with RMI
Remote Method Invocation
Creating a Distributed System with RMI
Java Remote Method Invocation
Jim Fawcett CSE791 – Distributed Objects Spring 2002
Creating a Distributed System with RMI
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Distribution Transparency in C# Klaus-Peter Löhr Institut für Informatik Freie Universität Berlin

Distribution Transparency (a.k.a. Network Transparency) = access transparency + location transparency DT as a property of a programming language and its supporting environment: a language system is dt if any program written in the language  looks like a „regular“ (centralized, non-distributed) program,  can be executed in a distributed fashion,  behaves no different if executed in a distributed instead of a centralized fashion.

„DT is a boon!“(the purists) „DT is a red herring!“(Waldo et al.) DT is more a quantitative than a qualitative property. A good amount of DT can be useful for many applications.

The two extremes No DT:- explicit message passing instead of remote invocation, or - syntactical access transparency, but differring semantics for remote invocation; - explicit handling of remote hosts and processes, of channel and ports; - program management: explicit stub generation (if any), program configuration, code placement,..... Perfect DT governed by - compilation/linking options, - platform switches, - configuration files.

Outline Basics of.NET Remoting Parameter Passing Remote Event Handling Assessment

Basics of.NET Remoting using C# notation Terminology: X remote invocation x clientserver clientserver

Remote Invocation: object x can be invoked remotely if these requirements are met:  its class X inherits from System.MarshalByRefObject : class X : MarshalByRefObject {..... public void op(string message) { Console.WriteLine(message); }  a server port number has explicitly been registered by the server;  the client has somehow got a remote reference to the object x.

clientserver ChannelServices.RegisterChannel( new TcpServerChannel(null, 4711); X rem = // create and publish x // get hold of x x.op("hello on server"); // local test.....Console.WriteLine( "Hit ENTER for shutting down server:"); rem.op("helloConsole.ReadLine(); from client"); // remote call.....

Remote Access to fields and properties: value = rem.age; works fine, and so does rem.age = value; ! Also holds for properties of class X : public int age { set... get... }

Publishing a local object for sharing: X x = new X(...);// local creation RemotingServices.Marshal(x,"publicX"); // publishing Client gets hold of the object named publicX in this way: X rem = (X)Activator.GetObject( typeof(X), "tcp://host:4711/publicX");

Remote Creation of private objects: Server must be prepared: RemotingConfiguration. RegisterActivatedServiceType(typeof(X)); Console.WriteLine( "Hit ENTER for shutting down server:"); Console.ReadLine(); Client has several options, among them: object[] attr = {new UrlAttribute("tcp://host:4711")}; object[] args = {...}; // constructor arguments object o = Activator.CreateInstance(typeof(X),args,attr); X rem = (X)o;

Program Management:compile X, compile server, compile client, install compiled server+ X on host, install compiled client+ X, start server hello on server start client hello from client then

Java RMIvs..NET Remoting Object and its proxy must shareTransparent proxy, can be cast to X a common interface RemoteException s must beno such requirement handled or declared Publishing requires extra naming no such requirement service ( rmiregistry ) Advance proxy/skeleton generationno such requirement (generation ( rmic X )on the fly from class metadata) not supportedRemote creation

Parameter Passing Parameter modes: int op( int a, // call-by-value argument out int b, // call-by-result argument ref int c) // call-by-reference argument result void inc(bool cond, ref int x, ref int y) { if(cond) x++; else y++; } ? Effect of x.inc(cond, a[i], a[k]); ! If x happens to be remote and cond && i == k then a is not modified ! BUT CAUTION with remote calls: ref works call-by-value-result :

! MORE CAUTION if actual parameter is object reference:  if object is remotely invokable: remote reference to object is handed out  if object is serializable: reference to local copy is handed out  if neither: exception is raised class RemoteStack : MarshalByRefObject { int[] stack = new int[100];..... public int[] dump() { return stack; } // arrays are serializable!..... }

RemoteStack a = rem.dump(); a rem a[0] = 8; x = rem.bot(); x == 0 RemoteStack x == 8 client server

Remember: in a distributed setting, you may not know whether or not an object is a MarshalByRefObject and if it is, whether or not it is indeed remote from the client -  unpredictable invocation semantics ! interface IStack {... } class RemStack : MarshalByRefObject, IStack {... } class Stack : IStack {... }..... void op(IStack stack) {..... }

Remote Event Handling Language supports observer pattern: classObserved { public delegate void ringHandler(.,.); public event ringHandler ring; // signal event:... ring(.,.);... } class Observer {... Observed x;... // subscribe to event: x.ring += new Observed. ringHandler(beep);... public void beep(.,.) {... // do beep} }

classObserved: Marshal.. { public delegate void ringHandler(.,.); public event ringHandler ring; // signal event:... ring(.,.);... } class Observer: Marshal.. {... Observed x;... // get remote x // subscribe to event: x.ring += new Observed. ringHandler(beep);... public void beep(.,.) {... // do beep} } Distributed version works fine, too: observer machine observed machine static ?? Subscription causes Observer class to be reinstantiated at observed site  Observed machine starts beeping !

Assessment  C#/CLR is richer than Java/JVM - curse or boon? .NET Remoting is more distribution-transparent than Java RMI, BUT does not avoid all of Java‘s transparency deficiencies AND introduces new ones along with the new features  Other important facets of.NET Remoting:  Achieve more transparency through configuration files (XML)  Http channels (as opposed to Tcp channels) support XML- coded remote invocation (SOAP)  Web Services ... more

Reference Web Resources: msdn.microsoft.com/library msdn.microsoft.com/library : search for.NET Remoting Book: Ingo Rammer: Advanced.NET Remoting. APress 2002 These slides: Code samples follow on slides below

// file server.cs: creates private RemText objects for clients on demand // compile with csc server.cs, producing server // compile with csc /t:library server.cs, producing server.dll using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Activation; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; public class RemText : MarshalByRefObject { public static void Main() { ChannelServices.RegisterChannel(new TcpServerChannel(4711)); RemotingConfiguration.RegisterActivatedServiceType(typeof(RemText)); Console.WriteLine("Hit ENTER to stop server."); Console.ReadLine(); } string text; public RemText(string init) { Console.WriteLine("Text object created."); text = init; } public void replace(string s) { Console.WriteLine("replacing " + text + " with " + s); text = s; return; } public string remove() { if(text==null) throw new Exception("nothing to remove"); string result = text; text = null; Console.WriteLine("removing " + result); return result; } }

// file client.cs: remote creation and invocation of a RemText object // compile with csc /r:server.dll client.cs, producing client // test: start server in separate window, // start client using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Activation; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; public class Test { public static void Main() { Console.WriteLine("Create remote text object..."); object[] attr = {new UrlAttribute("tcp://localhost:4711")}; object[] args = {"initial text"}; // constructor argument RemText text = (RemText)Activator.CreateInstance( typeof(RemText), args, attr); Console.WriteLine("Invoke object..."); Console.WriteLine(text.remove()); // should write "initial text" Console.WriteLine("Hit ENTER for another try:"); Console.ReadLine(); Console.WriteLine(text.remove()); // should raise exception }

// File od.cs: Observed code // compile with csc od.cs, producing od // compile with csc /t:library od.cs, producing od.dll using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; public class Observed : MarshalByRefObject { public static void Main() { ChannelServices.RegisterChannel(new TcpServerChannel(null, 4711)); Observed observed = new Observed(); Console.WriteLine("Register observed..."); RemotingServices.Marshal(observed,"observed object"); for(;;) {Console.Write("Hit ENTER to signal event:"); Console.ReadLine(); observed.ring(null,null); } public delegate void ringHandler(object source, EventArgs args); // mandatory signature for event handlers public event ringHandler ring; }

// File or.cs: Observer code // compile with csc /r:od.dll or.cs, producing or // test: start od in separate window, // start or, // hit ENTER in od window using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Activation; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; public class Observer : MarshalByRefObject { public static void Main() { ChannelServices.RegisterChannel(new TcpServerChannel(null, 4712)); Console.WriteLine("Get observed object..."); Observed observed = (Observed)Activator.GetObject( typeof(Observed), "tcp://localhost:4711/observed object"); Observer observer = new Observer(observed); Console.ReadLine(); // wait for events } public Observer(Observed observed) { Console.WriteLine("Subscribe to observed object..."); observed.ring += new Observed.ringHandler(beep); } public void beep(object o, EventArgs a) {Console.WriteLine("beep"); }