技术标签: Dubbo+Zookeeper dubbo
Dubbo编解码(一)-原理
Dubbo编解码(二)-Codec2和AbstractCodec
Dubbo编解码(三)-TransportCodec
Dubbo编解码(五)-Dubbo协议编码器
Dubbo编解码(六)-Dubbo协议解码器
在Dubbo-SPI(六)-各层扩展点中已经有相关介绍,根据URL中的codec参数决定使用哪一种编解码实现方式,扩展点实现如下:
传输层编解码实现
transport=org.apache.dubbo.remoting.transport.codec.TransportCodec
telnet=org.apache.dubbo.remoting.telnet.codec.TelnetCodec
交换层编解码实现
exchange=org.apache.dubbo.remoting.exchange.codec.ExchangeCodec
protected static Codec2 getChannelCodec(URL url) {
// 编解码器扩展名 必须与 协议名 保持相同
String codecName = url.getProtocol(); // codec extension name must stay the same with protocol name
if (ExtensionLoader.getExtensionLoader(Codec2.class).hasExtension(codecName)) {
return ExtensionLoader.getExtensionLoader(Codec2.class).getExtension(codecName);
} else {
return new CodecAdapter(ExtensionLoader.getExtensionLoader(Codec.class)
.getExtension(codecName));
}
}
实现了Codec2接口,但是没有去具体实现Codec2#encode和Codec2#decode方法
主要提供了检验报文长度 和 获取 具体编解码器的方法
protected static void checkPayload(Channel channel, long size) throws IOException {
// 获取报文长度
int payload = getPayload(channel);
// 判断报文长度是否超限
boolean overPayload = isOverPayload(payload, size);
if (overPayload) {
ExceedPayloadLimitException e = new ExceedPayloadLimitException(
"Data length too large: " + size + ", max payload: " + payload + ", channel: " + channel);
logger.error(e);
throw e;
}
}
int DEFAULT_PAYLOAD = 8 * 1024 * 1024;
protected static int getPayload(Channel channel) {
// payload=8M
int payload = Constants.DEFAULT_PAYLOAD;
if (channel != null && channel.getUrl() != null) {
// 获取url中的payload参数值
payload = channel.getUrl().getParameter(Constants.PAYLOAD_KEY, Constants.DEFAULT_PAYLOAD);
}
return payload;
}
protected static boolean isOverPayload(int payload, long size) {
if (payload > 0 && size > payload) {
return true;
}
return false;
}
protected Serialization getSerialization(Channel channel, Request req) {
return CodecSupport.getSerialization(channel.getUrl());
}
protected Serialization getSerialization(Channel channel, Response res) {
return CodecSupport.getSerialization(channel.getUrl());
}
protected Serialization getSerialization(Channel channel) {
return CodecSupport.getSerialization(channel.getUrl());
}
String SERIALIZATION_KEY = "serialization";
String DEFAULT_REMOTING_SERIALIZATION = "hessian2";
// CodecSupport#getSerialization
public static Serialization getSerialization(URL url) {
// 获取扩展接口(Serialization)的扩展实例,根据url的serialization参数获取,默认是hessian2
return ExtensionLoader.getExtensionLoader(Serialization.class).getExtension(
url.getParameter(Constants.SERIALIZATION_KEY, Constants.DEFAULT_REMOTING_SERIALIZATION));
}
String SIDE_KEY = "side";
protected boolean isClientSide(Channel channel) {
String side = (String) channel.getAttribute(SIDE_KEY);
if (CLIENT_SIDE.equals(side)) {
return true;
} else if (SERVER_SIDE.equals(side)) {
return false;
} else {
// side属性值既不是client也不是server
InetSocketAddress address = channel.getRemoteAddress();
URL url = channel.getUrl();
// 使用InetSocketAddress 和 URL 进行判断
boolean isClient = url.getPort() == address.getPort()
&& NetUtils.filterLocalHost(url.getIp()).equals(
NetUtils.filterLocalHost(address.getAddress()
.getHostAddress()));
channel.setAttribute(SIDE_KEY, isClient ? CLIENT_SIDE
: SERVER_SIDE);
return isClient;
}
}
protected boolean isServerSide(Channel channel) {
return !isClientSide(channel);
}
综合了网上的贴子,操作如下:ALT+SHIFT+ENTER 在详细列表状态下显示当前所有目录的大小设置->选项->显示->文件夹排序方式由原来的"按名称"改为"和文件一样"就ok了!上效果图: ...
IOC概念:控制反转,把创建对象的权力交给springDI概念:依赖注入,指把有依赖关系的对象也同时new出来AOP概念:面向切面编程,弥补了OOP的不足
一、软件简介: 一款免费且功能强大的数据包抓取软件。它通过代理的方式获取程序http通讯的数据,可以用其检测网页和服务器的交互情况,能够记录所有客户端和服务器间的http请求,支持监视、设置断点、甚至修改输入输出数据等功能。fiddler包含了一个强大的基于事件脚本的子系统,并且能够使用.net框架语言扩展。所以无论对开发人员或者测试人员来说,都是非常有用的工具。二、fiddler...
使用DBGridEh解决显示nText字段时显示memo的问题 使用过Dephi和CB++的朋友都知道DBGrid在数据库编程中经常会使用,而且会给我们在编辑程序上节省了不小时间。但使用DBGrid的时候有一个问题就是不是显示nText字段里面的字符串,只能显示出memo的信息,实在使人伤透了脑筋。要么不显示、要么就要多加一个DBmemo的控件来显示nText的数据。
当你在淘 宝上买买买的时候,是否想过已是至优惠?当你百般对比同类商品价格的时候,是否觉得已是至便 宜的呢?其实不然,天猫淘宝上80%的产品有内部优惠券,而你直接在淘宝购买是发现不了的!!因为这种券在店铺里没有入口,客服也不会和你说,这些券都是隐秘给大平台活动推广的,普通消费者是找不到的!而我们这次就是为大家介绍如何寻找这种内部的隐藏优惠券!微信搜索公众号:双十一优惠券购物领优惠券还有奖励...
4.1 自定义函数和结构体如果只是向屏幕输出一些内容,这时只需要定义一函数返回类型为void,而且无需使用return,有一个专门的函数来调用main函数,如操作系统,IDE,调试器,甚至是自动评判系统,这个return 0代表正常结束。求欧几里得距离:double dist(double x1, double y1, double x2, double y2){ return s
=====================================================================================tnsnames.ora# tnsnames.ora Network Configuration File: D:\05-sxylz_hmkj_yxgs\01-software\10-oracle\01-oracleSetup\o...
#!/usr/bin/Rscriptlibrary(survival)library(limma)file.create("survive.txt")#filestumors for (tumor in tumors){exp_file #read in filesrna=read.table(exp_file,header=TRUE,row.names=1,sep="t",stringsAsFa...
1 你怎么理解HTTP协议2 HTTP和HTTPS的区别3 ISO七层网络模型五层网络模型TCPIP四层网络模型4 TCP和UDP的区别5 同步和异步阻塞和非阻塞长线程和短线程的区别6 现在要访问wwwbaiducom整个过程是怎样的6 IPTCP首部7 TCP三次握手及四次挥手8 DNS是什么本机使用DNS时是TCP连接还是UDP10 TCP如何保证可靠性1、 你怎么理解HTTP
[2018-09-12 16:22:51,787]ERROR 0[main] - com.cloudera.enterprise.dbutil.DbProvisioner.executeSql(DbProvisioner.java) - Exception when creating/dropping database with user ‘root‘ and jdbc url ‘jdbc...
日期题量算法数比赛数备注11102300早上和中午准备语文课新闻分享3301遗留了一道题 稻草人 和一份代码 牛客网比赛的4201颓5000颓,调一道splay调了很久只有85分,弃坑6200...
3.1自己的窗口建立窗口很需呼叫CreateWindow函数.窗口以「消息」的形式接收窗口的输入,窗口也用消息与其它窗口通讯。程序建立的每一个窗口都有相关的窗口消息处理程序。「Windows给程序发送消息。是指Windows呼叫程序中的一个函数,该函数的参数描述了这个特定消息。这种位于Windows程序中的函数称为「窗口消息处理程序」。Windows通过呼叫窗口消息处理程序来给窗口发送消