/** * Start LocalOozie. * * @throws Exception if LocalOozie could not be started. */ public static synchronized void start() throws Exception { if (localOozieActive) { throw new IllegalStateException("LocalOozie is already initialized"); } String log4jFile = System.getProperty(XLogService.LOG4J_FILE_ENV, null); String oozieLocalLog = System.getProperty("oozielocal.log", null); if (log4jFile == null) { System.setProperty(XLogService.LOG4J_FILE_ENV, "localoozie-log4j.properties"); } if (oozieLocalLog == null) { System.setProperty("oozielocal.log", "./oozielocal.log"); } localOozieActive = true; new Services().init(); if (log4jFile != null) { System.setProperty(XLogService.LOG4J_FILE_ENV, log4jFile); } else { System.getProperties().remove(XLogService.LOG4J_FILE_ENV); } if (oozieLocalLog != null) { System.setProperty("oozielocal.log", oozieLocalLog); } else { System.getProperties().remove("oozielocal.log"); } container = new EmbeddedServletContainer("oozie"); container.addServletEndpoint("/callback", CallbackServlet.class); container.start(); String callbackUrl = container.getServletURL("/callback"); Services.get().getConf().set(CallbackService.CONF_BASE_URL, callbackUrl); XLog.getLog(LocalOozie.class).info("LocalOozie started callback set to [{0}]", callbackUrl); }
/** Stop LocalOozie. */ public static synchronized void stop() { RuntimeException thrown = null; try { if (container != null) { container.stop(); } } catch (RuntimeException ex) { thrown = ex; } container = null; XLog.getLog(LocalOozie.class).info("LocalOozie stopped"); try { Services.get().destroy(); } catch (RuntimeException ex) { if (thrown != null) { thrown = ex; } } localOozieActive = false; if (thrown != null) { throw thrown; } }