Heartbeat的可靠消息通信实现分析
http://tech.ddvip.com 2007年05月21日 社区交流
本文详细介绍Heartbeat的可靠消息通信实现分析
static void add2_xmit_hist (struct msg_xmit_hist *hist, struct ha_msg *msg,
seqno_t seq)
{
int slot;
struct ha_msg *slotmsg;
...
/*查找队列里消息存放的位置*/
slot = hist->lastmsg + 1;
if (slot >= MAXMSGHIST) {
/*到达队尾,从头开始。在这里实现循环队列*/
slot = 0;
}
hist->hiseq = seq;
slotmsg = hist->msgq[slot];
/*删除队列中找到的位置上的旧消息*/
if (slotmsg != NULL) {
hist->lowseq = hist->seqnos[slot];
hist->msgq[slot] = NULL;
if (!ha_is_allocated(slotmsg)) {
...
} else {
ha_msg_del(slotmsg);
}
}
hist->msgq[slot] = msg;
hist->seqnos[slot] = seq;
hist->lastrexmit[slot] = 0L;
hist->lastmsg = slot;
if (enable_flow_control && live_node_count > 1
&& (hist->hiseq – hist->lowseq) > ((MAXMSGHIST*3)/4)) {
/*消息队列长度大于告警长度,记录日志*/
...
}
if (enable_flow_control
&& hist->hiseq – hist->ackseq > FLOWCONTROL_LIMIT) {
/*消息队列的长度大于流控限制长度*/
if (live_node_count < 2) {
/*集群里只有本机节点为存活节点,更新历史消息队列,删除旧消息,
以防止历史消息队列满*/
update_ackseq(hist->hiseq – (FLOWCONTROL_LIMIT – 1));
all_clients_resume();
} else {
/*client进程发送消息过快,暂停所有的client进程*/
all_clients_pause();
hist_display(hist);
}
}
}
责编:豆豆技术应用
正在加载评论...
- Linux/Unix 新闻
- Linux/Unix 入门
- Linux/Unix 命令
- Linux/Unix 安装
- Linux 嵌入式系统
- Linux/Unix 编程
- Linux/Unix 管理
- Linux/Unix 桌面
- Linux/Unix 内核
- Linux/Unix 软件
- SCO Unix
- NetBSD
- OpenBSD
- Redhat/Fedora Linux
- 手机
- Linux/Unix find 搜索命令
- Linux/Unix vi 命令
- Linux/Unix kde 桌面环境
- Linux/Unix GNOME 桌面环境
- Linux/Unix Make 命令
- Linux/Unix crontab 命令
- Linux/Unix ext3 文件系统
- Linux/Unix 文件系统详解
- Linux/Unix ADSL 拨号设置
- Linux/Unix GRUB 配置及应用
- Linux/Unix nfs配置
- Linux/Unix 硬件信息查看及管理
- Linux/Unix 优化
- Linux/Unix 交换分区Swap管理及应用
- Linux/Unix 用户管理
- Linux/Unix Ramdisk
- Linux/Unix 密码恢复管理
- Linux/Unix 文件删除恢复
- Linux/Unix fdisk分区
- Linux/Unix lvs负载均衡管理
- Linux/Unix root用户
- Linux/Unix 集群
- Linux/Unix 日志
- 更多Linux/Unix专题……