DISTRIBUTED FILE SYSTEM USING RMI - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

DISTRIBUTED FILE SYSTEM USING RMI

Description:

point in time, asking for services from another node, or as a server ... MyRemoteFileSystem myfile = mew (MyRemoteFileSystem) Naming.lookup ( serverobjectname) ... – PowerPoint PPT presentation

Number of Views:95
Avg rating:3.0/5.0
Slides: 14
Provided by: georgekout
Category:
Tags: distributed | file | rmi | system | using | mew

less

Transcript and Presenter's Notes

Title: DISTRIBUTED FILE SYSTEM USING RMI


1
DISTRIBUTED FILE SYSTEM USING RMI
  • By George Koutsogiannakis

2
DISTRIBUTED SYSTEM
In a distributed system the nodes are connected
with each other (complete network). Usually
there is no distinction between a client and a
server. Services are distributed throughout the
nodes and a node can act as a client, at some
point in time, asking for services from another
node, or as a server at another time offering
services to another node.
3
FILE SYSTEM DISTRIBUTION
  • OFFERS RELIABILITY (DUPLICATION OF THE SYSTEM
  • IN VARIOUS NODES)
  • ALLOWS ANOTHER NODE TO CONCENTRATE
  • ITS RESOURCES TO OTHER TASKS (POSSIBLY
  • COMPUTATIONAL TASKS)
  • ALLOWS THE MIGRATION OF DATA FROM NODE TO
  • NODE AS NEEDED (SHARING OF DATA BETWEEN
  • NODES).

4
IMPLEMENTATION
  • A SERVICE AT A PARTICUALR NODE IS REPRESENTED BY
    A PROCESS. THEREFORE WE NEED A PROTOCOL FOR
    EXCHANGING MESSAGES.
  • THE DISTRIBUTED SERVICES AT A SERVER NODE (AND
    THE CLIENT NODE) CAN BE IMPLEMENTATED BY USING
    ONE OF THE FOLLOWING FRAMEWORKS
  • JAVA S REMOTE METHOD INVOCATION API
  • ALL SERVICES MUST BE WRITTEN IN JAVA.
  • USES THE JRMIP (JAVA REMOTE METHOD INVOCATION
    PROTOCOL) AS THE TRANSPORT LAYER PROTOCOL.
  • FREES THE DEVELOPER FROM
  • CREATING THE NETWORKING CODE
  • CREATING THE OBJECT SERIALIZATION CODE
  • CREATING THE MESSAGING MECHANISM

5
IMPLEMENTATION
  • JAVA S RMI OVER IIOP (RMI OVER INTERNET INTER
    OPERABILITY PROTOCOL) API.
  • SERVICES CAN COMMUNICATE WITH EACH OTHER EVEN IF
    THEY ARE NOT WRIITEN IN JAVA (AND THUS THEY ARE
    NOT USINGJAVA DATA TYPES)
  • USES IDL (INTERFACE DEFINITION LANGUAGE) AS THE
    LANGUAGE TO CREATE DATA TYPES THAT ARE UNDERSTOOD
    BY ALL NODES REGARDLESS OF THE LANGUAGE USED TO
    REPRESENT A PROCESS AT THE PARTICULAR NODE.
  • JUST LIKE RMI IT FREES THE DEVELOPER FROM
  • CREATING THE NETWORKING CODE
  • CREATING THE OBJECT SERIALIZATION CODE
  • CREATING THE MESSAGING MECHANISM
  • CREATING THE IDL DATA TYPES. THE SYSTEM CONVERTS
    JAVA DATA TYPE STO IDL AUTOMATICALLY.
  • USES THE IIOP PROTOCOL AT THE TRANSPORT LAYER.

6
IMPLEMENTATION
  • AN IMPLEMENTATION OF THE CORBA (COMMON OBJECT
    REQUEST BROKER) SPECIFICATION.
  • THERE ARE MANY VENDORS THAT PRODUCE
    IMPLEMENTATIONS IN DIFFERENT PROGRAMMING
    LANGUAGES (INCLUDING JAVA OR C).
  • MS OFFERS IT IN ITS .NET FRAMEWORK. SUN
    MICROSYSTEMS OFFERS IT AS A SEPARATE API IN THE
    JDK.
  • HARDER TO USE THAN THE PREVIOUS TWO FRAMEWORKS.
  • DEVELOPER H AS TO IMPLEMENT NETWORKING
  • DEVELOPER HA STO IMPLEMENT SERIALIZATION
    ALGORITHMS
  • DEVELOPER HAS TO IMPLEMENT IDL DATA TYPES MODULES.

