geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aba...@apache.org
Subject [25/58] [abbrv] geode git commit: GEODE-3025: Lucene queries are not allowed withing a transaction.
Date Mon, 17 Jul 2017 18:06:34 GMT
GEODE-3025: Lucene queries are not allowed withing a transaction.

	This closes #562


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

Branch: refs/heads/master
Commit: 5853cc2fb816dda7874277101abda22c79caeb9a
Parents: c5dbfd2
Author: nabarun <nnag@pivotal.io>
Authored: Thu Jun 8 10:33:04 2017 -0700
Committer: nabarun <nnag@pivotal.io>
Committed: Fri Jun 9 14:21:05 2017 -0700

----------------------------------------------------------------------
 .../cache/lucene/internal/LuceneQueryImpl.java  |  3 ++
 .../distributed/LuceneQueryFunction.java        |  1 -
 .../LuceneIndexMaintenanceIntegrationTest.java  | 26 --------------
 .../lucene/LuceneQueriesClientDUnitTest.java    | 38 --------------------
 .../internal/LuceneQueryImplJUnitTest.java      | 12 ++++++-
 5 files changed, 14 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/5853cc2f/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneQueryImpl.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneQueryImpl.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneQueryImpl.java
index 328eb3f..e84b27e 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneQueryImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneQueryImpl.java
@@ -108,6 +108,9 @@ public class LuceneQueryImpl<K, V> implements LuceneQuery<K,
V> {
     TopEntriesCollectorManager manager = new TopEntriesCollectorManager(null, limit);
     LuceneFunctionContext<TopEntriesCollector> context =
         new LuceneFunctionContext<>(query, indexName, manager, limit);
+    if (region.getCache().getCacheTransactionManager().exists()) {
+      throw new LuceneQueryException(LUCENE_QUERY_CANNOT_BE_EXECUTED_WITHIN_A_TRANSACTION);
+    }
 
     // TODO provide a timeout to the user?
     TopEntries<K> entries = null;

http://git-wip-us.apache.org/repos/asf/geode/blob/5853cc2f/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
index b60652f..c40b3a4 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
@@ -21,7 +21,6 @@ import java.util.Collection;
 
 import org.apache.geode.cache.CacheClosedException;
 import org.apache.geode.cache.execute.Function;
-import org.apache.geode.cache.lucene.LuceneIndexDestroyedException;
 import org.apache.geode.cache.lucene.LuceneIndexNotFoundException;
 import org.apache.geode.cache.lucene.internal.LuceneIndexImpl;
 import org.apache.geode.cache.lucene.internal.LuceneIndexStats;

http://git-wip-us.apache.org/repos/asf/geode/blob/5853cc2f/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
index f9273c1..2f39d78 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
@@ -46,32 +46,6 @@ public class LuceneIndexMaintenanceIntegrationTest extends LuceneIntegrationTest
 
   private static int WAIT_FOR_FLUSH_TIME = 10000;
 
-  @Test
-  public void indexIsNotUpdatedIfTransactionHasNotCommittedYet() throws Exception {
-    luceneService.createIndexFactory().setFields("title", "description").create(INDEX_NAME,
-        REGION_NAME);
-
-    Region region = createRegion(REGION_NAME, RegionShortcut.PARTITION);
-    region.put("object-1", new TestObject("title 1", "hello world"));
-    region.put("object-2", new TestObject("title 2", "this will not match"));
-    region.put("object-3", new TestObject("title 3", "hello world"));
-    region.put("object-4", new TestObject("hello world", "hello world"));
-
-    LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
-    luceneService.waitUntilFlushed(INDEX_NAME, REGION_NAME, WAIT_FOR_FLUSH_TIME,
-        TimeUnit.MILLISECONDS);
-    LuceneQuery query = luceneService.createLuceneQueryFactory().create(INDEX_NAME, REGION_NAME,
-        "description:\"hello world\"", DEFAULT_FIELD);
-    PageableLuceneQueryResults<Integer, TestObject> results = query.findPages();
-    assertEquals(3, results.size());
-
-    // begin transaction
-    cache.getCacheTransactionManager().begin();
-    region.put("object-1", new TestObject("title 1", "updated"));
-    luceneService.waitUntilFlushed(INDEX_NAME, REGION_NAME, WAIT_FOR_FLUSH_TIME,
-        TimeUnit.MILLISECONDS);
-    assertEquals(3, query.findPages().size());
-  }
 
   @Test
   public void indexIsUpdatedAfterTransactionHasCommitted() throws Exception {

http://git-wip-us.apache.org/repos/asf/geode/blob/5853cc2f/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesClientDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesClientDUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesClientDUnitTest.java
index e200a19..f893134 100755
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesClientDUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesClientDUnitTest.java
@@ -14,12 +14,8 @@
  */
 package org.apache.geode.cache.lucene;
 
-import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.DEFAULT_FIELD;
-import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME;
 import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME;
-import static org.junit.Assert.assertTrue;
 
-import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 import org.apache.geode.cache.Cache;
@@ -33,7 +29,6 @@ import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.runner.RunWith;
 
 import junitparams.JUnitParamsRunner;
-import junitparams.Parameters;
 
 @Category(DistributedTest.class)
 @RunWith(JUnitParamsRunner.class)
@@ -68,39 +63,6 @@ public class LuceneQueriesClientDUnitTest extends LuceneQueriesDUnitTest
{
     return new RegionTestableType[] {RegionTestableType.PARTITION_WITH_CLIENT};
   }
 
-  // Due to singlehop transactions differences, the exception actually isn't thrown
-  // So the parent test behaves differently if singlehop is enabled or not for a client
-  @Test
-  @Parameters(method = "getListOfRegionTestTypes")
-  public void transactionWithLuceneQueriesShouldThrowException(RegionTestableType regionTestType)
{
-    SerializableRunnableIF createIndex = () -> {
-      LuceneService luceneService = LuceneServiceProvider.get(getCache());
-      luceneService.createIndexFactory().addField("text").create(INDEX_NAME, REGION_NAME);
-    };
-    dataStore1.invoke(() -> initDataStore(createIndex, regionTestType));
-    dataStore2.invoke(() -> initDataStore(createIndex, regionTestType));
-    accessor.invoke(() -> initAccessor(createIndex, regionTestType));
-
-    putDataInRegion(accessor);
-    assertTrue(waitForFlushBeforeExecuteTextSearch(accessor, 60000));
-    assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore1, 60000));
-
-    accessor.invoke(() -> {
-      Cache cache = getCache();
-      try {
-        LuceneService service = LuceneServiceProvider.get(cache);
-        LuceneQuery<Integer, TestObject> query;
-        query = service.createLuceneQueryFactory().create(INDEX_NAME, REGION_NAME, "text:world",
-            DEFAULT_FIELD);
-        cache.getCacheTransactionManager().begin();
-        PageableLuceneQueryResults<Integer, TestObject> results = query.findPages();
-      } finally {
-        cache.getCacheTransactionManager().rollback();
-      }
-    });
-
-  }
-
 
 
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/5853cc2f/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneQueryImplJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneQueryImplJUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneQueryImplJUnitTest.java
index 03db6c9..58c0feb 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneQueryImplJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneQueryImplJUnitTest.java
@@ -23,6 +23,8 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheTransactionManager;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionAttributes;
 import org.apache.geode.cache.execute.Execution;
@@ -58,6 +60,10 @@ public class LuceneQueryImplJUnitTest {
   private ResultCollector<TopEntriesCollector, TopEntries> collector;
   private Region region;
   private PageableLuceneQueryResults<Object, Object> results;
+  private Cache cache;
+  private CacheTransactionManager cacheTransactionManager;
+
+
 
   @Before
   public void createMocks() {
@@ -65,7 +71,11 @@ public class LuceneQueryImplJUnitTest {
     execution = mock(Execution.class);
     collector = mock(ResultCollector.class);
     provider = mock(LuceneQueryProvider.class);
-
+    cache = mock(Cache.class);
+    cacheTransactionManager = mock(CacheTransactionManager.class);
+    when(region.getCache()).thenReturn(cache);
+    when(region.getCache().getCacheTransactionManager()).thenReturn(cacheTransactionManager);
+    when(region.getCache().getCacheTransactionManager().exists()).thenReturn(false);
     when(execution.setArguments(any())).thenReturn(execution);
     when(execution.withCollector(any())).thenReturn(execution);
     when(execution.execute(anyString())).thenReturn((ResultCollector) collector);


Mime
View raw message