Solved

RMI Implementation Problem

Posted on 2000-05-05
19
283 Views
Last Modified: 2013-12-29
Basically, my question is about how the server (remote object) serves the request?
Let's say one server is running all time waiting for requests coming in. When a client invokes one remote method through the remote object reference obtained by Naming lookup, what actually happen on server side? The method is running in the server's VM (correct me if i am wrong)'s memory space? What if many requests come in at the same time, the server spawn new threads for those requests? (Even the server is not implemented explicitly as multi-thread one?) Or RMI provides some queuing mechanism for the requests?
In the RMI specification, one possible place about this (maybe i misunderstand it) is in 3.2 as :
  "A method dispatched by the RMI ru ntime to a remote object implementation
may or may not execute in a separate thread. The RMI runtime makes no
guarantees with respect to mapping remote object invocations to threads. Since remote method invocation on the same remote object may execute
concurrently, a remote object implementation needs to make sure its
implementation is thread-safe."
 what actually does this mean?

 i am puzzled by thinking this problem, wish someone can get me off the hook!
 
0
Comment
Question by:xiaoxiao
  • 6
  • 4
  • 3
  • +3
19 Comments
 

Expert Comment

by:ytgprasad
Comment Utility
Server handles the request with a thread per the request. And concurrency is taken care by server if the method is synchronized otherwise it is the responsibility of the author.......

An implementation is thread safe if not more thatn one thread is there in the critical section(code in which racing conditions can appear).
0
 
LVL 7

Expert Comment

by:Ravindra76
Comment Utility
You have to provide thread safe synchronization to Your methods and data of the
Remote Server.

The data is not thead safe..
0
 

Expert Comment

by:ytgprasad
Comment Utility
Server handles the request with a thread per the request. And concurrency is taken care by server if the method is synchronized otherwise it is the responsibility of the author.......

An implementation is thread safe if not more thatn one thread is there in the critical section(code in which racing conditions can appear).
0
 
LVL 3

Expert Comment

by:Laminamia063099
Comment Utility
It happens the same as on your own JVM.  If two objects running in different parts of your JVM call the same method in the same object, two threads will be executing the same method code.  The method may not finish when one thread is thrown out of the execution (CPU) to allow the other thread to execute.  If this section of code is a "critical section" (see ravindra's comment), then you have to make your method synchronized (or make the section of code inside the method synchronized).

Laminamia :)
0
 
LVL 7

Expert Comment

by:Ravindra76
Comment Utility
Client Server programming with Java and CORBA -- Read this book if available

RMI - Pass by value mechanism     - Method execute at client

Corba - Pass by value mechanism   - Method execute at server

RMI is multi thread.

Each method call is thread. SO U have to provide thread safeness to ur Server Class data
and mthods
0
 
LVL 3

Expert Comment

by:Laminamia063099
Comment Utility
Ravindra:

"What do you mean by RMI Pass by value mechanism - method execute at client"?

Laminamia :)
0
 
LVL 1

Accepted Solution

by:
yanchou earned 300 total points
Comment Utility
As I understand ...

Basically, my question is about how the server (remote object) serves the request?
Let's say one server is running all time waiting for requests coming in. When a client invokes one remote method through the remote object reference obtained by Naming lookup, what actually happen on server side? ------------

Most of the thing  happen between client stub and server skeleton using JRMP protocol. Client stub serialize the request objects(or marshall the request objects into 101110101... pattern to be transfered alone the wire) the  and past them to skeleton (or rmi server), skeleon will deserialize the request objects and then invocate the actual server component just like local calling.
---------------------------------------------

The method is running in the server's VM (correct me if i am wrong)'s memory space?  You are right.

--------------------------------
What if many requests come in at the same time, the server spawn new threads for those requests?
(Even the server is not implemented explicitly as multi-thread one?) Or RMI provides some queuing mechanism for the requests?


I guess RMI system will spawn new skeleton or adaptor threads to call your component. So your component dont need to worry about that. However,  you should be aware of the fact so you can make your server component thread safe.

I don't think RMI provides some queuing mechanism (which is used in JMS). Multithread just call the same object currently.(similiar to servlet componet without implementing SigleThreadMode interface )
 
-----------------------------------
 
