Search in sources :

Example 1 with Services

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);
}
Also used : Services(org.apache.oozie.service.Services) EmbeddedServletContainer(org.apache.oozie.test.EmbeddedServletContainer)

Example 2 with Services

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();
}
Also used : Services(org.apache.oozie.service.Services)

Example 3 with Services

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();
}
Also used : Services(org.apache.oozie.service.Services)

Example 4 with Services

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());
    }
}
Also used : MessageConsumer(javax.jms.MessageConsumer) Configuration(org.apache.hadoop.conf.Configuration) JMSAccessorService(org.apache.oozie.service.JMSAccessorService) Date(java.util.Date) ParseException(java.text.ParseException) Services(org.apache.oozie.service.Services) Random(java.util.Random) ConnectionContext(org.apache.oozie.jms.ConnectionContext) BrokerService(org.apache.activemq.broker.BrokerService) TextMessage(javax.jms.TextMessage) JMSJobEventListener(org.apache.oozie.jms.JMSJobEventListener) Session(javax.jms.Session) Test(org.junit.Test)

Example 5 with Services

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;
    }
}
Also used : Services(org.apache.oozie.service.Services) EmbeddedServletContainer(org.apache.oozie.test.EmbeddedServletContainer)

Aggregations

Services (org.apache.oozie.service.Services)247 JPAService (org.apache.oozie.service.JPAService)32 Configuration (org.apache.hadoop.conf.Configuration)21 Date (java.util.Date)17 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)16 File (java.io.File)14 Before (org.junit.Before)14 XConfiguration (org.apache.oozie.util.XConfiguration)11 Path (org.apache.hadoop.fs.Path)10 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)10 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)8 EmbeddedServletContainer (org.apache.oozie.test.EmbeddedServletContainer)8 FileOutputStream (java.io.FileOutputStream)7 InputStream (java.io.InputStream)7 HashMap (java.util.HashMap)7 IOException (java.io.IOException)6 Properties (java.util.Properties)6 ActionService (org.apache.oozie.service.ActionService)6 StringWriter (java.io.StringWriter)5 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)5