• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to find a machine which is nearest in location?

 
kapil Gupta
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13055
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 291
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jini does this. You can specify the distance for your search.

See http://www.jini.org/
 
kapil Gupta
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
u can also do it via using HttpUrlconnection
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13055
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic