-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSessionManager.java
More file actions
48 lines (37 loc) · 1.1 KB
/
SessionManager.java
File metadata and controls
48 lines (37 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.mds.dubbo.session;
import com.mds.dubbo.config.AppInfo;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
/**
* session管理器
*
* @author baoyoujia
* @date 2024/6/13
*/
@Slf4j
public class SessionManager {
private SessionManager() {
}
/**
* 保存proxy和provide之间的连接,应用名和channel
*/
private final Map<String,Channel> readyRegistry = new ConcurrentHashMap<>(16);
private static class Singleton {
static SessionManager instance = new SessionManager();
}
public static SessionManager getInstance() {
return Singleton.instance;
}
public void addConnection(AppInfo appInfo, Channel channel, Channel inboundChannel) {
readyRegistry.put(appInfo.getName(), channel);
}
public Channel getConnection(String appName) {
return readyRegistry.get(appName);
}
public boolean existConnection(String appName) {
return readyRegistry.containsKey(appName);
}
}