Package net.hasor.rsf.protocol.message

Examples of net.hasor.rsf.protocol.message.ResponseMsg


        System.out.println("ok(%)     :" + okCount);
        System.out.println();
    }
    //
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        ResponseMsg response = (ResponseMsg) msg;
        //
        if (response.getStatus() == ProtocolStatus.Accepted.shortValue())
            acceptedCount++;
        else if (response.getStatus() == ProtocolStatus.ChooseOther.shortValue())
            chooseOtherCount++;
        else if (response.getStatus() == ProtocolStatus.OK.shortValue())
            okCount++;
        else if (response.getStatus() == ProtocolStatus.SerializeError.shortValue())
            serializeError++;
        else if (response.getStatus() == ProtocolStatus.RequestTimeout.shortValue())
            requestTimeout++;
        else {
            int a = 0;
            a++;
        }
View Full Code Here


        System.out.println("ok(%)     :" + okCount);
        System.out.println();
    }
    //
    public void atMsg(ChannelHandlerContext ctx, Object msg) throws Exception {
        ResponseMsg response = (ResponseMsg) msg;
        //
        if (response.getStatus() == ProtocolStatus.Accepted)
            acceptedCount++;
        else if (response.getStatus() == ProtocolStatus.ChooseOther)
            chooseOtherCount++;
        else if (response.getStatus() == ProtocolStatus.OK)
            okCount++;
        else if (response.getStatus() == ProtocolStatus.SerializeError)
            serializeError++;
        else if (response.getStatus() == ProtocolStatus.RequestTimeout)
            requestTimeout++;
        else {
            int a = 0;
            a++;
        }
View Full Code Here

        //
        try {
            Executor exe = this.rsfContext.getCallExecute(requestMsg.getServiceName());
            exe.execute(new InnerInvokeHandler(this.rsfContext, requestMsg, ctx.channel()));
            //
            ResponseMsg pack = TransferUtils.buildStatus(//
                    requestMsg.getVersion(), //协议版本
                    requestMsg.getRequestID(),//请求ID
                    ProtocolStatus.Accepted);//回应ACK
            ctx.pipeline().writeAndFlush(pack);
        } catch (RejectedExecutionException e) {
            ResponseMsg pack = TransferUtils.buildStatus(//
                    requestMsg.getVersion(), //协议版本
                    requestMsg.getRequestID(),//请求ID
                    ProtocolStatus.ChooseOther);//服务器资源紧张
            ctx.pipeline().writeAndFlush(pack);
        }
View Full Code Here

        return reqMetaData;
    };
    /**将{@link ResponseSocketBlock}转换为{@link ResponseMsg }消息。*/
    public static ResponseMsg responseToMessage(ResponseSocketBlock block) {
        //1.基本参数
        ResponseMsg resMetaData = new ResponseMsg();
        resMetaData.setVersion(block.getVersion());//协议版本
        resMetaData.setRequestID(block.getRequestID());//请求ID
        resMetaData.setStatus(block.getStatus());//响应状态
        resMetaData.setSerializeType(getString(block, block.getSerializeType()));//序列化策略
        resMetaData.setReturnType(getString(block, block.getReturnType()));//返回类型
        resMetaData.setReturnData(block.readPool(block.getReturnData()));//返回数据
        //2.Opt参数
        short[] oTypes = block.getOptionKeys();
        short[] oValues = block.getOptionValues();
        for (int i = 0; i < oTypes.length; i++) {
            String optKey = getString(block, oTypes[i]);
            String optVar = getString(block, oValues[i]);
            //
            resMetaData.addOption(optKey, optVar);
        }
        return resMetaData;
    };
View Full Code Here

        return buildStatus(version, requestID, status.shortValue());
    }
    /**生成指定状态的的响应包*/
    public static ResponseMsg buildStatus(byte version, long requestID, short status) {
        //1.发送ACK包
        ResponseMsg ack = new ResponseMsg();
        ack.setVersion(ProtocolUtils.finalVersionForResponse(version));
        ack.setRequestID(requestID);
        ack.setStatus(status);
        return ack;
    }
View Full Code Here

        if (pType == ProtocolType.Response) {
            //response
            Protocol<ResponseSocketBlock> responseProtocol = ProtocolUtils.responseProtocol(version);
            if (responseProtocol != null) {
                ResponseSocketBlock block = responseProtocol.decode(frame);
                ResponseMsg resMetaData = TransferUtils.responseToMessage(block);
                ctx.fireChannelRead(resMetaData);
                return null;/*正常处理后返回*/
            }
        }
        /*                    错误情况*/
 
View Full Code Here

    //
    /**发送协议错误 */
    private void fireProtocolError(ChannelHandlerContext ctx, byte oriVersion, long requestID) {
        //502 ProtocolError
        byte version = ProtocolUtils.getVersion(oriVersion);
        ResponseMsg error = TransferUtils.buildStatus(//
                version, requestID, ProtocolStatus.ProtocolError);
        ctx.pipeline().writeAndFlush(error);
    }
View Full Code Here

    private boolean        committed    = false;
    //
    public RsfResponseImpl(RsfRequestImpl rsfRequest, RsfContext rsfContext) {
        this.rsfRequest = rsfRequest;
        this.rsfContext = rsfContext;
        this.responseMsg = new ResponseMsg();
        this.responseMsg.setVersion(rsfRequest.getProtocol());
        this.responseMsg.setRequestID(rsfRequest.getRequestID());
        this.responseMsg.setStatus(ProtocolStatus.Unknown);
        this.responseMsg.setSerializeType(rsfRequest.getSerializeType());
    }
View Full Code Here

TOP

Related Classes of net.hasor.rsf.protocol.message.ResponseMsg

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.