Ran Luer wrote:Hello. I am fairly new to Java RMI and I have some questions regarding how a client can interact to particular server
I have developed a working program consist of 1 server and 1 client. I was asked to modify the program into multiple server and 1 client where 1 client send request to master server, then master server divide the task to several other sub server.
Paul Clapham wrote:[
Hi Ran, welcome to the Ranch!
I'm confused about whether the master server is supposed to send requests to the other sub servers, and then return the results to the client, or whether the clients are supposed to connect directly to the sub servers themselves. But from what you've written in your post, it looks to me like you have the same confusion. At the beginning of your post it looks like it's the former version, but by the time you get to the end of the post it looks like you're talking about changing the client software, which would be the latter version.
So to get your clear view on how to achieve your goal, I think it would be very helpful to consider what exactly the goal is. I know it sounds obvious, but there's no point in writing code when you don't know what the code is supposed to do. The hard part is to realize that you don't know.
Paul Clapham wrote:Good, that's much simpler.
The second part is for the master server to split a request into several tasks. That's very context-dependent, by which I mean it depends very much on the nature of the request and the tasks it's supposed to be split into.
Ran Luer wrote:My problem is, I don't really know how to make master server interact with sub server (they're in different port but in the same host). I know sub server is successfully created but to send all the task is quite blur to me.
Paul Clapham wrote:
Sure you do. The master server is acting as a client. The sub server is acting as a server. You already know how to write code for a client to communicate with a server.
Ran Luer wrote:After checking the time taken, it seems that sometime time taken for 1 thread is shorter than 2 - 5 thread. And there are time when 1 is longer than 2 but is shorter than 3-5 (i hope you get what i mean) and rarely 5 is shorter than 1-4 thread.
Did i do something wrong in the code? I thought 5 thread will always take shorter time compare to 1-4 thread.
Should i create new topic just for this problem? or just continue it here
Paul Clapham wrote:
Well, for this post I'll just point out that line 34 is unnecessary. Just call join() on each of the threads you're waiting for, it doesn't matter whether the threads are alive or not. But otherwise, yes, start a new thread.
Stinging nettles are edible. But I really want to see you try to eat this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton