geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zho...@apache.org
Subject incubator-geode git commit: GEODE-11: GFSH command fixes
Date Mon, 18 Jul 2016 21:29:39 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop 3473229fc -> 701909fd4


GEODE-11: GFSH command fixes

List lucene gfsh command is changed to "list lucene indexes --with-stats" (previously list
lucene index --stats)
Changed the create index command's result display to a tabular format

This closes #211


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

Branch: refs/heads/develop
Commit: 701909fd46626774d7b4ce0266a3a1c0340814b3
Parents: 3473229
Author: Aparna Dharmakkan <adharmakkan@pivotal.io>
Authored: Mon Jul 18 13:49:16 2016 -0700
Committer: zhouxh <gzhou@pivotal.io>
Committed: Mon Jul 18 14:29:12 2016 -0700

----------------------------------------------------------------------
 .../lucene/internal/cli/LuceneCliStrings.java   |  4 +-
 .../internal/cli/LuceneIndexCommands.java       | 63 +++-----------------
 .../cli/LuceneIndexCommandsJUnitTest.java       | 24 +++-----
 3 files changed, 20 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/701909fd/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/cli/LuceneCliStrings.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/cli/LuceneCliStrings.java
b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/cli/LuceneCliStrings.java
index 282e691..393ab22 100644
--- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/cli/LuceneCliStrings.java
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/cli/LuceneCliStrings.java
@@ -24,11 +24,11 @@ public class LuceneCliStrings {
   public static final String LUCENE__REGION_PATH = "region";
 
   //List lucene index commands
-  public static final String LUCENE_LIST_INDEX = "list lucene index";
+  public static final String LUCENE_LIST_INDEX = "list lucene indexes";
   public static final String LUCENE_LIST_INDEX__HELP = "Display the list of lucene indexes
created for all members.";
   public static final String LUCENE_LIST_INDEX__ERROR_MESSAGE = "An error occurred while
collecting all lucene index information across the Geode cluster: %1$s";
   public static final String LUCENE_LIST_INDEX__INDEXES_NOT_FOUND_MESSAGE = "No lucene indexes
found";
-  public static final String LUCENE_LIST_INDEX__STATS = "stats";
+  public static final String LUCENE_LIST_INDEX__STATS = "with-stats";
   public static final String LUCENE_LIST_INDEX__STATS__HELP = "Display lucene index stats";
 
   //Create lucene index commands 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/701909fd/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/cli/LuceneIndexCommands.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/cli/LuceneIndexCommands.java
b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/cli/LuceneIndexCommands.java
index 30028be..bb2b2c9 100755
--- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/cli/LuceneIndexCommands.java
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/cli/LuceneIndexCommands.java
@@ -181,68 +181,23 @@ public class LuceneIndexCommands extends AbstractCommandsSupport {
       final ResultCollector<?, ?> rc = this.executeFunctionOnGroups(createIndexFunction,
groups, indexInfo);
       final List<CliFunctionResult> funcResults = (List<CliFunctionResult>) rc.getResult();
 
-      final Set<String> successfulMembers = new TreeSet<String>();
-      final Map<String, Set<String>> indexOpFailMap = new HashMap<String,
Set<String>>();
-
+      final TabularResultData tabularResult = ResultBuilder.createTabularResultData();
       for (final CliFunctionResult cliFunctionResult : funcResults) {
+        tabularResult.accumulate("Member",cliFunctionResult.getMemberIdOrName());
 
           if (cliFunctionResult.isSuccessful()) {
-            successfulMembers.add(cliFunctionResult.getMemberIdOrName());
-
-            if (xmlEntity == null) {
-              xmlEntity = cliFunctionResult.getXmlEntity();
-            }
+            tabularResult.accumulate("Status","Successfully created lucene index");
+//            if (xmlEntity == null) {
+//              xmlEntity = cliFunctionResult.getXmlEntity();
+//            }
           }
           else {
-            final String exceptionMessage = cliFunctionResult.getMessage();
-            Set<String> failedMembers = indexOpFailMap.get(exceptionMessage);
-
-            if (failedMembers == null) {
-              failedMembers = new TreeSet<String>();
-            }
-            failedMembers.add(cliFunctionResult.getMemberIdOrName());
-            indexOpFailMap.put(exceptionMessage, failedMembers);
+            tabularResult.accumulate("Status","Failed: "+cliFunctionResult.getMessage());
           }
       }
-
-      if (!successfulMembers.isEmpty()) {
-
-        final InfoResultData infoResult = ResultBuilder.createInfoResultData();
-        infoResult.addLine(LuceneCliStrings.CREATE_INDEX__SUCCESS__MSG);
-        infoResult.addLine(CliStrings.format(LuceneCliStrings.CREATE_INDEX__NAME__MSG, indexName));
-        infoResult.addLine(CliStrings.format(LuceneCliStrings.CREATE_INDEX__REGIONPATH__MSG,
regionPath));
-        infoResult.addLine(LuceneCliStrings.CREATE_INDEX__MEMBER__MSG);
-
-        int num = 0;
-
-        for (final String memberId : successfulMembers) {
-          ++num;
-          infoResult.addLine(CliStrings.format(LuceneCliStrings.CREATE_INDEX__NUMBER__AND__MEMBER,
num, memberId));
-        }
-        result = ResultBuilder.buildResult(infoResult);
-
-
-      } else {
-        //Group members by the exception thrown.
-        final ErrorResultData erd = ResultBuilder.createErrorResultData();
-        erd.addLine(CliStrings.format(LuceneCliStrings.CREATE_INDEX__FAILURE__MSG, indexName));
-
-        final Set<String> exceptionMessages = indexOpFailMap.keySet();
-
-        for (final String exceptionMessage : exceptionMessages) {
-          erd.addLine(exceptionMessage);
-          erd.addLine(LuceneCliStrings.CREATE_INDEX__EXCEPTION__OCCURRED__ON);
-          final Set<String> memberIds = indexOpFailMap.get(exceptionMessage);
-
-          int num = 0;
-          for (final String memberId : memberIds) {
-            ++num;
-            erd.addLine(CliStrings.format(LuceneCliStrings.CREATE_INDEX__NUMBER__AND__MEMBER,
num, memberId));
-          }
-        }
-        result = ResultBuilder.buildResult(erd);
+        result = ResultBuilder.buildResult(tabularResult);
       }
-    } catch (CommandResultException crex) {
+     catch (CommandResultException crex) {
       result = crex.getResult();
     } catch (Exception e) {
       result = ResultBuilder.createGemFireErrorResult(e.getMessage());

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/701909fd/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
index 41f1ca4..e482ee4 100644
--- a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
@@ -168,9 +168,11 @@ public class LuceneIndexCommandsJUnitTest {
     final Cache mockCache=mock(Cache.class);
     final ResultCollector mockResultCollector = mock(ResultCollector.class);
     final LuceneIndexCommands commands=spy(createIndexCommands(mockCache,null));
-    final String memberId="member1";
+
     final List<CliFunctionResult> cliFunctionResults=new ArrayList<>();
-    cliFunctionResults.add(new CliFunctionResult(memberId,true,"Index Created"));
+    cliFunctionResults.add(new CliFunctionResult("member1",true,"Index Created"));
+    cliFunctionResults.add(new CliFunctionResult("member2",false,"Index creation failed"));
+    cliFunctionResults.add(new CliFunctionResult("member3",true,"Index Created"));
 
     doReturn(mockResultCollector).when(commands).executeFunctionOnGroups(isA(LuceneCreateIndexFunction.class),any(),any(LuceneIndexInfo.class));
     doReturn(cliFunctionResults).when(mockResultCollector).getResult();
@@ -180,20 +182,12 @@ public class LuceneIndexCommandsJUnitTest {
     String[] searchableFields={"field1","field2","field3"};
     String[] fieldAnalyzers = { StandardAnalyzer.class.getCanonicalName(), KeywordAnalyzer.class.getCanonicalName(),
StandardAnalyzer.class.getCanonicalName()};
 
-    Result actualResult=commands.createIndex(indexName,regionPath,searchableFields,fieldAnalyzers,null);
-    Result expectedResult = buildResult(indexName, regionPath, memberId);
-    assertEquals(Status.OK,actualResult.getStatus());
-    assertEquals(expectedResult,actualResult);
-  }
+    CommandResult result=(CommandResult) commands.createIndex(indexName,regionPath,searchableFields,fieldAnalyzers,null);
+    assertEquals(Status.OK,result.getStatus());
+    TabularResultData data = (TabularResultData) result.getResultData();
+    assertEquals(Arrays.asList("member1","member2","member3"), data.retrieveAllValues("Member"));
+    assertEquals(Arrays.asList("Successfully created lucene index","Failed: Index creation
failed","Successfully created lucene index"), data.retrieveAllValues("Status"));
 
-  private Result buildResult(final String indexName, final String regionPath, final String
memberId) {
-    final InfoResultData infoResult = ResultBuilder.createInfoResultData();
-    infoResult.addLine(LuceneCliStrings.CREATE_INDEX__SUCCESS__MSG);
-    infoResult.addLine(CliStrings.format(LuceneCliStrings.CREATE_INDEX__NAME__MSG, indexName));
-    infoResult.addLine(CliStrings.format(LuceneCliStrings.CREATE_INDEX__REGIONPATH__MSG,
regionPath));
-    infoResult.addLine(LuceneCliStrings.CREATE_INDEX__MEMBER__MSG);
-    infoResult.addLine(CliStrings.format(LuceneCliStrings.CREATE_INDEX__NUMBER__AND__MEMBER,
1 , memberId));
-    return ResultBuilder.buildResult(infoResult);
   }
 
   @Test


Mime
View raw message