private int stopMaster() {
   HBaseAdmin adm = null;
   try {
     Configuration conf = getConf();
     // Don't try more than once
     conf.setInt("hbase.client.retries.number", 1);
     adm = new HBaseAdmin(getConf());
   } catch (MasterNotRunningException e) {
     LOG.error("Master not running");
     return -1;
   } catch (ZooKeeperConnectionException e) {
     LOG.error("ZooKeeper not available");
     return -1;
   }
   try {
     adm.shutdown();
   } catch (Throwable t) {
     LOG.error("Failed to stop master", t);
     return -1;
   }
   return 0;
 }