You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geode.apache.org by YehEmily <gi...@git.apache.org> on 2017/07/31 18:31:52 UTC

[GitHub] geode pull request #671: GEODE-3255: Refactor CreateAlterDestroyRegionComman...

GitHub user YehEmily opened a pull request:

    https://github.com/apache/geode/pull/671

    GEODE-3255: Refactor CreateAlterDestroyRegionCommands and tests

    [View the JIRA ticket here.](https://issues.apache.org/jira/browse/GEODE-3255)
    
    `CreateAlterDestroyRegionCommands` was a large class that contained multiple commands. Each command was refactored into a separate class, and the methods shared by the commands were refactored into a new and appropriately named class of their own. Tests related to `CreateAlterDestroyRegionCommands` were also refactored.
    
    **Testing status: Precheckin completed successfully**
    
    - [x] JIRA ticket referenced
    
    - [x] PR rebased
    
    - [x] Single, squashed commit
    
    - [x] `gradlew build` runs cleanly
    
    - [x] Tests updated

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/YehEmily/geode GEODE-3255

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/geode/pull/671.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #671
    
----
commit 8a0e27fd3bf44cb63871b8b3b226800a845e0e4c
Author: YehEmily <em...@gmail.com>
Date:   2017-07-28T21:23:25Z

    GEODE-3255: Refactor CreateAlterDestroyRegionCommands and tests

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] geode pull request #671: GEODE-3255: Refactor CreateAlterDestroyRegionComman...

Posted by jaredjstewart <gi...@git.apache.org>.
Github user jaredjstewart commented on a diff in the pull request:

    https://github.com/apache/geode/pull/671#discussion_r130668398
  
    --- Diff: geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java ---
    @@ -1143,4 +721,26 @@ private boolean isAttributePersistent(RegionAttributes attributes) {
         return attributes != null && attributes.getDataPolicy() != null
             && attributes.getDataPolicy().toString().contains("PERSISTENT");
       }
    +
    +  private static boolean regionExists(InternalCache cache, String regionPath) {
    --- End diff --
    
    I don't see any tests that validate the behavior of this method.  I think we can simplify it to: 
    ```
    private static boolean regionExists(InternalCache cache, String regionPath) {
        if (regionPath == null || Region.SEPARATOR.equals(regionPath)) {
          return false;
        }
        
        ManagementService managementService = ManagementService.getExistingManagementService(cache);
        DistributedSystemMXBean dsMBean = managementService.getDistributedSystemMXBean();
    
        String[] allRegionPaths = dsMBean.listAllRegionPaths();
        return Arrays.stream(allRegionPaths).anyMatch(regionPath::equals);
      }
    ```
    
    But it would be nice to have a test that would fail with this implementation:
    ```
    private static boolean regionExists(InternalCache cache, String regionPath) {
    return true;
    }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] geode pull request #671: GEODE-3255: Refactor CreateAlterDestroyRegionComman...

Posted by YehEmily <gi...@git.apache.org>.
Github user YehEmily commented on a diff in the pull request:

    https://github.com/apache/geode/pull/671#discussion_r131002611
  
    --- Diff: geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java ---
    @@ -1143,4 +721,26 @@ private boolean isAttributePersistent(RegionAttributes attributes) {
         return attributes != null && attributes.getDataPolicy() != null
             && attributes.getDataPolicy().toString().contains("PERSISTENT");
       }
    +
    +  private static boolean regionExists(InternalCache cache, String regionPath) {
    --- End diff --
    
    Fixed! Thanks for your feedback! Do you mean it would be nice to have a test that would fail if `regionExists` always returns `true`, regardless of whether the region does or doesn't exist? I wrote a very simple test that does this and put it in `CreateRegionCommandTest`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] geode pull request #671: GEODE-3255: Refactor CreateAlterDestroyRegionComman...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/geode/pull/671


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---