Package org.jvnet.glassfish.comms.clb.proxy.http.util

Examples of org.jvnet.glassfish.comms.clb.proxy.http.util.HttpRequest


    }

    public boolean invoke(Request request, Response response)
        throws Exception {
       
        HttpRequest httpReq = (HttpRequest) request;               
        String requestUri = httpReq.requestURI().toString();
        if(_logger.isLoggable(Level.FINER))
            _logger.log(Level.FINER,
                    "clb.httpLBM_servicing_request",
                    new Object[]{requestUri});
       
        if (ProxyKeyExtractor.isHttpRequestProxied(httpReq)) {
            if(_logger.isLoggable(Level.FINER))
                _logger.log(Level.FINER,
                        "clb.httpLBM_request_already_proxied",
                        new Object[]{requestUri});
            setLocalEndPoint(httpReq);

            if(clbMonitoringManager.isCLBMonitoringEnabled()){
                clbMonitoringManager.getCLBStatsUpdater().
                        incrementTotalIncomingHttpRequestsBE();
            }
            return true;
        }

        if(clbMonitoringManager.isCLBMonitoringEnabled()){
                clbMonitoringManager.getCLBStatsUpdater().
                        incrementTotalIncomingHttpRequestsFE();
        }
       
        /* Case Controller is null
         * The possibility is that initialization is not done - This may happen in case
         * if converged-load-balancer.xml is corrupt or not present at all
         */
        if (controller == null) {
            /* Only case it can be null is when it is not intialized for load-balancing
             * Cannot handle this request so setting error in response
             */
            _logger.log(Level.SEVERE,
                    "clb.controller_null_returning_error",
                    new Object[]{requestUri});
            setErrorInResponse(response);
            return false;
        }

        RequestGroup reqGroup = controller.getRequestGroup(requestUri);
       
        if (reqGroup == null) {
            /* No request group found for this request
             * let pass it to the same instance and see if it can handle it
             */
           
            if(_logger.isLoggable(Level.FINER))
                _logger.log(Level.FINER,
                        "clb.locally_service_request",
                        new Object[]{requestUri});
            setLocalEndPoint(httpReq);
            if(clbMonitoringManager.isCLBMonitoringEnabled()){
                clbMonitoringManager.getCLBStatsUpdater().
                        incrementTotalLocalHttpRequestsFE();
                clbMonitoringManager.getCLBStatsUpdater().
                        incrementTotalIncomingHttpRequestsBE();
            }
            return true;
        }

        if(_logger.isLoggable(Level.FINER))
            _logger.log(Level.FINER,
                    "clb.request_group_found",
                    new Object[]{requestUri});
        reqGroup.serviceRequest(httpReq, (Response) response);
       
        if(httpReq.getConvergedLoadBalancerEndpoint() == null){
            _logger.log(Level.SEVERE,
                "clb.no_endpoint_set_to_service_request",
                new Object[]{requestUri});
            setErrorInResponse(response);
            return false;
        }

        if (httpReq.getConvergedLoadBalancerEndpoint().isLocal()) {
            if(_logger.isLoggable(Level.FINER))
                _logger.log(Level.FINER,
                        "clb.request_to_be_serviced_by_local_endpoint",
                        new Object[]{requestUri});
            if(clbMonitoringManager.isCLBMonitoringEnabled()){
View Full Code Here


    public boolean invoke(Request request, Response response)
    throws Exception {
        if (_logger.isLoggable(Level.FINEST)){
            _logger.log(Level.FINEST, "clb.proxy.test.loadbalancerlayer_begin");
        }
        HttpRequest httpReq = (HttpRequest) request;
        Endpoint remoteEndpoint = null;
        boolean ret = true;
        if (request.getHeader("ERRORTEST") != null) {
            response.setHeader("TESTHEADER", "ProxyTest");
            response.setErrorURI("testurl");
            response.setStatus(500);
            response.setMessage("Internal Server Error");
            _logger.log(Level.INFO, "clb.proxy.test.error_response");
            return false;
        }
        if ((httpReq.getHeader(LoadBalancerProxyConstants.HTTP_PROXY_HEADER) != null)) {
            Endpoint ep = new DefaultEndpoint();
            ep.setLocal(true);
            httpReq.setConvergedLoadBalancerEndpoint(ep);
            return false;
        }
        InetSocketAddress remoteHost = RoundRobinPolicy.getInetSocketAddress(request);
        if (_logger.isLoggable(Level.FINE)){
            _logger.log(Level.FINE,"clb.proxy.test.remote_host", remoteHost);
        }
        if (remoteHost.getAddress().isLoopbackAddress() &&
                (remoteHost.getPort() == ProxyConfig.getInstance().getLocalPort())) {
            remoteEndpoint = new DefaultEndpoint();
            remoteEndpoint.setLocal(true);
           
            ret = false;
        } else {
            remoteEndpoint = new DefaultEndpoint(remoteHost);
            httpReq.addHeader(LoadBalancerProxyConstants.HTTP_PROXY_HEADER,
                    remoteHost.getAddress().toString());
        }
       
        if (_logger.isLoggable(Level.FINEST)) {
            httpReq.dump();
        }       
        httpReq.setConvergedLoadBalancerEndpoint(remoteEndpoint);
        if (_logger.isLoggable(Level.FINEST)){
            _logger.log(Level.FINEST, "clb.proxy.test.loadbalancerlayer_end");
        }
        return ret;
    }
View Full Code Here

   
    @SuppressWarnings("empty-statement")
    public boolean invoke(Request request, Response response)
    throws Exception {
        HttpInputBuffer buffer = (HttpInputBuffer) request.getInputBuffer();
        HttpRequest httpReq = (HttpRequest) request;
        if (_logger.isLoggable(Level.FINEST)){
            _logger.log(Level.FINEST, "clb.proxy.test.parserlayer_begin");
        }
        try {
            buffer.parseRequestLine();
           
            if (_logger.isLoggable(Level.FINEST)) {
                httpReq.dump();
            }
           
            buffer.parseHeaders();
           
            if (_logger.isLoggable(Level.FINEST)) {
                httpReq.dumpHeaders();
            }
        } catch (IOException e) {
            e.printStackTrace();
            throw e;
           
View Full Code Here

        _logger = ProxyConfig.getInstance().getLogger();
        initialize(secure);
    }

    public void initialize(boolean secure){
        request  = new HttpRequest();
        inputBuffer = new HttpInputBuffer(request);
        inputStream = secure ? new SSLByteBufferInputStream()
        : new ByteBufferInputStream();
       
        inputBuffer.setInputStream(inputStream);
View Full Code Here

TOP

Related Classes of org.jvnet.glassfish.comms.clb.proxy.http.util.HttpRequest

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.