use of org.apache.oozie.service.Services in project oozie by apache.
the class LocalOozie method start.
/**
* 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, null);
String oozieLocalLog = System.getProperty("oozielocal.log", null);
if (log4jFile == null) {
System.setProperty(XLogService.LOG4J_FILE, "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, log4jFile);
} else {
System.getProperties().remove(XLogService.LOG4J_FILE);
}
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);
}
use of org.apache.oozie.service.Services in project oozie by apache.
the class TestWorkflowJobsGetFromCoordParentIdJPAExecutor method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
services = new Services();
setClassesToBeExcluded(services.getConf(), excludedServices);
services.init();
}
use of org.apache.oozie.service.Services in project oozie by apache.
the class TestWorkflowsJobGetJPAExecutor method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
services = new Services();
services.init();
}
use of org.apache.oozie.service.Services in project oozie by apache.
the class TestJMSJobEventListener method testConnectionDrop.
@Test
public void testConnectionDrop() {
Random random = new Random();
try {
services.destroy();
services = new Services();
Configuration conf = services.getConf();
conf.set(Services.CONF_SERVICE_EXT_CLASSES, JMSAccessorService.class.getName() + "," + JMSTopicService.class.getName());
int randomPort = 30000 + random.nextInt(10000);
String brokerURl = "tcp://localhost:" + randomPort;
conf.set(JMSJobEventListener.JMS_CONNECTION_PROPERTIES, "java.naming.factory.initial#" + ActiveMQConnFactory + ";" + "java.naming.provider.url#" + brokerURl + ";connectionFactoryNames#" + "ConnectionFactory");
services.init();
JMSJobEventListener wfEventListener = new JMSJobEventListener();
wfEventListener.init(conf);
BrokerService broker = new BrokerService();
broker.setDataDirectory(getTestCaseDir());
broker.addConnector(brokerURl);
broker.start();
ConnectionContext jmsContext = getConnectionContext();
assertNotNull(jmsContext);
broker.stop();
jmsContext = getConnectionContext();
// Exception Listener should have removed the old conn context
assertNull(jmsContext);
broker = new BrokerService();
broker.setDataDirectory(getTestCaseDir());
broker.addConnector(brokerURl);
broker.start();
WorkflowJobEvent wfe = new WorkflowJobEvent("wfId1", "caId1", WorkflowJob.Status.FAILED, "user1", "wf-app-name1", new Date(), new Date());
jmsContext = getConnectionContext();
Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = jmsContext.createConsumer(session, wfEventListener.getTopic(wfe));
wfEventListener.onWorkflowJobEvent(wfe);
TextMessage message = (TextMessage) consumer.receive(5000);
assertNotNull(message);
broker.stop();
wfEventListener.destroy();
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.oozie.service.Services in project oozie by apache.
the class DagServletTestCase method runTest.
protected void runTest(String[] servletPath, Class[] servletClass, boolean securityEnabled, Callable<Void> assertions) throws Exception {
Services services = new Services();
this.servletPath = servletPath[0];
try {
String proxyUser = getTestUser();
services.getConf().set(ProxyUserService.CONF_PREFIX + proxyUser + ProxyUserService.HOSTS, "*");
services.getConf().set(ProxyUserService.CONF_PREFIX + proxyUser + ProxyUserService.GROUPS, "*");
services.init();
services.getConf().setBoolean(AuthorizationService.CONF_SECURITY_ENABLED, securityEnabled);
Services.get().setService(ForTestAuthorizationService.class);
Services.get().setService(ForTestWorkflowStoreService.class);
Services.get().setService(MockDagEngineService.class);
Services.get().setService(MockCoordinatorEngineService.class);
container = new EmbeddedServletContainer("oozie");
for (int i = 0; i < servletPath.length; i++) {
container.addServletEndpoint(servletPath[i], servletClass[i]);
}
container.addFilter("*", HostnameFilter.class);
container.addFilter("*", AuthFilter.class);
setSystemProperty("user.name", getTestUser());
container.start();
assertions.call();
} finally {
this.servletPath = null;
if (container != null) {
container.stop();
}
services.destroy();
container = null;
}
}
Aggregations