Package org.geoserver.monitor

Examples of org.geoserver.monitor.RequestData


                while(it.hasNext()) {
                    //TODO: avoid the intense object creation, and reflection... we probably
                    // just want to expose the values directly to the visitor
                    Object[] values = q.getProperties().size() == 1 ? new Object[]{it.next()} :
                        (Object[]) it.next();
                    RequestData data = new RequestData();
                    for (int i = 0; i < values.length; i++) {
                        OwsUtils.set(data, q.getProperties().get(i), values[i]);
                    }
                    visitor.visit(data);
                }
View Full Code Here


        return bean;
    }
   
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if ("operationDispatched".equals(method.getName()) && monitor.current() != null) {
            RequestData data = monitor.current();
            if (data == null) {
                // means monitor is configured but inactive
                return method.invoke(target, args);
            }

            data.setStatus(Status.WAITING);
            monitor.update();
           
            Object result = method.invoke(target, args);
            data.setStatus(Status.RUNNING);
            monitor.update();
            return result;
        }
        else {
            return method.invoke(target, args);
View Full Code Here

    public Service serviceDispatched(Request request, Service service) throws ServiceException {
        return null;
    }
   
    public Operation operationDispatched(Request request, Operation operation) {
        RequestData data = monitor.current();
        if (data == null) {
            //will happen in cases where the filter is not active
            return operation;
        }
       
        data.setOwsService(operation.getService().getId().toUpperCase());
        data.setOwsOperation(normalizedOpId(operation));
        data.setOwsVersion(operation.getService().getVersion().toString());
       
        if (operation.getParameters().length > 0) {
            //TODO: a better check for the request object
            Object reqObj = operation.getParameters()[0];
            for (RequestObjectHandler h : HANDLERS) {
View Full Code Here

        return null;
    }
   
    public void finished(Request request) {
        if (request.getError() != null) {
            RequestData data = monitor.current();
            if (data == null) {
                //will happen in cases where the filter is not active
                return;
            }
           
            data.setStatus(Status.FAILED);
            data.setErrorMessage(request.getError().getLocalizedMessage());
            data.setError(request.getError());
           
            monitor.update();
        }
    }
View Full Code Here

           
            return monitor.getDAO().getRequests(q);
        }
        else {
            //return the individual
            RequestData data = monitor.getDAO().getRequest(Long.parseLong(req));
            if (data == null) {
                throw new RestletException("No such request" + req, Status.CLIENT_ERROR_NOT_FOUND);
            }
            return data;
        }
View Full Code Here

        monitor = new Monitor(dao);
    }
   
    @Test
    public void test() throws Exception {
        final RequestData data = monitor.start();
        DispatcherCallback callback = new DispatcherCallback() {
           
            public Service serviceDispatched(Request request, Service service) throws ServiceException {
                return null;
            }
           
            public Response responseDispatched(Request request, Operation operation, Object result,
                    Response response) {
                return null;
            }
           
            public Object operationExecuted(Request request, Operation operation, Object result) {
                return null;
            }
           
            public Operation operationDispatched(Request request, Operation operation) {
                assertEquals(Status.WAITING, data.getStatus());
                return operation;
            }
           
            public Request init(Request request) {
                return null;
            }
           
            public void finished(Request request) {
            }
        };
       
        ControlFlowCallbackProxy proxy = new ControlFlowCallbackProxy(monitor, callback);
        callback = (DispatcherCallback) Proxy.newProxyInstance(getClass().getClassLoader(),
                new Class[]{DispatcherCallback.class}, proxy);
       
        callback.operationDispatched(new Request(),
            new Operation("foo", new Service("bar", null, null, null), null, null));
       
        assertEquals(Status.RUNNING, data.getStatus());
    }
View Full Code Here

       
        Iterator<RequestData> it = monitor.getDAO().getRequests().iterator();
        while((line = in.readLine()) != null) {
            assertTrue(it.hasNext());
           
            RequestData data = it.next();
            String expected = data.getId() + "," + data.getPath() + "," +
                DateUtil.serializeDateTime(data.getStartTime());
            assertEquals(expected, line);
        }
       
        assertFalse(it.hasNext());
    }
View Full Code Here

        RequestResource.ZIPFormat zip = new RequestResource.ZIPFormat(
            Arrays.asList("id", "path", "startTime", "Error", "Body"), csv, monitor);
       
        Date startTime  = new Date();
        Throwable throwable = new Throwable();
        RequestData data = new RequestData();
        data.setId(12345);
        data.setPath("/foo");
        data.setStartTime(startTime);
       
        data.setBody("<foo></foo>".getBytes());
        data.setError(throwable);
       
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        zip.toRepresentation(data).write(out);
       
        ZipInputStream zin = new ZipInputStream(new ByteArrayInputStream(out.toByteArray()));
View Full Code Here

        req.getAttributes().put("request", 2);
       
        Response res = new Response(req);
       
        resource.init(null, req, res);
        RequestData data = (RequestData) resource.handleObjectGet();
        assertEquals("/two", data.getPath());
    }
View Full Code Here

    public RESTMonitorCallback(Monitor monitor) {
        this.monitor = monitor;
    }
   
    public void init(Request request, Response response) {
        RequestData data = monitor.current();
        if (data == null) {
            //will happen in cases where the filter is not active
            return;
        }
       
        data.setCategory(Category.REST);
        if (request.getResourceRef() != null) {
            String resource = request.getResourceRef().getLastSegment();
            resource = FilenameUtils.getBaseName(resource);
            data.getResources().add(resource);
        }
        monitor.update();
    }
View Full Code Here

TOP

Related Classes of org.geoserver.monitor.RequestData

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.