[ 
https://issues.apache.org/jira/browse/GEODE-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16242813#comment-16242813
 ] 

ASF GitHub Bot commented on GEODE-3898:
---------------------------------------

jujoramos commented on a change in pull request #1022: Fix for GEODE-3898: 
Defined Indexes are not Persisted in Cluster Configuration.
URL: https://github.com/apache/geode/pull/1022#discussion_r149492926
 
 

 ##########
 File path: 
geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/CreateDefinedIndexesFunction.java
 ##########
 @@ -55,8 +69,33 @@ public void execute(FunctionContext context) {
           queryService.defineIndex(indexName, indexedExpression, regionPath);
         }
       }
-      indexes = queryService.createDefinedIndexes();
-      context.getResultSender().lastResult(new CliFunctionResult(memberId));
+
+      List<Index> indexes = queryService.createDefinedIndexes();
+
+      // One XmlEntity per region.
+      ResultSender sender = context.getResultSender();
+      List<String> processedRegions = new ArrayList<>();
+      List<CliFunctionResult> functionResults = new ArrayList<>();
+
+      for (Index index : indexes) {
+        String regionName = index.getRegion().getName();
+
+        if (!processedRegions.contains(regionName)) {
+          XmlEntity xmlEntity = createXmlEntity(regionName);
+          functionResults.add(new CliFunctionResult(memberId, xmlEntity));
+          processedRegions.add(regionName);
+        }
+      }
+
+      int resultsSize = functionResults.size();
+
+      if (resultsSize > 0) {
 
 Review comment:
   For this particular case I'm accessing the elements by index using 
`functionResults.get(i)` and `functionResults.get(resultsSize - 1)` within a 
`for (int i = 0; i < resultsSize - 1; i++)` loop, so I need the check to avoid 
any `IndexOutOfBoundsException`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Indexes created through the `create defined indexes` command are not 
> persisted to the cluster configuration service
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: GEODE-3898
>                 URL: https://issues.apache.org/jira/browse/GEODE-3898
>             Project: Geode
>          Issue Type: Bug
>          Components: querying
>            Reporter: Juan José Ramos Cassella
>            Assignee: Juan José Ramos Cassella
>              Labels: configuration, gfsh
>
> When using the cluster configuration service, indexes created through {{gfsh 
> define index}} + {{gfsh create defined indexes}} are not persisted to the 
> cluster configuration service.
> Steps to reproduce:
> # Start a locator with {{enable-cluster-configuration-enabled=true}}.
> # Start a server with {{enable-cluster-configuration-enabled=true}}.
> # Create a sample region: {{gfsh create region --name=TestRegion 
> --type=REPLICATE}}.
> # Define an index: {{gfsh define index --name=index1 --expression=value1 
> --region=TestRegion}}.
> # Created the defined indexes: {{gfsh create defined indexes}}.
> # Restart the cluster.
> # Execute {{list indexes}}. The command returns no indexes.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to