/** * @param masters * @param fservers */ public static void shutdown(final List<MasterThread> masters, final List<FServerThread> fservers) throws IOException { LOG.debug("Shutting down HBase Cluster"); if (masters != null) { // Do backups first. JVMClusterUtil.MasterThread activeMaster = null; for (JVMClusterUtil.MasterThread t : masters) { if (!t.master.isActiveMaster()) { t.master.stopMaster(); } else { activeMaster = t; } } // Do active after. if (activeMaster != null) activeMaster.master.shutdown(); } if (fservers != null) { for (FServerThread t : fservers) { if (t.isAlive()) { try { t.getFServer().stop("Shutdown requested"); t.join(); } catch (InterruptedException e) { // continue } } } } if (masters != null) { for (JVMClusterUtil.MasterThread t : masters) { while (t.master.isAlive()) { try { // The below has been replaced to debug sometime hangs on end of // tests. // this.master.join(): Threads.threadDumpingIsAlive(t.master.getThread()); } catch (InterruptedException e) { // continue } } } } LOG.info( "Shutdown of " + ((masters != null) ? masters.size() : "0") + " master(s) and " + ((fservers != null) ? fservers.size() : "0") + " fserver(s) complete"); }
/** * Wait for Mini HBase Cluster to shut down. Presumes you've already called {@link #shutdown()}. */ public void join() { if (this.regionThreads != null) { for (Thread t : this.regionThreads) { if (t.isAlive()) { try { Threads.threadDumpingIsAlive(t); } catch (InterruptedException e) { LOG.debug("Interrupted", e); } } } } if (this.masterThreads != null) { for (Thread t : this.masterThreads) { if (t.isAlive()) { try { Threads.threadDumpingIsAlive(t); } catch (InterruptedException e) { LOG.debug("Interrupted", e); } } } } }