GEODE-2886 : 1. sent IllegalStateException instead of throwing IllegalArgumentException inside WaitUntilFlushedFunction. 2. Added dunit test with invalid indexName to get IllegalStateException to the caller of the WaitUntilFlushedFunction.
Project: http://git-wip-us.apache.org/repos/asf/geode/repo Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/11971d51 Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/11971d51 Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/11971d51 Branch: refs/heads/feature/GEODE-1279 Commit: 11971d51b946804e5c01c752be95c3174fea3569 Parents: 2f61dd6 Author: Amey Barve <[email protected]> Authored: Fri Jun 23 16:18:33 2017 +0530 Committer: Amey Barve <[email protected]> Committed: Thu Aug 17 15:38:41 2017 +0530 ---------------------------------------------------------------------- .../cache/lucene/internal/LuceneServiceImpl.java | 16 ++++++++++++---- .../distributed/WaitUntilFlushedFunction.java | 4 ++-- .../lucene/LuceneQueriesIntegrationTest.java | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode/blob/11971d51/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java index 39b5d36..258b8a4 100644 --- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java +++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java @@ -473,12 +473,20 @@ public class LuceneServiceImpl implements InternalLuceneService { new WaitUntilFlushedFunctionContext(indexName, timeout, unit); Execution execution = FunctionService.onRegion(dataRegion); ResultCollector rs = execution.setArguments(context).execute(WaitUntilFlushedFunction.ID); - List<Boolean> results = (List<Boolean>) rs.getResult(); - for (Boolean oneResult : results) { - if (oneResult == false) { + List<Object> results = (List<Object>) rs.getResult(); + if (results != null) { + if (results.get(0) instanceof IllegalStateException) { return false; + } else { + for (Object oneResult : results) { + if ((boolean) oneResult == false) { + return false; + } + } + return true; } + } else { + return false; } - return true; } } http://git-wip-us.apache.org/repos/asf/geode/blob/11971d51/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/WaitUntilFlushedFunction.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/WaitUntilFlushedFunction.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/WaitUntilFlushedFunction.java index bae0e74..6c14fcd 100644 --- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/WaitUntilFlushedFunction.java +++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/WaitUntilFlushedFunction.java @@ -62,8 +62,8 @@ public class WaitUntilFlushedFunction implements Function, InternalEntity { } } else { - throw new IllegalArgumentException( - "The AEQ does not exist for the index " + indexName + " region " + region.getFullPath()); + resultSender.sendException(new IllegalStateException( + "The AEQ does not exist for the index " + indexName + " region " + region.getFullPath())); } resultSender.lastResult(result); } http://git-wip-us.apache.org/repos/asf/geode/blob/11971d51/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesIntegrationTest.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesIntegrationTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesIntegrationTest.java index fb86e19..779b12a 100644 --- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesIntegrationTest.java +++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesIntegrationTest.java @@ -331,6 +331,24 @@ public class LuceneQueriesIntegrationTest extends LuceneIntegrationTest { } @Test() + public void testWaitUntilFlushedForException() throws Exception { + Map<String, Analyzer> fields = new HashMap<String, Analyzer>(); + fields.put("name", null); + fields.put("lastName", null); + fields.put("address", null); + luceneService.createIndexFactory().setFields(fields).create(INDEX_NAME, REGION_NAME); + Region region = cache.createRegionFactory(RegionShortcut.PARTITION).create(REGION_NAME); + final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME); + + // This is to send IllegalStateException from WaitUntilFlushedFunction + String nonCreatedIndex = "index2"; + + boolean b = + luceneService.waitUntilFlushed(nonCreatedIndex, REGION_NAME, 60000, TimeUnit.MILLISECONDS); + assertFalse(b); + } + + @Test() public void shouldAllowQueryOnRegionWithStringValue() throws Exception { luceneService.createIndexFactory().setFields(LuceneService.REGION_VALUE_FIELD) .create(INDEX_NAME, REGION_NAME);
