| Author |
How to find a machine which is nearest in location?
|
kapil Gupta
Ranch Hand
Joined: Dec 17, 2001
Posts: 89
|
|
Hi, I have a requirement to find a machine nearest to a server machine. The scenario is that I have a process running on different machines in a network. Now my server has to chose one of the process which is nearest to itself. Is is possible to find a machine which is closest using a Java API? Thanks Kapil
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12268
|
|
You could exec the "ping" utility with the IP addresses of the candidate machines, capture the text output and look for the shortest time. Here is what I got when pinging a local machine on my network. Bill
|
Java Resources at www.wbrogden.com
|
 |
Edward Harned
Ranch Hand
Joined: Sep 19, 2005
Posts: 288
|
|
Jini does this. You can specify the distance for your search. See http://www.jini.org/
|
Ed's latest article: A Java Parallel Calamity http://coopsoft.com/ar/Calamity2Article.html
|
 |
kapil Gupta
Ranch Hand
Joined: Dec 17, 2001
Posts: 89
|
|
Thanks for your replies. My application is a kind of asset management service running on a WAN. If a client check-in a file at a location say A, I would like to do some post check-in operations on that file by a process which is running closest to location A. I have no idea about JINI. Does Jini provide some api to get nearest host machine? Will it work over WAN? Thanks, Kapil
|
 |
pawank gupta
Ranch Hand
Joined: Jun 07, 2006
Posts: 34
|
|
|
u can also do it via using HttpUrlconnection
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12268
|
|
u can also do it via using HttpUrlconnection
Wrong! HttpURLConnection is for connecting to HTTP servers via a precise URL, it has nothing to do with the requirement.
|
 |
kapil Gupta
Ranch Hand
Joined: Dec 17, 2001
Posts: 89
|
|
I checked up Jini and could not find any API which finds the nearest machine. There is a concept of location in Jini but that is just a meta data information of a service and has nothing to do with physical distance between two machines in a network. Regards, Kapil
|
 |
 |
|
|
subject: How to find a machine which is nearest in location?
|
|
|