[
https://issues.apache.org/jira/browse/GEODE-7954?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17096883#comment-17096883
]
ASF GitHub Bot commented on GEODE-7954:
---------------------------------------
DonalEvans commented on a change in pull request #5004:
URL: https://github.com/apache/geode/pull/5004#discussion_r418222622
##########
File path:
geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/commands/StatusRedundancyCommand.java
##########
@@ -0,0 +1,121 @@
+/*
+ * 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.geode.management.internal.cli.commands;
+
+import static
org.apache.geode.management.internal.cli.commands.RedundancyCommandUtils.REDUNDANCY_COMMAND_ADDED_VERSION;
+import static
org.apache.geode.management.internal.functions.CliFunctionResult.StatusState.ERROR;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.management.cli.CliMetaData;
+import org.apache.geode.management.cli.GfshCommand;
+import
org.apache.geode.management.internal.cli.functions.RedundancyCommandFunction;
+import org.apache.geode.management.internal.cli.result.model.ResultModel;
+import org.apache.geode.management.internal.functions.CliFunctionResult;
+import org.apache.geode.management.internal.i18n.CliStrings;
+import
org.apache.geode.management.internal.operation.RebalanceOperationPerformer;
+import org.apache.geode.management.internal.security.ResourceOperation;
+import org.apache.geode.security.ResourcePermission;
+
+public class StatusRedundancyCommand extends GfshCommand {
+ static final String COMMAND_NAME = "status redundancy";
+ private static final String COMMAND_HELP =
+ "Report the redundancy status for partitioned regions in connected
members. The default is to report status for all regions.";
+ static final String INCLUDE_REGION = "include-region";
+ private static final String INCLUDE_REGION_HELP =
+ "Partitioned regions to be included when reporting redundancy status.
Includes take precedence over excludes.";
+ static final String EXCLUDE_REGION = "exclude-region";
+ private static final String EXCLUDE_REGION_HELP =
+ "Partitioned regions to be excluded when reporting redundancy status.";
+
+ @CliCommand(value = COMMAND_NAME, help = COMMAND_HELP)
+ @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DATA,
CliStrings.TOPIC_GEODE_REGION})
+ @ResourceOperation(resource = ResourcePermission.Resource.DATA,
+ operation = ResourcePermission.Operation.READ)
+ public ResultModel execute(
+ @CliOption(key = INCLUDE_REGION, help = INCLUDE_REGION_HELP) String[]
includeRegions,
+ @CliOption(key = EXCLUDE_REGION, help = EXCLUDE_REGION_HELP) String[]
excludeRegions) {
+ RedundancyCommandUtils utils = getUtils();
+
+ List<RebalanceOperationPerformer.MemberPRInfo> membersForEachRegion = new
ArrayList<>();
+ List<String> includedRegionsWithNoMembers = new ArrayList<>();
+
+ utils.populateLists(membersForEachRegion, includedRegionsWithNoMembers,
includeRegions,
+ excludeRegions, (InternalCache) getCache());
+
+ for (RebalanceOperationPerformer.MemberPRInfo prInfo :
membersForEachRegion) {
+ // Filter out any members using older versions of Geode
+ List<DistributedMember> viableMembers =
+ utils.filterViableMembersForVersion(prInfo,
REDUNDANCY_COMMAND_ADDED_VERSION);
+
+ if (viableMembers.size() == 0) {
+ // If no viable members were found, return with error status
+ return
utils.getNoViableMembersResult(REDUNDANCY_COMMAND_ADDED_VERSION, prInfo.region);
+ } else {
+ // Update the MemberPRInfo with the viable members
+ prInfo.dsMemberList = viableMembers;
+ }
+ }
+
+ List<CliFunctionResult> functionResults =
+ executeFunctionOnMembers(includeRegions, excludeRegions,
membersForEachRegion);
+
+ return utils.buildResultModelFromFunctionResults(functionResults,
includedRegionsWithNoMembers,
+ true);
+ }
+
+ List<CliFunctionResult> executeFunctionOnMembers(String[] includeRegions,
String[] excludeRegions,
+ List<RebalanceOperationPerformer.MemberPRInfo> membersForEachRegion) {
+
+ List<CliFunctionResult> functionResults = new ArrayList<>();
+ boolean shouldNotReassignPrimaries = false;
Review comment:
Agreed. I've removed the redundant variables and introduced a comment to
clarify the meaning of each of the function arguments instead.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
> Create restore redundancy and status redundancy gfsh commands
> -------------------------------------------------------------
>
> Key: GEODE-7954
> URL: https://issues.apache.org/jira/browse/GEODE-7954
> Project: Geode
> Issue Type: New Feature
> Components: gfsh
> Reporter: Donal Evans
> Assignee: Donal Evans
> Priority: Major
>
> Add two gfsh commands to allow redundancy to be restored and to check the
> current redundancy status:
> {{restore redundancy [--include-region=value(,value)*]
> [--exclude-region=value(,value)*] [--reassign-primaries(=value)]}}
> {{status redundancy [--include-region=value(,value)*]
> [--exclude-region=value(,value)*]}}
> The first command will execute a function on members hosting the specified
> partitioned regions and trigger the restore redundancy operation for those
> regions, then report the final redundancy status of those regions.
> The command will return success status if:
> * Redundancy is fully satisfied for all regions that were included, either
> explicitly or implicitly.
> * No partitioned regions were found and none were explicitly included.
> The command will return error status if:
> * At least one bucket in a region has zero redundant copies, and that region
> has redundancy configured.
> At least one bucket in a region has fewer than the configured number of
> redundant copies.
> * At least one of the explicitly included partitioned regions is not found.
> * There is a member in the system with a version of Geode older than 1.13.0
> (assuming that is the version in which this feature is implemented).
> * The restore redundancy function encounters an exception.
> The second command will determine the current redundancy status for the
> specified regions and report it to the user.
> Both commands will take optional {{\-\-include-region}} and
> {{\-\-exclude-region}} arguments, similar to the existing rebalance command.
> If neither argument is specified, all regions will be included. Included
> regions will take precedence over excluded regions when both are specified.
> The restore redundancy command will also take an optional
> {{\-\-reassign-primaries}} argument to determine if primaries should be
> reassigned or not during the operation. The default behaviour will be to
> reassign primaries.
> Both commands will output a list of regions with zero redundant copies first
> (unless they are configured to have zero redundancy), then regions with less
> than their configured redundancy, then regions with full redundancy. The
> restore redundancy command will also output information about how many
> primaries were reassigned and how long that process took, similar to the
> existing rebalance command.
> As described here:
> [https://cwiki.apache.org/confluence/display/GEODE/Redundancy+Gfsh+Commands]
--
This message was sent by Atlassian Jira
(v8.3.4#803005)