删除无用的缓存:license -> 服务端口映射

This commit is contained in:
aoshiguchen
2026-01-20 10:17:03 +08:00
parent 2ae5259670
commit 72d79b5ccf
@@ -28,16 +28,16 @@ import java.util.stream.Collectors;
*/ */
public class ProxyUtil { public class ProxyUtil {
public static final AttributeKey<ChannelAttribute> CHANNEL_ATTR_KEY = AttributeKey.valueOf("netty.channel.attr"); public static final AttributeKey<ChannelAttribute> CHANNEL_ATTR_KEY = AttributeKey.valueOf("netty.channel.attr");
/** // /**
* license -> 服务端口映射 // * license -> 服务端口映射
*/ // */
private static final Map<Integer, Set<Integer>> licenseToServerPortMap = new HashMap<>(); // private static final Map<Integer, Set<Integer>> licenseToServerPortMap = new HashMap<>();
/** /**
* 代理信息映射 e.g.: 9104 -> 127.0.0.1:8848 * 代理信息映射 e.g.: 9104 -> 127.0.0.1:8848
*/ */
private static final Map<Integer, String> proxyInfoMap = new ConcurrentHashMap<>(); private static final Map<Integer, String> proxyInfoMap = new ConcurrentHashMap<>();
/** /**
* 服务端口 -> 指令通道映射 * 服务端口 -> 指令通道映射proxyInfoMap
*/ */
private static Map<Integer, Channel> serverPortToCmdChannelMap = new ConcurrentHashMap<>(); private static Map<Integer, Channel> serverPortToCmdChannelMap = new ConcurrentHashMap<>();
/** /**
@@ -92,14 +92,14 @@ public class ProxyUtil {
* @param proxyMappingList 代理映射集合 * @param proxyMappingList 代理映射集合
*/ */
public static void initProxyInfo(Integer licenseId, List<ProxyMapping> proxyMappingList) { public static void initProxyInfo(Integer licenseId, List<ProxyMapping> proxyMappingList) {
licenseToServerPortMap.put(licenseId, new HashSet<>()); // licenseToServerPortMap.put(licenseId, new HashSet<>());
addProxyInfo(licenseId, proxyMappingList); addProxyInfo(licenseId, proxyMappingList);
} }
public static void addProxyInfo(Integer licenseId, List<ProxyMapping> proxyMappingList) { public static void addProxyInfo(Integer licenseId, List<ProxyMapping> proxyMappingList) {
if (!CollectionUtil.isEmpty(proxyMappingList)) { if (!CollectionUtil.isEmpty(proxyMappingList)) {
for (ProxyMapping proxyMapping : proxyMappingList) { for (ProxyMapping proxyMapping : proxyMappingList) {
licenseToServerPortMap.get(licenseId).add(proxyMapping.getServerPort()); // licenseToServerPortMap.get(licenseId).add(proxyMapping.getServerPort());
proxyInfoMap.put(proxyMapping.getServerPort(), proxyMapping.getLanInfo()); proxyInfoMap.put(proxyMapping.getServerPort(), proxyMapping.getLanInfo());
} }
} }
@@ -109,7 +109,7 @@ public class ProxyUtil {
if (null == licenseId || null == proxyMapping) { if (null == licenseId || null == proxyMapping) {
return; return;
} }
licenseToServerPortMap.get(licenseId).add(proxyMapping.getServerPort()); // licenseToServerPortMap.get(licenseId).add(proxyMapping.getServerPort());
proxyInfoMap.put(proxyMapping.getServerPort(), proxyMapping.getLanInfo()); proxyInfoMap.put(proxyMapping.getServerPort(), proxyMapping.getLanInfo());
} }
@@ -117,14 +117,14 @@ public class ProxyUtil {
proxyInfoMap.remove(serverPort); proxyInfoMap.remove(serverPort);
} }
/** // /**
* 根据licenseId获取服务端端口集合 // * 根据licenseId获取服务端端口集合
* @param licenseId licenseId // * @param licenseId licenseId
* @return 服务端端口集合 // * @return 服务端端口集合
*/ // */
public static Set<Integer> getServerPortsByLicenseKey(Integer licenseId) { // public static Set<Integer> getServerPortsByLicenseKey(Integer licenseId) {
return licenseToServerPortMap.get(licenseId); // return licenseToServerPortMap.get(licenseId);
} // }
/** /**
* 根据服务端端口获取客户端代理信息 * 根据服务端端口获取客户端代理信息