In the RMI specification, one possible place about this (maybe i misunderstand it) is in 3.2 as :
  "A method dispatched by the RMI ru ntime to a remote object implementation
may or may not execute in a separate thread. The RMI runtime makes no
guarantees with respect to mapping remote object invocations to threads. Since remote method invocation on the same remote object may execute
concurrently, a remote object implementation needs to make sure its
implementation is thread-safe."
 what actually does this mean?


That means one remote server componset instance can service multi threads. You should make sure that all public resource, including instance variables, class variables, sharing objects etc should be accessed in thread-safe mode.

 

Please correct me if I am wrong.

 
0
 
LVL 1

Expert Comment

by:yanchou
Comment Utility
Laminamia :

If the local object implement serializable interface, then the object can be passed between client and server by the copy or clon of the object. Any methods invoked in those object happens in local machine. This is differrent to CORBA.

Is that correct?

0
 
LVL 5

Expert Comment

by:mbormann
Comment Utility
xiaoxiao  == yanchou ?
:)
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 1

Expert Comment

by:yanchou
Comment Utility
Amit:

1. (xiaoxiao.getBirthday().equal( yanchou.getBirthday() )  = false

2. yanchou.getPoints() < 300

3. yanchou.getLastVisitAccount() = mbormann.getAccount()
0
 
LVL 7

Expert Comment

by:Ravindra76
Comment Utility
Hi : Laminamia ,


My comment's explanation has given by
yanchou

:)



0
 
LVL 5

Expert Comment

by:mbormann
Comment Utility
sorry yanchou,

was in a tearing hurry so i thought that u and xiaoxiao were the same.

please forgive me, but what is yanchou.getLastVisitAccount() = mbormann.getAccount()?

i understood the first 2 though

0
 
LVL 1

Expert Comment

by:yanchou
Comment Utility
mbormann

Never mind, I know you are kidding!

yanchou.getLastVisitAccount() means I just visited your profile before I wrote those "Object Oriented" comment.


XioXio! Are you happy with our comment? If yes, We will try to claim the points.

Thanks

0
 

Author Comment

by:xiaoxiao
Comment Utility
Well, it seems i have kept silence for days. Frankly speaking, i am still waiting for more comments on this topic. i will close this question and give out the points by this week? OK?
Just share with all of you about what i understand about this question (of course, got this point of view from various sources), maybe you guys can correct me:
 
There are three parts in RMI systems -- client, RMI engine, and server. RMI engine has one thread listening the port and dispatches the incoming request to the destination -- this action will cost one connection to the server. RMI engine tries to use the same connection to direct the service request if he can finish sending previous one, but otherwise, a new thread (and connection will be created). This part leads to the multi-threaded problem.

By the way, the RMI-Users page gives lots of discussions on this topic, and some of the comments are from RMI team, they are very very good and useful.

0
 
LVL 1

Expert Comment

by:yanchou
Comment Utility
Connection is identified by client (IP, port) and server (IP, port) pair.

In the client side, There is a sigleton class (or client side RMI engine)maintain the connection to the server. The connection in client side might be reused by different thread. This connection will keep alive for a period of time.

The server RMI engine will keep as many connections as clients claim. Thread will be spawn per connection.
0
 

Author Comment

by:xiaoxiao
Comment Utility
Opps? A bit of confused!
Does client need to know server's address? Well, from my understanding, client talks to RMI engine, RMI engine directs request to server. i don't think (well, again, correct me if i am wrong), client talks to server directly.

How do they communicate? Anyone can confirm this?
0
 
LVL 1

Expert Comment

by:yanchou
Comment Utility
The client does not need to know the address of the RMI Server, however, it need to know the address of broker (or rmiregistry). It is the borker tell the client where RMI engine  and the services are. After locating the RMI engine, the client will talk to it directly.




0
 

Author Comment

by:xiaoxiao
Comment Utility
Comment accepted as answer
0
 

Author Comment

by:xiaoxiao
Comment Utility
It's been one month since i posted this question. Thanks for the answers provided! It's time to end this question.
Well, since this question is not so specific -- it can be answered with a few words, and it can also be analysed with one whole article. I would say this answer seems rather good.

Well, for those who still has doubts on this problem, maybe you can check one message in the RMI users mailing list: Reference #201 for September 1998, answered by one of the member in RMI team. It is really good!

Thanks!
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now