浅谈RMI技术的运用-英国代写Assignment

英国代写Assignment论文精选:“浅谈RMI技术的运用”,这篇论文主要介绍了远程接口调用(RMI)分布式系统技术的概念,并在文章中详细介绍了RMI的使用方法和运用环境。

 

Remote Method Invocation (RMI) is a distributed systems technology that allows JVM to invoke object methods that will run on another JVM in a network. This is important for the development of large systems, as it makes it possible to distribute resources and processing load across more than one machine.

 

Designing a RMI Lottery application. Each time you run the client program -- 'java LotteryClient n', the server program 'LotteryServer' will generate n sets of Lottery numbers. Here n is a positive integer, representing the money you will spend on Lottery in sterling pounds.

 

An objective of this task is to implement a RMI Lottery application that will generate random numbers similar the way the national Lottery works. I have implement the RMI in such a way that every time the LotteryClient is run it, it will generate six numbers for every sterling pound the client is willing to spend on my RMI Lottery application. The lottery numbers will be between 1 and 49 same way as the national lottery.

 

RMI applications consist of two separate programs, a Server and a Client program.

 

A typical Server program creates remote objects

 

Makes references to these objects accessible

 

Server waits for clients to invoke methods on these objects.

 

A typical client program obtains a remote reference remote object on the server and invokes the methods on them. The RMI is responsible for the communication between the server and the client.

 

LITERATURE REVIEW OF RMI

 

HOW DOES RMI WORK

 

RMI is a system that is used for communication typically divided into two categories a Clients and Servers. A server provides an RMI service, and a client invokes this object methods.

 

The RMI servers hast to register with a lookup service, in order to allow clients to find them, or they will make available a reference to the service in some other fashion. An application called rmiregistry, runs as a separate process and allows applications to register RMI services or obtain references to a named service.

 

According to, when the server has registered, it will then just sit idle and wait for incoming RMI requests from clients.

 

STEPS IN CREATING AN RMI SYSTEM

 

According to, the essential steps in creating an RMI system are as follows: define interface, implementation of remote object, create a stub using MIR write server and write client.

 

Define an interface for the remote object that must inherit from Remote

 

Implement an implementation for the remote object, the class must inherit from UnicastRemoteObject

 

Use the RMIC program to create a stub that used by the server and also by the client

Write a server program to create an instance of the registered remote object and register it with the RMI registry.

 

Write a client to use this remote object by obtaining a reference to the remote object from the RMI registry and invoking the remote object's methods by sending messages to it.

 

RESULTS AND DISCUSSION

 

ADVANTAGES OF RMI

 

Object Oriented

Mobile Behavior

Safe and Secure

Easy to Write/Easy to Use

Write Once, Run Anywhere

 

RMI PROBLEM OVERVIEW

 

According to, RMI poses the following problems when run in a cluster

environment:

 

RMI is too slow for environments with low latency and high bandwidth. ? RMI's overhead for dealing with network problems is too verbose for a cluster environment. ? The program size increases significantly reducing productivity and maintainability. ? Writing advanced code to implement RMI can become tedious, time consuming and hard to manage.

 

IMPLEMENTING MY LOTTER APPLICATION

 

In order to implement my RMI application I had to implement four source files for the Lottery, Server and the client

 

· Separate file for writing the interface (in my lottery application RandomNumberGenerator.java

· Separate file for writing the interface (in my lottery application RandomNumberGenerator.java

· Separate file in which i have writen the code for the implementation of the interface RandomNumberGeneratorImpl.java

 

RUNNING MY LOTTERY APPLICATION

 

Open a command line console e.g. like MS-Dos

 

1. To compile the interface and its implementation, make sure you in the same directory type 'rmic RandomNumberGeneratorImpl'.

2. Type 'javac LotteryServer.java' and 'javac LotteryClient.java' to compile the client and server programs.

3. Type 'rmiregistry' to start the RMI registry so that objects can be registered, the MS-Dos window will hang in there.

Open another MS-Dos window, make sure you in the same directory, type 'java LotteryServer' to run the server program again the MS-Dos window will hang in there.

4. Open another MS-Dos window, make sure you in the same directory, type 'java LotteryClient' n note n should be an integer and indicates the amount of money you willing to spend on the lottery e.g. 'java LotteryClient 1' to run the client program and the random lottery numbers will be displayed.

Running LotteryClient where the client is choosing to spend only one sterling pound on the lottery.

 

CONCLUSIONS

 

I have successfully managed to complete my lottery application. I had two different options which i could use to implement my lottery application. One was to create an array with 49 integer between 1 and 49 and index each element of the array to make sure once a random number is generated that number will be moved from the array to make sure i would not get same number twice. The other option was to create six functions so each function would be responsible for generating a random number.

 

I decided to use the second option and generated six functions to generate the lottery numbers and organised it in such a way that the numbers generated will be in order (increasing order).

 

In order to display the random numbers i have used a (for loop) which corresponds to the six functions. Since the syntax for an RMI application is exactly as the Java syntax i did not have any problems to implement the lottery applications.

 

RMI provides a platform for object oriented distributed computing. RMI is used to connect to Java components Java can be use to get all the benefits-no porting, secure environment and low maintenance costs.