fix:修复redis连接加入database参数问题 fix:修复redis获取元信息获取不到问题
fix:优化代码
Showing 1 of 1 files from the diff.
@@ -44,9 +44,9 @@
Loading
44 | 44 | public class RedisMetaDataCollector implements MetaDataCollector { |
|
45 | 45 | ||
46 | 46 | private final static Logger logger = LoggerFactory.getLogger(RedisMetaDataCollector.class); |
|
47 | + | private final static String REDIS_DATABASE_KEY = "database"; |
|
47 | 48 | private URL url; |
|
48 | 49 | private JedisPool pool; |
|
49 | - | private static final String META_DATA_SOTRE_TAG = ".metaData"; |
|
50 | 50 | Set<HostAndPort> jedisClusterNodes; |
|
51 | 51 | private int timeout; |
|
52 | 52 | private String password; |
@@ -73,7 +73,8 @@
Loading
73 | 73 | jedisClusterNodes.add(new HostAndPort(tmpUrl.getHost(), tmpUrl.getPort())); |
|
74 | 74 | } |
|
75 | 75 | } else { |
|
76 | - | pool = new JedisPool(new JedisPoolConfig(), url.getHost(), url.getPort(), timeout, url.getPassword()); |
|
76 | + | int database = url.getParameter(REDIS_DATABASE_KEY, 0); |
|
77 | + | pool = new JedisPool(new JedisPoolConfig(), url.getHost(), url.getPort(), timeout, url.getPassword(), database); |
|
77 | 78 | } |
|
78 | 79 | } |
|
79 | 80 |
@@ -98,7 +99,7 @@
Loading
98 | 99 | } |
|
99 | 100 | } else { |
|
100 | 101 | try (Jedis jedis = pool.getResource()) { |
|
101 | - | result = jedis.get(identifier.getUniqueKey(KeyTypeEnum.UNIQUE_KEY) + META_DATA_SOTRE_TAG); |
|
102 | + | result = jedis.get(identifier.getUniqueKey(KeyTypeEnum.UNIQUE_KEY)); |
|
102 | 103 | } catch (Throwable e) { |
|
103 | 104 | logger.error("Failed to get " + identifier + " from redis, cause: " + e.getMessage(), e); |
|
104 | 105 | throw new RpcException("Failed to get " + identifier + " from redis, cause: " + e.getMessage(), e); |
Files | Complexity | Coverage |
---|---|---|
dubbo-admin-server/src/main/java/org/apache/dubbo/admin | 20.30% | 21.98% |
Project Totals (98 files) | 20.30% | 21.98% |
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file.
The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files.
The size and color of each slice is representing the number of statements and the coverage, respectively.