• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to check a system (computer) is running and it was not shutdown  RSS feed

 
Raaja Gotluru
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In our application previous developers has written code such that if a primary db server is down then it will shift to secondary db server running in another machine. Up to this it is working fine. But if the system in which primary db server is running is switched off (shut down) then the application is not switching to secondary db server it gets hanged at the tme of startup itself. So in order to directly connect to the secondary server we need to check initially, is that primary db server system is running by using java code. Is it possible to do this. When I tried to use java.net pacjkage I found a port number is required to ping. But this can check only whether a process is running or not but not the computer machine running status.

can anyone guide me in this. Even any other scenario where we can achieve our task.

Thanks.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no way to determine for certain that a host is "not running." The concept doesn't even make sense for what you're trying to do. What if it's running but its network cable is disconnected? Or running in single-user mode with no networking? Or running normally, but none of the services that you're using to failover to the backup server normally are running?
 
Raaja Gotluru
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for the reply.


I found one solution for this after browsing API and searching in google.


But I am always getting Host is NOT reachable. Eventhough that machine is on.

Is there anything I need to configure.
 
Paul Clapham
Sheriff
Posts: 22838
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you can read the description of the isReachable() method, where it explains how the method is implemented. And sure, you can configure the target machine so that it responds to whatever isReachable() is doing. But then, as Jeff says, so what? That still isn't going to tell you whether the database server is running or not. So there really isn't any point in doing it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!