免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2954 | 回复: 2
打印 上一主题 下一主题

[WebLogic] weblogic JSESSIONID primary server解析 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-05-04 09:33 |只看该作者 |倒序浏览

需要根据weblogic集群cookie做负载均衡(c语言实现),我在网上看说JSESSIONID格式里的primary server是JVM Hash 值,我想通过这个hash值来找到相应的ip地址,网上说可以构建一个请求Header(在这个Header中将:X-WebLogic-Request-ClusterInfo值设置为true),发送到后台服务器上,查看返回header中的X-WebLogic-Request-ClusterInfo信息,但是负载均衡肯定是作为一个代理服务器,不可能来一次get请求就查询一次X-WebLogic-Request-ClusterInfo信息。有比较好的办法没,请大牛帮忙解答小弟疑惑

论坛徽章:
15
2015年辞旧岁徽章
日期:2015-03-03 16:54:15双鱼座
日期:2015-01-15 17:29:44午马
日期:2015-01-06 17:06:51子鼠
日期:2014-11-24 10:11:13寅虎
日期:2014-08-18 07:10:55酉鸡
日期:2014-04-02 12:24:51双子座
日期:2014-04-02 12:19:44天秤座
日期:2014-03-17 11:43:36亥猪
日期:2014-03-13 08:13:51未羊
日期:2014-03-11 12:42:03白羊座
日期:2013-11-20 10:15:18CU大牛徽章
日期:2013-04-17 11:48:45
2 [报告]
发表于 2013-05-06 11:02 |只看该作者
问题问的很好,我也回答不了。不过我们可以讨论讨论。

这是JSESSIONID 的标准格式,里面就是你说的 JVM hash 值。
  1. JSESSIONID=SESSION_ID!PRIMARY_JVMID_HASH!SECONDARY_JVM_HASH!CREATION_TIME
复制代码
如果主服务当了, 就找第二个。 如果只有一个:
  1. JSESSIONID=SESSION_ID!PRIMARY_JVMID_HASH!CREATION_TIME
复制代码
服务没有重启前,PRIMARY_JVMID_HASH 或者SECONDARY_JVM_HASH 通常不再变。所以weblogic就根据这个不变的 JVMID hash,自己会知道如何找到对应的服务去连, 你自己应该不用考虑。

除非主服务当了,就会跳去下一个,如果激活sesson replication, 你的数据会恢复。

这个是英文解释,你也可以看看。 (http://stackoverflow.com/questions/6429990/weblogic-jsessionid)
Looking at some randomly generated Weblogic JSessionIDs from my own application

BrYx4hyPZ4VSP9Wo4eU0OrqmhXMLFONbRHnpLFwRKZ9MSaf6wvYj!-314662473
and

BrYiFED29itaC4EBpWYM8RKVQQauHkvnTsA2OAKUPZXVc9oUD5fB!-784323496.
Now if you notice the part of the session id after the first ! i.e 314662473 and 784323496.

This number is the unique identifier that Weblogic gives to the running JVM i.e. the running Weblogic server.

If there is more than one server in your application, Weblogic knows how to route your session back to the correct server by using this 9 digit JVM number which is part of the session ID.

Each time you restart the weblogic server, it will generate a new JVM id and use it as long as that weblogic server is running. So any hits to that server will have the same ID at the end of the session ID.

The format of the session ID is:

JSESSIONID=SESSION_ID!PRIMARY_JVMID_HASH!SECONDARY_JVM_HASH!CREATION_TIME

So if the primary is not available, it will try to jump over to secondary and if you have enabled session replication - then the session data can be recovered. If you are running only a single server on local, then the format is simply

JSESSIONID=SESSION_ID!PRIMARY_JVMID_HASH!CREATION_TIME

regarding some times it does not appear, I've seen it is usually a browser dependent whether the sessionid is shown in the address bar or not


论坛徽章:
0
3 [报告]
发表于 2013-05-26 22:26 |只看该作者
不好意思,今天才上来看,非常感谢版主的回答,之前项目时间比较紧,已经做完了,还是每次get实现的,只不过是融合到健康检查里面了。因为健康检查本来就要频繁的发get报文,就干脆header里加了个请求字段,时间紧就没怎么多考虑了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP