@Test
 public void testClusterRestart() throws Exception {
   cluster.stop();
   // Give the cluster time to stop the whole cluster.
   AbstractDaemonClient cli = cluster.getJTClient();
   int i = 1;
   while (i < 40) {
     try {
       cli.ping();
       Thread.sleep(1000);
       i++;
     } catch (Exception e) {
       break;
     }
   }
   if (i >= 40) {
     Assert.fail("JT on " + cli.getHostName() + " Should have been down.");
   }
   i = 1;
   for (AbstractDaemonClient tcli : cluster.getTTClients()) {
     i = 1;
     while (i < 40) {
       try {
         tcli.ping();
         Thread.sleep(1000);
         i++;
       } catch (Exception e) {
         break;
       }
     }
     if (i >= 40) {
       Assert.fail("TT on " + tcli.getHostName() + " Should have been down.");
     }
   }
   cluster.start();
   cli = cluster.getJTClient();
   i = 1;
   while (i < 40) {
     try {
       cli.ping();
       break;
     } catch (Exception e) {
       i++;
       Thread.sleep(1000);
       LOG.info("Waiting for Jobtracker on host : " + cli.getHostName() + " to come up.");
     }
   }
   if (i >= 40) {
     Assert.fail("JT on " + cli.getHostName() + " Should have been up.");
   }
   for (AbstractDaemonClient tcli : cluster.getTTClients()) {
     i = 1;
     while (i < 40) {
       try {
         tcli.ping();
         break;
       } catch (Exception e) {
         i++;
         Thread.sleep(1000);
         LOG.info("Waiting for Tasktracker on host : " + tcli.getHostName() + " to come up.");
       }
     }
     if (i >= 40) {
       Assert.fail("TT on " + tcli.getHostName() + " Should have been Up.");
     }
   }
 }