Package org.apache.oozie.service

Examples of org.apache.oozie.service.CallbackService


        Services.get().destroy();
        super.tearDown();
    }

    public void testService() throws Exception {
        CallbackService cs = Services.get().get(CallbackService.class);
        assertNotNull(cs);
    }
View Full Code Here


        CallbackService cs = Services.get().get(CallbackService.class);
        assertNotNull(cs);
    }

    public void testCallbacks() throws Exception {
        CallbackService cs = Services.get().get(CallbackService.class);
        assertNotNull(cs);
        String callback = cs.createCallBackUrl("a", "@STATUS");
        assertTrue(callback.contains("http://"));
        assertTrue(callback.contains("id=a"));
        assertTrue(callback.contains("status=@STATUS"));
        callback = callback.replace("@STATUS", "OK");
        assertEquals("a", cs.getActionId(callback));
        assertEquals("OK", cs.getExternalStatus(callback));
    }
View Full Code Here

     * GET callback
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String queryString = request.getQueryString();
        CallbackService callbackService = Services.get().get(CallbackService.class);

        if (!callbackService.isValid(queryString)) {
            throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E0402, queryString);
        }

        String actionId = callbackService.getActionId(queryString);
        if (actionId == null) {
            throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E0402, queryString);
        }
        int idx = actionId.lastIndexOf('@', actionId.length());
        String jobId;
        if (idx == -1) {
            jobId = actionId;
        }
        else {
            jobId = actionId.substring(0, idx);
        }
        setLogInfo(jobId, actionId);
        log = XLog.getLog(getClass());
        log.debug("Received a CallbackServlet.doGet() with query string " + queryString);

        DagEngine dagEngine = Services.get().get(DagEngineService.class).getSystemDagEngine();
        try {
            log.info(XLog.STD, "callback for action [{0}]", actionId);
            dagEngine.processCallback(actionId, callbackService.getExternalStatus(queryString), null);
        }
        catch (DagEngineException ex) {
            throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
        }
    }
View Full Code Here

     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
            IOException {
        String queryString = request.getQueryString();
        CallbackService callbackService = Services.get().get(CallbackService.class);

        if (!callbackService.isValid(queryString)) {
            throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E0402, queryString);
        }

        String actionId = callbackService.getActionId(queryString);
        if (actionId == null) {
            throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E0402, queryString);
        }
        int idx = actionId.lastIndexOf('@', actionId.length());
        String jobId;
        if (idx == -1) {
            jobId = actionId;
        }
        else {
            jobId = actionId.substring(0, idx);
        }
        setLogInfo(jobId, actionId);
        log = XLog.getLog(getClass());
        log.debug("Received a CallbackServlet.doPost() with query string " + queryString);

        validateContentType(request, RestConstants.TEXT_CONTENT_TYPE);
        try {
            log.info(XLog.STD, "callback for action [{0}]", actionId);
            String data = IOUtils.getReaderAsString(request.getReader(), maxDataLen);
            Properties props = PropertiesUtils.stringToProperties(data);
            DagEngine dagEngine = Services.get().get(DagEngineService.class).getSystemDagEngine();
            dagEngine.processCallback(actionId, callbackService.getExternalStatus(queryString), props);
        }
        catch (IOException ex) {
            if (ex.getMessage().startsWith("stream exceeds limit")) {
                // TODO, WE MUST SET THE ACTION TO ERROR
                throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E0403, "data too long");
View Full Code Here

public class TestCallbackService extends XTestCase {

    public void testService() throws Exception {
        Services services = new Services();
        services.init();
        CallbackService cs = services.get(CallbackService.class);
        assertNotNull(cs);
        services.destroy();
    }
View Full Code Here

    }

    public void testCallbacks() throws Exception {
        Services services = new Services();
        services.init();
        CallbackService cs = services.get(CallbackService.class);
        assertNotNull(cs);
        String callback = cs.createCallBackUrl("a", "@STATUS");
        assertTrue(callback.contains("http://"));
        assertTrue(callback.contains("id=a"));
        assertTrue(callback.contains("status=@STATUS"));
        callback = callback.replace("@STATUS", "OK");
        assertEquals("a", cs.getActionId(callback));
        assertEquals("OK", cs.getExternalStatus(callback));
        services.destroy();
    }
View Full Code Here

        Services.get().destroy();
        super.tearDown();
    }

    public void testService() throws Exception {
        CallbackService cs = Services.get().get(CallbackService.class);
        assertNotNull(cs);
    }
View Full Code Here

        CallbackService cs = Services.get().get(CallbackService.class);
        assertNotNull(cs);
    }

    public void testCallbacks() throws Exception {
        CallbackService cs = Services.get().get(CallbackService.class);
        assertNotNull(cs);
        String callback = cs.createCallBackUrl("a", "@STATUS");
        assertTrue(callback.contains("http://"));
        assertTrue(callback.contains("id=a"));
        assertTrue(callback.contains("status=@STATUS"));
        callback = callback.replace("@STATUS", "OK");
        assertEquals("a", cs.getActionId(callback));
        assertEquals("OK", cs.getExternalStatus(callback));
    }
View Full Code Here

public class TestCallbackService extends XTestCase {

    public void testService() throws Exception {
        Services services = new Services();
        services.init();
        CallbackService cs = services.get(CallbackService.class);
        assertNotNull(cs);
        services.destroy();
    }
View Full Code Here

    }

    public void testCallbacks() throws Exception {
        Services services = new Services();
        services.init();
        CallbackService cs = services.get(CallbackService.class);
        assertNotNull(cs);
        String callback = cs.createCallBackUrl("a", "@STATUS");
        assertTrue(callback.contains("http://"));
        assertTrue(callback.contains("id=a"));
        assertTrue(callback.contains("status=@STATUS"));
        callback = callback.replace("@STATUS", "OK");
        assertEquals("a", cs.getActionId(callback));
        assertEquals("OK", cs.getExternalStatus(callback));
        services.destroy();
    }
View Full Code Here

TOP

Related Classes of org.apache.oozie.service.CallbackService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.