知识库--DistributedManager 集群 (50)
来源:互联网 发布:xps分析软件下载 编辑:程序博客网 时间:2024/05/21 12:39
DistributedManager **Tomcat4中的集群环境–昙花一现**zk
A subclass of PersistentManagerBase, DistributedManager is used in a clustered environment with two or more nodes. A node represents a Tomcat deployment. Nodes in a cluster can exist in different machines or the same machine. In a clustered environment, each node must use an instance of DistributedManager as its Manager to support session replication, which is the main responsibility of DistributedManager.
For the replication purpose, DistributeManager sends notification to other nodes whenever a session object is created or destroyed. In addition, a node must be able to receive notification from other nodes as well. This way, an HTTP request can be served by any node in the cluster.
For sending and receiving notification to and from other instances of DistributedManager in other nodes, Catalina provides classes in the org.apache.catalina.cluster package. Among others, the ClusterSender class is used for sending notifications to other nodes and the ClusterReceiver class for receiving notifications from other nodes.
The createSession method of DistrbutedManager must create a session object to be stored in the current instance and use a ClusterSender instance to send notification to other nodes.
public Session createSession(){ Session session = super.createSession(); ObjectOutputStream oos = null; ByteArrayOutputStream bos = null; ByteArrayInputStream bis = null; try{ bos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(new BufferedOutputStream(bos)); ((StandardSession)session).writeObjectData(oos); oos.close(); byte[] obs = bos.toByteArray(); clusterSender.send(obs);//send if(debug > 0) log("Replicating Session:"+session.getId()); }catch(IOException e){ log(); } return(session); }
- 知识库--DistributedManager 集群 (50)
- 知识库--PersistentManagerBase(50)
- 知识库--Lifecycle (44)
- 知识库--SimpleLoader (46)
- 知识库--Logger (46)
- 知识库--WebappLoader(47)
- 知识库--WebappClassLoader(47)
- 知识库--Session(47)
- 知识库--Sessions(48)
- 知识库--StandardSession (49)
- 知识库--Realm(51)
- 知识库--Authenticator(51)
- 知识库--StandardWrapperFacade(54)
- 知识库--StandardContext(57)
- 知识库--Digester(72)
- 知识库--STM(118)
- 知识库
- 知识库
- 原码,反码,补码,移码
- 基于MFC单文档下调用opencv库并将图片效果显示在单文档窗口
- 浅谈~ 算法的艺术
- bzoj 3674 (可持久化线段树+并查集按秩合并)
- Java上传下载完全解析(一)
- 知识库--DistributedManager 集群 (50)
- 科林明伦杯 - B Time
- Mysql-聚簇索排序慢案例分析
- c::关于虚函数的一点补充
- 网络编程(36)—— 线程安全函数和非线程安全函数
- PHP与UTF-8的最佳实践
- 你只管努力,剩下的交给时光---一个南方姑娘的2016北漂之旅
- C语言实践-结构体
- 浏览器禁用cookie后,非共享使用session