aspose file tools*
The moose likes Distributed Java and the fly likes How to find a machine which is nearest in location? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "How to find a machine which is nearest in location?" Watch "How to find a machine which is nearest in location?" New topic
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: 12785
    
    5
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
Edward Harned
Ranch Hand

Joined: Sep 19, 2005
Posts: 291

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: 12785
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to find a machine which is nearest in location?