geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstew...@apache.org
Subject [1/2] geode git commit: GEODE-2416: Export logs includes locators
Date Thu, 16 Feb 2017 19:42:45 GMT
Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-2267 6c154a55f -> eef1601d1


GEODE-2416: Export logs includes locators


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/f542a860
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/f542a860
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/f542a860

Branch: refs/heads/feature/GEODE-2267
Commit: f542a8603662e5ced85f5fdb85f82f8b7102f6a3
Parents: 6c154a5
Author: Jared Stewart <jstewart@pivotal.io>
Authored: Tue Feb 14 11:45:13 2017 -0800
Committer: Jared Stewart <jstewart@pivotal.io>
Committed: Thu Feb 16 11:40:59 2017 -0800

----------------------------------------------------------------------
 .../geode/management/internal/cli/CliUtil.java  | 29 ++++++++++++++++----
 .../cli/commands/MiscellaneousCommands.java     |  8 ++----
 2 files changed, 26 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/f542a860/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
index 8525b58..fe56186 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CliUtil.java
@@ -301,7 +301,27 @@ public class CliUtil {
     return matchingMembers;
   }
 
+  /**
+   * Finds all Members (including both servers and locators) which belong to the given arrays
of groups or members.
+   */
+  public static Set<DistributedMember> findMembersIncludingLocators(String[] groups,
String[] members) {
+    Cache cache = CacheFactory.getAnyInstance();
+    Set<DistributedMember> allMembers = getAllMembers(cache);
+
+    return findMembers(allMembers, groups, members);
+  }
+
+  /**
+   * Finds all Servers which belong to the given arrays of groups or members.  Does not include
locators.
+   */
   public static Set<DistributedMember> findMembers(String[] groups, String[] members)
{
+    Cache cache = CacheFactory.getAnyInstance();
+    Set<DistributedMember> allNormalMembers = getAllNormalMembers(cache);
+
+    return findMembers(allNormalMembers, groups, members);
+  }
+
+  private static Set<DistributedMember> findMembers(Set<DistributedMember> membersToConsider,
String[] groups, String[] members) {
     if (groups == null) {
       groups = new String[] {};
     }
@@ -310,21 +330,18 @@ public class CliUtil {
       members = new String[] {};
     }
 
-    Cache cache = CacheFactory.getAnyInstance();
-
     if ((members.length > 0) && (groups.length > 0)) {
       throw new IllegalArgumentException(CliStrings.PROVIDE_EITHER_MEMBER_OR_GROUP_MESSAGE);
     }
 
-    Set<DistributedMember> allNormalMembers = getAllNormalMembers(cache);
     if (members.length == 0 && groups.length == 0) {
-      return allNormalMembers;
+      return membersToConsider;
     }
 
     Set<DistributedMember> matchingMembers = new HashSet<DistributedMember>();
     // it will either go into this loop or the following loop, not both.
     for (String memberNameOrId : members) {
-      for (DistributedMember member : allNormalMembers) {
+      for (DistributedMember member : membersToConsider) {
         if (memberNameOrId.equalsIgnoreCase(member.getId())
             || memberNameOrId.equals(member.getName())) {
           matchingMembers.add(member);
@@ -333,7 +350,7 @@ public class CliUtil {
     }
 
     for (String group : groups) {
-      for (DistributedMember member : allNormalMembers) {
+      for (DistributedMember member : membersToConsider) {
         if (member.getGroups().contains(group)) {
           matchingMembers.add(member);
         }

http://git-wip-us.apache.org/repos/asf/geode/blob/f542a860/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
index b30633a..b8845e2 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
@@ -725,16 +725,14 @@ public class MiscellaneousCommands implements CommandMarker {
       ExportLogsCacheWriter cacheWriter =
           (ExportLogsCacheWriter) region.getAttributes().getCacheWriter();
 
-      // TODO: Make this work for locators as well
-      Set<DistributedMember> targetServers = CliUtil.findMembers(groups, memberIds);
+      Set<DistributedMember> targetMembers = CliUtil.findMembersIncludingLocators(groups,
memberIds);
       Logger logger = LogService.getLogger();
 
       Map<String, Path> zipFilesFromMembers = new HashMap<>();
-      for (DistributedMember server : targetServers) {
+      for (DistributedMember server : targetMembers) {
         cacheWriter.startFile(server.getName());
 
-        CliUtil
-            .executeFunction(new ExportLogsFunction(),
+        CliUtil.executeFunction(new ExportLogsFunction(),
                 new ExportLogsFunction.Args(start, end, logLevel, onlyLogLevel), server)
             .getResult();
         Path zipFile = cacheWriter.endFile();


Mime
View raw message