Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 01CB2200B6F for ; Wed, 10 Aug 2016 00:51:54 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id F1349160AAD; Tue, 9 Aug 2016 22:51:53 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id EC269160AA5 for ; Wed, 10 Aug 2016 00:51:52 +0200 (CEST) Received: (qmail 82619 invoked by uid 500); 9 Aug 2016 22:51:52 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 82610 invoked by uid 99); 9 Aug 2016 22:51:52 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Aug 2016 22:51:52 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id BE45CC0957 for ; Tue, 9 Aug 2016 22:51:51 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.645 X-Spam-Level: X-Spam-Status: No, score=-4.645 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id TnChXU8DlrNv for ; Tue, 9 Aug 2016 22:51:48 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 3D9555FBB8 for ; Tue, 9 Aug 2016 22:51:47 +0000 (UTC) Received: (qmail 82601 invoked by uid 99); 9 Aug 2016 22:51:46 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Aug 2016 22:51:46 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5B6E2E03C0; Tue, 9 Aug 2016 22:51:46 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: zhouxj@apache.org To: commits@geode.incubator.apache.org Message-Id: <9c70770273a242a290699d247d92d756@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-geode git commit: This closes #229 Date: Tue, 9 Aug 2016 22:51:46 +0000 (UTC) archived-at: Tue, 09 Aug 2016 22:51:54 -0000 Repository: incubator-geode Updated Branches: refs/heads/develop affb50495 -> e0d80a255 This closes #229 GEODE-11: Fixing bug in definedIndexMap in LuceneServiceImpl If an index is created on an existing region, an exception is thrown, but the index is still stored in definedIndexMap. This is fixed by removing the index definition before the exception is thrown. Added a test to verify GEODE-11: Describe/Search index gfsh commands returns error message when region not created - Previously, the describe/search index gfsh command on definied indexes returned an exception. Changed the behavior to return a message. Added dunit test to verify - Changed Search index command to "search lucene" (previously "lucene search") Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/e0d80a25 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/e0d80a25 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/e0d80a25 Branch: refs/heads/develop Commit: e0d80a25583f8fb0be20f69ee62d43107ac87208 Parents: affb504 Author: Aparna Dharmakkan Authored: Tue Aug 9 13:56:02 2016 -0700 Committer: zhouxh Committed: Tue Aug 9 15:41:13 2016 -0700 ---------------------------------------------------------------------- .../cache/lucene/internal/LuceneServiceImpl.java | 1 + .../lucene/internal/cli/LuceneCliStrings.java | 2 +- .../lucene/internal/cli/LuceneIndexCommands.java | 12 +++++++++--- .../LuceneIndexCreationIntegrationTest.java | 12 ++++++++++++ .../cli/LuceneIndexCommandsDUnitTest.java | 18 +++--------------- 5 files changed, 26 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e0d80a25/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImpl.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImpl.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImpl.java index b0da08d..8375888 100644 --- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImpl.java +++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImpl.java @@ -143,6 +143,7 @@ public class LuceneServiceImpl implements InternalLuceneService { Region region = cache.getRegion(regionPath); if(region != null) { + definedIndexMap.remove(LuceneServiceImpl.getUniqueIndexName(indexName, regionPath)); throw new IllegalStateException("The lucene index must be created before region"); } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e0d80a25/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 f573bf5..b424d8f 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 @@ -59,7 +59,7 @@ public class LuceneCliStrings { //Search lucene index commands - public static final String LUCENE_SEARCH_INDEX = "lucene search"; + public static final String LUCENE_SEARCH_INDEX = "search lucene"; public static final String LUCENE_SEARCH_INDEX__HELP = "Search lucene index"; public static final String LUCENE_SEARCH_INDEX__ERROR_MESSAGE = "An error occurred while searching lucene index across the Geode cluster: %1$s"; public static final String LUCENE_SEARCH_INDEX__NAME__HELP = "Name of the lucene index to search."; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e0d80a25/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 e25f7dd..20c3990 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 @@ -243,6 +243,9 @@ public class LuceneIndexCommands extends AbstractCommandsSupport { SystemFailure.initiateFailure(e); throw e; } + catch (IllegalArgumentException e) { + return ResultBuilder.createInfoResult(e.getMessage()); + } catch (Throwable t) { SystemFailure.checkFailure(); getCache().getLogger().info(t); @@ -311,6 +314,9 @@ public class LuceneIndexCommands extends AbstractCommandsSupport { SystemFailure.initiateFailure(e); throw e; } + catch (IllegalArgumentException e) { + return ResultBuilder.createInfoResult(e.getMessage()); + } catch (Throwable t) { SystemFailure.checkFailure(); getCache().getLogger().info(t); @@ -433,13 +439,13 @@ public class LuceneIndexCommands extends AbstractCommandsSupport { protected ResultCollector executeFunctionOnGroups(FunctionAdapter function, String[] groups, - final LuceneIndexInfo indexInfo) throws Exception + final LuceneIndexInfo indexInfo) throws IllegalArgumentException, CommandResultException { final Set targetMembers; if (function != createIndexFunction) { targetMembers = CliUtil.getMembersForeRegionViaFunction(getCache(), indexInfo.getRegionPath()); if (targetMembers.isEmpty()) { - throw new Exception("Region not found."); + throw new IllegalArgumentException("Region not found."); } } else { @@ -451,7 +457,7 @@ public class LuceneIndexCommands extends AbstractCommandsSupport { protected ResultCollector executeSearch(final LuceneQueryInfo queryInfo) throws Exception { final Set targetMembers = CliUtil.getMembersForeRegionViaFunction(getCache(),queryInfo.getRegionPath()); if (targetMembers.isEmpty()) - throw new Exception("Region not found."); + throw new IllegalArgumentException("Region not found."); return CliUtil.executeFunction(searchIndexFunction, queryInfo, targetMembers); } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e0d80a25/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationIntegrationTest.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationIntegrationTest.java b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationIntegrationTest.java index fc1f84f..0974bf0 100644 --- a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationIntegrationTest.java +++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationIntegrationTest.java @@ -213,6 +213,18 @@ public class LuceneIndexCreationIntegrationTest extends LuceneIntegrationTest { .collect(Collectors.toList())); } + @Test + public void shouldRemoveDefinedIndexIfRegionAlreadyExists() + { + try { + createRegion(); + createIndex("field1", "field2", "field3"); + + } catch(IllegalStateException e) { + assertEquals("The lucene index must be created before region", e.getMessage()); + assertEquals(0,((LuceneServiceImpl) luceneService).getAllDefinedIndexes().size()); + } + } private void verifyInternalRegions(Consumer verify) { LuceneTestUtilities.verifyInternalRegions(luceneService, cache, verify); } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e0d80a25/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java index bdede47..ce7c7b2 100755 --- a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java +++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java @@ -296,7 +296,7 @@ public class LuceneIndexCommandsDUnitTest extends CliCommandTestBase { } @Test - public void describeIndexWithoutRegionShouldReturnError() throws Exception { + public void describeIndexWithoutRegionShouldReturnErrorMessage() throws Exception { final VM vm1 = Host.getHost(0).getVM(1); @@ -304,13 +304,7 @@ public class LuceneIndexCommandsDUnitTest extends CliCommandTestBase { CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESCRIBE_INDEX); csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME,"notAnIndex"); csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH,REGION_NAME); - - String commandString = csb.toString(); - writeToLog("Command String :\n ", commandString); - CommandResult commandResult = executeCommand(commandString); - String resultAsString = commandResultToString(commandResult); - writeToLog("Result String :\n ", resultAsString); - assertEquals(Status.ERROR, commandResult.getStatus()); + String resultAsString = executeCommandAndLogResult(csb); assertTrue(resultAsString.contains("Region not found")); } @@ -459,14 +453,8 @@ public class LuceneIndexCommandsDUnitTest extends CliCommandTestBase { csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__QUERY_STRING, "EFG"); csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, "field2"); - String commandString = csb.toString(); - writeToLog("Command String :\n ", commandString); - CommandResult commandResult = executeCommand(commandString); - String resultAsString = commandResultToString(commandResult); - writeToLog("Result String :\n ", resultAsString); - assertEquals(Status.ERROR, commandResult.getStatus()); + String resultAsString = executeCommandAndLogResult(csb); assertTrue(resultAsString.contains("Region not found")); - } @Test