-
Notifications
You must be signed in to change notification settings - Fork 1.9k
IGNITE-27457 Implement result output for wal enable/disable control.sh commands #12608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Please, fix merge conflicts |
# Conflicts: # modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerWalTest.java # modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterImpl.java # modules/core/src/main/java/org/apache/ignite/internal/management/wal/WalSetStateTask.java # modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WalModeChangeAdvancedSelfTest.java
| */ | ||
| @Test | ||
| public void testWalChangeForMultiCacheGroup() throws Exception { | ||
| public void testWalManagementOperations() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep old test name
| * @throws Exception If failed. | ||
| */ | ||
| @Test | ||
| public void testWalChangeForNonPersistentCaches() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fix this behavior in different patch
| @Override protected Void run(@Nullable WalDisableCommandArg arg) throws IgniteException { | ||
| Set<String> grps = F.isEmpty(arg.groups()) ? null : new HashSet<>(Arrays.asList(arg.groups())); | ||
| @Override protected WalSetStateTaskResult run(@Nullable WalDisableCommandArg arg) throws IgniteException { | ||
| Set<String> requestedGrps = F.isEmpty(arg.groups()) ? null : new HashSet<>(Arrays.asList(arg.groups())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arr -> list -> set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use List
| } | ||
| } | ||
|
|
||
| for (String requestedGrp : requestedGrps) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can reuse request groups after removing
| } | ||
| catch (Exception e) { | ||
| errors.add("Failed to execute operation - " + e.getMessage()); | ||
| return new WalSetStateTaskResult(successGrps, errors); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add NL before return
| else { | ||
| WalSetStateTaskResult result = jobRes.getData(); | ||
| if (result.successGroups() != null) | ||
| successGrps.addAll(result.successGroups()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can safely reuse success groups from any response
| if (errors.isEmpty()) | ||
| return new WalSetStateTaskResult(new ArrayList<>(successGrps)); | ||
| else | ||
| return new WalSetStateTaskResult(new ArrayList<>(successGrps), errors); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make successGrps list in definition
| if (result.successGroups() != null) | ||
| successGrps.addAll(result.successGroups()); | ||
| if (!Boolean.TRUE.equals(result.success()) && result.errorMessages() != null) | ||
| errors.addAll(result.errorMessages()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are duplicates of errors
| private static final long serialVersionUID = 0L; | ||
|
|
||
| /** Success flag. */ | ||
| private Boolean success; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can check errors for empty.
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override public void printResult(WalDisableCommandArg arg, WalSetStateTaskResult res, Consumer<String> printer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move logic to a separate class
| Set<String> requestedGrps = F.isEmpty(arg.groups()) ? null : new HashSet<>(Arrays.asList(arg.groups())); | ||
| boolean isEnable = arg instanceof WalEnableCommandArg; | ||
| List<String> successGrps = new ArrayList<>(); | ||
| List<String> errors = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use map
| successGrps.add(grpName); | ||
| } | ||
| catch (Exception e) { | ||
| errors.add("Failed to " + (isEnable ? "enable" : "disable") + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Send only exception messages
Thank you for submitting the pull request to the Apache Ignite.
In order to streamline the review of the contribution
we ask you to ensure the following steps have been taken:
The Contribution Checklist
The description explains WHAT and WHY was made instead of HOW.
The following pattern must be used:
IGNITE-XXXX Change summarywhereXXXX- number of JIRA issue.(see the Maintainers list)
the
green visaattached to the JIRA ticket (see TC.Bot: Check PR)Notes
If you need any help, please email [email protected] or ask anу advice on http://asf.slack.com #ignite channel.