当前位置: 首页 > news >正文

网站logo的颜色与网页的颜色旅游网站建设调研

网站logo的颜色与网页的颜色,旅游网站建设调研,乐云seo模板网站建设,西安单位网站建设文章目录 RPC项目 配置中心项目 网关项目 在前面的文章了解完毕之后#xff0c;我们以及设计了一个基本的RPC协议#xff0c;之后#xff0c;我们要做的就是基于这个RPC协议#xff0c;去实现一个能解析这个RPC协议的编解码器。 这里编解码器比较容易写#xff0c;按照… 文章目录 RPC项目 配置中心项目 网关项目 在前面的文章了解完毕之后我们以及设计了一个基本的RPC协议之后我们要做的就是基于这个RPC协议去实现一个能解析这个RPC协议的编解码器。 这里编解码器比较容易写按照前面几篇文章中讲解的方式来编写即可。 Slf4j public class RpcEncode extends MessageToByteEncoderRpcDtoObject {Overrideprotected void encode(ChannelHandlerContext ctx, RpcDtoObject msg, ByteBuf out) throws Exception {log.info(Start encoding the data);//判断请求头合法性if (Objects.isNull(msg)) {log.warn(the RpcDto msg is Null!!!);return;}RpcHeader RpcHeadermsg.getHeader();out.writeByte(RpcHeader.getVersionId());out.writeByte(RpcHeader.getAlgorithmType());out.writeByte(RpcHeader.getReqType());out.writeLong(RpcHeader.getReqId());//设定序列化算法Serializer serializer SerializerStrategy.getSerializer(RpcHeader.getAlgorithmType());byte[] dataserializer.serialize(msg.getData());//设定数据长度out.writeInt(data.length);//设定数据out.writeBytes(data);} }解码器的代码也并不难写我们不断的从bytebuf中读取数据即可然后最后还原为RpcDto对象即可。 package blossom.project.rpc.core.netty.codec;import blossom.project.rpc.common.constants.RpcCommonConstants; import blossom.project.rpc.common.enums.ReqTypeEnum; import blossom.project.rpc.core.entity.RpcDto; import blossom.project.rpc.core.entity.RpcHeader; import blossom.project.rpc.core.entity.RpcRequest; import blossom.project.rpc.core.entity.RpcResponse; import blossom.project.rpc.core.serialize.Serializer; import blossom.project.rpc.core.serialize.SerializerStrategy; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ByteToMessageDecoder; import lombok.extern.slf4j.Slf4j;import java.util.List; import java.util.Objects;/*** author: ZhangBlossom* date: 2023/12/16 18:58* contact: QQ:4602197553* contact: WX:qczjhczs0114* blog: https://blog.csdn.net/Zhangsama1* github: https://github.com/ZhangBlossom* RpcDecode类* 平平无奇RPC自定义协议的解码器*/ Slf4j public class RpcDecode extends ByteToMessageDecoder {Overrideprotected void decode(ChannelHandlerContext ctx, ByteBuf in, ListObject out) throws Exception {log.info(Start decoding the data);//判断请求头合法性if (Objects.isNull(in)) {log.warn(the data is Null!!!);return;}//因为我们的数据至少包含请求头请求体 因此长度小于此肯定有问题if (in.readableBytes() RpcCommonConstants.HEADER_LENGTH) {log.warn(The length of the request header does not meet the requirements!!!);return;}//读取版本号byte versionId in.readByte();if (versionId ! RpcCommonConstants.VERSION_ID) {throw new IllegalArgumentException(Illegal versionId!!!);}//继续读取请求头信息byte algorithmType in.readByte();byte reqType in.readByte();long reqId in.readLong();int length in.readInt();//判断可读长度是否小于请求头中设定的请求体长度if (in.readableBytes() length) {//数据长度不对劲 先丢掉log.info(the readable bytess length is less!!!);return;}RpcHeader header new RpcHeader(versionId, algorithmType, reqType, reqId, length);//获得反序列化器Serializer serializer SerializerStrategy.getSerializer(algorithmType);//获得请求类型ReqTypeEnum reqTypeEnum ReqTypeEnum.getReqTypeByCode(reqType);//得到实际传输的数据byte[] data new byte[length];in.readBytes(data);RpcDto dto null;switch (reqTypeEnum) {case REQUEST:// 处理 GET 请求逻辑log.info(Handling REQUEST request);RpcRequest request serializer.deserialize(data, RpcRequest.class);dto new RpcDtoRpcRequest();dto.setHeader(header);dto.setData(request);//设定到out中 会自动被handler处理out.add(dto);break;case RESPONSE:// 处理 RESPONSE 请求逻辑log.info(Handling RESPONSE request);RpcResponse response serializer.deserialize(data, RpcResponse.class);dto new RpcDtoRpcResponse();dto.setHeader(header);dto.setData(response);//设定到out中 会自动被handler处理out.add(dto);break;case HEARTBEAT:// 处理心跳检测逻辑log.info(Handling HEARTBEAT request);break;default:log.warn(Unsupported request type: reqTypeEnum);}} }编解码器我们就写完了接下来我们先不编写Handler因为其实从上到下Handler最终的设计思路还没办法那么快确定。 我们先去编写一个Server端和Client端。 然后设计一下我们希望的RPC调用方式。 这里我们参考dubbo的实现。
http://www.pierceye.com/news/723828/

相关文章:

  • 网站建设在哪wordpress ping地址
  • 资讯文章网站模板徐州百度推广
  • 网站排名如何做西安有哪些网站设计公司
  • 广州网站开发学校wordpress优秀站点
  • wordpress 当前文章所属分类seo网站推广怎么做
  • 做网站要求电脑配置wordpress页眉描述
  • 做网站感想室内设计联盟邀请码怎么弄
  • 上海高端网站制作公司互联网黄页是什么
  • 网站服务器在阿里云专有网络做网站
  • 泰坦科技网站建设js代码 嵌入网站
  • 首都之窗门户网站首页中山做百度网站的公司吗
  • 网站 关键字 标签dede关闭网站
  • 甘肃路桥建设集团公司网站网页搭建模板
  • 山西省住房和城乡建设厅官网长沙seo关键词
  • 红酒 网站 模板网页qq登录保护在哪里
  • 目前哪些企业需要做网站建设的呢官方网站建设最重要的是
  • 电影题材网页设计欣赏长春seo关键词排名
  • 深圳网站建设索q.479185700如何修改网站后台的用户名和密码
  • 长春网站推广专门做二手书网站或app
  • 北京智能网站建设制作什么叫优化
  • 免费移动网站建站wordpress加skype
  • 企业推广建站网页开发教程
  • 外贸网站定制开发网站虚拟主机过期
  • 学习网站建设要报班吗中国建设银行晋中分行网站
  • 学校网站建设经验介绍西安建设网站公司
  • 江西营销网站建设公司的企业诚信建设分析
  • 生活家装饰官方网站动画设计考研
  • 网站内部的信息安全建设怎么才能在百度上做引流呢
  • 男男做的视频网站wordpress 系统
  • 网站建设合同 附件上海网站制作费用