Examples of CallbackService


Examples of org.apache.oozie.service.CallbackService

    }

    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

Examples of org.apache.oozie.service.CallbackService

     * 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

Examples of org.apache.oozie.service.CallbackService

     */
    @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

Examples of org.apache.oozie.service.CallbackService

     * 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);
        }
        log = XLog.getLog(getClass());
        setLogInfo(actionId);
        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

Examples of org.apache.oozie.service.CallbackService

     */
    @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);
        }
        log = XLog.getLog(getClass());
        setLogInfo(actionId);
        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

Examples of org.exolab.jms.net.CallbackService

        Proxy proxy = server.exportObject(serviceImpl);
        server.getRegistry().bind("service", proxy);

        ORB client = getClientORB();
        Registry registry = client.getRegistry(getConnectionProperties());
        CallbackService service = (CallbackService) registry.lookup("service");

        LoggingCallback callback = new LoggingCallback();
        Callback callbackProxy = (Callback) client.exportObjectTo(callback,
                                                                  getServerURI());
        service.addCallback(callbackProxy);

        assertNull(serviceImpl.getException());
        client.shutdown();

        if (!latch.attempt(10 * 1000)) {
View Full Code Here

Examples of org.exolab.jms.net.CallbackService

        ORB client = getClientORB();
        client.addCallerListener(getServerURI(), listener);

        Registry registry = getRegistry(); // will establish a connection
        assertNotNull(registry);
        CallbackService service = (CallbackService) registry.lookup("service");
        assertNotNull(service);

        // make sure the connection isn't reaped through inactivity
        // while there are proxies associated with it.
        for (int i = 0; i < 10; ++i) {
View Full Code Here

Examples of org.exolab.jms.net.CallbackService

     */
    public void testCallback() throws Exception {
        final int count = 10;
        ORB client = getClientORB();
        Registry registry = client.getRegistry(getConnectionProperties());
        CallbackService service =
                (CallbackService) registry.lookup(CALLBACK_SERVICE);

        LoggingCallback callback = new LoggingCallback();
        Callback proxy = (Callback) client.exportObjectTo(callback,
                                                          getServerURI());
        service.addCallback(proxy);

        for (int i = 0; i < count; ++i) {
            _service.invoke(new Integer(i));
        }

View Full Code Here

Examples of org.exolab.jms.net.CallbackService

        final int count = 10;
        final int depth = 4; // recursion depth

        ORB client = getClientORB();
        Registry registry = client.getRegistry(getConnectionProperties());
        CallbackService service =
                (CallbackService) registry.lookup(CALLBACK_SERVICE);

        RecursiveCallback callback = new RecursiveCallback(service, depth);
        Callback proxy = (Callback) client.exportObjectTo(callback,
                                                          getServerURI());
        service.addCallback(proxy);

        for (int i = 0; i < count; ++i) {
            _service.invoke(new Integer(i));
        }
View Full Code Here

Examples of org.exolab.jms.net.CallbackService

        }

        Authenticator authenticator = new TestAuthenticator(principal);
        ORB orb = createORB(authenticator);

        CallbackService serviceImpl = new CallbackServiceImpl();
        Proxy proxy = orb.exportObject(serviceImpl);
        orb.getRegistry().bind("service", proxy);

        ORB client = getClientORB();
        Registry registry = getRegistry(principal);
        CallbackService service = (CallbackService) registry.lookup("service");

        LoggingCallback callback = new LoggingCallback();
        Callback callbackProxy = (Callback) client.exportObjectTo(
                callback, getServerURI(), user, password);
        service.addCallback(callbackProxy);

        for (int i = 0; i < count; ++i) {
            service.invoke(new Integer(i));
        }

        Integer[] objects = (Integer[]) callback.getObjects().toArray(
                new Integer[0]);
        assertEquals(count, objects.length);
        for (int i = 0; i < count; ++i) {
            assertEquals(i, objects[i].intValue());
        }

        client.unexportObject(callback);
        try {
            service.invoke(new Integer(0));
        } catch (RemoteInvocationException expected) {
            // expected behaviour
            assertTrue(expected.getTargetException()
                       instanceof NoSuchObjectException);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.