?
Solved

RMI Implementation Problem

Posted on 2000-05-05
19
Medium Priority
?
319 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 3
  • +3
19 Comments
 

Expert Comment

by:ytgprasad
ID: 2781700
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
ID: 2781706
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
ID: 2781715
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:Laminamia063099
ID: 2781749
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
ID: 2781752
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
ID: 2781779
Ravindra:

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

Laminamia :)
0
 
LVL 1

Accepted Solution

by:
yanchou earned 600 total points
ID: 2781823
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
ID: 2781852
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
ID: 2782103
xiaoxiao  == yanchou ?
:)
0
 
LVL 1

Expert Comment

by:yanchou
ID: 2782162
Amit:

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

2. yanchou.getPoints() < 300

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

Expert Comment

by:Ravindra76
ID: 2783315
Hi : Laminamia ,


My comment's explanation has given by
yanchou

:)



0
 
LVL 5

Expert Comment

by:mbormann
ID: 2790374
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
ID: 2790540
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
ID: 2792047
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
ID: 2793508
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
ID: 2795289
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
ID: 2798074
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
ID: 2890080
Comment accepted as answer
0
 

Author Comment

by:xiaoxiao
ID: 2890081
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month12 days, 8 hours left to enroll

777 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