jvarenina commented on code in PR #7856:
URL: https://github.com/apache/geode/pull/7856#discussion_r971989985


##########
geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/commands/StartGatewaySenderCommand.java:
##########
@@ -77,6 +77,49 @@ public ResultModel startGatewaySender(@CliOption(key = 
CliStrings.START_GATEWAYS
       return ResultModel.createError(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
     }
 
+    if (cleanQueues) {
+
+      Set<DistributedMember> allServers = findMembers(null, null);
+
+      if (dsMembers.size() != allServers.size()) {
+        return ResultModel.createError(CliStrings.EXECUTE_ON_ALL_MEMBERS);
+      }

Review Comment:
   This code will reject a start clean queue command when you execute it for a 
particular group of servers when there are multiple groups of servers. Could it 
be possible to check that only servers in the provided group have configured 
senders and continue?



##########
geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/commands/StartGatewaySenderCommand.java:
##########
@@ -77,6 +77,49 @@ public ResultModel startGatewaySender(@CliOption(key = 
CliStrings.START_GATEWAYS
       return ResultModel.createError(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
     }
 
+    if (cleanQueues) {
+
+      Set<DistributedMember> allServers = findMembers(null, null);
+
+      if (dsMembers.size() != allServers.size()) {
+        return ResultModel.createError(CliStrings.EXECUTE_ON_ALL_MEMBERS);
+      }
+
+      GatewaySenderMXBean bean;
+      boolean commmandRejected = false;
+
+      ResultModel rejectResultModel =
+          ResultModel.createError(CliStrings.START_GATEWAYSENDER_REJECTED);
+      TabularResultModel rejectResultData =
+          
rejectResultModel.addTable(CliStrings.REJECT_START_GATEWAYSENDER_REASON);
+
+      for (DistributedMember member : dsMembers) {
+        if 
(cache.getDistributedSystem().getDistributedMember().getId().equals(member.getId()))
 {
+          bean = service.getLocalGatewaySenderMXBean(senderId);
+        } else {
+          ObjectName objectName = service.getGatewaySenderMBeanName(member, 
senderId);
+          bean = service.getMBeanProxy(objectName, GatewaySenderMXBean.class);
+        }
+        if (bean != null) {
+          if (bean.isRunning()) {
+            commmandRejected = true;
+            rejectResultData.addMemberStatusResultRow(member.getId(), 
CliStrings.GATEWAY_ERROR,
+                CliStrings.format(
+                    
CliStrings.GATEWAY_SENDER_0_IS_ALREADY_STARTED_ON_MEMBER_1, id,
+                    member.getId()));
+          }
+        } else {
+          commmandRejected = true;
+          rejectResultData.addMemberStatusResultRow(member.getId(), 
CliStrings.GATEWAY_ERROR,
+              CliStrings.format(
+                  CliStrings.GATEWAY_SENDER_0_IS_NOT_AVAILABLE_ON_MEMBER_1, 
id, member.getId()));
+        }
+      }

Review Comment:
   The same checks are performed just a few lines below in callable objects 
which execute the command on a member. Do we need still need those checks? Or, 
If they are required, is it possible to create a function that encapsulates 
them to avoid duplicated code?



-- 
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: notifications-unsubscr...@geode.apache.org

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

Reply via email to