public static void start() throws Exception { testStackIndex++; if (standaloneMain == null) { LOG.info("Starting standalone instance"); try { CConfiguration cConf = CConfiguration.create(); tempDirectory = Files.createTempDir(); cConf.set(Constants.CFG_LOCAL_DATA_DIR, tempDirectory.getAbsolutePath()); cConf.set(Constants.Router.ADDRESS, HOSTNAME); cConf.set(Constants.Dangerous.UNRECOVERABLE_RESET, "true"); // Start without UI standaloneMain = StandaloneMain.create(null, cConf, new Configuration()); standaloneMain.startUp(); waitForStandalone(30000); } catch (Exception e) { LOG.error("Failed to start standalone", e); if (standaloneMain != null) { standaloneMain.shutDown(); } try { DirUtils.deleteDirectoryContents(tempDirectory); } catch (IOException ex) { LOG.warn("Failed to delete temp directory: " + tempDirectory.getAbsolutePath(), ex); } throw e; } } }
public static void stop() throws Exception { testStackIndex--; if (standaloneMain != null && testStackIndex == 0) { LOG.info("Stopping standalone instance"); standaloneMain.shutDown(); standaloneMain = null; try { DirUtils.deleteDirectoryContents(tempDirectory); } catch (IOException e) { LOG.warn("Failed to delete temp directory: " + tempDirectory.getAbsolutePath(), e); } } }