Package org.jvnet.glassfish.comms.clb.proxy.api

Examples of org.jvnet.glassfish.comms.clb.proxy.api.Endpoint


    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)){
View Full Code Here


    /**
     * Creater a TCP client connection handler.
     */
    private  ConnectorHandler createHandler(ProxyRequestHandler task)
    throws Exception {
        Endpoint ep = task.getEndpoint();
        SocketAddress remote = ep.getSocketAddress();
        CallbackHandler callbackHandler = null;
        ConnectorHandler connectorHandler =
                cacheableHandlerPool.getConnection(ep)
       
        if ((connectorHandler == null) ||
                (connectorHandler.getUnderlyingChannel() == null) ||
                (!connectorHandler.getUnderlyingChannel().isOpen())){
            connectorHandler =
                    controller.acquireConnectorHandler(Controller.Protocol.TCP);               
            callbackHandler =
                new DefaultCallBackHandler(connectorHandler, task);
            ((TCPConnectorHandler)connectorHandler).setConnectionTimeout(10*1000);
            try {
                if (ep.getBindAddress() == null){
                    connectorHandler.connect(remote, callbackHandler);
                } else {
                    connectorHandler.connect(remote,
                            new InetSocketAddress(ep.getBindAddress(), 0), callbackHandler);
                }
            } catch (Exception ex) {
                throw ex;
            }
        } else {
View Full Code Here

    public boolean equals(Object obj) {
        if (!(obj instanceof Endpoint)) {
            return false;
        }
       
        Endpoint ep = (Endpoint) obj;
       
        if (port != ep.getPort()) {
            return false;
        }
       
        if ((getIp() != null) && !getIp().equals(ep.getIp())) {
            return false;
        }
       
        if (isSecure() != ep.isSecure()) {
            return false;
        }
       
        return true;
    }
View Full Code Here

            task.setOutputBB(protocolInfo.outputBB);
            task.doTask();
            protocolInfo.inputBB = task.getBuffer();
            protocolInfo.bytesRead = task.getBuffer().position();
            protocolInfo.byteBuffer = task.getBuffer();
            Endpoint remoteHost = task.getEndpoint();
           
            /**
             *  Possible conditions
             * 1. Endpoint is null and the layer execution
             * completed (without any layer returning false).
             * In this case pass it on to the local container.
             * 2. Endpoint is null and one of the layers failed
             * and set a response code != 200, then we send back
             * an error response through the handler.
             * 3. Endpoint is not null and is a local one then pass
             * it on to container.
             * 4. Endpoint is not null and is a remote one, then proxy
             * it.
             * Assumption: If a layer fails (returns false), then it
             * will set a proper http status code in response
             */
            if (remoteHost == null) {
                if (task.getResponse().getStatus() == 200) {
                    if(_logger.isLoggable(Level.FINE)){
                        _logger.log(Level.FINE, "clb.proxy.request_endpoint_null_200");
                    }
                    task.recycle();
                    objManager.offerTask(task, protocolInfo.isSecure);
                    return false;
                } else {
                    if(_logger.isLoggable(Level.FINE)){
                        _logger.log(Level.FINE, "clb.proxy.request_endpoint_null");
                    }
                }
            } else if (remoteHost.isLocal()) {
                if(_logger.isLoggable(Level.FINE)){
                    _logger.log(Level.FINE, "clb.proxy.request_local");
                }
                task.recycle();
                objManager.offerTask(task, protocolInfo.isSecure);
View Full Code Here

            _logger.log(Level.FINEST, "clb.proxy.http.protocol_handler_invoked", protocolInfo.key);
        }
        Object ptask = ((ClbProxyProtocolInfo) protocolInfo).object;

        ProxyRequestHandler task = null;
        Endpoint endpoint = null;
        Request request = null;
        Response response = null;       
        proxy.setSelectorThread(((ClbProxyProtocolInfo) protocolInfo).selectorThread);
      
        if (ptask != null) {
View Full Code Here

        }
        process();
        if (_logger.isLoggable(Level.FINEST)){
            _logger.log(Level.FINEST,"clb.proxy.requesthandler.finished_process");
        }
        Endpoint endpoint = getEndpoint();
        if( endpoint != null && !endpoint.isLocal())
            handleRemoteTermination();
        postProcess();
        if (_logger.isLoggable(Level.FINEST)){
            _logger.log(Level.FINEST,"clb.proxy.requesthandler.finished_postprocess");
        }
View Full Code Here

TOP

Related Classes of org.jvnet.glassfish.comms.clb.proxy.api.Endpoint

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.