1 Nordjyllands Erhvervakademi - 2009.Net Remoting Architecture Marshalling –Marshalling By Reference(MBR) –Marshalling By Value(MBV) Activation by MBR.

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
Advertisements

What is RMI? Remote Method Invocation –A true distributed computing application interface for Java, written to provide easy access to objects existing.
1 Nordjyllands Erhvervakademi Web Services Purpose Examples of Web Services Architecture Web Services in.Net.
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.
Copyright © 2002 Landl Software, Inc. All Rights Reserved. Twin Cities.NET Users Group Next Meeting - Thursday, April 4, 2002 A Look Inside Reflection.
.NET Remoting in Delphi and C# Alain “Lino” Tadros President & CEO Falafel Software Inc. ComponentScience Inc. BORCON 2004.
.Net Remoting Pooja Panjala 06/17/10. Agenda What is.net Remoting? Explanation of terms Architecture Implementation of Remoting Sample example.net Security.
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.
.NET REMOTING CertSIG Tom Perkins. FUNDAMENTALS Distributed Applications Process A Process B Process C Objects can communicate across process boundaries.
Author: Bill Buchanan. Authentication (to identify the clients of your application) Authorization (to provide access controls for those clients) Secure.
.NET Remoting. .Net Remoting Replaces DCOM (Distributed Component Object Model – a proprietary Microsoft technology for communication among software components.
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.
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
CSE331: Introduction to Networks and Security Lecture 11 Fall 2002.
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)
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
.NET Remoting A Distributed Application Cookbook.
.NET, and Service Gateways Group members: Andre Tran, Priyanka Gangishetty, Irena Mao, Wileen Chiu.
CIS NET Applications1 Chapter 10 – Remoting.
.NET Remoting Architecture. Slide 2 CITE 4420.NET Remoting Topics Remoting Boundaries Crossing the Boundaries Distributed Applications Marshalling Channels.
Java RMI Essentials Based on Mastering RMI Rickard Oberg.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 12 Communicating over.
An program As a simple example of socket programming we can implement a program that sends to a remote site As a simple example of socket.
Jozef Goetz, Application Layer PART VI Jozef Goetz, Position of application layer The application layer enables the user, whether human.
1 UCN / IT Distributed Programming Web Services Purpose Examples of Web Services Architecture Web Services in.Net.
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.
Develop Distributed Applications using.NET Remoting Kate Gregory Regional Director Gregory Consulting Limited
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.
Presentation 23.NET Remoting Introduced. Ingeniørhøjskolen i Århus Slide 2 af 20 Outline.NET Framework introduced.NET Remoting strategies Architecture.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
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.
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.
Presentation: RMI Continued 2 Using The Registry & Callbacks.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
.Net Remoting The Other RPC Architecture Doug Gregory October 27, 2003.
Java Remote Method Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
Web Services An Introduction Copyright © Curt Hill.
Presentation: RMI Continued 2 Using The Registry & Callbacks.
.NET Mobile Application Development XML Web Services.
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.
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.
.NET Remoting. Remoting Introduction The process of programs or components interacting across certain boundaries either different processes or machines.
RMI (Java RMI) P 460 in text UUIDs / system wide references Transparent: all objects either by ref. or by value. Not efficient, especially int, bool, etc.
.NET Remoting Priyanka Bharatula.
Java Remote Method Invocation (RMI)
Remote Method Invocation
Presentation 23 .NET Remoting Introduced
Advanced .NET Programming II 10th Lecture
What is RMI? Remote Method Invocation
Remote Method Invocation
Programming Models for Distributed Application
Java Remote Method Invocation
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

1 Nordjyllands Erhvervakademi Net Remoting Architecture Marshalling –Marshalling By Reference(MBR) –Marshalling By Value(MBV) Activation by MBR –Well-Known Object(WKO) Singleton SingleCall –Client-Activated Object(CAO)

2 Nordjyllands Erhvervakademi Architecture Marshalling –Marshalling By Reference(MBR) –Marshalling By Value(MBV) Activation by MBR –Well-Known Object(WKO) Singleton SingleCall –Client-Activated Object(CAO)

3 Nordjyllands Erhvervakademi Why remoting? The advanced of remoting is a common platform on both sides: –Allows use of a proprietary communication protocol –Allows use of a proprietary dataformat Meaning? –More efficient Examples of proprietary technologies: –COM (MS) –CORBA (omg.com) –RMI (Java) There might be different OS's on client and server i.e. Windows and Linux Server.exe (.NET) Client.exe (.NET)

4 Nordjyllands Erhvervakademi Why use remoting? To connect tiers within the same application... –client & server is both.NET assemblies Example: –A typical business app has Business and Data Access tiers –GUI calls into the business tier to get data, calculation & validation –Business tier makes calls to the data tier for writing / reading data DB DTBT Client (.NET) Server (.NET) Business Tier Data Access Tier

5 Nordjyllands Erhvervakademi Remoting seen from the client and server The client sees the server as an assembly.DLL –sets a reference to a object as normally The server makes.DLL available in one of two ways: 1.Runs as a service on the server, that responds on remote calls 2.Runs in the web server & trigger remote calls via URL –advances? #1 can use proprietary protocols & formats (more efficient) #2 is firewall-friendly, easy use of Windows security Client.exe.DLL Server

6 Nordjyllands Erhvervakademi In principle

7 Nordjyllands Erhvervakademi Proxy pattern

8 Nordjyllands Erhvervakademi Design, more detailed Business and calculation objects lives on the server Data objects marshals to the clients Client Data call ProxyDataStubComp Client DataProxy Server call DataStubComp

9 Nordjyllands Erhvervakademi Architecture Marshalling –Marshalling By Reference(MBR) –Marshalling By Value(MBV) Activation by MBR –Well-Known Object(WKO) Singleton SingleCall –Client-Activated Object(CAO)

10 Nordjyllands Erhvervakademi Marshalling models Marshalling By Reference(MBR) –The object lives on the server. –It can exist as a well-known object (WKO) that either: is created each time a service is requested[SingleCall] (and deleted afterwards) or shared by all clients. [Singleton] It is created first time a service is called –It can also exist as a Client Activated Object (CAO). Here is it the application domain of the client that controls life and death

11 Nordjyllands Erhvervakademi Marshalling models Marshalling By Value(MBV) –The object is created on the server then serialized and send to the client. –State changes of the object on the client side are not registried on the server –Is often a return value from a public method from a MBR object

12 Nordjyllands Erhvervakademi Eksample.... of MBR and MBV

13 Nordjyllands Erhvervakademi Procedure: Steps: 1.Mark data objects as serializable [Serializable] 2.Define the remote interface (which services are possible) 3.The remote object have to –implement the remote interface –inherit from MarshalByRefObject –have a default constructor (a parameter less constructor) 4.On the server side: 1.Create and register a channel type 2.Register the remote service 5.On the client side: 1.Register server connection 2.Create a reference to the remote object Note: The interface but not the implementing class should be available on the client.

14 Nordjyllands Erhvervakademi Exsample: Step 1: The data object: [Serializable] //Makes Customer a MBV public class Customer { String _firstName; String _lastName; DateTime _dateOfBirth; public Customer() {...} public String FirstName{ get { return _firstName; } set { _firstName = value; } } public String LastName{.... //omitted on slide} public DateTime DateOfBirth{.... //omitted on slide} public int GetAge(){ TimeSpan tmp = DateTime.Today.Subtract(DateOfBirth); return tmp.Days / 365; } }

15 Nordjyllands Erhvervakademi Step 2: Interface public interface ICustomerManager { Customer GetCustomer(int id); }

