funky-eyes commented on code in PR #6538:
URL: https://github.com/apache/incubator-seata/pull/6538#discussion_r1680916514


##########
server/src/main/java/org/apache/seata/server/storage/db/store/VGroupMappingDataBaseDAO.java:
##########
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.server.storage.db.store;
+
+import org.apache.seata.common.metadata.Instance;
+import org.apache.seata.common.util.IOUtil;
+import org.apache.seata.config.Configuration;
+import org.apache.seata.config.ConfigurationFactory;
+import org.apache.seata.core.store.MappingDO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class VGroupMappingDataBaseDAO {
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(VGroupMappingDataBaseDAO.class);
+
+    protected DataSource vGroupMappingDataSource = null;
+
+    protected final String vMapping;
+
+    private static final String DEFAULT_VGROUP_MAPPING = "vgroup_table";
+
+    private static final String REGISTRY_NAMINGSERVER_CLUSTER = 
"registry.namingserver.cluster";
+
+    protected static final Configuration CONFIG = 
ConfigurationFactory.getInstance();
+
+    public VGroupMappingDataBaseDAO(DataSource vGroupMappingDataSource) {
+        this.vGroupMappingDataSource = vGroupMappingDataSource;
+        this.vMapping = CONFIG.getConfig("store.db.mapping-table", 
DEFAULT_VGROUP_MAPPING);

Review Comment:
   使用一个常量,而不是局部变量
   Use a constant instead of a local variable



##########
server/src/main/java/org/apache/seata/server/storage/redis/store/RedisVGroupMappingStoreManager.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.server.storage.redis.store;
+
+import org.apache.seata.common.exception.RedisException;
+import org.apache.seata.common.loader.LoadLevel;
+import org.apache.seata.common.metadata.Instance;
+import org.apache.seata.core.store.MappingDO;
+import org.apache.seata.server.storage.redis.JedisPooledFactory;
+import org.apache.seata.server.store.VGroupMappingStoreManager;
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.Pipeline;
+
+import java.util.HashMap;
+import java.util.List;
+
+
+@LoadLevel(name = "redis")
+public class RedisVGroupMappingStoreManager implements 
VGroupMappingStoreManager {
+
+    private static final String REDIS_SPLIT_KEY = ":";
+
+
+    @Override
+    public boolean addVGroup(MappingDO mappingDO) {
+        String vGroup = mappingDO.getVGroup();
+        String namespace = mappingDO.getNamespace();
+        String clusterName = mappingDO.getCluster();
+        String mappingKey = namespace + REDIS_SPLIT_KEY + clusterName;
+        try (Jedis jedis = JedisPooledFactory.getJedisInstance(); Pipeline 
pipelined = jedis.pipelined()) {
+            pipelined.lrem(mappingKey, 0, vGroup);
+            pipelined.rpush(mappingKey, vGroup);

Review Comment:
   为什么不用hash结构?
   Why not use a hash structure?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to