You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2021/12/07 03:43:43 UTC

[GitHub] [rocketmq] yuz10 commented on a change in pull request #3595: [ISSUE #3593] entrySet() replace keySet()

yuz10 commented on a change in pull request #3595:
URL: https://github.com/apache/rocketmq/pull/3595#discussion_r763604377



##########
File path: tools/src/main/java/org/apache/rocketmq/tools/command/broker/GetBrokerConfigCommand.java
##########
@@ -83,19 +86,19 @@ public void execute(final CommandLine commandLine, final Options options,
                 Map<String, List<String>> masterAndSlaveMap
                     = CommandUtil.fetchMasterAndSlaveDistinguish(defaultMQAdminExt, clusterName);
 
-                for (String masterAddr : masterAndSlaveMap.keySet()) {
+                for (Entry<String, List<String>> masterAddrEntry : masterAndSlaveMap.entrySet()) {

Review comment:
       masterAddrEntry could be renamed to masterAndSlaveEntry

##########
File path: tools/src/main/java/org/apache/rocketmq/tools/command/broker/GetBrokerConfigCommand.java
##########
@@ -121,8 +124,8 @@ protected void getAndPrint(final MQAdminExt defaultMQAdminExt, final String prin
             return;
         }
 
-        for (Object key : properties.keySet()) {
-            System.out.printf("%-50s=  %s\n", key, properties.get(key));
+        for (Entry<Object, Object> keyEntry : properties.entrySet()) {
+            System.out.printf("%-50s=  %s\n", keyEntry.getKey(), keyEntry.getValue());

Review comment:
       keyEntry could be renamed to entry, and so is the obove

##########
File path: tools/src/main/java/org/apache/rocketmq/tools/command/consumer/GetConsumerConfigSubCommand.java
##########
@@ -63,14 +65,14 @@ public void execute(CommandLine commandLine, Options options,
             List<ConsumerConfigInfo> consumerConfigInfoList = new ArrayList<>();
             ClusterInfo clusterInfo = adminExt.examineBrokerClusterInfo();
             Map<String, Set<String>> clusterAddrTable = clusterInfo.getClusterAddrTable();
-            for (String brokerName : clusterInfo.getBrokerAddrTable().keySet()) {
-                String clusterName = this.getClusterName(brokerName, clusterAddrTable);
-                String brokerAddress = clusterInfo.getBrokerAddrTable().get(brokerName).selectBrokerAddr();
+            for (Entry<String, BrokerData> brokerNameEntry : clusterInfo.getBrokerAddrTable().entrySet()) {

Review comment:
       brokerNameEntry could be rename to brokerEntry

##########
File path: tools/src/main/java/org/apache/rocketmq/tools/command/export/ExportConfigsCommand.java
##########
@@ -79,10 +81,10 @@ public void execute(CommandLine commandLine, Options options, RPCHook rpcHook)
             Map<String, Properties> brokerConfigs = new HashMap<>();
             Map<String, List<String>> masterAndSlaveMap
                 = CommandUtil.fetchMasterAndSlaveDistinguish(defaultMQAdminExt, clusterName);
-            for (String masterAddr : masterAndSlaveMap.keySet()) {
-                Properties masterProperties = defaultMQAdminExt.getBrokerConfig(masterAddr);
+            for (Entry<String, List<String>> masterAddrEntry : masterAndSlaveMap.entrySet()) {

Review comment:
       masterAddrEntry could be renamed to masterAndSlaveEntry

##########
File path: test/src/main/java/org/apache/rocketmq/test/util/MQAdmin.java
##########
@@ -123,10 +124,10 @@ public static boolean isBrokerExist(String ns, String ip) {
             return false;
         } else {
             HashMap<String, BrokerData> brokers = clusterInfo.getBrokerAddrTable();
-            for (String brokerName : brokers.keySet()) {
-                HashMap<Long, String> brokerIps = brokers.get(brokerName).getBrokerAddrs();
-                for (long brokerId : brokerIps.keySet()) {
-                    if (brokerIps.get(brokerId).contains(ip))
+            for (Entry<String, BrokerData> brokerNameEntry : brokers.entrySet()) {

Review comment:
       brokerNameEntry could be renamed to brokerEntry

##########
File path: tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java
##########
@@ -63,12 +64,12 @@
             String masterAddr = brokerData.getBrokerAddrs().get(MixAll.MASTER_ID);
             masterAndSlaveMap.put(masterAddr, new ArrayList<String>());
 
-            for (Long id : brokerData.getBrokerAddrs().keySet()) {
-                if (brokerData.getBrokerAddrs().get(id) == null || id == MixAll.MASTER_ID) {
+            for (Entry<Long, String> idEntry : brokerData.getBrokerAddrs().entrySet()) {
+                if (idEntry.getValue() == null || idEntry.getKey() == MixAll.MASTER_ID) {

Review comment:
       idEntry could be renamed to brokerAddrEntry

##########
File path: tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/GetNamesrvConfigCommand.java
##########
@@ -66,11 +69,11 @@ public void execute(final CommandLine commandLine, final Options options,
 
             Map<String, Properties> nameServerConfigs = defaultMQAdminExt.getNameServerConfig(serverList);
 
-            for (String server : nameServerConfigs.keySet()) {
+            for (Entry<String, Properties> serverEntry : nameServerConfigs.entrySet()) {

Review comment:
       serverEntry could be renamed to nameServerConfigEntry




-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org