7
IMPLEMENTATION USING RMI
SUPPOSE A SERVER HAS THE FILE SERVICE int
openFile(String name). That means that a client
requesting the service(invoking the service
openFile remotely) has to pass to the server a
string representing the name of the file to be
opened. The server will execute the service and
then return to the client an int representing
either success or the code for an error
message. The following communications take place
8
IMPLEMENTATION USING RMI
  • Server implements the method and registers an
    object that can be used by a client to a registry
    ( a database that
  • Keeps track of all services and their
    locations).
  • The client is aware of the remote object. It
    contacts the registry to obtain information about
    the location of the
  • server node, the port number where the process
    resides and the object id number (Many clients
    can request
  • the service simultaneously).
  • The client sends a request to invoke the service
    on the server.
  • The server executes the service and returns the
    results to the client.

9
IMPLEMENTATION USING RMI
  • Most of the communications discussed thus far are
    created by providing a single line of code in our
    coding of the corresponding processes. The RMI
    system and the local O.S. handle the rest.
  • SERVER CODING
  • Create an interface that represents the service
  • public interface MyRemoteFileSystem exetnds
    Remote
  • public int openFile ( String name) throws
    RemoteException
  • Create a class that implements the remote service
    (method).
  • public class MyRemoteFileSystemImpl extends
    UnicastRemoteObject implements MyRemoteFileSystem
  • //constructor that calls super() .
    Super is a call to the superclasses constructor.
    In the case the super class creates network
    connections. Nothing else is needed on the part
    of the developer.

10
IMPLEMENTATION USING RMI
  • // implement the code for the remotely invokable
    method public int openFile(name)
    //code to open the file
  • return int
  • //main method for the class that starts the
    server
  • public static void main ( String args)
  • // start the server by instantiating an instance
    of the class
  • MyRemoteFileSystemImpl rfs new
    MyRemoteFileSystemImpl ( )
  • //create a string that represents the location of
    the registry and the name of a remote object that
    can be used by a client to invoke the
    service String serverobjectname
    //localhost/remoteobject
  • // we assume that the registry resides localhost
    (or it can be the ip address of another node
  • //proceed to register the remote object with the
    registry Naming.rebind ( serverobjectname,
    impl) //end of main
  • // end of the class THTATS ALL IS NEEDED
    FOR THE SERVER!

11
IMPLEMENTATION USING RMI
  • CLIENT CODING
  • Create a class that represents the client
    process.
  • public class Client
  • // global declarations as needed
  • //constructor
  • //other methods as needed 9including a main
    method for the client
  • // method that needs to open a file from the File
    Server node
  • public void getRemoteFile ( )
  • String serverobjectname //localhost/remoteobjec
    t
  • // lookup remote object on the registry. Notice
    that the name of the interface is used below
  • MyRemoteFileSystem myfile mew
    (MyRemoteFileSystem) Naming.lookup (
    serverobjectname)
  • //proceed with remote invocation
  • int c myfile. openFile(filename)
  • // where filename is a string representing the
    name of the file. It is passed to the server. The
    server returns the result which is capured by the
    int c.
  • //end of the method
  • //end of the client class

12
IMPLEMENTATION USING RMI
  • As you can see the implementation is simple. Most
    of the work is handled by the system under the
    hood.
  • COMPILING
  • Compile the server interface class first by using
    javac.
  • Compile the server class that implemets the
    interface next by using the javac compiler
  • Compile the server class that implements the
    interface one more time by using the rmic
    compiler (it comes with the jdk). This produces
    an extra class called the stub
  • gt rmic v1.2 MyRemoteFileSystemImpl
    //notice that no extensuion is use dafter the
    file name
  • The file MyRemoteFile SystemImpl_stub.cla
    ss is produced
  • Compile the client class by using javac compilker

13
IMPLEMENTATION USING RMI
  • MAKING IT WORK
  • Place the compiled interface file (
    MyRemoteInterface.class) in the client node (in
    addition to the server node)
  • Place the stub (MyRemoteFileSystemImpl_stub.class)
    in the client nod ealso (in addition to the
    server node).
  • Place the server MyRemoteFielSystem.class on the
    server node
  • Place the client cod eon the client node.
  • Start the registry. RMI provides registry
    automatically
  • gt start rmiregistry
  • Start the server gtjava
    MyRemoteFileSystemImpl
  • Start the cleint
  • gtjava Client
Write a Comment
User Comments (0)
About PowerShow.com