Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_57962205
redisson
提交
ac83c953
R
redisson
项目概览
weixin_57962205
/
redisson
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redisson
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ac83c953
编写于
5月 07, 2021
作者:
N
Nikita Koksharov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Feature - broadcastSessionUpdates setting added to Tomcat Session Manager. #3596
上级
ee20d528
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
93 addition
and
49 deletion
+93
-49
redisson-tomcat/redisson-tomcat-10/src/main/java/org/redisson/tomcat/RedissonSession.java
...10/src/main/java/org/redisson/tomcat/RedissonSession.java
+9
-7
redisson-tomcat/redisson-tomcat-10/src/main/java/org/redisson/tomcat/RedissonSessionManager.java
...main/java/org/redisson/tomcat/RedissonSessionManager.java
+14
-5
redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSession.java
...-7/src/main/java/org/redisson/tomcat/RedissonSession.java
+9
-7
redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSessionManager.java
...main/java/org/redisson/tomcat/RedissonSessionManager.java
+14
-5
redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSession.java
...-8/src/main/java/org/redisson/tomcat/RedissonSession.java
+9
-7
redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSessionManager.java
...main/java/org/redisson/tomcat/RedissonSessionManager.java
+15
-6
redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSession.java
...-9/src/main/java/org/redisson/tomcat/RedissonSession.java
+9
-7
redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSessionManager.java
...main/java/org/redisson/tomcat/RedissonSessionManager.java
+14
-5
未找到文件。
redisson-tomcat/redisson-tomcat-10/src/main/java/org/redisson/tomcat/RedissonSession.java
浏览文件 @
ac83c953
...
...
@@ -71,14 +71,16 @@ public class RedissonSession extends StandardSession {
private
Set
<
String
>
removedAttributes
=
Collections
.
emptySet
();
private
final
boolean
broadcastSessionEvents
;
private
final
boolean
broadcastSessionUpdates
;
public
RedissonSession
(
RedissonSessionManager
manager
,
ReadMode
readMode
,
UpdateMode
updateMode
,
boolean
broadcastSessionEvents
)
{
public
RedissonSession
(
RedissonSessionManager
manager
,
ReadMode
readMode
,
UpdateMode
updateMode
,
boolean
broadcastSessionEvents
,
boolean
broadcastSessionUpdates
)
{
super
(
manager
);
this
.
redissonManager
=
manager
;
this
.
readMode
=
readMode
;
this
.
updateMode
=
updateMode
;
this
.
topic
=
redissonManager
.
getTopic
();
this
.
broadcastSessionEvents
=
broadcastSessionEvents
;
this
.
broadcastSessionUpdates
=
broadcastSessionUpdates
;
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
removedAttributes
=
Collections
.
newSetFromMap
(
new
ConcurrentHashMap
<
String
,
Boolean
>());
...
...
@@ -183,7 +185,7 @@ public class RedissonSession extends StandardSession {
}
else
{
map
.
delete
();
}
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
topic
.
publish
(
new
AttributesClearMessage
(
redissonManager
.
getNodeId
(),
getId
()));
}
map
=
null
;
...
...
@@ -201,7 +203,7 @@ public class RedissonSession extends StandardSession {
newMap
.
put
(
LAST_ACCESSED_TIME_ATTR
,
lastAccessedTime
);
newMap
.
put
(
THIS_ACCESSED_TIME_ATTR
,
thisAccessedTime
);
map
.
putAll
(
newMap
);
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
topic
.
publish
(
createPutAllMessage
(
newMap
));
}
}
...
...
@@ -253,7 +255,7 @@ public class RedissonSession extends StandardSession {
return
;
}
map
.
fastPut
(
name
,
value
);
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
try
{
topic
.
publish
(
new
AttributeUpdateMessage
(
redissonManager
.
getNodeId
(),
getId
(),
name
,
value
,
this
.
map
.
getCodec
().
getMapValueEncoder
()));
}
catch
(
IOException
e
)
{
...
...
@@ -319,7 +321,7 @@ public class RedissonSession extends StandardSession {
newMap
.
put
(
LAST_ACCESSED_TIME_ATTR
,
lastAccessedTime
);
newMap
.
put
(
THIS_ACCESSED_TIME_ATTR
,
thisAccessedTime
);
map
.
putAll
(
newMap
);
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
topic
.
publish
(
createPutAllMessage
(
newMap
));
}
expireSession
();
...
...
@@ -376,7 +378,7 @@ public class RedissonSession extends StandardSession {
private
void
removeRedisAttribute
(
String
name
)
{
if
(
updateMode
==
UpdateMode
.
DEFAULT
&&
map
!=
null
)
{
map
.
fastRemove
(
name
);
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
topic
.
publish
(
new
AttributeRemoveMessage
(
redissonManager
.
getNodeId
(),
getId
(),
new
HashSet
<
String
>(
Arrays
.
asList
(
name
))));
}
}
...
...
@@ -425,7 +427,7 @@ public class RedissonSession extends StandardSession {
map
.
putAll
(
newMap
);
map
.
fastRemove
(
removedAttributes
.
toArray
(
new
String
[
0
]));
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
topic
.
publish
(
createPutAllMessage
(
newMap
));
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
...
...
redisson-tomcat/redisson-tomcat-10/src/main/java/org/redisson/tomcat/RedissonSessionManager.java
浏览文件 @
ac83c953
...
...
@@ -48,14 +48,15 @@ public class RedissonSessionManager extends ManagerBase {
private
final
Log
log
=
LogFactory
.
getLog
(
RedissonSessionManager
.
class
);
pr
ivate
RedissonClient
redisson
;
pr
otected
RedissonClient
redisson
;
private
String
configPath
;
private
ReadMode
readMode
=
ReadMode
.
REDIS
;
private
UpdateMode
updateMode
=
UpdateMode
.
DEFAULT
;
pr
ivate
String
keyPrefix
=
""
;
pr
otected
String
keyPrefix
=
""
;
private
boolean
broadcastSessionEvents
=
false
;
private
boolean
broadcastSessionUpdates
=
true
;
private
final
String
nodeId
=
UUID
.
randomUUID
().
toString
();
...
...
@@ -80,7 +81,15 @@ public class RedissonSessionManager extends ManagerBase {
public
void
setBroadcastSessionEvents
(
boolean
replicateSessionEvents
)
{
this
.
broadcastSessionEvents
=
replicateSessionEvents
;
}
public
boolean
isBroadcastSessionUpdates
()
{
return
broadcastSessionUpdates
;
}
public
void
setBroadcastSessionUpdates
(
boolean
broadcastSessionUpdates
)
{
this
.
broadcastSessionUpdates
=
broadcastSessionUpdates
;
}
public
String
getReadMode
()
{
return
readMode
.
toString
();
}
...
...
@@ -194,7 +203,7 @@ public class RedissonSessionManager extends ManagerBase {
@Override
public
Session
createEmptySession
()
{
return
new
RedissonSession
(
this
,
readMode
,
updateMode
,
broadcastSessionEvents
);
return
new
RedissonSession
(
this
,
readMode
,
updateMode
,
broadcastSessionEvents
,
this
.
broadcastSessionUpdates
);
}
@Override
...
...
@@ -259,7 +268,7 @@ public class RedissonSessionManager extends ManagerBase {
}
}
if
(
readMode
==
ReadMode
.
MEMORY
||
broadcastSessionEvents
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
||
broadcastSessionEvents
)
{
RTopic
updatesTopic
=
getTopic
();
messageListener
=
new
MessageListener
<
AttributeMessage
>()
{
...
...
redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSession.java
浏览文件 @
ac83c953
...
...
@@ -71,14 +71,16 @@ public class RedissonSession extends StandardSession {
private
Set
<
String
>
removedAttributes
=
Collections
.
emptySet
();
private
final
boolean
broadcastSessionEvents
;
private
final
boolean
broadcastSessionUpdates
;
public
RedissonSession
(
RedissonSessionManager
manager
,
ReadMode
readMode
,
UpdateMode
updateMode
,
boolean
broadcastSessionEvents
)
{
public
RedissonSession
(
RedissonSessionManager
manager
,
ReadMode
readMode
,
UpdateMode
updateMode
,
boolean
broadcastSessionEvents
,
boolean
broadcastSessionUpdates
)
{
super
(
manager
);
this
.
redissonManager
=
manager
;
this
.
readMode
=
readMode
;
this
.
updateMode
=
updateMode
;
this
.
topic
=
redissonManager
.
getTopic
();
this
.
broadcastSessionEvents
=
broadcastSessionEvents
;
this
.
broadcastSessionUpdates
=
broadcastSessionUpdates
;
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
removedAttributes
=
Collections
.
newSetFromMap
(
new
ConcurrentHashMap
<
String
,
Boolean
>());
...
...
@@ -183,7 +185,7 @@ public class RedissonSession extends StandardSession {
}
else
{
map
.
delete
();
}
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
topic
.
publish
(
new
AttributesClearMessage
(
redissonManager
.
getNodeId
(),
getId
()));
}
map
=
null
;
...
...
@@ -201,7 +203,7 @@ public class RedissonSession extends StandardSession {
newMap
.
put
(
LAST_ACCESSED_TIME_ATTR
,
lastAccessedTime
);
newMap
.
put
(
THIS_ACCESSED_TIME_ATTR
,
thisAccessedTime
);
map
.
putAll
(
newMap
);
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
topic
.
publish
(
createPutAllMessage
(
newMap
));
}
}
...
...
@@ -253,7 +255,7 @@ public class RedissonSession extends StandardSession {
return
;
}
map
.
fastPut
(
name
,
value
);
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
try
{
topic
.
publish
(
new
AttributeUpdateMessage
(
redissonManager
.
getNodeId
(),
getId
(),
name
,
value
,
this
.
map
.
getCodec
().
getMapValueEncoder
()));
}
catch
(
IOException
e
)
{
...
...
@@ -319,7 +321,7 @@ public class RedissonSession extends StandardSession {
newMap
.
put
(
LAST_ACCESSED_TIME_ATTR
,
lastAccessedTime
);
newMap
.
put
(
THIS_ACCESSED_TIME_ATTR
,
thisAccessedTime
);
map
.
putAll
(
newMap
);
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
topic
.
publish
(
createPutAllMessage
(
newMap
));
}
expireSession
();
...
...
@@ -399,7 +401,7 @@ public class RedissonSession extends StandardSession {
private
void
removeRedisAttribute
(
String
name
)
{
if
(
updateMode
==
UpdateMode
.
DEFAULT
&&
map
!=
null
)
{
map
.
fastRemove
(
name
);
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
topic
.
publish
(
new
AttributeRemoveMessage
(
redissonManager
.
getNodeId
(),
getId
(),
new
HashSet
<
String
>(
Arrays
.
asList
(
name
))));
}
}
...
...
@@ -448,7 +450,7 @@ public class RedissonSession extends StandardSession {
map
.
putAll
(
newMap
);
map
.
fastRemove
(
removedAttributes
.
toArray
(
new
String
[
0
]));
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
topic
.
publish
(
createPutAllMessage
(
newMap
));
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
...
...
redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSessionManager.java
浏览文件 @
ac83c953
...
...
@@ -48,14 +48,15 @@ public class RedissonSessionManager extends ManagerBase {
private
final
Log
log
=
LogFactory
.
getLog
(
RedissonSessionManager
.
class
);
pr
ivate
RedissonClient
redisson
;
pr
otected
RedissonClient
redisson
;
private
String
configPath
;
private
ReadMode
readMode
=
ReadMode
.
REDIS
;
private
UpdateMode
updateMode
=
UpdateMode
.
DEFAULT
;
pr
ivate
String
keyPrefix
=
""
;
pr
otected
String
keyPrefix
=
""
;
private
boolean
broadcastSessionEvents
=
false
;
private
boolean
broadcastSessionUpdates
=
true
;
private
final
String
nodeId
=
UUID
.
randomUUID
().
toString
();
...
...
@@ -80,7 +81,15 @@ public class RedissonSessionManager extends ManagerBase {
public
void
setBroadcastSessionEvents
(
boolean
replicateSessionEvents
)
{
this
.
broadcastSessionEvents
=
replicateSessionEvents
;
}
public
boolean
isBroadcastSessionUpdates
()
{
return
broadcastSessionUpdates
;
}
public
void
setBroadcastSessionUpdates
(
boolean
broadcastSessionUpdates
)
{
this
.
broadcastSessionUpdates
=
broadcastSessionUpdates
;
}
public
String
getReadMode
()
{
return
readMode
.
toString
();
}
...
...
@@ -194,7 +203,7 @@ public class RedissonSessionManager extends ManagerBase {
@Override
public
Session
createEmptySession
()
{
return
new
RedissonSession
(
this
,
readMode
,
updateMode
,
broadcastSessionEvents
);
return
new
RedissonSession
(
this
,
readMode
,
updateMode
,
broadcastSessionEvents
,
this
.
broadcastSessionUpdates
);
}
@Override
...
...
@@ -259,7 +268,7 @@ public class RedissonSessionManager extends ManagerBase {
}
}
if
(
readMode
==
ReadMode
.
MEMORY
||
broadcastSessionEvents
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
||
broadcastSessionEvents
)
{
RTopic
updatesTopic
=
getTopic
();
messageListener
=
new
MessageListener
<
AttributeMessage
>()
{
...
...
redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSession.java
浏览文件 @
ac83c953
...
...
@@ -71,14 +71,16 @@ public class RedissonSession extends StandardSession {
private
Set
<
String
>
removedAttributes
=
Collections
.
emptySet
();
private
final
boolean
broadcastSessionEvents
;
private
final
boolean
broadcastSessionUpdates
;
public
RedissonSession
(
RedissonSessionManager
manager
,
ReadMode
readMode
,
UpdateMode
updateMode
,
boolean
broadcastSessionEvents
)
{
public
RedissonSession
(
RedissonSessionManager
manager
,
ReadMode
readMode
,
UpdateMode
updateMode
,
boolean
broadcastSessionEvents
,
boolean
broadcastSessionUpdates
)
{
super
(
manager
);
this
.
redissonManager
=
manager
;
this
.
readMode
=
readMode
;
this
.
updateMode
=
updateMode
;
this
.
topic
=
redissonManager
.
getTopic
();
this
.
broadcastSessionEvents
=
broadcastSessionEvents
;
this
.
broadcastSessionUpdates
=
broadcastSessionUpdates
;
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
removedAttributes
=
Collections
.
newSetFromMap
(
new
ConcurrentHashMap
<
String
,
Boolean
>());
...
...
@@ -183,7 +185,7 @@ public class RedissonSession extends StandardSession {
}
else
{
map
.
delete
();
}
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
topic
.
publish
(
new
AttributesClearMessage
(
redissonManager
.
getNodeId
(),
getId
()));
}
map
=
null
;
...
...
@@ -201,7 +203,7 @@ public class RedissonSession extends StandardSession {
newMap
.
put
(
LAST_ACCESSED_TIME_ATTR
,
lastAccessedTime
);
newMap
.
put
(
THIS_ACCESSED_TIME_ATTR
,
thisAccessedTime
);
map
.
putAll
(
newMap
);
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
topic
.
publish
(
createPutAllMessage
(
newMap
));
}
}
...
...
@@ -253,7 +255,7 @@ public class RedissonSession extends StandardSession {
return
;
}
map
.
fastPut
(
name
,
value
);
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
try
{
topic
.
publish
(
new
AttributeUpdateMessage
(
redissonManager
.
getNodeId
(),
getId
(),
name
,
value
,
this
.
map
.
getCodec
().
getMapValueEncoder
()));
}
catch
(
IOException
e
)
{
...
...
@@ -319,7 +321,7 @@ public class RedissonSession extends StandardSession {
newMap
.
put
(
LAST_ACCESSED_TIME_ATTR
,
lastAccessedTime
);
newMap
.
put
(
THIS_ACCESSED_TIME_ATTR
,
thisAccessedTime
);
map
.
putAll
(
newMap
);
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
topic
.
publish
(
createPutAllMessage
(
newMap
));
}
expireSession
();
...
...
@@ -376,7 +378,7 @@ public class RedissonSession extends StandardSession {
private
void
removeRedisAttribute
(
String
name
)
{
if
(
updateMode
==
UpdateMode
.
DEFAULT
&&
map
!=
null
)
{
map
.
fastRemove
(
name
);
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
topic
.
publish
(
new
AttributeRemoveMessage
(
redissonManager
.
getNodeId
(),
getId
(),
new
HashSet
<
String
>(
Arrays
.
asList
(
name
))));
}
}
...
...
@@ -425,7 +427,7 @@ public class RedissonSession extends StandardSession {
map
.
putAll
(
newMap
);
map
.
fastRemove
(
removedAttributes
.
toArray
(
new
String
[
0
]));
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
topic
.
publish
(
createPutAllMessage
(
newMap
));
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
...
...
redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSessionManager.java
浏览文件 @
ac83c953
...
...
@@ -48,14 +48,15 @@ public class RedissonSessionManager extends ManagerBase {
private
final
Log
log
=
LogFactory
.
getLog
(
RedissonSessionManager
.
class
);
pr
ivate
RedissonClient
redisson
;
pr
otected
RedissonClient
redisson
;
private
String
configPath
;
private
ReadMode
readMode
=
ReadMode
.
REDIS
;
private
UpdateMode
updateMode
=
UpdateMode
.
DEFAULT
;
pr
ivate
String
keyPrefix
=
""
;
pr
otected
String
keyPrefix
=
""
;
private
boolean
broadcastSessionEvents
=
false
;
private
boolean
broadcastSessionUpdates
=
true
;
private
final
String
nodeId
=
UUID
.
randomUUID
().
toString
();
...
...
@@ -80,7 +81,15 @@ public class RedissonSessionManager extends ManagerBase {
public
void
setBroadcastSessionEvents
(
boolean
replicateSessionEvents
)
{
this
.
broadcastSessionEvents
=
replicateSessionEvents
;
}
public
boolean
isBroadcastSessionUpdates
()
{
return
broadcastSessionUpdates
;
}
public
void
setBroadcastSessionUpdates
(
boolean
broadcastSessionUpdates
)
{
this
.
broadcastSessionUpdates
=
broadcastSessionUpdates
;
}
public
String
getReadMode
()
{
return
readMode
.
toString
();
}
...
...
@@ -194,7 +203,7 @@ public class RedissonSessionManager extends ManagerBase {
@Override
public
Session
createEmptySession
()
{
return
new
RedissonSession
(
this
,
readMode
,
updateMode
,
broadcastSessionEvents
);
return
new
RedissonSession
(
this
,
readMode
,
updateMode
,
broadcastSessionEvents
,
this
.
broadcastSessionUpdates
);
}
@Override
...
...
@@ -259,7 +268,7 @@ public class RedissonSessionManager extends ManagerBase {
}
}
if
(
readMode
==
ReadMode
.
MEMORY
||
broadcastSessionEvents
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
||
broadcastSessionEvents
)
{
RTopic
updatesTopic
=
getTopic
();
messageListener
=
new
MessageListener
<
AttributeMessage
>()
{
...
...
@@ -354,7 +363,7 @@ public class RedissonSessionManager extends ManagerBase {
super
.
stopInternal
();
setState
(
LifecycleState
.
STOPPING
);
Pipeline
pipeline
=
getContext
().
getPipeline
();
synchronized
(
pipeline
)
{
if
(
readMode
==
ReadMode
.
REDIS
)
{
...
...
redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSession.java
浏览文件 @
ac83c953
...
...
@@ -71,14 +71,16 @@ public class RedissonSession extends StandardSession {
private
Set
<
String
>
removedAttributes
=
Collections
.
emptySet
();
private
final
boolean
broadcastSessionEvents
;
private
final
boolean
broadcastSessionUpdates
;
public
RedissonSession
(
RedissonSessionManager
manager
,
ReadMode
readMode
,
UpdateMode
updateMode
,
boolean
broadcastSessionEvents
)
{
public
RedissonSession
(
RedissonSessionManager
manager
,
ReadMode
readMode
,
UpdateMode
updateMode
,
boolean
broadcastSessionEvents
,
boolean
broadcastSessionUpdates
)
{
super
(
manager
);
this
.
redissonManager
=
manager
;
this
.
readMode
=
readMode
;
this
.
updateMode
=
updateMode
;
this
.
topic
=
redissonManager
.
getTopic
();
this
.
broadcastSessionEvents
=
broadcastSessionEvents
;
this
.
broadcastSessionUpdates
=
broadcastSessionUpdates
;
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
removedAttributes
=
Collections
.
newSetFromMap
(
new
ConcurrentHashMap
<
String
,
Boolean
>());
...
...
@@ -183,7 +185,7 @@ public class RedissonSession extends StandardSession {
}
else
{
map
.
delete
();
}
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
topic
.
publish
(
new
AttributesClearMessage
(
redissonManager
.
getNodeId
(),
getId
()));
}
map
=
null
;
...
...
@@ -201,7 +203,7 @@ public class RedissonSession extends StandardSession {
newMap
.
put
(
LAST_ACCESSED_TIME_ATTR
,
lastAccessedTime
);
newMap
.
put
(
THIS_ACCESSED_TIME_ATTR
,
thisAccessedTime
);
map
.
putAll
(
newMap
);
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
topic
.
publish
(
createPutAllMessage
(
newMap
));
}
}
...
...
@@ -253,7 +255,7 @@ public class RedissonSession extends StandardSession {
return
;
}
map
.
fastPut
(
name
,
value
);
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
try
{
topic
.
publish
(
new
AttributeUpdateMessage
(
redissonManager
.
getNodeId
(),
getId
(),
name
,
value
,
this
.
map
.
getCodec
().
getMapValueEncoder
()));
}
catch
(
IOException
e
)
{
...
...
@@ -319,7 +321,7 @@ public class RedissonSession extends StandardSession {
newMap
.
put
(
LAST_ACCESSED_TIME_ATTR
,
lastAccessedTime
);
newMap
.
put
(
THIS_ACCESSED_TIME_ATTR
,
thisAccessedTime
);
map
.
putAll
(
newMap
);
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
topic
.
publish
(
createPutAllMessage
(
newMap
));
}
expireSession
();
...
...
@@ -376,7 +378,7 @@ public class RedissonSession extends StandardSession {
private
void
removeRedisAttribute
(
String
name
)
{
if
(
updateMode
==
UpdateMode
.
DEFAULT
&&
map
!=
null
)
{
map
.
fastRemove
(
name
);
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
topic
.
publish
(
new
AttributeRemoveMessage
(
redissonManager
.
getNodeId
(),
getId
(),
new
HashSet
<
String
>(
Arrays
.
asList
(
name
))));
}
}
...
...
@@ -425,7 +427,7 @@ public class RedissonSession extends StandardSession {
map
.
putAll
(
newMap
);
map
.
fastRemove
(
removedAttributes
.
toArray
(
new
String
[
0
]));
if
(
readMode
==
ReadMode
.
MEMORY
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
)
{
topic
.
publish
(
createPutAllMessage
(
newMap
));
if
(
updateMode
==
UpdateMode
.
AFTER_REQUEST
)
{
...
...
redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSessionManager.java
浏览文件 @
ac83c953
...
...
@@ -48,14 +48,15 @@ public class RedissonSessionManager extends ManagerBase {
private
final
Log
log
=
LogFactory
.
getLog
(
RedissonSessionManager
.
class
);
pr
ivate
RedissonClient
redisson
;
pr
otected
RedissonClient
redisson
;
private
String
configPath
;
private
ReadMode
readMode
=
ReadMode
.
REDIS
;
private
UpdateMode
updateMode
=
UpdateMode
.
DEFAULT
;
pr
ivate
String
keyPrefix
=
""
;
pr
otected
String
keyPrefix
=
""
;
private
boolean
broadcastSessionEvents
=
false
;
private
boolean
broadcastSessionUpdates
=
true
;
private
final
String
nodeId
=
UUID
.
randomUUID
().
toString
();
...
...
@@ -80,7 +81,15 @@ public class RedissonSessionManager extends ManagerBase {
public
void
setBroadcastSessionEvents
(
boolean
replicateSessionEvents
)
{
this
.
broadcastSessionEvents
=
replicateSessionEvents
;
}
public
boolean
isBroadcastSessionUpdates
()
{
return
broadcastSessionUpdates
;
}
public
void
setBroadcastSessionUpdates
(
boolean
broadcastSessionUpdates
)
{
this
.
broadcastSessionUpdates
=
broadcastSessionUpdates
;
}
public
String
getReadMode
()
{
return
readMode
.
toString
();
}
...
...
@@ -194,7 +203,7 @@ public class RedissonSessionManager extends ManagerBase {
@Override
public
Session
createEmptySession
()
{
return
new
RedissonSession
(
this
,
readMode
,
updateMode
,
broadcastSessionEvents
);
return
new
RedissonSession
(
this
,
readMode
,
updateMode
,
broadcastSessionEvents
,
this
.
broadcastSessionUpdates
);
}
@Override
...
...
@@ -259,7 +268,7 @@ public class RedissonSessionManager extends ManagerBase {
}
}
if
(
readMode
==
ReadMode
.
MEMORY
||
broadcastSessionEvents
)
{
if
(
readMode
==
ReadMode
.
MEMORY
&&
this
.
broadcastSessionUpdates
||
broadcastSessionEvents
)
{
RTopic
updatesTopic
=
getTopic
();
messageListener
=
new
MessageListener
<
AttributeMessage
>()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录