GOES-13 GOES-12 Hurricane Florence. GOES-12 Hurricane Florence GOES-13.
Changing the the way of designing distributed applications Communication design orientation: The...
-
date post
20-Dec-2015 -
Category
Documents
-
view
213 -
download
0
Transcript of Changing the the way of designing distributed applications Communication design orientation: The...
![Page 1: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/1.jpg)
Changing the the way ofdesigning distributed applications
• Communication design orientation: The design of the protocol goes first and then the development of the system is done based on the protocol.
• Application design orientation: The development and design of the system is done like if everything is local and then the application is divided into modules that will be running on different machines.
• This first strategy has a more complicated design but the programming will use less resources.
• The second is better when the communications are complicated, at the point to make the application difficult.
![Page 2: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/2.jpg)
Alternative Technologies
• Development of networks => Development of distributed systems
• Development of middleware (libraries,tools,services, etc..) that support the programming of distributed systems
• Based on TCP/IP protocol• The programming language is more high-
level• The problem of the distributed applications
is not a particular case.
![Page 3: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/3.jpg)
Remote Procedure Calls (RPC)
• Motivation: Development of NFS (SUN)• A client can call a function in an application
running on a server just like if it is locally implemented.
• Sends the parameters and receives the results in a correct format(Integer,String,float...)
• eXternal Data Representation• Serialization.
![Page 4: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/4.jpg)
Remote Procedure Calls • The client stops the execution until the results
are received.
Call(parameters)
Receive results
RPC ServerRPC Client
Server framework: provided by the middleware
![Page 5: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/5.jpg)
The Interface file• Specifies the protocol of the remote function: name,
required parameters (how many, and what type), result (type)
• It is called “interface” file because server and the client get the needed information.
The client usesthe interface tocompile
The serverimplements it
RPC Server
RPC ClientInterface definition file
![Page 6: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/6.jpg)
Remote Objects• As the object orientation paradigm developed
the “remote object” approach replaced the previous paradigm.
• An Application can call a method of an object located on another JVM.
• The interface file is the key concept of the implementation.
RemoteObjectServerInvokes the method
Gets the result
![Page 7: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/7.jpg)
Necessary files
• Gets a reference to the remote object.
• Use the method and,
• Receives the results as if it is locally located.
Client program Server program
• Defines a particular class to implement the methods specified in the interface
• Creates the remote object from this class.
• It is published in some registry service, to be located by the clients.
Defines the methods (just the header) that could be remotely invoked.
ImplementsUse for compilation
interface
![Page 8: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/8.jpg)
Example: Remote Date Server • The only method of the object will be getDate(),
this method will return as a result the date of the computer where it is located.
Remote Server
getDate()
getDate()
Tue Jun 12 17:20:24
![Page 9: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/9.jpg)
The interface file
import java.rmi.*;import java.util.Date;
public interface RemoteDate extends Remote { public Date getDate() throws RemoteException;}
• Must import java.rmi.*• Must extend the Remote class• Each declared method must throw a
RemoteException
![Page 10: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/10.jpg)
Defining a class to implement remote objects.
Definition of the class forthe remote object
Remote Interface
RemoteObject
Implements
Remote
Extends
Extends
DateServer.java
![Page 11: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/11.jpg)
The client program
import java.rmi.*;import java.rmi.server.*;import java.util.Date;
public class DateClient { public static void main( String args[] ) { try { RemoteDate dateobj = (RemoteDate)Naming.lookup( "rmi://"+args[0]+"/DateServer" ); Date datum = dateobj.getDate(); System.out.println( “Server Date : " + datum ); } catch ( Exception e ){ System.out.println(e); } }}
![Page 12: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/12.jpg)
The Stub and Skel files• The communications are implemented by the stub
and skel files.• They are generated when the sourcecode is
compiled using the rmic command.• With the 1.5 version of java they are generated
automatically
Client
Stub
Remote Object Server
Skel
![Page 13: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/13.jpg)
The name registry server• It is a server for registring and making public the
remote objects.• The server of the remote object registers the object
in it and the clients obtain a reference to the object from it.
• Must run in the host server, and have access to the stub and skel files.
• Must be reinitialized before the server registers the object.
Client Remote Object Server
rmiregistry
1
2
3
4
![Page 14: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/14.jpg)
¿ What file and where?
• The client need the interface and stub file.• The server need the Stub and Skel file.
ClientRemote Object Server
DateClient.classRemoteDate.classDateServer_stub.class
DateServer.class RemoteDate.classDateServer_stub.classDateServer_skel.class
![Page 15: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/15.jpg)
Generating stub & skel
• The class file of the implementation must be compiled again with the rmic command.
DateClient.javaRemoteDate.java
DateClient.class
DateServer.class
DateServer_stub.class
DateServer_skel.class
DateServer.java
RemoteDate.classjavac
javacjavac
rmic
![Page 16: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/16.jpg)
Initiating the rmiregistry from the application.
• It is possible to initiate the rmiregistry from an application calling a java method.
• The following example will also demostrate concurrent problems.
Remote Number Server
Client Clie
ntClient
getNumber()
getNumber()getNumber()
1 2 3
![Page 17: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/17.jpg)
The RMI based chat• The client must receive the messages of the server.• The client implements a remote object wich is
passed to the server as a parameter!!!• The server does not need to locate the client
Remote Object Client
Remote Object Server
addClient(this)
sendMessage(text)
newMessage(text)
![Page 18: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/18.jpg)
A remote file server
Access to files
Client
-open file read/write-close file-Read line-Write line
What happends if:- It is asked to open a non-existing file.- It is asked to read a non-opened file.- More errors are generated.
![Page 19: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/19.jpg)
Automatic Distribution (stub)• The stub file can be distributed atomaticly but it is
necessary to add a safety controller.• For this it is necessary to write in a security policy
file.• When the server is initialized it is necessary to
specify an URL to tell the server where the policty file is located.
java –Djava.security.policy=policy.txt -Djava.rmi.server.codebase=http://hostname/filelocation ClientProgram
• Se examples: PideNumero ReparteNumeros (askNumber) (GiveNumber)
![Page 20: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/20.jpg)
Automatic Distribution (stub)• The stub file is obtained using the URL protocol• A “web-server” must be running.• A small class server can be used.• ClassFileServer (extends ClassServer)• Steps :
– Download RFSClient.cass, RFSInterface.class, policy.txt
– Run the class Server with the command ClassFileServer port path.
– Run the remote object server.– The client contacts the server (with the policy and
codebase parameters)
![Page 21: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/21.jpg)
Automatic activation of the remote server
• Sometimes it is not convienient to have many servers running at the same time, just when it is necessary.
• RMI provides a schema to activate objects.• Only one server is always running (the rmideamon),
that will wakeup the objects when it is necesary. (Call from a client )
• It is necessary to write and run a “set-up” program to registry the sleeping server with the rmid that will wake it up.
• For the client there is no difference.
![Page 22: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/22.jpg)
Steps to write an activable server
• Rewrite the Server to extend an “activable” class instead of the RemoteUnicastObject.
import java.rmi.activation.*; public class MyRemoteClass extends Activable implement
MyInterface
• Replace the constructor to one that has 2 parameters. public MyRemoteClass(ActivationID id, MarshalledObject data) throws RemoteException {
super(id, 0); }
• Compile it with javac and rmic.• Write and compile the Setup program
![Page 23: Changing the the way of designing distributed applications Communication design orientation: The design of the protocol goes first and then the development.](https://reader035.fdocuments.in/reader035/viewer/2022062714/56649d485503460f94a23416/html5/thumbnails/23.jpg)
Steps to run it
• Run the ClassFileServer and rmiregistry• Run the rmid
rmid –J-Djava.security.policy=policy.txt
• Run the Setup programJava -Djava.security.policy=policy.txt – Djava.rmi.server.codebase=http://hostname:port/ Setup
• Run the client.Java -Djava.security.policy=policy.txt
– Djava.rmi.server.codebase=http://hostname:port/ client