16 Nordjyllands Erhvervakademi Step 3: Implement the remote objekt class CustomerManager : MarshalByRefObject, ICustomerManager { public CustomerManager() { Console.WriteLine("CustomerManager Created"); } public Customer GetCustomer(int id) { Console.WriteLine("CustomerManager.GetCustomer called"); Customer tmp = new Customer(); tmp.FirstName = "John"; tmp.LastName = "Doe"; tmp.DateOfBirth = new DateTime(1970, 7, 4); return tmp; }

17 Nordjyllands Erhvervakademi Step 4: Implement the server Set up the socket communication (protocol and port) class ServerStartup { static void Main(string[] args) { Console.WriteLine("Start service"); HttpChannel channel = new HttpChannel(1234); ChannelServices.RegisterChannel(channel, false); RemotingConfiguration.RegisterWellKnownServiceType( typeof(CustomerManager), "CustomerManager.soap”, WellKnownObjectMode.Singleton); Console.WriteLine("Service startet"); Console.ReadLine(); }

18 Nordjyllands Erhvervakademi Step 4: Implement the server Register the object, CustomerManager, as a remote object, reference id on the server (CustomerManager.soap) and WKO mode class ServerStartup { static void Main(string[] args) { Console.WriteLine("Start service"); HttpChannel channel = new HttpChannel(1234); ChannelServices.RegisterChannel(channel); RemotingConfiguration.RegisterWellKnownServiceType( typeof(CustomerManager), "CustomerManager.soap”, WellKnownObjectMode.Singleton); Console.WriteLine("Service startet"); Console.ReadLine(); }

19 Nordjyllands Erhvervakademi Step 5: Implement the client Set up the socket static void Main(string[] args) { try { HttpChannel channel = new HttpChannel(); ChannelServices.RegisterChannel(channel); ICustomerManager mgr = (ICustomerManager)Activator.GetObject( typeof(ICustomerManager), " Console.WriteLine("Reference to CustomerManager created "+mgr); Customer cust = mgr.GetCustomer(4711); int age = cust.GetAge(); Console.WriteLine("{0} {1} er {2} år", cust.FirstName, cust.LastName, age); }

20 Nordjyllands Erhvervakademi Step 5: Implement the client Get an ICustomerManager object from the given url. Note that only the interface is given as the type static void Main(string[] args) { try { HttpChannel channel = new HttpChannel(); ChannelServices.RegisterChannel(channel, false); ICustomerManager mgr = (ICustomerManager)Activator.GetObject( typeof(ICustomerManager), " Console.WriteLine("Reference to CustomerManager created "+mgr); Customer cust = mgr.GetCustomer(4711); int age = cust.GetAge(); Console.WriteLine("{0} {1} er {2} år", cust.FirstName, cust.LastName, age); }

21 Nordjyllands Erhvervakademi Step 5: Implement the client Get a copy of the Customer object from the server. Note that the class is necessary static void Main(string[] args) { try { HttpChannel channel = new HttpChannel(); ChannelServices.RegisterChannel(channel, false); ICustomerManager mgr = (ICustomerManager)Activator.GetObject( typeof(ICustomerManager), " Console.WriteLine("Reference to CustomerManager created "+mgr); Customer cust = mgr.GetCustomer(4711); int age = cust.GetAge(); Console.WriteLine("{0} {1} is {2} years old", cust.FirstName, cust.LastName, age); }

22 Nordjyllands Erhvervakademi What is happening? A stub is generated for both server and client The stub is responsible for sending messages by a socket a proxy classOn the client, the stub represents the remote object (located on the server) as a proxy class The example: The stub implements ICustomerManager like the remote object (CustomerManager). The course of events is in principle like this: 1.The client calls a method in the stub. The client doesn't know the stub's implementation, but knows the method because of the interface 2.The client's stub sends the request to the server's stub. 3.The server's stub calls the relevant method in remote object. 4.And sends the return value back

23 Nordjyllands Erhvervakademi Communication channels Requests, objects etc. are sent by channels. Channels differs by protocols A channel uses a socket stream. There is 3 types of channels: TcpChannel: –Uses BinaryFormatter –Advances: Is fast because raw data are sent. –Back draw: Might have problems with firewalls and nat'ing. HttpChannel: –Uses SoapFormatter –Advances: Sends text by http on port 80, therefore no firewall problems (normally). –Back draw: Is slower, because of overhead from xml-tags. –Do not support generic classes IpcChannel: –Used for communication by two applications in the same application domain, and therefore on the same machine.

24 Nordjyllands Erhvervakademi Architecture Marshalling –Marshalling By Reference(MBR) –Marshalling By Value(MBV) Activation by MBR –Well-Known Object(WKO) Singleton SingleCall –Client-Activated Object(CAO)

25 Nordjyllands Erhvervakademi WellKnown Objekt (WKO) As you might remember: A reference to a remote object. There is two types of WKO's: SingleCall Singleton WKO's should be handled as stateless.

26 Nordjyllands Erhvervakademi WellKnown Objekt (WKO) SingleCall: –Every time a call to remote object is made, a new object is created. It is deleted when the call is finished. –One client pr. object –Advances: There is no problems with transactions. –Back draw: The server uses resources creation and deletion of objects. Both activities uses resources for memory management.

27 Nordjyllands Erhvervakademi WellKnown Objekt (WKO) Singleton: –First time a call is made, the object is created. It is not deleted before the lease (or timeout period) runs out. –Many clients pr. object –Advances: No time used for memory management –Back draw: Concurrent calls to the same object might break the class invariant, and therefore returning false return values.

28 Nordjyllands Erhvervakademi Architecture Marshalling –Marshalling By Reference(MBR) –Marshalling By Value(MBV) Activation by MBR –Well-Known Object(WKO) Singleton SingleCall –Client-Activated Object(CAO)

29 Nordjyllands Erhvervakademi Client Activated Object (CAO) CAO objects are MBR objects too. The client can instantiate objects on the server (even with new) Often CAO-objects are returned by method calls to MBR objects There exists a 1-1 relation between object and client Therefore CAO can be used as state full.

30 Nordjyllands Erhvervakademi A remote object public class MyRemoteObject: MarshalByRefObject { int myvalue; public MyRemoteObject(int val) { Console.WriteLine("MyRemoteObject.ctor(int) called"); myvalue = val; } public MyRemoteObject() { Console.WriteLine("MyRemoteObject.ctor() called"); } public void setValue(int newval){.... } public int getValue(){...} }

31 Nordjyllands Erhvervakademi Server "MyServer" is used in the reference on the client static void Main(string[] args) { Console.WriteLine ("ServerStartup.Main(): Server started"); HttpChannel chnl = new HttpChannel(1234); ChannelServices.RegisterChannel(chnl); RemotingConfiguration.ApplicationName = "MyServer"; RemotingConfiguration.RegisterActivatedServiceType( typeof(MyRemoteObject)); // the server will keep running until keypress. Console.ReadLine(); }

32 Nordjyllands Erhvervakademi Server Register the CAO on the server Is not necessary if the object is returned by a remote method static void Main(string[] args) { Console.WriteLine ("ServerStartup.Main(): Server started"); HttpChannel chnl = new HttpChannel(1234); ChannelServices.RegisterChannel(chnl); RemotingConfiguration.ApplicationName = "MyServer"; RemotingConfiguration.RegisterActivatedServiceType( typeof(MyRemoteObject)); // the server will keep running until keypress. Console.ReadLine(); }

33 Nordjyllands Erhvervakademi Client Register the CAO. Note that the class MyRemoteObject is used static void Main(string[] args) { HttpChannel channel = new HttpChannel(); ChannelServices.RegisterChannel(channel); RemotingConfiguration.RegisterActivatedClientType( typeof(Server.MyRemoteObject), " Console.WriteLine("Client.Main(): Creating first object"); Server.MyRemoteObject obj1 = new Server.MyRemoteObject(); obj1.setValue(42); Console.WriteLine("Client.Main(): Creating second object"); Server.MyRemoteObject obj2 = new Server.MyRemoteObject(); obj2.setValue(4711); Console.WriteLine("Obj1.getValue(): {0}",obj1.getValue()); Console.WriteLine("Obj2.getValue(): {0}",obj2.getValue()); Console.ReadLine(); }

34 Nordjyllands Erhvervakademi Client Make a new instance using new static void Main(string[] args) { HttpChannel channel = new HttpChannel(); ChannelServices.RegisterChannel(channel); RemotingConfiguration.RegisterActivatedClientType( typeof(Server.MyRemoteObject), " Console.WriteLine("Client.Main(): Creating first object"); Server.MyRemoteObject obj1 = new Server.MyRemoteObject(); obj1.setValue(42); Console.WriteLine("Client.Main(): Creating second object"); Server.MyRemoteObject obj2 = new Server.MyRemoteObject(); obj2.setValue(4711); Console.WriteLine("Obj1.getValue(): {0}",obj1.getValue()); Console.WriteLine("Obj2.getValue(): {0}",obj2.getValue()); Console.ReadLine(); }

35 Nordjyllands Erhvervakademi Error: Because of security restrictions, the type System.Runtime.Remoting.ObjRef cannot be accessed. Caused by insufficient security level. change to Easier to do in the config-file (next lesson) HttpChannel channel = new HttpChannel(1234); ChannelServices.RegisterChannel(channel, false); SoapServerFormatterSinkProvider serverProv = new SoapServerFormatterSinkProvider(); serverProv.TypeFilterLevel = TypeFilterLevel.Full; SoapClientFormatterSinkProvider clientPorv = new SoapClientFormatterSinkProvider(); IDictionary props = new Hashtable(); props["port"] = 1234; HttpChannel channel = new HttpChannel(props, clientPorv, serverProv); ChannelServices.RegisterChannel(channel, false);